Skip to content

Commit

Permalink
Merge pull request #21 from HDRUK/add/hdruk/2.1.3
Browse files Browse the repository at this point in the history
Add/hdruk/2.1.3
  • Loading branch information
calmacx authored Jan 9, 2024
2 parents ecfc30c + 7dc1918 commit 152f453
Show file tree
Hide file tree
Showing 28 changed files with 2,086 additions and 26 deletions.
1 change: 1 addition & 0 deletions available.json
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"
],
Expand Down
2,015 changes: 2,015 additions & 0 deletions hdr_schemata/models/HDRUK/2.1.3/schema.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions hdr_schemata/models/HDRUK/__init__.py
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
8 changes: 8 additions & 0 deletions hdr_schemata/models/HDRUK/create_json_schema.py
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")
23 changes: 12 additions & 11 deletions hdr_schemata/models/HDRUK/latest/dev/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1607,14 +1607,6 @@
"Temporal": {
"additionalProperties": false,
"properties": {
"accrualPeriodicity": {
"allOf": [
{
"$ref": "#/$defs/Periodicity"
}
],
"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 \u201con-demand\u201d 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/"
},
"distributionReleaseDate": {
"anyOf": [
{
Expand Down Expand Up @@ -1679,12 +1671,21 @@
],
"description": "Please indicate the typical time-lag between an event and the data for that event appearing in the dataset",
"title": "Time Lag"
},
"publishingFrequency": {
"allOf": [
{
"$ref": "#/$defs/Periodicity"
}
],
"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 \u201con-demand\u201d 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/",
"title": "Publishing Frequency"
}
},
"required": [
"accrualPeriodicity",
"startDate",
"timeLag"
"timeLag",
"publishingFrequency"
],
"title": "Temporal",
"type": "object"
Expand Down Expand Up @@ -2009,6 +2010,6 @@
"accessibility",
"observations"
],
"title": "Hdruk212",
"title": "Hdruk213",
"type": "object"
}
5 changes: 0 additions & 5 deletions hdr_schemata/models/HDRUK/test.py

This file was deleted.

8 changes: 0 additions & 8 deletions hdr_schemata/models/HDRUK/v2_1_2.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from datetime import date, datetime
from enum import Enum
from typing import List, Optional, Union

from pydantic import AnyUrl, BaseModel, EmailStr, Field, constr

from hdr_schemata.definitions.HDRUK import *
Expand All @@ -17,7 +17,8 @@
from .DataClass import DataClass
from .DataElement import DataElement

class HdrukBaseModel(BaseModel):

class Hdruk212(BaseModel):
class Config:
extra = 'forbid'

Expand Down Expand Up @@ -91,3 +92,8 @@ class Config:
description='Descriptions of all tables and data elements that can be included in the dataset',
title='Structural Metadata',
)

@classmethod
def save_schema(cls,location='./2.1.2/schema.json'):
with open(location,'w') as f:
json.dump(cls.model_json_schema(),f,indent=6)
6 changes: 6 additions & 0 deletions hdr_schemata/models/HDRUK/v2_1_3/Provenance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from hdr_schemata.models.HDRUK.v2_1_2 import Provenance as BaseProvenance
from .Temporal import Temporal


class Provenance(BaseProvenance):
temporal: Temporal
16 changes: 16 additions & 0 deletions hdr_schemata/models/HDRUK/v2_1_3/Temporal.py
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.v2_1_2.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"])
18 changes: 18 additions & 0 deletions hdr_schemata/models/HDRUK/v2_1_3/__init__.py
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)
1 change: 1 addition & 0 deletions hdr_schemata/utils/print_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
structure = {}
for schema in glob.glob('hdr_schemata/models/**/schema.json',recursive=True):
items = schema.split('/')
if len(items) != 5: continue
model = items[2]
version = items[3]
if model not in structure:
Expand Down

0 comments on commit 152f453

Please sign in to comment.