Turn tifs_to_geozarr into a real CLI subcommand#45
Merged
scottstanie merged 2 commits intoopera-adt:mainfrom Apr 24, 2026
Merged
Turn tifs_to_geozarr into a real CLI subcommand#45scottstanie merged 2 commits intoopera-adt:mainfrom
scottstanie merged 2 commits intoopera-adt:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves
scripts/tifs_to_geozarr.pyintosrc/bowser/_tifs_to_geozarr.pyand registers the command asbowser tifs-to-geozarr. Invocation changes fromto
Conversion logic is unchanged — the new module is the old script minus click decorators, renamed to a plain
convert()function. All options live oncli.py:tifs_to_geozarrand delegate.Lazy imports
The point of the split is so
bowser --helpdoesn't have to evaluate the scientific stack on every invocation:_tifs_to_geozarr.pyimports numpy / xarray / rasterio / pandas / opera_utils at module top (as before)cli.pyimports_tifs_to_geozarronly inside the command bodybowser.geozarralready handlesgeozarr-toolkit(the one truly optional dep, behind[writer]extras) via lazy import insideannotate_store, so the new command raisesImportErroronly on actual invocation without the writer env — same as the script didDefault values in the
@click.optiondecorators are literal copies ofbowser.geozarr.DEFAULT_*. A sync comment flags this — importingbowser.geozarrat cli.py top would pull numpy/xarray into everybowser --helpcall, and the project already treats that module as lazy-import-only (seecli.py:_sniff_bboxandstate.py:__init__— bothnoqa: PLC0415).Also updated
README.mdDISP-S1 → GeoZarr section uses the new commandREADME.mdlegacy-VRT paragraph path referencepyproject.toml[writer]extras commentTECH_DEBT.mdthree script-path referencesTest plan
bowser --helpliststifs-to-geozarrbowser tifs-to-geozarr --helprenders correctlypython -c "from bowser import _tifs_to_geozarr"imports cleanlyBuilt on top of #44 (threadpool/streaming perf refactor).
🤖 Generated with Claude Code