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

Create load_data and load_schema APIs [RHELDST-4862] #19

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

crungehottman
Copy link
Member

@crungehottman crungehottman commented Jan 30, 2021

The load_schema API allows clients to more easily consume the
schema.json file that is included in the cdn-definitions package.

The load_data API will return a raw dictionary of the chosen data
file. This will allow users to access various types of data in a
uniform way.

In order to encourage a single, consistent method of access to
the cdn-definitions data, the legacy access methods and related
classes (i.e., PathAlias, rhui_alias, and origin_alias) will be
deprecated. A dedicated Python object will no longer need to be
created for each new addition to the schema.

The load_data API also includes an optional "source" argument to
the load_data method. The source parameter allows the user to
specify the source of the cdn_definitions JSON or YAML data file.
The source could be a URL or a local path in a directory tree.

If a source is not specified, the location may be overriden via the
CDN_DEFINITIONS_PATH environment variable, which also may either
be in the form of a URL or a local path.

If neither a source is specified, nor a CDN_DEFINITIONS_PATH
environment variable is set, the data.yaml file included in the
cdn-definitions package will be used as a source. If that file is
unavailable, load_data will attempt to load data from
/usr/share/cdn-definitions/data.yaml. If all of the sources are
invalid, a RuntimeError will be thrown.

src/cdn_definitions/_impl/__init__.py Outdated Show resolved Hide resolved
src/cdn_definitions/_impl/__init__.py Outdated Show resolved Hide resolved
src/cdn_definitions/__init__.py Outdated Show resolved Hide resolved
src/cdn_definitions/_impl/__init__.py Outdated Show resolved Hide resolved
tests/test_load.py Outdated Show resolved Hide resolved
tests/test_load.py Outdated Show resolved Hide resolved
src/cdn_definitions/_impl/cdn_data.py Outdated Show resolved Hide resolved
src/cdn_definitions/api/__init__.py Outdated Show resolved Hide resolved
@crungehottman crungehottman changed the title Create wrapper class so data.json is only loaded once [RHELDST-4863] Create load_data and load_schema APIs [RHELDST-4862] Feb 3, 2021
@crungehottman crungehottman force-pushed the RHELDST-4863 branch 2 times, most recently from b3cd75e to 90df90a Compare February 3, 2021 22:03
tox.ini Outdated Show resolved Hide resolved
docs/userguide.rst Outdated Show resolved Hide resolved
docs/userguide.rst Outdated Show resolved Hide resolved
src/cdn_definitions/_impl/__init__.py Outdated Show resolved Hide resolved
src/cdn_definitions/_impl/__init__.py Outdated Show resolved Hide resolved
tests/test_load.py Outdated Show resolved Hide resolved
tests/test_load.py Outdated Show resolved Hide resolved
rohanpm
rohanpm previously approved these changes Feb 4, 2021
src/cdn_definitions/_impl/__init__.py Outdated Show resolved Hide resolved
Copy link
Member

@rohanpm rohanpm left a comment

Choose a reason for hiding this comment

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

Could you comment about the release of this - do you want it to be released immediately once it's approved?

src/cdn_definitions/_impl/__init__.py Outdated Show resolved Hide resolved
src/cdn_definitions/_impl/__init__.py Outdated Show resolved Hide resolved
tests/test_load.py Outdated Show resolved Hide resolved
@crungehottman
Copy link
Member Author

Could you comment about the release of this - do you want it to be released immediately once it's approved?

Well, progress on release-engineering/exodus-lambda#116 and merging of https://gitlab.cee.redhat.com/cdn/cdn-definitions-private/-/merge_requests/6 will be blocked until a new release of cdn-definitions lands in PyPI. I still need to add the schemas (etc) though, and I don't want to burden you (? I don't think I can release this) with several releases, so I will add the schemas first--I think the release can wait until the schemas have been merged.

rohanpm
rohanpm previously approved these changes Feb 8, 2021
@crungehottman
Copy link
Member Author

Sorry, @nathanegillett @lipoja - I neglected to CC you here earlier. Again, I cannot add either of you as a reviewer.

negillett
negillett previously approved these changes Feb 12, 2021
src/cdn_definitions/_impl/__init__.py Outdated Show resolved Hide resolved
The load_schema API allows clients to more easily consume the
schema.json file that is included in the cdn-definitions package.

The load_data API will return a raw dictionary of the chosen data
file. This will allow users to access various types of data in a
uniform way.

In order to encourage a single, consistent method of access to
the cdn-definitions data, the legacy access methods and related
classes (i.e., PathAlias, rhui_alias, and origin_alias) will be
deprecated. A dedicated Python object will no longer need to be
created for each new addition to the schema.

The load_data API also includes an optional "source" argument to
the load_data method. The source parameter allows the user to
specify the source of the cdn_definitions JSON or YAML data file.
The source could be a URL or a local path in a directory tree.

If a source is not specified, the location may be overriden via the
CDN_DEFINITIONS_PATH environment variable, which also may either
be in the form of a URL or a local path.

If neither a source is specified, nor a CDN_DEFINITIONS_PATH
environment variable is set, the data.yaml file included in the
cdn-definitions package will be used as a source. If that file is
unavailable, load_data will attempt to load data from
/usr/share/cdn-definitions/data.yaml. If all of the sources are
invalid, a RuntimeError will be thrown.
Copy link
Member

@rohanpm rohanpm left a comment

Choose a reason for hiding this comment

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

Any reasons not to submit this yet? (Doesn't have to be released yet.)

@rohanpm rohanpm merged commit e3c6468 into release-engineering:master Feb 16, 2021
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.

None yet

3 participants