-
Notifications
You must be signed in to change notification settings - Fork 0
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
Read and write EPICS Archiver Appliance Protocol Buffer files #2
Conversation
PB files in the Archiver Appliance have one message per line, and special characters are escaped. This requires functions for escaping and unescaping, and removing and adding newline symbols when reading and writing.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2 +/- ##
============================================
- Coverage 100.00% 10.81% -89.19%
============================================
Files 2 3 +1
Lines 12 111 +99
============================================
Hits 12 12
- Misses 0 99 +99 ☔ View full report in Codecov by Sentry. |
|
||
|
||
class PBUtils: | ||
def __init__(self, filepath: PathLike | None = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filepath here is optional, but I don't know how useful this class is without it. I would suggest making this a required input and then assigning it to a member variable (self.filepath). That way in the subsequent member functions you can call self.filepath
rather than taking the filepath in as an input.
An additional function called 'update_filepath' or similar can also be added to change the target PB file on the fly. This way we are only using the API provided by PBUtils.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few different filepaths, i.e one to read from, one to write to .txt, one to write to .pb. Should all of these be a member variable?
sample_class = getattr(EPICSEvent_pb2, sample_type_camel) | ||
return sample_class | ||
|
||
def write_to_txt(self, filepath: PathLike): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an example, write_to_txt
can now just take self
as an input and use the self.filepath
property in its functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the code is clean, reads well and is very pythonic. I've left some comments with the aim of trying to provide an API for this utility. I think it would be useful to also include an entrypoint and argparse functionality so that this can be used as a separate command line tool.
Feel free to come and talk to me if any of the comments are confusing, or you would like to discuss your implementation.
5fa25e8
to
f4def8f
Compare
f4def8f
to
9c317ff
Compare
Created a PBUtils class to read and write EPICS Archiver Appliance Protocol Buffer (PB) files. These files are structured in a specific way, the details of which can be found here. This class handles the interpretation of PB files according to this structure so that the contents can be manipulated before being written back. It can also convert a PB file to text to make it human-readable.