From d2ee2b93c7889461ae6eaccbd88c973abd84e115 Mon Sep 17 00:00:00 2001 From: Jan Sander <63044278+JanhSander@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:36:22 +0100 Subject: [PATCH] Saving contains_data_from and contains_data_until to metadata Co-authored-by: Cecilie Seim Co-authored-by: Miles Mason Winther --- src/datadoc/backend/dapla_dataset_path_info.py | 1 + src/datadoc/backend/datadoc_metadata.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/datadoc/backend/dapla_dataset_path_info.py b/src/datadoc/backend/dapla_dataset_path_info.py index da787897..b24284bd 100644 --- a/src/datadoc/backend/dapla_dataset_path_info.py +++ b/src/datadoc/backend/dapla_dataset_path_info.py @@ -254,6 +254,7 @@ def convert_ssb_period( class DaplaDatasetPathInfo: """Extract info from a path following SSB's dataset naming convention.""" + # def __init__(self, dataset_path: str | os.PathLike[str]) -> None: def __init__(self, dataset_path: str) -> None: """Digest the path so that it's ready for further parsing.""" self.dataset_path = pathlib.Path(dataset_path) diff --git a/src/datadoc/backend/datadoc_metadata.py b/src/datadoc/backend/datadoc_metadata.py index 2b255396..86c7ed83 100644 --- a/src/datadoc/backend/datadoc_metadata.py +++ b/src/datadoc/backend/datadoc_metadata.py @@ -11,6 +11,7 @@ from datadoc_model import model from datadoc import config +from datadoc.backend.dapla_dataset_path_info import DaplaDatasetPathInfo from datadoc.backend.dataset_parser import DatasetParser from datadoc.backend.model_backwards_compatibility import upgrade_metadata from datadoc.backend.storage_adapter import StorageAdapter @@ -214,10 +215,14 @@ def extract_metadata_from_dataset( """ self.ds_schema: DatasetParser = DatasetParser.for_file(dataset) + dapla_dataset_path_info = DaplaDatasetPathInfo(dataset) + self.meta.dataset = model.Dataset( short_name=self.short_name, dataset_state=self.dataset_state, version=self.get_dataset_version(short_name), + contains_data_from=str(dapla_dataset_path_info.contains_data_from), + contains_data_until=str(dapla_dataset_path_info.contains_data_until), data_source_path=self.dataset, created_by=self.current_user, )