diff --git a/docs/api_docs.md b/docs/api_docs.md index 5404629b..dd47fac1 100644 --- a/docs/api_docs.md +++ b/docs/api_docs.md @@ -1,4 +1,4 @@ -Final targets: convert_project, get_available_pep_filters, inspect_project, read_schema, validate_config, validate_project, validate_sample +Final targets: EidoValidationError, convert_project, get_available_pep_filters, get_input_files_size, inspect_project, read_schema, validate_config, validate_input_files, validate_project, validate_sample -# Built-in `eido` Plugins Documentation +# Package `eido` Documentation + +Project configuration ```python -def basic_pep_filter(p, **kwargs) +def basic_pep_filter(p, **kwargs) -> Dict[str, str] ``` Basic PEP filter, that does not convert the Project object. @@ -48,7 +48,7 @@ This filter can save the PEP representation to file, if kwargs include `path`. ```python -def yaml_pep_filter(p, **kwargs) +def yaml_pep_filter(p, **kwargs) -> Dict[str, str] ``` YAML PEP filter, that returns Project object representation. @@ -62,7 +62,7 @@ This filter can save the YAML to file, if kwargs include `path`. ```python -def csv_pep_filter(p, **kwargs) +def csv_pep_filter(p, **kwargs) -> Dict[str, str] ``` CSV PEP filter, that returns Sample object representations @@ -77,7 +77,7 @@ This filter can save the CSVs to files, if kwargs include ```python -def yaml_samples_pep_filter(p, **kwargs) +def yaml_samples_pep_filter(p, **kwargs) -> Dict[str, str] ``` YAML samples PEP filter, that returns only Sample object representations. @@ -93,4 +93,4 @@ This filter can save the YAML to file, if kwargs include `path`. -*Version Information: `eido` v0.1.5-dev, generated by `lucidoc` v0.4.2* +*Version Information: `eido` v0.2.2-dev, generated by `lucidoc` v0.4.4* diff --git a/eido/_version.py b/eido/_version.py index 3ced3581..b5fdc753 100644 --- a/eido/_version.py +++ b/eido/_version.py @@ -1 +1 @@ -__version__ = "0.2.1" +__version__ = "0.2.2" diff --git a/eido/argparser.py b/eido/argparser.py index f5ae7632..e5581f9c 100644 --- a/eido/argparser.py +++ b/eido/argparser.py @@ -88,16 +88,6 @@ def build_argparser(): metavar="S", ) - sps[VALIDATE_CMD].add_argument( - "-e", - "--exclude-case", - default=False, - action="store_true", - help="Whether to exclude the validation case from an error. " - "Only the human readable message explaining the error will " - "be raised. Useful when validating large PEPs.", - ) - sps[INSPECT_CMD].add_argument( "-n", "--sample-name", diff --git a/eido/cli.py b/eido/cli.py index a41ebff5..3aa2e11c 100644 --- a/eido/cli.py +++ b/eido/cli.py @@ -142,19 +142,19 @@ def main(): f"against a schema: {args.schema}" ) validator = validate_sample - arguments = [p, args.sample_name, args.schema, args.exclude_case] + arguments = [p, args.sample_name, args.schema] elif args.just_config: _LOGGER.debug( f"Comparing Project ('{args.pep}') against a schema: {args.schema}" ) validator = validate_config - arguments = [p, args.schema, args.exclude_case] + arguments = [p, args.schema] else: _LOGGER.debug( f"Comparing Project ('{args.pep}') against a schema: {args.schema}" ) validator = validate_project - arguments = [p, args.schema, args.exclude_case] + arguments = [p, args.schema] try: validator(*arguments) except EidoValidationError as e: diff --git a/eido/exceptions.py b/eido/exceptions.py index 6067063b..ca401459 100644 --- a/eido/exceptions.py +++ b/eido/exceptions.py @@ -43,3 +43,7 @@ class EidoValidationError(EidoException): def __init__(self, message, errors_by_type): super().__init__(message) self.errors_by_type = errors_by_type + self.message = message + + def __str__(self): + return f"EidoValidationError ({self.message}): {self.errors_by_type}" diff --git a/eido/inspection.py b/eido/inspection.py index f76726c8..2f47ae53 100644 --- a/eido/inspection.py +++ b/eido/inspection.py @@ -77,7 +77,11 @@ def get_input_files_size(sample, schema): all_inputs.update(required_inputs) with catch_warnings(record=True) as w: input_file_size = sum( - [size(f, size_str=False) or 0.0 for f in all_inputs if f != ""] + [ + size(f, size_str=False) or 0.0 + for f in all_inputs + if f != "" and f != None + ] ) / (1024**3) if w: _LOGGER.warning( diff --git a/eido/validation.py b/eido/validation.py index 528aa853..c15db164 100644 --- a/eido/validation.py +++ b/eido/validation.py @@ -21,19 +21,19 @@ _LOGGER = getLogger(__name__) -def _validate_object(object, schema, sample_name_colname=False): +def _validate_object(obj, schema, sample_name_colname=False): """ Generic function to validate object against a schema - :param Mapping object: an object to validate + :param Mapping obj: an object to validate :param str | dict schema: schema dict to validate against or a path to one from the error. Useful when used ith large projects :raises EidoValidationError: if validation is unsuccessful """ validator = Draft7Validator(schema) - _LOGGER.debug(f"{object},\n {schema}") - if not validator.is_valid(object): - errors = sorted(validator.iter_errors(object), key=lambda e: e.path) + _LOGGER.debug(f"{obj},\n {schema}") + if not validator.is_valid(obj): + errors = sorted(validator.iter_errors(obj), key=lambda e: e.path) errors_by_type = {} # Accumulate and restructure error objects by error type diff --git a/requirements/requirements-all.txt b/requirements/requirements-all.txt index 6c9f39c0..5517bdc8 100644 --- a/requirements/requirements-all.txt +++ b/requirements/requirements-all.txt @@ -1,5 +1,5 @@ jsonschema>=3.0.1 logmuse>=0.2.5 pandas -peppy>=0.35.5 +peppy>=0.35.7 ubiquerg>=0.5.2 diff --git a/webeido/webeido/main.py b/webeido/webeido/main.py index 3375e021..f5e67f2c 100644 --- a/webeido/webeido/main.py +++ b/webeido/webeido/main.py @@ -112,7 +112,7 @@ async def validate_pep(request: Request, files: List[UploadFile] = File(...)): def vwrap(p, schema): x = None try: - eido.validate_project(project=p, schema=schema, exclude_case=True) + eido.validate_project(project=p, schema=schema) except Exception as e: x = e print(x)