Skip to content

Commit 57ba220

Browse files
author
Alan Christie
committed
fix: Use of decoder 1.12.2
Now copies nextflow config into place Fixed network name Removing group compose deletes orphans Sleeps for 10 seconds after running the group compose file Fix -k behaviour for group files
1 parent 42a6b37 commit 57ba220

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
docker-compose == 1.29.2
2-
im-data-manager-job-decoder == 1.12.1
2+
im-data-manager-job-decoder == 1.12.2
33
munch == 2.5.0
44
pyyaml == 5.4.1
55
yamllint == 1.28.0

src/jote/compose.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import os
1313
import shutil
1414
import subprocess
15+
import time
1516
from typing import Any, Dict, Optional, Tuple
1617

1718
# The 'simulated' instance directory,
@@ -226,10 +227,16 @@ def run(
226227

227228
try:
228229
# Run the container
229-
# and then cleanup
230+
# and then cleanup.
231+
# By using '-p' ('--project-name')
232+
# we set the prefix for the network name and can use compose files
233+
# from different directories. Without this the network name
234+
# is prefixed by the directory the compose file is in.
230235
test = subprocess.run(
231236
[
232237
"docker-compose",
238+
"-p",
239+
"data-manager",
233240
"up",
234241
"--exit-code-from",
235242
"job",
@@ -267,12 +274,18 @@ def run_group_compose_file(compose_file: str) -> bool:
267274
"""Runs a group compose file in a detached state.
268275
The file is expected to be resident in the 'data-manager' directory."""
269276
try:
270-
# Bring the compose file up...
277+
# Bring the group-test compose file up.
278+
# By using '-p' ('--project-name')
279+
# we set the prefix for the network name and services from this container
280+
# are visible to the test container. Without this the network name
281+
# is prefixed by the directory the compose file is in.
271282
_ = subprocess.run(
272283
[
273284
"docker-compose",
274285
"-f",
275286
os.path.join("data-manager", compose_file),
287+
"-p",
288+
"data-manager",
276289
"up",
277290
"-d",
278291
],
@@ -282,6 +295,10 @@ def run_group_compose_file(compose_file: str) -> bool:
282295
except: # pylint: disable=bare-except
283296
return False
284297

298+
# Wait for 10 seconds.
299+
# Giving the container
300+
time.sleep(10)
301+
285302
return True
286303

287304
@staticmethod
@@ -296,6 +313,7 @@ def stop_group_compose_file(compose_file: str) -> bool:
296313
"-f",
297314
os.path.join("data-manager", compose_file),
298315
"down",
316+
"--remove-orphans",
299317
],
300318
capture_output=False,
301319
timeout=240,

src/jote/jote.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,19 @@ def _check(
475475

476476

477477
def _run_nextflow(
478-
command: str, project_path: str, timeout_minutes: int = DEFAULT_TEST_TIMEOUT_M
478+
command: str,
479+
project_path: str,
480+
nextflow_config_file: str,
481+
timeout_minutes: int = DEFAULT_TEST_TIMEOUT_M,
479482
) -> Tuple[int, str, str]:
480483
"""Runs nextflow in the project directory returning the exit code,
481484
stdout and stderr.
482485
"""
483486
assert command
484487
assert project_path
485488

489+
print('# Executing the test ("nextflow")...')
490+
486491
# The user cannot have a nextflow config in their home directory.
487492
# Nextflow looks here and any config will be merged with the test config.
488493
if _USR_HOME:
@@ -496,7 +501,17 @@ def _run_nextflow(
496501
print("! You cannot test Jobs and have your own config file")
497502
return 1, "", ""
498503

499-
print('# Executing the test ("nextflow")...')
504+
# Is there a Nextflow config file defined for this test?
505+
# It's a file in the 'data-manager' directory.
506+
if nextflow_config_file:
507+
print(
508+
f'# Copying nextflow config file ("{nextflow_config_file}") to {project_path}'
509+
)
510+
shutil.copyfile(
511+
os.path.join("data-manager", nextflow_config_file),
512+
os.path.join(project_path, "nextflow.config"),
513+
)
514+
500515
print(f'# Execution directory is "{project_path}"')
501516

502517
cwd = os.getcwd()
@@ -733,8 +748,16 @@ def _run_a_test(
733748
# Run nextflow directly
734749
assert job_command
735750
assert project_path
751+
752+
# Is there a nextflow config file for this test?
753+
nextflow_config_file: str = ""
754+
if "nextflow-config-file" in job_definition.tests[job_test_name]:
755+
nextflow_config_file = job_definition.tests[job_test_name][
756+
"nextflow-config-file"
757+
]
758+
736759
exit_code, out, err = _run_nextflow(
737-
job_command, project_path, timeout_minutes
760+
job_command, project_path, nextflow_config_file, timeout_minutes
738761
)
739762
else:
740763
print("! FAILURE")
@@ -971,7 +994,7 @@ def _run_grouped_tests(
971994

972995
# Always try and teardown the test compose
973996
# between tests in a group.
974-
if compose:
997+
if compose and not args.keep_results:
975998
compose.delete()
976999

9771000
# And stop if any test has failed.

0 commit comments

Comments
 (0)