Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor files and required_files to sizing and tangible keys respect… #73

Merged
merged 1 commit into from
Sep 10, 2024
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
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
Loading