tfgm / sbedecoder

Python based Simple Binary Encoding (SBE) decoder
MIT License
76 stars 44 forks source link

Add SBE Defaults #29

Closed ryanohnemus closed 6 years ago

ryanohnemus commented 6 years ago

I found the project very useful (thank you!) and added the following for my own usage. I thought others might like these additions too... If there are any changes needed, please let me know!

tfgm-bud commented 6 years ago

Thanks for the contribution @ryanohnemus! I'll review and try to get it merged in within the next day or two.

tfgm-bud commented 6 years ago

@ryanohnemus

In hindsight, using the "description" as the "name" was probably not a great idea. It just so happened that the CME put the TID in the name of their messages and we used the description to make the name more friendly. For example, the CME's AdminHeartbeat message's name is "AdminHeartbeat12" and the description is "AdminHeartbeat". Argh! Your approach is definitely the "right" way to do it.

I have a minor concern that this will break a couple of applications downstream. What would you think about having a use_description_as_message_name flag or something like that for the schema to retain the old behavior? I'm fine with the default being False. I do know of downstream code code that relies on the message names being derived from the description and that would make it pretty easy to fix up these applications. Especially if the MDPMessageFactory() toggled use_description_as_message_name flag to true automatically.

A couple of other things. There are some test cases (./tests) that are broken with this change. Also, there is also an impact is to the SBE class generator in the ./generator subdirectory which is not accounted for. It needs a --message-factory=MDP or something to select the MDPMessageFactory() and a way to deal with the name vs description issue.

ryanohnemus commented 6 years ago

@tfgm-bud can I set include_message_size_header=False by default as well since this seems like a cme/mdp specific thing, and to me it would be nice to just have generic SBE be all the defaults?

I'll go fix the tests, generator, and scripts accordingly.

I'm a little confused on what you said about needing a message-factory with the generator script. I didn't see anything regarding MessageFactory stuff in that folder, everything was just using the SBESchema, but I did miss updating these in my earlier commits... so I can fix these based on my generic/defaults proposal.

Thanks!

tfgm-bud commented 6 years ago

@ryanohnemus sorry, you are right, the factory is only used to decode messages so the generator doesn't need it. Sorry about the confusion there.

ryanohnemus commented 6 years ago

Hey @tfgm-bud! I changed a few things in the last commit, but i'm hoping it's all acceptable!

SBESchema init now has the following parameters

The reason I defaulted include_message_size_header to False is because the current behavior seems very CME specific, and I'd like to have the SBESchema defaults be as close to the base standard as possible

I updated all the files accordingly (the tests worked from my machine, let me know if you run into any problems 😄) and I put a note in the README.md about these SBESchema fields

ryanohnemus commented 6 years ago

@tfgm-bud do you have any updates for this PR? thank you!

ryanohnemus commented 6 years ago

also ignore my question about marshaling (i updated/removed the comment)... I should have just read the bottom of the README.md where it mentions using the generated classes... sorry about that!

tfgm-bud commented 6 years ago

Thanks @ryanohnemus. I'll review this early next week and get it checked in.

tfgm-bud commented 6 years ago

@ryanohnemus Sorry for the delay. One more minor issue. In scripts/mdp_book_builder.py, we are still using SBEMessageFactory() it needs to import and use the new MDPMessageFactory(). Make that change and I'll merge. Thanks again. -- Bud

ryanohnemus commented 6 years ago

@tfgm-bud no problem! I updated mdp_book_builder.py.

I have 2 more questions to follow up after this PR:

  1. the classes generated with generator do not support subgroups. However if you are using the non-generated SbeSchema.parse you'll be able to parse messages that have groups with subgroups.

Would anyone be able to fix the generator to support groups in groups?

  1. will this package ever be available on the public pypi.org / pypi.python.org?

Thank you!

tfgm-bud commented 6 years ago

@ryanohnemus - Can you open tickets for the last two items? Neither looks too bad to implement.

BTW, If you need to pip install, you can do:

pip install git+https://github.com/tfgm/sbedecoder

for master or if you want a specific tag:

pip install git+https://github.com/tfgm/sbedecoder@0.1.2

ryanohnemus commented 6 years ago

ok thank you! I'll open tickets for those.