linumpy.cli.args#
Common argument-parsing helpers for linumpy CLI scripts.
Attributes#
Functions#
Get the number of available CPUs, respecting environment variables. |
|
|
Parse the n_processes argument, respecting system limits. |
|
Add the |
|
Add the |
|
Error out if output already exists and overwrite flag is not set. |
|
Add the |
|
Detect whether OME-Zarr resolution is in mm or µm, return (res_x_um, res_y_um). |
Module Contents#
- linumpy.cli.args.get_available_cpus()[source]#
Get the number of available CPUs, respecting environment variables.
Checks in order: 1. LINUMPY_MAX_CPUS - maximum CPUs to use (explicit limit) 2. LINUMPY_RESERVED_CPUS - CPUs to reserve for overhead (default: 0)
- Returns:
int
- Return type:
Number of available CPUs
- linumpy.cli.args.parse_processes_arg(n_processes)[source]#
Parse the n_processes argument, respecting system limits.
- Parameters:
n_processes (int | None) – Number of processes requested. If None or <= 0, uses the default (get_available_cpus()).
- Returns:
int
- Return type:
Number of processes to use
- linumpy.cli.args.add_processes_arg(parser)[source]#
Add the
--n_processesargument to parser.- Parameters:
parser (argparse.ArgumentParser | argparse._ActionsContainer)
- Return type:
- linumpy.cli.args.add_overwrite_arg(parser)[source]#
Add the
-f/--overwriteflag to parser.- Parameters:
parser (argparse.ArgumentParser)
- Return type:
None
- linumpy.cli.args.assert_output_exists(output, parser, args)[source]#
Error out if output already exists and overwrite flag is not set.
- Parameters:
output (pathlib.Path)
parser (argparse.ArgumentParser)
args (argparse.Namespace)
- Return type:
None
- linumpy.cli.args.add_verbose_arg(parser)[source]#
Add the
-v/--verboseargument to parser.- Parameters:
parser (argparse.ArgumentParser)
- Return type:
None
- linumpy.cli.args.detect_shift_units(resolution)[source]#
Detect whether OME-Zarr resolution is in mm or µm, return (res_x_um, res_y_um).
OME-Zarr resolution can be in mm (OME-NGFF standard) or µm depending on the writer. Detects by magnitude: values < 1.0 are assumed mm, >= 1.0 are assumed µm.
- Parameters:
resolution (sequence) – Resolution tuple from read_omezarr (res_z, res_y, res_x).
- Returns:
res_x_um, res_y_um – XY resolution in microns per pixel.
- Return type: