Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev' into dev_rename_args_455
Browse files Browse the repository at this point in the history
# Conflicts:
#	looper/cli_pydantic.py
  • Loading branch information
donaldcampbelljr committed Jun 25, 2024
2 parents 256d585 + ed410cc commit 848f0ee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 42 deletions.
51 changes: 27 additions & 24 deletions looper/cli_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
),
Expand Down
3 changes: 0 additions & 3 deletions looper/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
"DEBUG_EIDO_VALIDATION",
"LOOPER_GENERIC_OUTPUT_SCHEMA",
"LOOPER_GENERIC_COUNT_LINES",
"CLI_MODS_KEY",
"PipelineLevel",
]

Expand Down Expand Up @@ -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 = [
Expand Down
13 changes: 0 additions & 13 deletions looper/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 4 additions & 2 deletions looper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:

Expand Down

0 comments on commit 848f0ee

Please sign in to comment.