Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use katcp-codec for encoding and decoding messages #90

Merged
merged 7 commits into from
Apr 16, 2024

Conversation

bmerry
Copy link
Contributor

@bmerry bmerry commented Apr 16, 2024

I've made this as a beta release (1.10.0b1) because katcp-codec is still at beta.

I also ditched katversion rather than wait for ska-sa/katversion#31, so that I could make the release.

The minimum version is already listed in the README and setup.cfg, so I
deleted this incorrect copy rather than trying to maintain it in yet
another place.
katversion doesn't support the full range of version specifiers
including beta versions. This also allows setup.py to finally be
removed.
@bmerry
Copy link
Contributor Author

bmerry commented Apr 16, 2024

@ludwigschwardt I requested your review just for the packaging side of things.

@coveralls
Copy link

coveralls commented Apr 16, 2024

Coverage Status

coverage: 92.759% (-0.7%) from 93.445%
when pulling 456953c on use-katcp-codec-basic
into db4dc44 on master.

Copy link
Contributor

@ludwigschwardt ludwigschwardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alas, poor katversion, I knew him...

else:
mid = None
mtype = cls._REVERSE_TYPE_SYMBOLS[clean[:1]]
raise ValueError("message does not end with newline")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not KatcpSyntaxError anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValueErrors get turned into KatcpSyntaxErrors lower down anyway, so it seemed simpler to only raise ValueError (it's what ends up in msgs[0] if the message is invalid) and not have to worry about catching KatcpSyntaxError.

raise ValueError("no message")
if len(msgs) > 1 or parser.buffer_size > 0:
raise ValueError("internal newline")
if isinstance(msgs[0], Exception):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could introduce a line like msg = msgs[0] here to streamline the code a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea.

@bmerry bmerry merged commit 6b07834 into master Apr 16, 2024
19 of 20 checks passed
@bmerry bmerry deleted the use-katcp-codec-basic branch April 16, 2024 15:06
Copy link
Contributor

@ludwigschwardt ludwigschwardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, out of interest, how significant is the speedup with katcp-codec?

@bmerry
Copy link
Contributor Author

bmerry commented Apr 16, 2024

Also, out of interest, how significant is the speedup with katcp-codec?

In microbenchmarks (particularly large requests like setting gains) it can be 5x, although in practice a lot of the time is spent elsewhere anyway, particularly converting Python objects (strings, floats) to/from raw bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants