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

EVALG-77 follow up: Change design to use Last-Value Cache and Read #703

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Alxe
Copy link
Member

@Alxe Alxe commented Aug 26, 2024

Summary

This PR changes the example to follow a Last-Value Cache pattern on the subscriber. This removes the need for asynchronous code and focuses on polling.

Additionally, a few other changes have been made as left-over TODO from previous PR, #695.

Details and comments

Checks

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

Copy link
Contributor

@alexcamposruiz alexcamposruiz left a comment

Choose a reason for hiding this comment

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

Fix python formatting with black

tutorials/application_design/py/subscriber.py Outdated Show resolved Hide resolved
tutorials/application_design/py/subscriber.py Outdated Show resolved Hide resolved
tutorials/application_design/py/subscriber.py Outdated Show resolved Hide resolved
tutorials/application_design/py/subscriber.py Show resolved Hide resolved
tutorials/application_design/py/subscriber.py Show resolved Hide resolved
tutorials/application_design/py/subscriber.py Outdated Show resolved Hide resolved
tutorials/application_design/py/subscriber.py Outdated Show resolved Hide resolved
tutorials/application_design/py/subscriber.py Show resolved Hide resolved
tutorials/application_design/py/subscriber.py Outdated Show resolved Hide resolved
tutorials/application_design/py/subscriber.py Outdated Show resolved Hide resolved
Copy link
Contributor

@alexcamposruiz alexcamposruiz left a comment

Choose a reason for hiding this comment

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

Suggested several improvements to reduce complexity and improve readability.

@Alxe Alxe self-assigned this Sep 30, 2024
Copy link
Contributor

@alexcamposruiz alexcamposruiz left a comment

Choose a reason for hiding this comment

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

Replied to open comments.

Also, make sure to apply relevant feedback to the C++ example as well.

self._metrics_app(),
self._transit_app(),
string += f"[INFO] Vehicle {sample.vehicle_vin}"
if sample.current_route and len(sample.current_route):
Copy link
Contributor

Choose a reason for hiding this comment

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

if sample.current_route:

The and is always true.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this is accurate as if sample.current_route will evaluate to sample.current_route.__bool__ which tests for whether if the optional is present or not. Once we've checked that, we need to check that the sequence is not empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

Both None and an empty list/string test to False:

>>> bool([])
False
>>> bool(None)
False
>>> bool([1])
True

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.

2 participants