Skip to content

Commit

Permalink
Merge pull request #1224 from cfe-lab/docker-microtest
Browse files Browse the repository at this point in the history
Docker microtest
  • Loading branch information
Donaim authored Jan 2, 2025
2 parents 8bdb9ed + 324836b commit 2e64c4d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ jobs:
run: docker run micall --help
- name: Check docker image entrypoint
run: docker run micall --help | grep -i -e 'docker'
- name: Check docker image microtest
run: python micall/main.py release_test_microtest micall --docker

singularity-test:
runs-on: ubuntu-20.04
Expand Down
54 changes: 41 additions & 13 deletions micall/utils/release_test_microtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,9 @@ def create_sample_scratch(fastq_file):


class SampleRunner:
def __init__(self, image_path: Path):
def __init__(self, image_path: Path, is_docker: bool = False):
self.image_path = image_path
self.is_docker = is_docker
self.is_denovo = False
self.bad_cycles_path = None

Expand Down Expand Up @@ -572,21 +573,46 @@ def process_resistance(self, sample_group: SampleGroup):
def build_command(self, inputs, outputs, app_name=None):
input_path = inputs[0].parent
output_path = outputs[0].parent
command = ['singularity',
'run',
'--contain',
'--cleanenv',
'-B',
'{}:/mnt/input,{}:/mnt/output'.format(input_path,
output_path)]
if app_name:
command.append('--app')
command.append(app_name)
command.append(self.image_path)

if self.is_docker:
command = ['docker',
'run',
'--rm',
'--read-only',
'--volume', '{}:/mnt/input'.format(input_path),
'--volume', '{}:/mnt/output'.format(output_path),
'--volume', '{}:/tmp'.format(output_path / 'tmp'),
'--entrypoint', 'micall',
'--', str(self.image_path),
]

app_arguments = {
None: ['micall_kive'],
'filter_quality': ['filter_quality'],
'resistance': ['micall_kive_resistance'],
'denovo': ['micall_kive', '--denovo'],
}[app_name]

command.extend(app_arguments)

else:
command = ['singularity',
'run',
'--contain',
'--cleanenv',
'-B',
'{}:/mnt/input,{}:/mnt/output'.format(input_path,
output_path)]
if app_name:
command.append('--app')
command.append(app_name)
command.append(str(self.image_path))

for arguments, guest_path in zip((inputs, outputs),
('/mnt/input', '/mnt/output')):
for argument in arguments:
command.append(os.path.join(guest_path, argument.name))

return command


Expand Down Expand Up @@ -622,6 +648,8 @@ def main():
help='Folder to copy microtest samples into.')
parser.add_argument('--sample',
help='Prefix of sample name to run.')
parser.add_argument('--docker', action='store_true',
help='If to use docker instead of Singularity.')
# noinspection PyTypeChecker
parser.add_argument('image',
type=Path,
Expand All @@ -642,7 +670,7 @@ def main():
for source_file in source_files:
target_file: Path = sandbox_path / source_file.name
shutil.copy(str(source_file), str(target_file))
runner = SampleRunner(args.image)
runner = SampleRunner(args.image, is_docker=args.docker)
with ProcessPoolExecutor() as pool:
search_pattern = '*_R1_*.fastq'
if args.sample:
Expand Down

0 comments on commit 2e64c4d

Please sign in to comment.