Skip to content

Commit

Permalink
Remove --output-folder-path CLI flag
Browse files Browse the repository at this point in the history
Removing in favour of another approach to allow the SLURM logfile
created by the DLS launcher to be put into the httomo output dir
(see #458 and #483 for more details).
  • Loading branch information
yousefmoazzam committed Oct 14, 2024
1 parent ac72fcf commit 18c2e04
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 77 deletions.
19 changes: 1 addition & 18 deletions docs/source/howto/run_httomo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ The :code:`run` command
Options:
--output-folder-name DIRECTORY Define the name of the output folder created
by HTTomo
--output-folder-path DIRECTORY Provide path to folder in which output
should be stored. This overrides the
`out_dir` argument
--save-all Save intermediate datasets for all tasks in
the pipeline.
--gpu-id INTEGER The GPU ID of the device to use.
Expand Down Expand Up @@ -226,10 +223,9 @@ directory created by HTTomo would be
Options/flags
#############

The :code:`run` command has 14 options/flags:
The :code:`run` command has 13 options/flags:

- :code:`--output-folder-name`
- :code:`--output-folder-path`
- :code:`--save-all`
- :code:`--gpu-id`
- :code:`--reslice-dir`
Expand Down Expand Up @@ -257,19 +253,6 @@ For example, if the :code:`OUT_DIR` path provided was :code:`/home/myuser`, and
:code:`--output-folder-name=test-1` was given, then the absolute path of the output directory
created by HTTomo would be :code:`/home/myuser/test-1/`.

:code:`--output-folder-path`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If one wishes to have HTTomo *not* create an output directory, and instead for HTTomo to place
the output in an existing directory, then the :code:`--output-folder-path` flag may be used.

For example, if :code:`--output-folder-path=/home/myuser/my-output` was given, then HTTomo
wouldn't create an output directory and would simply place the results in
:code:`/home/myuser/my-output`.

.. note:: This flag overrides the :code:`OUT_DIR` argument. Also, the given directory must
exist prior to running HTTomo

:code:`--save-all`
~~~~~~~~~~~~~~~~~~

Expand Down
25 changes: 2 additions & 23 deletions httomo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ def check(yaml_config: Path, in_data_file: Optional[Path] = None):
default=None,
help="Define the name of the output folder created by HTTomo",
)
@click.option(
"--output-folder-path",
type=click.Path(exists=True, file_okay=False, writable=True, path_type=Path),
default=None,
help=(
"Provide path to folder in which output should be stored. This overrides "
"the `out_dir` argument"
),
)
@click.option(
"--save-all",
is_flag=True,
Expand Down Expand Up @@ -155,7 +146,6 @@ def run(
yaml_config: Path,
out_dir: Path,
output_folder_name: Optional[Path],
output_folder_path: Optional[Path],
gpu_id: int,
save_all: bool,
reslice_dir: Union[Path, None],
Expand All @@ -179,7 +169,6 @@ def run(
syslog_host,
syslog_port,
output_folder_name,
output_folder_path,
)

does_contain_sweep = is_sweep_pipeline(yaml_config)
Expand Down Expand Up @@ -258,7 +247,6 @@ def set_global_constants(
syslog_host: str,
syslog_port: int,
output_folder_name: Optional[Path],
output_folder_path: Optional[Path],
) -> None:
if compress_intermediate:
frames_per_chunk = 1
Expand All @@ -268,21 +256,12 @@ def set_global_constants(
httomo.globals.SYSLOG_SERVER = syslog_host
httomo.globals.SYSLOG_PORT = syslog_port

if output_folder_name is not None and output_folder_path is not None:
msg = (
"The flags `--output-folder-name` and `--output-folder-path` are mutually "
"exclusive, please use only one at most"
)
raise ValueError(msg)

if output_folder_name is None and output_folder_path is None:
if output_folder_name is None:
httomo.globals.run_out_dir = out_dir.joinpath(
f"{datetime.now().strftime('%d-%m-%Y_%H_%M_%S')}_output"
)
if output_folder_name is not None:
else:
httomo.globals.run_out_dir = out_dir.joinpath(output_folder_name)
if output_folder_path is not None:
httomo.globals.run_out_dir = output_folder_path

if max_cpu_slices < 1:
raise ValueError("max-cpu-slices must be greater or equal to 1")
Expand Down
36 changes: 0 additions & 36 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,41 +93,5 @@ def test_output_folder_name_correctly_sets_run_out_dir_global_constant(output_fo
syslog_host="localhost",
syslog_port=514,
output_folder_name=Path(dir_name),
output_folder_path=None,
)
assert httomo.globals.run_out_dir == custom_output_dir


def test_output_folder_name_and_path_flags_raise_error_if_both_provided():
with pytest.raises(ValueError) as e:
set_global_constants(
out_dir=Path("/"),
intermediate_format="hdf5",
compress_intermediate=False,
frames_per_chunk=0,
max_cpu_slices=1,
syslog_host="localhost",
syslog_port=514,
output_folder_name=Path("folder-1"),
output_folder_path=Path("/path/to/folder-2"),
)
assert (
"The flags `--output-folder-name` and `--output-folder-path` are mutually exclusive"
in str(e)
)


def test_output_folder_path_correctly_sets_run_out_dir_global_constant():
output_folder_path = Path("/some/path/for/output")
set_global_constants(
out_dir=Path("/"),
intermediate_format="hdf5",
compress_intermediate=False,
frames_per_chunk=0,
max_cpu_slices=1,
syslog_host="localhost",
syslog_port=514,
output_folder_name=None,
output_folder_path=output_folder_path,
)
assert httomo.globals.run_out_dir == output_folder_path

0 comments on commit 18c2e04

Please sign in to comment.