Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request]: Add Standardized Dry Run And Verbose Flags To All flepimop CLI Actions #470

Open
TimothyWillard opened this issue Jan 16, 2025 · 0 comments
Labels
cli Relating to command line interfaces enhancement Request for improvement or addition of new feature(s). medium priority Medium priority.

Comments

@TimothyWillard
Copy link
Contributor

Label

enhancement, cli

Priority Label

medium priority

Is your feature request related to a problem? Please describe.

Dry run and verbose flags provide developers/users a way to debug/diagnose issues using a CLI tool and a way to control the level of output from a tool. Furthermore, a dry run flag provides a way to painlessly test/experiment with a tool without unintended side effects. These are missing from flepiMoP's CLI interface.

Is your feature request related to a new application, scenario round, pathogen? Please describe.

No response

Describe the solution you'd like

An existing example of these features can be found in GH-394. See this for an example of verbosity:

# Generic setup
now = datetime.now(timezone.utc)
logger = get_script_logger(__name__, kwargs["verbosity"])
log_cli_inputs(kwargs)
cfg = parse_config_files(config, ctx, **kwargs)
# Job name/run id
name = cfg["name"].get(str) if cfg["name"].exists() else None
job_name = _job_name(name, now)
logger.info("Assigning job name of '%s'", job_name)
if kwargs["run_id"] is None:
kwargs["run_id"] = run_id(now)
logger.info("Using a run id of '%s'", kwargs["run_id"])
# Determine inference method
inference_method = (
cfg["inference"]["method"].as_str()
if cfg["inference"].exists() and cfg["inference"]["method"].exists()
else None
)
inference_method = (
inference_method if inference_method is None else inference_method.lower()
)
if kwargs["reset_chimerics"] and inference_method is not None:
logger.warning(
"The inference method is '%s', which does not support "
"the reset chimerics on global accept flag.",
inference_method,
)

Which leverages logging infrastructure from the now merged into dev GH-447. See this for an example of dry run:

if dry_run:
if verbosity is not None:
logger.info(
"If not dry mode would have executed script with: %s",
" ".join(cmd_args),
)
return
if verbosity is not None:
logger.info("Executing script with: %s", " ".join(cmd_args))
process = subprocess.run(cmd_args, capture_output=True)
stdout = process.stdout.decode().strip()
stderr = process.stderr.decode().strip()
if verbosity is not None:
if process.returncode != 0:
logger.critical(
"Received non-zero exit code, %u, from executed script.", process.returncode
)
if stdout:
logger.debug("Captured stdout from executed script: %s", stdout)
if stderr:
logger.error("Captured stderr from executed script: %s", stderr)

This issue is about extracting the verbose and dry run options as they exist in GH-394 and integrating them into other commands:

verbosity_options = {
"verbosity": click.Option(
param_decls=["-v", "--verbose", "verbosity"],
count=True,
help="The verbosity level to use for this command.",
),
"dry_run": click.Option(
param_decls=["--dry-run", "dry_run"],
type=bool,
default=False,
is_flag=True,
help="Should this command be run using dry run?",
),
}

@TimothyWillard TimothyWillard added cli Relating to command line interfaces enhancement Request for improvement or addition of new feature(s). medium priority Medium priority. labels Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Relating to command line interfaces enhancement Request for improvement or addition of new feature(s). medium priority Medium priority.
Projects
None yet
Development

No branches or pull requests

1 participant