Skip to content

Commit

Permalink
added force flag to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
eacharles committed Dec 3, 2024
1 parent 7bfd22a commit 4ea5cfd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/rail/cli/pipe_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def inspect_command(config_file: str) -> int:
@pipe_cli.command(name="build")
@pipe_options.config_file()
@pipe_options.flavor()
@pipe_options.force()
def build_command(config_file: str, **kwargs: Any) -> int:
"""Build the ceci pipeline configuration files"""
project = RailProject.load_config(config_file)
Expand Down
7 changes: 7 additions & 0 deletions src/rail/cli/pipe_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
__all__: list[str] = [
"RunMode",
"config_path",
"force",
"flavor",
"input_dir",
"input_file",
Expand Down Expand Up @@ -54,6 +55,12 @@ class RunMode(enum.Enum):
type=click.Path(),
)

force = PartialOption(
"--force",
help="Overwrite existing ceci configuration files",
is_flag=True,
)

flavor = PartialOption(
"--flavor",
help="Pipeline configuraiton flavor",
Expand Down
13 changes: 10 additions & 3 deletions src/rail/cli/pipe_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ def subsample_data(
def build_pipelines(
project: RailProject,
flavor: str='baseline',
*,
force: bool=False,
) -> int:
"""Build ceci pipeline configuraiton files for this project
Expand All @@ -753,6 +755,9 @@ def build_pipelines(
flavor: str
Which analysis flavor to draw from
force: bool
Force overwriting of existing pipeline files
Returns
-------
returncode: int
Expand All @@ -771,9 +776,11 @@ def build_pipelines(
continue
output_yaml = project.get_path('pipeline_path', pipeline=pipeline_name, flavor=flavor)
if os.path.exists(output_yaml):
print(f"Skipping existing pipeline {output_yaml}")
continue

if force:
print(f"Overwriting existing pipeline {output_yaml}")
else:
print(f"Skipping existing pipeline {output_yaml}")
continue
pipe_out_dir = os.path.dirname(output_yaml)

try:
Expand Down

0 comments on commit 4ea5cfd

Please sign in to comment.