Skip to content

Turn tifs_to_geozarr into a real CLI subcommand#45

Merged
scottstanie merged 2 commits intoopera-adt:mainfrom
scottstanie:feat/tifs-to-geozarr-subcommand
Apr 24, 2026
Merged

Turn tifs_to_geozarr into a real CLI subcommand#45
scottstanie merged 2 commits intoopera-adt:mainfrom
scottstanie:feat/tifs-to-geozarr-subcommand

Conversation

@scottstanie
Copy link
Copy Markdown
Collaborator

Summary

Moves scripts/tifs_to_geozarr.py into src/bowser/_tifs_to_geozarr.py and registers the command as bowser tifs-to-geozarr. Invocation changes from

python scripts/tifs_to_geozarr.py bowser_rasters.json cube.zarr --pyramid --los-dir ...

to

bowser tifs-to-geozarr bowser_rasters.json cube.zarr --pyramid --los-dir ...

Conversion logic is unchanged — the new module is the old script minus click decorators, renamed to a plain convert() function. All options live on cli.py:tifs_to_geozarr and delegate.

Lazy imports

The point of the split is so bowser --help doesn't have to evaluate the scientific stack on every invocation:

  • _tifs_to_geozarr.py imports numpy / xarray / rasterio / pandas / opera_utils at module top (as before)
  • cli.py imports _tifs_to_geozarr only inside the command body
  • bowser.geozarr already handles geozarr-toolkit (the one truly optional dep, behind [writer] extras) via lazy import inside annotate_store, so the new command raises ImportError only on actual invocation without the writer env — same as the script did

Default values in the @click.option decorators are literal copies of bowser.geozarr.DEFAULT_*. A sync comment flags this — importing bowser.geozarr at cli.py top would pull numpy/xarray into every bowser --help call, and the project already treats that module as lazy-import-only (see cli.py:_sniff_bbox and state.py:__init__ — both noqa: PLC0415).

Also updated

  • README.md DISP-S1 → GeoZarr section uses the new command
  • README.md legacy-VRT paragraph path reference
  • pyproject.toml [writer] extras comment
  • TECH_DEBT.md three script-path references

Test plan

  • bowser --help lists tifs-to-geozarr
  • bowser tifs-to-geozarr --help renders correctly
  • python -c "from bowser import _tifs_to_geozarr" imports cleanly
  • pre-commit (ruff / ruff-format / mypy) passes
  • End-to-end run against a DISP-S1 cube (reviewer please verify on real data)

Built on top of #44 (threadpool/streaming perf refactor).

🤖 Generated with Claude Code

scottstanie and others added 2 commits April 24, 2026 14:23
Moves scripts/tifs_to_geozarr.py into src/bowser/_tifs_to_geozarr.py
and registers the command on the main CLI group, so

    python scripts/tifs_to_geozarr.py bowser_rasters.json cube.zarr ...

becomes

    bowser tifs-to-geozarr bowser_rasters.json cube.zarr ...

The conversion logic is unchanged — the new module is the old script
minus click decorators, renamed to a plain `convert()` function. The
click options now live on `cli.py:tifs_to_geozarr` and delegate.

### Lazy imports

The conversion module imports the full scientific stack
(numpy/xarray/rasterio/pandas/opera_utils) and bowser.geozarr at
module top. cli.py imports it only inside the command body so
`bowser --help` stays fast and doesn't need to evaluate those at
every CLI invocation.

The only truly optional dep is geozarr-toolkit (behind the `writer`
extras). bowser.geozarr already imports it lazily inside
`annotate_store`, so the new command raises a clear ImportError only
when actually invoked without the `writer` env installed — which
matches the existing behaviour of the standalone script.

Default values in the @click.option decorators are duplicated as
literals with a sync comment pointing at bowser.geozarr.DEFAULT_*.
Deliberate: importing bowser.geozarr at cli.py module top would pull
numpy/xarray into every `bowser --help` invocation, and the project
already treats bowser.geozarr as lazy-import-only from cli.py/state.py.

README, pyproject comment, and TECH_DEBT references updated to the
new path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scottstanie scottstanie merged commit f882a9c into opera-adt:main Apr 24, 2026
0 of 2 checks passed
@scottstanie scottstanie deleted the feat/tifs-to-geozarr-subcommand branch April 24, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant