Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 5 additions & 1 deletion relecov_tools/build_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand Down
11 changes: 11 additions & 0 deletions relecov_tools/read_lab_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,13 +932,24 @@ 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)):
value = re.match(
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))))
Expand Down
Loading