-
Notifications
You must be signed in to change notification settings - Fork 0
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/hdruk/2.1.3 #21
Merged
Merged
Add/hdruk/2.1.3 #21
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b0c3939
add a version 2.1.3
calmacx d477033
add 2.1.3
calmacx 1be6f85
didnt register changes
calmacx 3aa87b0
Merge remote-tracking branch 'origin/master' into add/hdruk/2.1.3
calmacx 22ce473
changes
calmacx c5a48b7
fix code
calmacx f5432d0
add new schema
calmacx bdbc0b1
update
calmacx 5da5f0b
include removal of accrualPeriodicity
calmacx 4575f4a
rename base --> 2.1.2
calmacx 7dc1918
update printing available stuff
calmacx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"HDRUK": [ | ||
"2.1.2", | ||
"2.1.3", | ||
"2.1.0", | ||
"2.0.2" | ||
], | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .v2_1_2 import Hdruk212 | ||
from .v2_1_3 import Hdruk213 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from pydantic import ValidationError | ||
import v2_1_2 | ||
import v2_1_3 | ||
import json | ||
|
||
v2_1_2.Hdruk212.save_schema() | ||
v2_1_3.Hdruk213.save_schema() | ||
v2_1_3.Hdruk213.save_schema("latest/dev/schema.json") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from hdr_schemata.models.HDRUK.base import Provenance as BaseProvenance | ||
from .Temporal import Temporal | ||
|
||
|
||
class Provenance(BaseProvenance): | ||
temporal: Temporal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from pydantic import Field | ||
from hdr_schemata.definitions.HDRUK import Periodicity | ||
from hdr_schemata.models.HDRUK.base.Temporal import Temporal as BaseTemporal | ||
from pydantic import BaseModel, Field | ||
from hdr_schemata.models import remove_fields_from_cls | ||
|
||
|
||
class Temporal(BaseTemporal): | ||
publishingFrequency: Periodicity = Field( | ||
..., | ||
title="Publishing Frequency", | ||
description="Please indicate the frequency of distribution release. If a dataset is distributed regularly please choose a distribution release periodicity from the constrained list and indicate the next release date. When the release date becomes historical, a new release date will be calculated based on the publishing periodicity. If a dataset has been published and will remain static please indicate that it is static and indicated when it was released. If a dataset is released on an irregular basis or “on-demand” please indicate that it is Irregular and leave release date as null. If a dataset can be published in real-time or near-real-time please indicate that it is continuous and leave release date as null. Notes: see https://www.dublincore.org/specifications/dublin-core/collection-description/frequency/", | ||
) | ||
|
||
|
||
remove_fields_from_cls(Temporal, ["accrualPeriodicity"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from hdr_schemata.models.HDRUK.v2_1_2 import Hdruk212 | ||
import json | ||
from typing import Optional | ||
from pydantic import Field | ||
from .Provenance import Provenance | ||
|
||
|
||
class Hdruk213(Hdruk212): | ||
provenance: Optional[Provenance] = Field( | ||
None, | ||
description="Provenance information allows researchers to understand data within the context of its origins and can be an indicator of quality, authenticity and timeliness.", | ||
title="Provenance", | ||
) | ||
|
||
@classmethod | ||
def save_schema(cls, location="./2.1.3/schema.json"): | ||
with open(location, "w") as f: | ||
json.dump(cls.model_json_schema(), f, indent=6) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm wondering if it would make sense to import
Temporal
from the latest schema version rather than fromHDRUK.base
?Hypothetically, say for version
2.1.4
we wanted to change the nametimeLag
totimeDelay
or something. For2.1.4
the developer would importbase.Temporal
and have to make two modifications to it (timeLag
->timeDelay
andaccrualPeriodicity
->publishFrequency
). I imagine it would be easy to miss a previous iteration that was made tobase.Temporal
. IIUC, importing from the latest version by default should mean the developer doesn't have to go back and check previous iterations.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.
Great that you checked but this is simply because
2.1.2
is the base and the latest version.While we have older versions of the schema, these are json-schema only and not pydantic. Therefore the 'base' of the HDRUK schema is
2.1.2
. When we make a2.1.4
then yeh definitely you're right to import from the latest schema which would befrom hdr_schemata.models.HDRUK.v2_1_3.Temporal
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.
Could rename
Base
to be2.1.2
if that's less confusing?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.
Right of course, I hadn't realised this was a special case because
2.1.2
is theBase
. It's probably worth writing some documentation about how to make these updates to the schema re importing from the latest version.