diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e887ba6..f84613c2 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Updated add-extra-config and included Initial configuration description in README.md [#861]https://github.com/BU-ISCIII/relecov-tools/pull/861 - Updated test workflows to load initial_config-relecov.yaml first [#861]https://github.com/BU-ISCIII/relecov-tools/pull/861 - Included three initial_config.yaml files for three projects: relecov, mepram & EQA2026 [#861]https://github.com/BU-ISCIII/relecov-tools/pull/861 +- Normalize compact YYYYMMDD dates in read-lab-metadata [#867]https://github.com/BU-ISCIII/relecov-tools/pull/867 #### Fixes @@ -38,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Changed `assets/schema_utils/metadatalab_template.py`: Now supports iterative recursion to flatten nested schemas [#849](https://github.com/BU-ISCIII/relecov-tools/pull/849) - Updated how project name is extracted from config in read-lab-metadata [#861]https://github.com/BU-ISCIII/relecov-tools/pull/861 - Include extra_config=True in all modules that did not have it [#863](https://github.com/BU-ISCIII/relecov-tools/pull/863) +- Update relecov_schema.json title and add space removal check [#867]https://github.com/BU-ISCIII/relecov-tools/pull/867 #### Removed diff --git a/relecov_tools/build_schema.py b/relecov_tools/build_schema.py index 53e0fba2..537eecf1 100644 --- a/relecov_tools/build_schema.py +++ b/relecov_tools/build_schema.py @@ -745,8 +745,12 @@ def build_new_schema( # Fill schema header # FIXME: it gets 'relecov-tools' instead of RELECOV project_name = relecov_tools.utils.get_package_name() + if isinstance(project_name, str): + project_name = project_name.strip() + if " " in project_name: + project_name = re.sub(r"\s+", "-", project_name) new_schema["$id"] = relecov_tools.utils.get_schema_url() - new_schema["title"] = f"{project_name} Schema." + new_schema["title"] = f"{project_name}-schema" new_schema["description"] = ( f"Json Schema that specifies the structure, content, and validation rules for {project_name}" ) diff --git a/relecov_tools/read_lab_metadata.py b/relecov_tools/read_lab_metadata.py index 2aee2ccc..1b2cafd8 100755 --- a/relecov_tools/read_lab_metadata.py +++ b/relecov_tools/read_lab_metadata.py @@ -932,6 +932,7 @@ def read_metadata_file(self): ) if isinstance(key_for_checks, str) and "date" in key_for_checks.lower(): pattern = r"^\d{4}[-/.]\d{2}[-/.]\d{2}" + compact_pattern = r"^\d{8}$" if isinstance(raw_value, dtime): value = str(raw_value.date()) elif re.match(pattern, str(raw_value)): @@ -939,6 +940,16 @@ def read_metadata_file(self): pattern, str(raw_value).replace("/", "-").replace(".", "-"), ).group(0) + elif re.match(compact_pattern, str(raw_value)): + try: + value = dtime.strptime(str(raw_value), "%Y%m%d").strftime( + "%Y-%m-%d" + ) + except ValueError: + log_text = f"Invalid date format in {raw_key}: {raw_value}" + self.logsum.add_error(sample=sample_id, entry=log_text) + stderr.print(f"[red]{log_text} for sample {sample_id}") + continue else: try: value = str(int(float(str(raw_value))))