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 Metadata to every Maintenance, addresses issue #246 #249

Merged
merged 17 commits into from
Nov 20, 2023

Conversation

chadell
Copy link
Collaborator

@chadell chadell commented Nov 15, 2023

The idea is to provide some basic information about how the Maintenance has been generated to allow consumers to take decisions

TODO

  • Update Readme

Example of the information retrieved via CLI:

image

Copy link
Contributor

@glennmatthews glennmatthews left a 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!

@chadell
Copy link
Collaborator Author

chadell commented Nov 16, 2023

Looks like a reasonable enhancement to me!

nice, I have updated the readme to explain it.

glennmatthews
glennmatthews previously approved these changes Nov 20, 2023
circuit_maintenance_parser/parser.py Outdated Show resolved Hide resolved
@chadell chadell merged commit 9ba38f0 into develop Nov 20, 2023
14 checks passed
@chadell chadell deleted the issue-246-metadata branch November 20, 2023 16:08

# Non mandatory attributes
uid: StrictStr = "0"
sequence: StrictInt = 1
summary: StrictStr = ""

def __init__(self, **data):
"""Initialize the Maintenance object."""
self._metadata = data.pop("_metadata")
Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

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