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

Add header messages (including latched) to EventsFileWriter #196

Merged
merged 28 commits into from
Dec 18, 2023

Conversation

Hackerman342
Copy link
Collaborator

No description provided.

@Hackerman342 Hackerman342 marked this pull request as ready for review December 12, 2023 21:01
Copy link
Member

@edgarriba edgarriba left a comment

Choose a reason for hiding this comment

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

can you add tests ?

@Hackerman342
Copy link
Collaborator Author

@edgarriba I've spent some time working on adding tests. I went down a rabbithole and ultimately think found that the asyncio test infrastructure is not functioning as we expect. There is an issue when testing the EventServiceRecorder that the record queue cannot be read. Please see #200 for more details

py/farm_ng/core/event_service_recorder.py Outdated Show resolved Hide resolved
py/farm_ng/core/events_file_writer.py Outdated Show resolved Hide resolved
Copy link
Member

@edgarriba edgarriba left a comment

Choose a reason for hiding this comment

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

LGTM. Question/suggestion: how can we read/parse easily header messages ?

py/farm_ng/core/event_service_recorder.py Outdated Show resolved Hide resolved
py/farm_ng/core/events_file_writer.py Outdated Show resolved Hide resolved
py/farm_ng/core/events_file_writer.py Outdated Show resolved Hide resolved
@ethanrublee
Copy link
Member

ethanrublee commented Dec 15, 2023

I still feel like this could be simpler.

I can imagine latched topics can generate new data mid recording pretty easily, which would cause this to fail, and a programmer or user to scratch their head.

Also if new meta data is added after a split, header messages will be inconsistent across log files. When is this likely to be needed?

As a user how do I edit the meta data after it's recorded?

I think for latched topics, if we can extend the query string on the sender side, then the latched topics can easily and transparently be carried across log splits with no additional api.

Could meta data just be of the convention /header/foo and be a latched topic?

And then we keep the semantics simple and really don't need to change the APIs?

@Hackerman342
Copy link
Collaborator Author

@ethanrublee

I still feel like this could be simpler.

Yeah I'd like it to be too.

I can imagine latched topics can generate new data mid recording pretty easily, which would cause this to fail, and a programmer or user to scratch their head.

I don't think this does fail .Or maybe I'm misunderstanding what you mean by fail? There's no special casing for latched topics anymore. The only special case is a white list of URIs to consider as header messages, whether it is latched or not. That message comes in, we try to add it as a header, and we write it to the log either way. If we already created a header with that URI in this recording, then the old header is not overwritten. So either way, the new message received is still included in the log.

def subscribe():
        async for event, payload in client.subscribe(subscription, decode=False):
            if uri_to_string(event.uri) in header_uris:
                # Handle header events - typically these will be metadata or calibrations
                self.header_deque.append((event, payload))
            try:
                self.record_queue.put_nowait((event, payload))
            except asyncio.QueueFull:
                self.logger.warning("Queue full, dropping event %s", event)
                continue

Also if new meta data is added after a split, header messages will be inconsistent across log files. When is this likely to be needed?

Likely never. Just thinking through edge cases.

As a user how do I edit the meta data after it's recorded?

We could make a python script with an example for this in farm-ng-amiga when this comes up as a need

I think for latched topics, if we can extend the query string on the sender side, then the latched topics can easily and transparently be carried across log splits with no additional api.

Oh I like this. Instead of a whitelist of subscribed topic URIs, we check for /header as the final component of the Uri path. That simplifies that logic and can remove the change to the proto definition in this PR

Could meta data just be of the convention /header/foo and be a latched topic?

And then we keep the semantics simple and really don't need to change the APIs?

This would require creating a separate service / publisher for the recording app just to publish metadata. I think it makes more sense to keep it as a client and use the request/reply API, but if you'd prefer that direction I can do that,

@Hackerman342
Copy link
Collaborator Author

@edgarriba

LGTM. Question/suggestion: how can we read/parse easily header messages ?

Good idea. I added a method for this in: e790025

@Hackerman342 Hackerman342 merged commit e872fbe into main Dec 18, 2023
11 checks passed
@Hackerman342 Hackerman342 deleted the headers-split-logs branch December 18, 2023 19:30
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.

3 participants