Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,9 @@ po/*~

# RStudio Connect folder
rsconnect/


# Test output files
testdata/out_files/*
example_data/pxbuild_output/*
!testdata/out_files/**/.gitkeep
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
],
"python.analysis.typeCheckingMode": "basic",
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
"python.testing.pytestEnabled": true,
"files.eol": "\r\n"
}
4 changes: 2 additions & 2 deletions docs/dev/Keywords.md
Original file line number Diff line number Diff line change
Expand Up @@ -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||
Expand Down
1 change: 1 addition & 0 deletions example_data/pxmetadata/03024.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"cellNotes": null,
"timeDimension": {
"columnName": "TID",
"isHeading": true,
"timePeriodFormat": "ååååUuu",
"label": {
"no": "uke",
Expand Down
1 change: 1 addition & 0 deletions example_data/pxmetadata/07459.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"cellNotes": null,
"timeDimension": {
"columnName": "TID",
"isHeading": true,
"timePeriodFormat": "åååå",
"label": {
"no": "år",
Expand Down
1 change: 1 addition & 0 deletions example_data/pxmetadata/12576.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"timeDimension": {
"columnName": "TID",
"timePeriodFormat": "åååå",
"isHeading": true,
"label": {
"no": "år",
"en": "year"
Expand Down
6 changes: 6 additions & 0 deletions jsonformats/openapiyaml/pxmetadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion pxbuild/models/input/pydantic_pxmetadata.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions pxbuild/models/middle/dims.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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]:
Expand Down
1 change: 1 addition & 0 deletions testdata/test_cube_1/pxmetadata_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"timeDimension": {
"columnName": "TIME",
"timePeriodFormat": "åååå",
"isHeading": true,
"label": {
"no": "år",
"en": "year"
Expand Down
1 change: 1 addition & 0 deletions testdata/test_cube_2/pxmetadata_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"cellNotes": null,
"timeDimension": {
"columnName": "TIME",
"isHeading": true,
"timePeriodFormat": "åååå",
"label": {
"no": "år",
Expand Down
1 change: 1 addition & 0 deletions testdata/test_cubes_1nn/pxmetadata_101.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"timeDimension": {
"columnName": "TIME",
"timePeriodFormat": "åååå",
"isHeading": true,
"label": {
"no": "år",
"en": "year"
Expand Down
1 change: 1 addition & 0 deletions testdata/test_cubes_1nn/pxmetadata_102.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"timeDimension": {
"columnName": "TIME",
"timePeriodFormat": "åååå",
"isHeading": true,
"label": {
"no": "år",
"en": "year"
Expand Down
1 change: 1 addition & 0 deletions testdata/test_cubes_1nn/pxmetadata_103.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"timeDimension": {
"columnName": "TIME",
"timePeriodFormat": "åååå",
"isHeading": true,
"label": {
"no": "år",
"en": "year"
Expand Down
1 change: 1 addition & 0 deletions testdata/test_cubes_1nn/pxmetadata_104.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"timeDimension": {
"columnName": "TIME",
"timePeriodFormat": "åååå",
"isHeading": true,
"label": {
"no": "år",
"en": "year"
Expand Down
1 change: 1 addition & 0 deletions testdata/test_cubes_1nn/pxmetadata_130.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"timeDimension": {
"columnName": "dim",
"timePeriodFormat": "åååå",
"isHeading": true,
"label": {
"no": "år",
"en": "year"
Expand Down
1 change: 1 addition & 0 deletions testdata/test_cubes_1nn/pxmetadata_131.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"timeDimension": {
"columnName": "dim",
"timePeriodFormat": "åååå",
"isHeading": true,
"label": {
"no": "år",
"en": "year"
Expand Down
1 change: 1 addition & 0 deletions testdata/test_cubes_2nn/pxmetadata_200.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"timeDimension": {
"columnName": "TIME",
"timePeriodFormat": "åååå",
"isHeading": true,
"label": {
"no": "år",
"en": "year"
Expand Down