kizzx2 / sbe-python Goto Github PK
View Code? Open in Web Editor NEWEasy-to-use Python SBE decoder and encoder
License: MIT License
Easy-to-use Python SBE decoder and encoder
License: MIT License
Hi guys, just wanted to run this by here. Would the body of the second if statement ever be hit? Doesn't seem like it would. Is this a bug?
if isinstance(f, Group):
assert cursor.val >= header.value['blockLength']
if cursor.val < header.value['blockLength']:
format_str_parts.append(str(header.value['blockLength'] - cursor.val) + 'x')
Link to line of the code
Hi,
I like the library, ease of use is great. We have a common constant field defined across all templates in my project that can be used for semantic grouping however the DecodedMessage value dict doesn't not contain representation of the constant. I'd like to use this library in a project that uses some SBE constant fields however I can see in the code that constants are specifically ignored.
Can the constant value be added to the values dict instead of being ignored?
Thanks,
Mike
Hello
I think it does not support referencing custom data type. The xml i fail to parse is here:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sbe:messageSchema xmlns:sbe="http://fixprotocol.io/2016/sbe"
package="proper.market.api"
id="1"
version="1"
semanticVersion="1.0"
description="for market data transfer"
byteOrder="littleEndian">
<types>
<composite name="messageHeader" description="Message identifiers and length of message root">
<type name="blockLength" primitiveType="uint16"/>
<type name="templateId" primitiveType="uint16"/>
<type name="schemaId" primitiveType="uint16"/>
<type name="version" primitiveType="uint16"/>
</composite>
<enum name="innerthing" encodingType="uint8" description="trading exchange">
<validValue name="value0">0</validValue>
<validValue name="value1">1</validValue>
</enum>
<composite name="something">
<ref name="innerthing" type="innerthing"/>
</composite>
</types>
<sbe:message name="someMsg" id="1">
<field name="something" id="1" type="something"/>
</sbe:message>
</sbe:messageSchema>
When parsing a schema with message tags that don't specify the blockLength
attribute, I get this error:
...
...\lib\site-packages\sbe\__init__.py", line 1088, in _parse_schema
blockLength=int(attrs['blockLength']),
KeyError: 'blockLength'
It looks like the parser depends on this attribute being there, however SBE specifies that blockLength is optional:
<xs:attribute name="blockLength" type="xs:nonNegativeInteger" use="optional">
when decoded data_type: Fixed Array Fields(array-int),result is single value,not array。
Would be great to have an example of how to encode the message. There is a snippet in the documentation, but I'm not sure I understand what obj
is:
import sbe
with open('./your-schema.xml', 'r') as f:
schema = sbe.Schema.parse(f)
# message_id from the schema you want to encode
message_id = 3
# Encode from Python dict in one-line
schema.encode(schema.messages[3], obj)
# You can supply your header values as a dict
schema.encode(schema.messages[3], obj, headers)
I've noticed that after parsing a schema, the description
field of instances of several classes remains None
. I haven't exhaustively tested this, but at least for message and field tags the description attribute does not get propagated to the corresponding objects.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.