Skip to content

Commit eade88a

Browse files
authored
Merge pull request #39 from iamcipherdev/fix/zarr-format-check-subset-concat-2026-10-15
fix(cli): validate --zarr-format in subset and concat
2 parents 8a69561 + e65b177 commit eade88a

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎src/adata/cli.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ def subset(
347347
adata subset data.h5ad -o out.h5ad -q "n_counts > 1000 and cluster in A,B"
348348
adata subset data.h5ad -o out.h5ad --var-query "highly_variable == True"
349349
"""
350+
if zarr_format is not None and zarr_format not in (2, 3):
351+
console.print("[bold red]Error:[/] --zarr-format must be 2 or 3.")
352+
raise typer.Exit(code=1)
353+
350354
if obs is None and var is None and obs_query is None and var_query is None:
351355
console.print(
352356
"[bold red]Error:[/] Provide at least one of --obs, --var, "
@@ -447,6 +451,10 @@ def concat(
447451
adata concat *.h5ad -o merged.h5ad --join outer --label sample
448452
adata concat a.h5ad b.h5ad -o m.h5ad --keys a,b --index-unique - --uns-merge same
449453
"""
454+
if zarr_format is not None and zarr_format not in (2, 3):
455+
console.print("[bold red]Error:[/] --zarr-format must be 2 or 3.")
456+
raise typer.Exit(code=1)
457+
450458
for name, value in (("--merge", merge), ("--uns-merge", uns_merge)):
451459
if value is not None and value not in MERGE_CHOICES:
452460
console.print(

‎tests/test_commands_coverage.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,28 @@ def test_create_rejects_a_bad_zarr_format(temp_dir):
297297
assert "must be 2 or 3" in _out(result)
298298

299299

300+
def test_subset_rejects_a_bad_zarr_format(store, temp_dir):
301+
path, _ = store
302+
result = runner.invoke(
303+
app,
304+
["subset", str(path), "-o", str(temp_dir / "o.h5ad"),
305+
"-q", "obs_names", "--zarr-format", "4"],
306+
)
307+
assert result.exit_code == 1
308+
assert "must be 2 or 3" in _out(result)
309+
310+
311+
def test_concat_rejects_a_bad_zarr_format(store, temp_dir):
312+
path, _ = store
313+
result = runner.invoke(
314+
app,
315+
["concat", str(path), str(path), "-o", str(temp_dir / "o.h5ad"),
316+
"--zarr-format", "4"],
317+
)
318+
assert result.exit_code == 1
319+
assert "must be 2 or 3" in _out(result)
320+
321+
300322
def test_create_requires_a_size_or_a_name_file(temp_dir):
301323
result = runner.invoke(app, ["create", str(temp_dir / "x.h5ad"), "--n-var", "2"])
302324
assert result.exit_code == 1

0 commit comments

Comments
 (0)