dapla-toolbelt-metadata 0.9.3__py3-none-any.whl → 0.9.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dapla-toolbelt-metadata might be problematic. Click here for more details.
- dapla_metadata/datasets/model_validation.py +28 -19
- dapla_metadata/datasets/utility/constants.py +2 -2
- dapla_metadata/datasets/utility/utils.py +56 -0
- {dapla_toolbelt_metadata-0.9.3.dist-info → dapla_toolbelt_metadata-0.9.4.dist-info}/METADATA +1 -1
- {dapla_toolbelt_metadata-0.9.3.dist-info → dapla_toolbelt_metadata-0.9.4.dist-info}/RECORD +7 -7
- {dapla_toolbelt_metadata-0.9.3.dist-info → dapla_toolbelt_metadata-0.9.4.dist-info}/WHEEL +0 -0
- {dapla_toolbelt_metadata-0.9.3.dist-info → dapla_toolbelt_metadata-0.9.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -13,20 +13,19 @@ from typing_extensions import Self
|
|
|
13
13
|
|
|
14
14
|
from dapla_metadata.datasets.utility.constants import DATE_VALIDATION_MESSAGE
|
|
15
15
|
from dapla_metadata.datasets.utility.constants import NUM_OBLIGATORY_DATASET_FIELDS
|
|
16
|
-
from dapla_metadata.datasets.utility.constants import NUM_OBLIGATORY_VARIABLES_FIELDS
|
|
17
16
|
from dapla_metadata.datasets.utility.constants import OBLIGATORY_METADATA_WARNING
|
|
18
17
|
from dapla_metadata.datasets.utility.utils import get_missing_obligatory_dataset_fields
|
|
19
18
|
from dapla_metadata.datasets.utility.utils import (
|
|
20
19
|
get_missing_obligatory_variables_fields,
|
|
21
20
|
)
|
|
21
|
+
from dapla_metadata.datasets.utility.utils import (
|
|
22
|
+
get_missing_obligatory_variables_pseudo_fields,
|
|
23
|
+
)
|
|
22
24
|
from dapla_metadata.datasets.utility.utils import get_timestamp_now
|
|
23
25
|
from dapla_metadata.datasets.utility.utils import incorrect_date_order
|
|
24
26
|
from dapla_metadata.datasets.utility.utils import (
|
|
25
27
|
num_obligatory_dataset_fields_completed,
|
|
26
28
|
)
|
|
27
|
-
from dapla_metadata.datasets.utility.utils import (
|
|
28
|
-
num_obligatory_variables_fields_completed,
|
|
29
|
-
)
|
|
30
29
|
from dapla_metadata.datasets.utility.utils import set_variables_inherit_from_dataset
|
|
31
30
|
|
|
32
31
|
if TYPE_CHECKING:
|
|
@@ -146,21 +145,31 @@ class ValidateDatadocMetadata(model.DatadocMetadata):
|
|
|
146
145
|
ObligatoryVariableWarning: If not all obligatory variable metadata fields
|
|
147
146
|
are filled in.
|
|
148
147
|
"""
|
|
149
|
-
if self.variables is not None
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
148
|
+
if self.variables is not None:
|
|
149
|
+
missing_fields_dict = {}
|
|
150
|
+
for d in get_missing_obligatory_variables_fields(self.variables):
|
|
151
|
+
for var, fields in d.items():
|
|
152
|
+
missing_fields_dict[var] = fields.copy()
|
|
153
|
+
|
|
154
|
+
for d in get_missing_obligatory_variables_pseudo_fields(self.variables):
|
|
155
|
+
for var, fields in d.items():
|
|
156
|
+
if var in missing_fields_dict:
|
|
157
|
+
missing_fields_dict[var].extend(fields)
|
|
158
|
+
else:
|
|
159
|
+
missing_fields_dict[var] = fields.copy()
|
|
160
|
+
|
|
161
|
+
missing_fields = [
|
|
162
|
+
{var: fields} for var, fields in missing_fields_dict.items()
|
|
163
|
+
]
|
|
164
|
+
if missing_fields:
|
|
165
|
+
message = f"{OBLIGATORY_METADATA_WARNING} {missing_fields}"
|
|
166
|
+
warnings.warn(message, ObligatoryVariableWarning, stacklevel=2)
|
|
167
|
+
logger.warning(
|
|
168
|
+
"Type warning: %s.%s %s",
|
|
169
|
+
ObligatoryVariableWarning,
|
|
170
|
+
OBLIGATORY_METADATA_WARNING,
|
|
171
|
+
missing_fields,
|
|
172
|
+
)
|
|
164
173
|
return self
|
|
165
174
|
|
|
166
175
|
|
|
@@ -47,9 +47,9 @@ OBLIGATORY_VARIABLES_METADATA_IDENTIFIERS = [
|
|
|
47
47
|
"temporality_type",
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
OBLIGATORY_VARIABLES_PSEUDONYMIZATION_IDENTIFIERS = [
|
|
51
51
|
"encryption_algorithm",
|
|
52
|
-
"
|
|
52
|
+
"encryption_key_reference",
|
|
53
53
|
]
|
|
54
54
|
|
|
55
55
|
|
|
@@ -36,6 +36,9 @@ from dapla_metadata.datasets.utility.constants import (
|
|
|
36
36
|
from dapla_metadata.datasets.utility.constants import (
|
|
37
37
|
OBLIGATORY_VARIABLES_METADATA_IDENTIFIERS_MULTILANGUAGE,
|
|
38
38
|
)
|
|
39
|
+
from dapla_metadata.datasets.utility.constants import (
|
|
40
|
+
OBLIGATORY_VARIABLES_PSEUDONYMIZATION_IDENTIFIERS,
|
|
41
|
+
)
|
|
39
42
|
from dapla_metadata.datasets.utility.constants import PAPIS_ENCRYPTION_KEY_REFERENCE
|
|
40
43
|
from dapla_metadata.datasets.utility.constants import PAPIS_STABLE_IDENTIFIER_TYPE
|
|
41
44
|
from dapla_metadata.datasets.utility.enums import EncryptionAlgorithm
|
|
@@ -367,6 +370,25 @@ def num_obligatory_variable_fields_completed(
|
|
|
367
370
|
return NUM_OBLIGATORY_VARIABLES_FIELDS - len(missing_metadata)
|
|
368
371
|
|
|
369
372
|
|
|
373
|
+
def num_obligatory_pseudo_fields_missing(
|
|
374
|
+
variables: list[all_optional_model.Variable],
|
|
375
|
+
) -> int:
|
|
376
|
+
"""Counts the number of obligatory pseudonymization fields are missing.
|
|
377
|
+
|
|
378
|
+
Args:
|
|
379
|
+
variables: The variables to count obligatory fields for.
|
|
380
|
+
|
|
381
|
+
Returns:
|
|
382
|
+
The number of obligatory pseudonymization fields that are missing.
|
|
383
|
+
"""
|
|
384
|
+
return sum(
|
|
385
|
+
getattr(v.pseudonymization, field, None) is None
|
|
386
|
+
for v in variables
|
|
387
|
+
if v.pseudonymization is not None
|
|
388
|
+
for field in OBLIGATORY_VARIABLES_PSEUDONYMIZATION_IDENTIFIERS
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
|
|
370
392
|
def get_missing_obligatory_dataset_fields(
|
|
371
393
|
dataset: DatasetType,
|
|
372
394
|
) -> list:
|
|
@@ -433,6 +455,40 @@ def get_missing_obligatory_variables_fields(variables: list) -> list[dict]:
|
|
|
433
455
|
return [item for item in missing_variables_fields if next(iter(item.values()))]
|
|
434
456
|
|
|
435
457
|
|
|
458
|
+
def get_missing_obligatory_variables_pseudo_fields(
|
|
459
|
+
variables: list[all_optional_model.Variable],
|
|
460
|
+
) -> list[dict]:
|
|
461
|
+
"""Identify obligatory variable pseudonymization fields that are missing values for each variable.
|
|
462
|
+
|
|
463
|
+
This function checks for obligatory fields that are directly missing
|
|
464
|
+
(i.e., set to `None`).
|
|
465
|
+
|
|
466
|
+
Args:
|
|
467
|
+
variables: A list of variable objects to check for missing obligatory pseudonymization fields.
|
|
468
|
+
|
|
469
|
+
Returns:
|
|
470
|
+
A list of dictionaries with variable short names as keys and list of missing
|
|
471
|
+
obligatory variable pseudonymization fields as values. This includes:
|
|
472
|
+
- Fields that are directly `None` and are listed as obligatory metadata.
|
|
473
|
+
"""
|
|
474
|
+
return [
|
|
475
|
+
{
|
|
476
|
+
v.short_name: [
|
|
477
|
+
key
|
|
478
|
+
for key, value in v.pseudonymization.model_dump().items()
|
|
479
|
+
if _is_missing_metadata(
|
|
480
|
+
key,
|
|
481
|
+
value,
|
|
482
|
+
OBLIGATORY_VARIABLES_PSEUDONYMIZATION_IDENTIFIERS,
|
|
483
|
+
[],
|
|
484
|
+
)
|
|
485
|
+
]
|
|
486
|
+
}
|
|
487
|
+
for v in variables
|
|
488
|
+
if v.pseudonymization is not None
|
|
489
|
+
]
|
|
490
|
+
|
|
491
|
+
|
|
436
492
|
def running_in_notebook() -> bool:
|
|
437
493
|
"""Return True if running in Jupyter Notebook."""
|
|
438
494
|
try:
|
{dapla_toolbelt_metadata-0.9.3.dist-info → dapla_toolbelt_metadata-0.9.4.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dapla-toolbelt-metadata
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.4
|
|
4
4
|
Summary: Dapla Toolbelt Metadata
|
|
5
5
|
Project-URL: homepage, https://github.com/statisticsnorway/dapla-toolbelt-metadata
|
|
6
6
|
Project-URL: repository, https://github.com/statisticsnorway/dapla-toolbelt-metadata
|
|
@@ -11,7 +11,7 @@ dapla_metadata/datasets/code_list.py,sha256=JtCE-5Q8grAKvkn0KKjzeGhO-96O7yGsastb
|
|
|
11
11
|
dapla_metadata/datasets/core.py,sha256=p-2OJsAEWCUqBlzn0YIYkK-pAgtvMROdoxXvCyjfWYs,20434
|
|
12
12
|
dapla_metadata/datasets/dapla_dataset_path_info.py,sha256=WPeV_mwKk2B9sXd14SaP-kTb1bOQ_8W2KtrqOG7sJIY,26867
|
|
13
13
|
dapla_metadata/datasets/dataset_parser.py,sha256=3dtRXNy1C8SfG8zTYWdY26nV4l-dG25IC_0J5t2bYwI,8285
|
|
14
|
-
dapla_metadata/datasets/model_validation.py,sha256=
|
|
14
|
+
dapla_metadata/datasets/model_validation.py,sha256=6qqq1ueTWRWBPTwEGJD49Pv7ksMEaq0iDtuOXelaw-s,7223
|
|
15
15
|
dapla_metadata/datasets/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
dapla_metadata/datasets/statistic_subject_mapping.py,sha256=ovT-bZv6eGPD3L0UIs5nIw4AjJrfZn0hyWyD72JBmhs,6395
|
|
17
17
|
dapla_metadata/datasets/compatibility/__init__.py,sha256=hKoLOIhF-BMS8EZQUaAI_S-rf6QXufyI0tr9LB3ly74,400
|
|
@@ -21,9 +21,9 @@ dapla_metadata/datasets/compatibility/model_backwards_compatibility.py,sha256=W5
|
|
|
21
21
|
dapla_metadata/datasets/external_sources/__init__.py,sha256=qvIdXwqyEmXNUCB94ZtZXRzifdW4hiXASFFPtC70f6E,83
|
|
22
22
|
dapla_metadata/datasets/external_sources/external_sources.py,sha256=9eIcOIUbaodNX1w9Tj2wl4U4wUmr5kF1R0i01fKUzGs,2974
|
|
23
23
|
dapla_metadata/datasets/utility/__init__.py,sha256=pp6tUcgUbo8iq9OPtFKQrTbLuI3uY7NHptwWSTpasOU,33
|
|
24
|
-
dapla_metadata/datasets/utility/constants.py,sha256=
|
|
24
|
+
dapla_metadata/datasets/utility/constants.py,sha256=YKsn6GfNIkwLoBp0yq209o0TbsEhsA_jGaZLVR984JU,2933
|
|
25
25
|
dapla_metadata/datasets/utility/enums.py,sha256=i6dcxWya5k4LjLdGGIM_H37rRndizug3peaAgoE5UdM,652
|
|
26
|
-
dapla_metadata/datasets/utility/utils.py,sha256=
|
|
26
|
+
dapla_metadata/datasets/utility/utils.py,sha256=Enlmhj1BA7C9Im1ju3EwS6_kV1cpT53wb2cCtBGs_lI,20145
|
|
27
27
|
dapla_metadata/standards/__init__.py,sha256=n8jnMrudLuScSdfQ4UMJorc-Ptg3Y1-ilT8zAaQnM70,179
|
|
28
28
|
dapla_metadata/standards/name_validator.py,sha256=6-DQE_EKVd6UjL--EXpFcZDQtusVbSFaWaUY-CfOV2c,9184
|
|
29
29
|
dapla_metadata/standards/standard_validators.py,sha256=tcCiCI76wUVtMzXA2oCgdauZc0uGgUi11FKu-t7KGwQ,3767
|
|
@@ -90,7 +90,7 @@ dapla_metadata/variable_definitions/_utils/constants.py,sha256=zr5FNVCEz6TM9PVEr
|
|
|
90
90
|
dapla_metadata/variable_definitions/_utils/files.py,sha256=JbPgPNQ7iA38juMqGEdcg5OjZZUwCb6NQtPL0AEspD0,10933
|
|
91
91
|
dapla_metadata/variable_definitions/_utils/template_files.py,sha256=7fcc7yEHOl5JUZ698kqj4IiikXPHBi3SrAVOk4wqQtw,3308
|
|
92
92
|
dapla_metadata/variable_definitions/_utils/variable_definition_files.py,sha256=sGhcSpckR9NtYGNh2oVkiCd5SI3bbJEBhc1PA2uShs0,4701
|
|
93
|
-
dapla_toolbelt_metadata-0.9.
|
|
94
|
-
dapla_toolbelt_metadata-0.9.
|
|
95
|
-
dapla_toolbelt_metadata-0.9.
|
|
96
|
-
dapla_toolbelt_metadata-0.9.
|
|
93
|
+
dapla_toolbelt_metadata-0.9.4.dist-info/METADATA,sha256=xJyJK0IwI1cbzZyCNPNnBnGEAjHcwcwtjMPMt_MysrM,4723
|
|
94
|
+
dapla_toolbelt_metadata-0.9.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
95
|
+
dapla_toolbelt_metadata-0.9.4.dist-info/licenses/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
|
|
96
|
+
dapla_toolbelt_metadata-0.9.4.dist-info/RECORD,,
|
|
File without changes
|
{dapla_toolbelt_metadata-0.9.3.dist-info → dapla_toolbelt_metadata-0.9.4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|