diff --git a/acmc/phen.py b/acmc/phen.py index 1ae243d160ac24a10303a3fab3c24a0d8175da55..3db5beba072ccd8e9997b3ba11d6b6d091795d26 100644 --- a/acmc/phen.py +++ b/acmc/phen.py @@ -54,7 +54,7 @@ CONFIG_SCHEMA = { "version": { "type": "string", "required": True, - "regex": r"^v\d+\.\d+\.\d+$" # Enforces 'vN.N.N' format + "regex": r"^v\d+\.\d+\.\d+$", # Enforces 'vN.N.N' format }, "omop": { "type": "dict", @@ -65,9 +65,9 @@ CONFIG_SCHEMA = { "vocabulary_reference": { "type": "string", "required": True, - "regex": r"^https?://.*" # Ensures it's a URL + "regex": r"^https?://.*", # Ensures it's a URL }, - } + }, }, "concept_sets": { "type": "list", @@ -82,23 +82,24 @@ CONFIG_SCHEMA = { "schema": { "path": {"type": "string", "required": True}, "columns": {"type": "dict", "required": True}, - "category": {"type": "string"}, # Optional but must be string if present + "category": { + "type": "string" + }, # Optional but must be string if present "actions": { "type": "dict", - "schema": { - "divide_col": {"type": "string"} - }, - }, - }, + "schema": {"divide_col": {"type": "string"}}, + }, + }, }, "metadata": {"type": "dict", "required": True}, }, - }, + }, }, }, } } + class PhenValidationException(Exception): """Custom exception class raised when validation errors in phenotype configuration file""" @@ -314,18 +315,16 @@ def validate(phen_dir): try: with config_path.open("r") as file: phenotype = yaml.safe_load(file) - + validator = Validator(CONFIG_SCHEMA) if validator.validate(phenotype): logger.debug("YAML structure is valid.") else: logger.error(f"YAML structure validation failed: {validator.errors}") - raise Exception( - f"YAML structure validation failed: {validator.errors}" - ) + raise Exception(f"YAML structure validation failed: {validator.errors}") except yaml.YAMLError as e: logger.error(f"YAML syntax error: {e}") - raise e + raise e else: raise Exception( f"Unsupported configuration filetype: {str(config_path.resolve())}" @@ -387,7 +386,6 @@ def validate(phen_dir): if action not in COL_ACTIONS: validation_errors.append(f"Action {action} is not supported") - if len(validation_errors) > 0: logger.error(validation_errors) raise PhenValidationException( diff --git a/acmc/trud.py b/acmc/trud.py index d8852cc5b424c20e7271bd6162e849671f5ba840..93298f90f672daec34dc92ca5f308d4b07caa149 100644 --- a/acmc/trud.py +++ b/acmc/trud.py @@ -6,7 +6,7 @@ import shutil import hashlib import zipfile import pandas as pd -import simpledbf # type: ignore +import simpledbf # type: ignore import yaml from pathlib import Path diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml deleted file mode 100644 index d39abac886728a3d771701ec7da4779f2c4b142a..0000000000000000000000000000000000000000 --- a/docs/mkdocs.yml +++ /dev/null @@ -1,28 +0,0 @@ -site_name: ACMC Documentation -theme: - name: material - features: - - navigation.tabs - - navigation.expand - - content.code.copy -nav: - - Home: index.md - - Installation: installation.md - - Usage: usage.md - - Contributing: contributing.md - - API Reference: api.md - - Tutorials: - - Example 1 - Basic local phenotype: ./tutorials/example1.md - - Example 2 - More complex local phenotype: ./tutorials/example2.md - - Example 3 - Using a remote git repository: ./tutorials/example3.md - - Contributing: contributing.md - - Change Log: changelog.md - - Troubleshooting: troubleshooting.md -repo_url: https://git.soton.ac.uk/meldb/concepts-processing/ -plugins: - - search - - mkdocstrings: - handlers: - python: - options: - show_source: false diff --git a/mkdocs.yml b/mkdocs.yml index d3b89a064436f44c90ebdb4489f065b39dfa0210..493e64b2ffdedb7f2b1a5b81d691881533811644 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -9,13 +9,11 @@ nav: - Home: index.md - Installation: installation.md - Usage: usage.md - - Contributing: contributing.md - API Reference: api.md - Tutorials: - Example 1 - Basic local phenotype: ./tutorials/example1.md - Example 2 - More complex local phenotype: ./tutorials/example2.md - Example 3 - Using a remote git repository: ./tutorials/example3.md - - Contributing: contributing.md - Change Log: changelog.md - Troubleshooting: troubleshooting.md repo_url: https://git.soton.ac.uk/meldb/concepts-processing/