Skip to content

Commit a95e379

Browse files
author
Alan Christie
committed
feat: Now supports comma-separated input file lists
1 parent a46f9bb commit a95e379

File tree

4 files changed

+34
-27
lines changed

4 files changed

+34
-27
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
minimum_pre_commit_version: 2.18.1
2+
minimum_pre_commit_version: 3.3.3
33
exclude: ^src/jote/VERSION
44

55
repos:
@@ -9,7 +9,7 @@ repos:
99

1010
# Conventional Commit message checker (commitizen)
1111
- repo: https://github.com/commitizen-tools/commitizen
12-
rev: v2.23.0
12+
rev: v3.5.3
1313
hooks:
1414
- id: commitizen
1515
stages:
@@ -20,7 +20,7 @@ repos:
2020

2121
# Standard pre-commit rules
2222
- repo: https://github.com/pre-commit/pre-commit-hooks
23-
rev: v4.1.0
23+
rev: v4.4.0
2424
hooks:
2525
- id: check-case-conflict
2626
- id: check-docstring-first
@@ -33,15 +33,15 @@ repos:
3333
- --markdown-linebreak-ext=md
3434
# Black (uncompromising) Python code formatter
3535
- repo: https://github.com/psf/black
36-
rev: 22.3.0
36+
rev: 23.7.0
3737
hooks:
3838
- id: black
3939
args:
4040
- --target-version
4141
- py39
4242
# MyPy
4343
- repo: https://github.com/pre-commit/mirrors-mypy
44-
rev: v0.942
44+
rev: v1.4.1
4545
hooks:
4646
- id: mypy
4747
files: ^src
@@ -50,7 +50,7 @@ repos:
5050
- --non-interactive
5151
# Pylint
5252
- repo: https://github.com/pycqa/pylint
53-
rev: v2.13.5
53+
rev: v2.17.4
5454
hooks:
5555
- id: pylint
5656
files: ^src

DEVELOPER-README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ To build the package distribution manually run: -
4141

4242
To install the local build, without needing to publish the package run: -
4343

44-
pip install dist/im_jote-1.0.0-py3-none-any.whl
44+
pip install dist/im_jote-*-py3-none-any.whl
4545

4646
---
4747

build-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pyroma == 4.2
22
pytest == 7.4.0
33
pytest-cov == 4.1.0
4-
mypy ==1.4.1
4+
mypy == 1.4.1
55
pre-commit == 3.3.3

src/jote/jote.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class TestResult(Enum):
6767

6868

6969
def _print_test_banner(collection: str, job_name: str, job_test_name: str) -> None:
70-
7170
print(" ---")
7271
print(f"+ collection={collection} job={job_name} test={job_test_name}")
7372

