-
Notifications
You must be signed in to change notification settings - Fork 24
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 Metadata to every Maintenance, addresses issue #246 #249
Conversation
Co-authored-by: Glenn Matthews <[email protected]>
Co-authored-by: Glenn Matthews <[email protected]>
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.
Looks like a reasonable enhancement to me!
nice, I have updated the readme to explain it. |
Co-authored-by: Glenn Matthews <[email protected]>
|
||
# Non mandatory attributes | ||
uid: StrictStr = "0" | ||
sequence: StrictInt = 1 | ||
summary: StrictStr = "" | ||
|
||
def __init__(self, **data): | ||
"""Initialize the Maintenance object.""" | ||
self._metadata = data.pop("_metadata") |
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.
This throws KeyError if _metadata key isn't present, thus this change becomes a breaking change.
Some of my existing tests used in my projects start to throw KeyError exception. For example:
self = Maintenance()
data = {'account': '12623', 'circuits': [{'circuit_id': '297487', 'impact': 'NO-IMPACT'}], 'end': 1649073600, 'maintenance_id': 'GIN-CHG0042605', ...}
def __init__(self, **data):
"""Initialize the Maintenance object."""
> self._metadata = data.pop("_metadata")
E KeyError: '_metadata'
../../dev/MNA/lib/python3.10/site-packages/circuit_maintenance_parser/output.py:166: KeyError
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.
It seems like Maintenance dataclass is now expecting _metadata to be supplied by users. can't it default to 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.
thanks @csessh for reporting. I'm going to check and fix.
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.
checking the code, I see that the _metadata
is injected by the Processors
automatically, so I don't get why don't you get it in your tests.
The idea is to provide some basic information about how the Maintenance has been generated to allow consumers to take decisions
TODO
Example of the information retrieved via CLI: