diff --git a/looper/cli_pydantic.py b/looper/cli_pydantic.py index 669c7f65..16bb6206 100644 --- a/looper/cli_pydantic.py +++ b/looper/cli_pydantic.py @@ -138,31 +138,36 @@ def run_looper(args: TopLevelParser, parser: ArgumentParser, test_args=None): _LOGGER.info("Looper version: {}\nCommand: {}".format(__version__, subcommand_name)) - looper_cfg_path = os.path.relpath(dotfile_path(), start=os.curdir) - - try: - if subcommand_args.looper_config: - looper_config_dict = read_looper_config_file(subcommand_args.looper_config) - else: - looper_config_dict = read_looper_dotfile() - _LOGGER.info(f"Using looper config ({looper_cfg_path}).") - - sample_modifiers_dict = None - cli_modifiers_dict = None - for looper_config_key, looper_config_item in looper_config_dict.items(): - if looper_config_key == SAMPLE_MODS_KEY: - sample_modifiers_dict = looper_config_item - elif looper_config_key == CLI_MODS_KEY: - cli_modifiers_dict = looper_config_item + if subcommand_args.config_file is None: + looper_cfg_path = os.path.relpath(dotfile_path(), start=os.curdir) + try: + if subcommand_args.looper_config: + looper_config_dict = read_looper_config_file( + subcommand_args.looper_config + ) else: - setattr(subcommand_args, looper_config_key, looper_config_item) - - except OSError: - parser.print_help(sys.stderr) + looper_config_dict = read_looper_dotfile() + _LOGGER.info(f"Using looper config ({looper_cfg_path}).") + + cli_modifiers_dict = None + for looper_config_key, looper_config_item in looper_config_dict.items(): + if looper_config_key == CLI_KEY: + cli_modifiers_dict = looper_config_item + else: + setattr(subcommand_args, looper_config_key, looper_config_item) + + except OSError: + parser.print_help(sys.stderr) + _LOGGER.warning( + f"Looper config file does not exist. Use looper init to create one at {looper_cfg_path}." + ) + sys.exit(1) + else: _LOGGER.warning( - f"Looper config file does not exist. Use looper init to create one at {looper_cfg_path}." + "This PEP configures looper through the project config. This approach is deprecated and will " + "be removed in future versions. Please use a looper config file. For more information see " + "looper.databio.org/en/latest/looper-config" ) - sys.exit(1) subcommand_args = enrich_args_via_cfg( subcommand_name, @@ -195,7 +200,6 @@ def run_looper(args: TopLevelParser, parser: ArgumentParser, test_args=None): amendments=subcommand_args.amend, divcfg_path=divcfg, runp=subcommand_name == "runp", - sample_modifiers=sample_modifiers_dict, **{ attr: getattr(subcommand_args, attr) for attr in CLI_PROJ_ATTRS @@ -211,7 +215,6 @@ def run_looper(args: TopLevelParser, parser: ArgumentParser, test_args=None): amendments=subcommand_args.amend, divcfg_path=divcfg, runp=subcommand_name == "runp", - sample_modifiers=sample_modifiers_dict, project_dict=PEPHubClient()._load_raw_pep( registry_path=subcommand_args.config_file ), diff --git a/looper/const.py b/looper/const.py index e38cee18..de080260 100644 --- a/looper/const.py +++ b/looper/const.py @@ -93,7 +93,6 @@ "DEBUG_EIDO_VALIDATION", "LOOPER_GENERIC_OUTPUT_SCHEMA", "LOOPER_GENERIC_COUNT_LINES", - "CLI_MODS_KEY", "PipelineLevel", ] @@ -224,8 +223,6 @@ def _get_apperance_dict(type, templ=APPEARANCE_BY_FLAG): SAMPLE_PL_ARG = "sample_pipeline_interfaces" PROJECT_PL_ARG = "project_pipeline_interfaces" -CLI_MODS_KEY = "cli_modifiers" - DEFAULT_CFG_PATH = os.path.join(os.getcwd(), LOOPER_DOTFILE_NAME) CLI_PROJ_ATTRS = [ diff --git a/looper/project.py b/looper/project.py index 6daecac1..7a652db7 100644 --- a/looper/project.py +++ b/looper/project.py @@ -131,19 +131,6 @@ def __init__(self, cfg=None, amendments=None, divcfg_path=None, **kwargs): except NotImplementedError: self.name = None - # consolidate sample modifiers - if kwargs.get(SAMPLE_MODS_KEY) and self._modifier_exists(): - _LOGGER.warning( - "Sample modifiers were provided in Looper Config and in PEP Project Config. Merging..." - ) - deep_update(self.config["sample_modifiers"], kwargs.get(SAMPLE_MODS_KEY)) - _LOGGER.debug( - msg=f"Merged sample modifiers: {self.config['sample_modifiers']}" - ) - elif kwargs.get(SAMPLE_MODS_KEY): - self.config.setdefault("sample_modifiers", {}) - self.config["sample_modifiers"] = kwargs.get(SAMPLE_MODS_KEY) - # add sample pipeline interface to the project if kwargs.get(SAMPLE_PL_ARG): self.set_sample_piface(kwargs.get(SAMPLE_PL_ARG)) diff --git a/looper/utils.py b/looper/utils.py index 26776db7..4eb8ca4b 100644 --- a/looper/utils.py +++ b/looper/utils.py @@ -283,6 +283,8 @@ def enrich_args_via_cfg( if getattr(parser_args, key, None): new_value = getattr(parser_args, key) cfg_args_all[key] = new_value + else: + cfg_args_all = {} looper_config_cli_modifiers = None if cli_modifiers: @@ -604,8 +606,8 @@ def read_looper_config_file(looper_config_path: str) -> dict: if SAMPLE_MODS_KEY in dp_data: return_dict[SAMPLE_MODS_KEY] = dp_data[SAMPLE_MODS_KEY] - if CLI_MODS_KEY in dp_data: - return_dict[CLI_MODS_KEY] = dp_data[CLI_MODS_KEY] + if CLI_KEY in dp_data: + return_dict[CLI_KEY] = dp_data[CLI_KEY] if PIPELINE_INTERFACES_KEY in dp_data: