Skip to content

Commit

Permalink
Add profiles (#36)
Browse files Browse the repository at this point in the history
* Add case name to output directory path

* Update CHANGELOG

* Bump to rc2

* Fix return type

* Add profiles option

* Update README

* Update CHANGELOG

* Simplify config resolution

* Add quoting for profiles args
  • Loading branch information
yashpatel6 authored Mar 24, 2023
1 parent 1799580 commit 3e9a326
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

---

## [1.0.0-rc.2] - 2023-02-13
## [1.0.0-rc.2] - 2023-03-09
### Added
- Case name to output directory path to avoid over-writing
- Support for Nextflow profiles
### Changed
- Override `skip` from configuration YAML for command line test cases

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ The settings available for each case:
|:--:|:--:|:--:|
|`temp_dir`|Directory to be added to `NFT_TEMP` environment variable to create Nextflow working directory.|_value from global_|
|`nf_config`|Path to be added to `NFT_INIT` to derive global `.config` file for Nextflow.|_value from global_|
|`profiles`|Ordered list of profiles to use with Nextflow through the `-profile` option.|`None`|
|`remove_temp`|Whether to remove the Nextflow working directory after each case.|_value from global_|
|`clean_logs`|Whether to remove log files generated by Nextflow.|_value from global_|
|`name`|Name of the test case; used to identify the case and for selecting specific cases to run.|`None`|
Expand Down
6 changes: 5 additions & 1 deletion nftest/NFTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
import re
from pathlib import Path
from shlex import quote
import subprocess as sp
from subprocess import PIPE
from logging import getLogger
Expand All @@ -20,7 +21,7 @@ class NFTestCase():
# pylint: disable=R0902
# pylint: disable=R0913
def __init__(self, name:str=None, message:str=None, nf_script:str=None,
nf_configs:List[str]=None, params_file:str=None,
nf_configs:List[str]=None, profiles:List[str]=None, params_file:str=None,
output_directory_param_name:str='output_dir',
asserts:List[NFTestAssert]=None, temp_dir:str=None,
remove_temp:bool=None, clean_logs:bool=True,
Expand All @@ -33,6 +34,7 @@ def __init__(self, name:str=None, message:str=None, nf_script:str=None,
self.message = message
self.nf_script = nf_script
self.nf_configs = nf_configs or []
self.profiles = profiles or []
self.params_file = params_file
self.output_directory_param_name = output_directory_param_name
self.asserts = self.resolve_actual(asserts)
Expand Down Expand Up @@ -90,13 +92,15 @@ def submit(self) -> sp.CompletedProcess:
for nf_config in self.nf_configs:
config_arg += f'-c {nf_config} '
params_file_arg = f"-params-file {self.params_file}" if self.params_file else ""
profiles_arg = f"-profile {quote(','.join(self.profiles))}" if self.profiles else ""
output_directory_with_case = Path(self._env.NFT_OUTPUT)/self.name_for_output
output_directory_arg = f"--{self.output_directory_param_name} " \
f"{output_directory_with_case}"
cmd = f"""
NXF_WORK={self.temp_dir} \
nextflow run \
{self.nf_script} \
{profiles_arg} \
{config_arg} \
{params_file_arg} \
{output_directory_arg}
Expand Down
3 changes: 1 addition & 2 deletions nftest/NFTestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def load_from_config(self, config_yaml:str, target_cases:List[str]):
else:
asserts = []
case['asserts'] = asserts
case['nf_configs'] = [case['nf_config']] if case['nf_config'] is not None else []
del case['nf_config']
case['nf_configs'] = [case.pop('nf_config')] if case.get('nf_config', None) else []
test_case = NFTestCase(**case)
test_case.combine_global(self._global)
if target_cases:
Expand Down

0 comments on commit 3e9a326

Please sign in to comment.