@@ -180,7 +179,6 @@ def _add_grouped_test(
180179
"""
181180

182181
for run_group_name in run_group_names:
183-
184182
# Find the test-group for this test
185183
test_group_definition: Optional[DefaultMunch] = None
186184
for test_group in test_groups:
@@ -272,7 +270,6 @@ def _load(
272270
num_tests: int = 0
273271

274272
for jd_filename in manifest_munch["job-definition-files"]:
275-
276273
# Does the definition comply with the schema?
277274
# No options here - it must.
278275
jd_path: str = os.path.join(_DEFINITION_DIRECTORY, jd_filename)
@@ -349,7 +346,6 @@ def _copy_inputs(test_inputs: List[str], project_path: str) -> bool:
349346
# The files are assumed to reside in the repo's 'data' directory.
350347
print(f'# Copying inputs (from "${{PWD}}/{_DATA_DIRECTORY_PATH}")...')
351348
for test_input in test_inputs:
352-
353349
print(f"# + {test_input}")
354350

355351
if not test_input.startswith(_DATA_DIRECTORY_PATH):
@@ -370,7 +366,6 @@ def _copy_inputs(test_inputs: List[str], project_path: str) -> bool:
370366

371367

372368
def _check_exists(name: str, path: str, expected: bool, fix_permissions: bool) -> bool:
373-
374369
exists: bool = os.path.exists(path)
375370
if expected and not exists:
376371
print(f"# exists ({expected}) [FAILED]")
@@ -427,7 +422,6 @@ def _check_exists(name: str, path: str, expected: bool, fix_permissions: bool) -
427422

428423

429424
def _check_line_count(name: str, path: str, expected: int) -> bool:
430-
431425
line_count: int = 0
432426
with open(path, "rt", encoding="UTF-8") as check_file:
433427
for _ in check_file:
@@ -682,17 +676,32 @@ def _run_a_test(
682676
else:
683677
# It is an input (not an option).
684678
# The input is a list if it's declared as 'multiple'.
679+
#
680+
# We also have to deal with each file being a potential pair
681+
# i.e. "data/nsp13-x0176_0B.mol,data/nsp13-x0176_0B_apo-desolv.pdb"
682+
# This will appear in job_variables as: -
683+
# "nsp13-x0176_0B.mol,nsp13-x0176_0B_apo-desolv.pdb"
684+
# and in the input files as two files: -
685+
# "data/nsp13-x0176_0B.mol" and "data/nsp13-x0176_0B_apo-desolv.pdb"
685686
if job_definition.variables.inputs.properties[variable].multiple:
686687
job_variables[variable] = []
687688
for value in job_definition.tests[job_test_name].inputs[
688689
variable
689690
]:
690-
job_variables[variable].append(os.path.basename(value))
691-
input_files.append(value)
691+
basename_values = []
692+
for value_item in value.split(","):
693+
value_basename = os.path.basename(value_item)
694+
basename_values.append(value_basename)
695+
input_files.append(value_item)
696+
job_variables[variable].append(",".join(basename_values))
692697
else:
693698
value = job_definition.tests[job_test_name].inputs[variable]
694-
job_variables[variable] = os.path.basename(value)
695-
input_files.append(value)
699+
basename_values = []
700+
for value_item in value.split(","):
701+
value_basename = os.path.basename(value_item)
702+
basename_values.append(value_basename)
703+
input_files.append(value_item)
704+
job_variables[variable].append(",".join(basename_values))
696705

697706
decoded_command: str = ""
698707
test_environment: Dict[str, str] = {}
@@ -728,6 +737,9 @@ def _run_a_test(
728737
# Get the raw (encoded) command from the job definition...
729738
raw_command: str = job_definition.command
730739
# Decode it using our variables...
740+
if args.verbose:
741+
print(f"> raw_command={raw_command}")
742+
print(f"> job_variables={job_variables}")
731743
decoded_command, test_status = decoder.decode(
732744
raw_command,
733745
job_variables,
@@ -800,7 +812,6 @@ def _run_a_test(
800812

801813
# Run the container
802814
if not args.dry_run:
803-
804815
timeout_minutes: int = DEFAULT_TEST_TIMEOUT_M
805816
if "timeout-minutes" in job_definition.tests[job_test_name]:
806817
timeout_minutes = job_definition.tests[job_test_name]["timeout-minutes"]
@@ -888,7 +899,6 @@ def _run_ungrouped_tests(
888899
tests_failed: int = 0
889900

890901
for job_test_name in job_definition.tests:
891-
892902
# If a job test has been named,
893903
# skip this test if it doesn't match.
894904
# We do not include this test in the count.
@@ -957,11 +967,9 @@ def _run_grouped_tests(
957967

958968
test_result: Optional[TestResult] = None
959969
for jd_filename, grouped_tests in grouped_job_definitions.items():
960-
961970
# The grouped definitions are indexed by JobDefinition filename
962971
# and for each there is a list of dictionaries (indexed by group name).
963972
for file_run_group in grouped_tests:
964-
965973
run_group_name: str = file_run_group["test-group-name"]
966974
if args.run_group and run_group_name != args.run_group:
967975
# A specific group has been named
@@ -1004,15 +1012,13 @@ def _run_grouped_tests(
10041012
and existing_group_test[3] == job[1]
10051013
and existing_group_test[4] == job_test_name
10061014
):
1007-
10081015
new_test = False
10091016
break
10101017

10111018
if run_group.ordinal == existing_group_test[1] and (
10121019
existing_group_test[2] != job[0]
10131020
or existing_group_test[3] != job[1]
10141021
):
1015-
10161022
# Oops - ordinal used elsewhere in this group.
10171023
# Return a failure!
10181024
print("! FAILURE")
@@ -1052,7 +1058,6 @@ def _run_grouped_tests(
10521058
# 3. stop the compose file
10531059
group_compose_file: Optional[str] = None
10541060
for index, grouped_test in enumerate(grouped_tests):
1055-
10561061
# For each grouped test we have a test-group definition [at index 0],
10571062
# an 'ordinal' [1], 'collection' [2], 'job name' [3], 'job test' [4]
10581063
# and the 'job' definition [5]
@@ -1254,7 +1259,10 @@ def main() -> int:
12541259
)
12551260

12561261
arg_parser.add_argument(
1257-
"-v", "--verbose", action="store_true", help="Displays test stdout"
1262+
"-v",
1263+
"--verbose",
1264+
action="store_true",
1265+
help="Displays test stdout amongst other things",
12581266
)
12591267

12601268
arg_parser.add_argument(
@@ -1457,7 +1465,6 @@ def main() -> int:
14571465
# MAIN
14581466
# -----------------------------------------------------------------------------
14591467
if __name__ == "__main__":
1460-
14611468
_RET_VAL: int = main()
14621469
if _RET_VAL != 0:
14631470
sys.exit(_RET_VAL)

0 commit comments

Comments
 (0)