Skip to content

Commit

Permalink
Merge pull request #73 from pepkit/dev_schema_revisions
Browse files Browse the repository at this point in the history
refactor files and required_files to sizing and tangible keys respect…
  • Loading branch information
donaldcampbelljr authored Sep 10, 2024
2 parents 68ac5b2 + c7416bd commit 1ed79ab
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
9 changes: 6 additions & 3 deletions eido/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
CONVERT_CMD: "Convert PEP format using filters",
}
PROP_KEY = "properties"
REQUIRED_FILES_KEY = "required_files"
FILES_KEY = "files"

TANGIBLE_KEY = "tangible"
SIZING_KEY = "sizing"

# sample schema input validation key names, these values are required by looper
# to refer to the dict values
Expand All @@ -34,7 +35,9 @@
"FILTERS_CMD",
"SUBPARSER_MSGS",
]
SCHEMA_SECTIONS = ["PROP_KEY", "REQUIRED_FILES_KEY", "FILES_KEY"]

SCHEMA_SECTIONS = ["PROP_KEY", "TANGIBLE_KEY", "SIZING_KEY"]

SCHEMA_VALIDAION_KEYS = [
"MISSING_KEY",
"REQUIRED_INPUTS_KEY",
Expand Down
12 changes: 6 additions & 6 deletions eido/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

from .const import (
ALL_INPUTS_KEY,
FILES_KEY,
INPUT_FILE_SIZE_KEY,
MISSING_KEY,
PROP_KEY,
REQUIRED_FILES_KEY,
REQUIRED_INPUTS_KEY,
SIZING_KEY,
TANGIBLE_KEY,
)
from .schema import read_schema
from .validation import _validate_sample_object, _get_attr_values
Expand Down Expand Up @@ -68,11 +68,11 @@ def get_input_files_size(sample, schema):
required_inputs = set()
schema = schema[-1] # use only first schema, in case there are imports
sample_schema_dict = schema["properties"]["_samples"]["items"]
if FILES_KEY in sample_schema_dict:
all_inputs.update(_get_attr_values(sample, sample_schema_dict[FILES_KEY]))
if REQUIRED_FILES_KEY in sample_schema_dict:
if SIZING_KEY in sample_schema_dict:
all_inputs.update(_get_attr_values(sample, sample_schema_dict[SIZING_KEY]))
if TANGIBLE_KEY in sample_schema_dict:
required_inputs = set(
_get_attr_values(sample, sample_schema_dict[REQUIRED_FILES_KEY])
_get_attr_values(sample, sample_schema_dict[TANGIBLE_KEY])
)
all_inputs.update(required_inputs)
with catch_warnings(record=True) as w:
Expand Down
12 changes: 6 additions & 6 deletions eido/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import peppy

from .const import (
FILES_KEY,
PROP_KEY,
REQUIRED_FILES_KEY,
SIZING_KEY,
TANGIBLE_KEY,
)
from .exceptions import PathAttrNotFoundError
from .schema import preprocess_schema, read_schema
Expand Down Expand Up @@ -212,11 +212,11 @@ def validate_input_files(
required_inputs = set()
schema = schemas[-1] # use only first schema, in case there are imports
sample_schema_dict = schema["properties"]["_samples"]["items"]
if FILES_KEY in sample_schema_dict:
all_inputs.update(_get_attr_values(sample, sample_schema_dict[FILES_KEY]))
if REQUIRED_FILES_KEY in sample_schema_dict:
if SIZING_KEY in sample_schema_dict:
all_inputs.update(_get_attr_values(sample, sample_schema_dict[SIZING_KEY]))
if TANGIBLE_KEY in sample_schema_dict:
required_inputs = set(
_get_attr_values(sample, sample_schema_dict[REQUIRED_FILES_KEY])
_get_attr_values(sample, sample_schema_dict[TANGIBLE_KEY])
)
all_inputs.update(required_inputs)

Expand Down
4 changes: 2 additions & 2 deletions tests/data/schemas/schema_test_file_exist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ properties:
- type: array
items:
type: string
files:
sizing:
- local_files

required_files:
tangible:
- local_files

required:
Expand Down

0 comments on commit 1ed79ab

Please sign in to comment.