diff --git a/.gitignore b/.gitignore index 1c9870cc..92f1503d 100644 --- a/.gitignore +++ b/.gitignore @@ -234,3 +234,9 @@ po/*~ # RStudio Connect folder rsconnect/ + + +# Test output files +testdata/out_files/* +example_data/pxbuild_output/* +!testdata/out_files/**/.gitkeep \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 9deec5d2..955f0933 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,6 @@ ], "python.analysis.typeCheckingMode": "basic", "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true + "python.testing.pytestEnabled": true, + "files.eol": "\r\n" } \ No newline at end of file diff --git a/docs/dev/Keywords.md b/docs/dev/Keywords.md index ff2cb1bd..cd92993e 100644 --- a/docs/dev/Keywords.md +++ b/docs/dev/Keywords.md @@ -21,8 +21,8 @@ Keywords included in Round 1: |TITLE|Meta|| |DESCRIPTIONDEFAULT|Conf|| |CONTENTS|Meta|| -|STUB|None|| -|HEADING|None|| +|STUB|None|derived by isHeading| +|HEADING|None|derived by isHeading| |CONTVARIABLE|Meta|| |VALUES|codes|| |CODES|codes|| diff --git a/example_data/pxmetadata/03024.json b/example_data/pxmetadata/03024.json index c6e4e78b..fbcdd47c 100644 --- a/example_data/pxmetadata/03024.json +++ b/example_data/pxmetadata/03024.json @@ -25,6 +25,7 @@ "cellNotes": null, "timeDimension": { "columnName": "TID", + "isHeading": true, "timePeriodFormat": "ååååUuu", "label": { "no": "uke", diff --git a/example_data/pxmetadata/07459.json b/example_data/pxmetadata/07459.json index 0d8d6a15..fc7871b6 100644 --- a/example_data/pxmetadata/07459.json +++ b/example_data/pxmetadata/07459.json @@ -25,6 +25,7 @@ "cellNotes": null, "timeDimension": { "columnName": "TID", + "isHeading": true, "timePeriodFormat": "åååå", "label": { "no": "år", diff --git a/example_data/pxmetadata/12576.json b/example_data/pxmetadata/12576.json index ec923acd..73af7165 100644 --- a/example_data/pxmetadata/12576.json +++ b/example_data/pxmetadata/12576.json @@ -55,6 +55,7 @@ "timeDimension": { "columnName": "TID", "timePeriodFormat": "åååå", + "isHeading": true, "label": { "no": "år", "en": "year" diff --git a/jsonformats/openapiyaml/pxmetadata.yaml b/jsonformats/openapiyaml/pxmetadata.yaml index 1341eacc..d5b2282e 100644 --- a/jsonformats/openapiyaml/pxmetadata.yaml +++ b/jsonformats/openapiyaml/pxmetadata.yaml @@ -98,6 +98,9 @@ components: timePeriodFormat: type: string description: "example: yyyy" + isHeading: + type: boolean + description: If true the dimension is a heading otherwise it is a stub label: $ref: '#/components/schemas/StringByLanguage' codedDimensions: @@ -164,6 +167,9 @@ components: type: boolean default: false description: Geo variable or not + isHeading: + type: boolean + description: If true the dimension is a heading otherwise it is a stub codelistId: type: string description: A Link to a PxCodes document diff --git a/pxbuild/models/input/pydantic_pxmetadata.py b/pxbuild/models/input/pydantic_pxmetadata.py index b68394ca..4a513ad7 100644 --- a/pxbuild/models/input/pydantic_pxmetadata.py +++ b/pxbuild/models/input/pydantic_pxmetadata.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: pxmetadata.yaml -# timestamp: 2024-02-06T15:13:33+00:00 +# timestamp: 2024-12-11T10:48:15+00:00 from __future__ import annotations @@ -65,6 +65,10 @@ class TimeDimension(BaseModel): """ example: yyyy """ + is_heading: Optional[bool] = Field(None, alias='isHeading') + """ + If true the dimension is a heading otherwise it is a stub + """ label: Optional[Dict[str, str]] = None @@ -99,6 +103,10 @@ class CodedDimension(BaseModel): """ Geo variable or not """ + is_heading: Optional[bool] = Field(None, alias='isHeading') + """ + If true the dimension is a heading otherwise it is a stub + """ codelist_id: str = Field(..., alias='codelistId') """ A Link to a PxCodes document diff --git a/pxbuild/models/middle/dims.py b/pxbuild/models/middle/dims.py index fb2d3e0b..9a2f54d0 100644 --- a/pxbuild/models/middle/dims.py +++ b/pxbuild/models/middle/dims.py @@ -34,10 +34,13 @@ def __init__(self, in_loaded_jsons: LoadedJsons, in_datadatasource: Datadatasour ) for n_dim in meta.coded_dimensions: - n_dim.codelist_id temp_cd = CodedDim(n_dim, pxcodes_helper_by_codelist_id[n_dim.codelist_id], in_loaded_jsons) n_code = temp_cd.get_code() - self._stubCodes.append(n_code) + # Defaults to stub as is_heading is optional property without default value + if n_dim.is_heading: + self._headingCodes.append(n_code) + else: + self._stubCodes.append(n_code) self.dim_by_code[n_code] = temp_cd self.coded_dimensions.append(temp_cd) @@ -50,7 +53,11 @@ def __init__(self, in_loaded_jsons: LoadedJsons, in_datadatasource: Datadatasour # TIME self.time: TimeDim = TimeDim(in_loaded_jsons, in_datadatasource) time_code = self.time.get_code() - self._headingCodes.append(time_code) + # Defaults to heading as is_heading is optional property without default value + if meta.time_dimension.is_heading: + self._headingCodes.append(time_code) + else: + self._stubCodes.append(time_code) self.dim_by_code[time_code] = self.time def get_dims_in_output_order(self) -> List[AbstractDim]: diff --git a/testdata/test_cube_1/pxmetadata_1.json b/testdata/test_cube_1/pxmetadata_1.json index cdc6512f..8f772bad 100644 --- a/testdata/test_cube_1/pxmetadata_1.json +++ b/testdata/test_cube_1/pxmetadata_1.json @@ -26,6 +26,7 @@ "timeDimension": { "columnName": "TIME", "timePeriodFormat": "åååå", + "isHeading": true, "label": { "no": "år", "en": "year" diff --git a/testdata/test_cube_2/pxmetadata_2.json b/testdata/test_cube_2/pxmetadata_2.json index 588c7e47..c789c623 100644 --- a/testdata/test_cube_2/pxmetadata_2.json +++ b/testdata/test_cube_2/pxmetadata_2.json @@ -25,6 +25,7 @@ "cellNotes": null, "timeDimension": { "columnName": "TIME", + "isHeading": true, "timePeriodFormat": "åååå", "label": { "no": "år", diff --git a/testdata/test_cubes_1nn/pxmetadata_101.json b/testdata/test_cubes_1nn/pxmetadata_101.json index 60fd1c42..50aa28a1 100644 --- a/testdata/test_cubes_1nn/pxmetadata_101.json +++ b/testdata/test_cubes_1nn/pxmetadata_101.json @@ -28,6 +28,7 @@ "timeDimension": { "columnName": "TIME", "timePeriodFormat": "åååå", + "isHeading": true, "label": { "no": "år", "en": "year" diff --git a/testdata/test_cubes_1nn/pxmetadata_102.json b/testdata/test_cubes_1nn/pxmetadata_102.json index 3bf57504..8ce2012f 100644 --- a/testdata/test_cubes_1nn/pxmetadata_102.json +++ b/testdata/test_cubes_1nn/pxmetadata_102.json @@ -28,6 +28,7 @@ "timeDimension": { "columnName": "TIME", "timePeriodFormat": "åååå", + "isHeading": true, "label": { "no": "år", "en": "year" diff --git a/testdata/test_cubes_1nn/pxmetadata_103.json b/testdata/test_cubes_1nn/pxmetadata_103.json index a0b437ee..611522fb 100644 --- a/testdata/test_cubes_1nn/pxmetadata_103.json +++ b/testdata/test_cubes_1nn/pxmetadata_103.json @@ -28,6 +28,7 @@ "timeDimension": { "columnName": "TIME", "timePeriodFormat": "åååå", + "isHeading": true, "label": { "no": "år", "en": "year" diff --git a/testdata/test_cubes_1nn/pxmetadata_104.json b/testdata/test_cubes_1nn/pxmetadata_104.json index e54bc904..61c16068 100644 --- a/testdata/test_cubes_1nn/pxmetadata_104.json +++ b/testdata/test_cubes_1nn/pxmetadata_104.json @@ -28,6 +28,7 @@ "timeDimension": { "columnName": "TIME", "timePeriodFormat": "åååå", + "isHeading": true, "label": { "no": "år", "en": "year" diff --git a/testdata/test_cubes_1nn/pxmetadata_130.json b/testdata/test_cubes_1nn/pxmetadata_130.json index edfa459a..fe12a3c5 100644 --- a/testdata/test_cubes_1nn/pxmetadata_130.json +++ b/testdata/test_cubes_1nn/pxmetadata_130.json @@ -28,6 +28,7 @@ "timeDimension": { "columnName": "dim", "timePeriodFormat": "åååå", + "isHeading": true, "label": { "no": "år", "en": "year" diff --git a/testdata/test_cubes_1nn/pxmetadata_131.json b/testdata/test_cubes_1nn/pxmetadata_131.json index c390c9d6..f34cdf82 100644 --- a/testdata/test_cubes_1nn/pxmetadata_131.json +++ b/testdata/test_cubes_1nn/pxmetadata_131.json @@ -28,6 +28,7 @@ "timeDimension": { "columnName": "dim", "timePeriodFormat": "åååå", + "isHeading": true, "label": { "no": "år", "en": "year" diff --git a/testdata/test_cubes_2nn/pxmetadata_200.json b/testdata/test_cubes_2nn/pxmetadata_200.json index 393dccc0..5ff09841 100644 --- a/testdata/test_cubes_2nn/pxmetadata_200.json +++ b/testdata/test_cubes_2nn/pxmetadata_200.json @@ -71,6 +71,7 @@ "timeDimension": { "columnName": "TIME", "timePeriodFormat": "åååå", + "isHeading": true, "label": { "no": "år", "en": "year"