Repository navigation
Conversation
For zarr files, set up a .complete marker file to check when data is fully written. This replaces relying on zarr.json -- that doesn't work because zarr.json is the first to be written. This might happen from a failed or aborted calculation, or because multiple processes are trying to write the same file (e.g. running 2 countries which share a tile) A partially-written zarr might be not cause any warning signs later, since it might be techncially valid in spite of missing data. Now an empty .complete marker is written beside the zarr after its last chunk, and the entry counts as cached only once the marker exists. A zarr found without its marker is a write that was killed part-way or is still running: serialize raises FileExistsError and leaves it for someone to resolve by hand, usually by deleting the zarr, rather than writing over it and risking a race with a live writer. Entries written before this change have no marker, so each raises once until deleted.
An autouse fixture in jdluc/__tests__/conftest.py stubs Config.from_dot_env for every test not marked integration. Each field gets its type's empty value, with two dask workers, so a unit test that reaches for a storage root fails instead of touching a bucket. Integration tests still read the real .env. This replaces the fixture storage_test carried for itself, so the next unit test that writes a zarr needs no copy of it, and a new Config field needs no edit to the tests.
An optional `orchestration` package with one subcommand per workflow task (plan, ingest-tile, compute, trace), and an example Argo WorkflowTemplate that runs each tile's ingest -> compute as a DAG of its own, so a failed tile stops only itself. jdluc runs unmodified in the pods; every cache-key argument passes straight through, and an import-linter contract keeps jdluc from importing orchestration. trace writes the emissions-factor table to a new EXPORT_ROOT, through a small `export.write_table` utility. The package is built to be wrapped rather than edited: `build_parser` and `run` let a wrapper add subcommands, `plan.get_task_to_items` returns the lists for it to add to before `write_task_to_items`, and the template's tasks can be called by templateRef. See docs/orchestration.md. Also adds the Dockerfile the workflow's image is built from.
get_name no longer mentions mosaics, get_task_to_items describes the flat lists without a flat workflow to point at, and trace's --help is a whole sentence.
A Python API only: nothing calls it, a workflow opts in. Writes the chosen
variables of a lazy dataset to {EXPORT_ROOT}/{name}/{tile_id}.{tif|zarr},
provenance from get_metadata.
- COG: every variable as float32 2-D bands, NaN no-data; extra dims are
flattened to one band per combination of values, named
variable:value[:value...]. Staged locally and uploaded whole, through
storage.write_dask_dataset_to_cog (moved into storage with stack_bands).
- zarr: variables as they are, dtypes and extra dims kept. An export is
re-runnable, so it writes over an existing zarr (write_dask_dataset_to_zarr
gains mode=, default "w-" so the cache is unchanged), dropping the
.complete marker first and touching it once the write finishes.
…on}/
write_tile and write_table take version=, such as a run id or a release
label. Blank, the default, writes directly under EXPORT_ROOT as before; set,
the whole export goes under {EXPORT_ROOT}/{version}/ and the version is
stamped as cornerstone-export-version. A version must be one path segment.
Also from review:
- write_tile rejects a bare str as variables, rather than reading its letters
- the COG compute runs under COMPUTE_LOCK, as the zarr write does
- iter_bands notes how datetime and float coords name their bands
- to_zarr_dataset says why only coords become variable-length strings
A detached HEAD, as CI checks out a pull request, has no active branch, so get_git_version raised and with it every export that stamps provenance. It now returns the short commit SHA. No .git still fails, as before.
This was referenced Oct 19, 2026
Closed
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.
Adds
export.write_tile, which writes a pipeline step's per-tile raster output underEXPORT_ROOT, as a COG or a zarr. It is a Python API only: nothing calls it automatically, and a workflow opts in.Builds on #19 (
jdluc/export.py,EXPORT_ROOT) and #16 (the.completemarker on zarrs), so it merges after both.What it writes
{output_root or EXPORT_ROOT}[/{version}]/{name}/{tile_id}.{tif|zarr}.versionis optional, for example a run id or a release label. Blank, the default, writes directly under the export root, so a rerun writes over the last one.{root}/{version}/and is stamped ascornerstone-export-version. It must be one path segment.write_tabletakes the sameversion=, so the tiles and tables of one export sit together.trace.export_workflowdoesn't pass one yet.get_metadataeither way.variablesdefaults to every data variable, in the dataset's order. A variable that isn't indset, or a barestrin place of a list, raises before anything is written.dsetis lazy, and only the selected variables are computed, as they are written.(y, x)is flattened to one band per combination of coordinate values, namedvariable:value[:value…]. This is the:convention emit already uses for its band names.geo.get_chunk_size.write_dask_dataset_to_cogandstack_bandsare added tostorage, next to the zarr writer, and the COG compute runs underCOMPUTE_LOCK, as the zarr write does.object, because zarr v3 has no fixed-length strings. String data variables are left as they are, because converting a lazy one would load it whole. Metadata goes in the dataset attributes.{uri}.complete, write withmode="w", then touch{uri}.complete.write_dask_dataset_to_zarrgainsmode=. It defaults to"w-", so the cache is unchanged.storage.get_zarr_complete_uri, shared withZarrCacher.utils.get_git_versionnow returns the short commit SHA on a detached HEAD, rather than raising. This is how CI checks out a pull request, and every export stamps the version. A checkout with no.gitstill fails, as before.docs/data.mdnow points towrite_tileas the way to write the raster outputs underEXPORT_ROOT.Not in scope
Default deliverables or band selections, changes to emit or statistical, a CLI, orchestration, and mosaics.
Testing
jdluc/__tests__/export_test.pyruns on synthetic data and needs no.env. It covers:str;.completemarker, rewriting an export, and removal of a stale marker when a write fails;output_rootandversion, and a version that isn't one path segment;cornerstone-export-versiontag, present only when a version is set.pytest jdluc orchestrationandpre-commit run --all-filespass..completewere as expected, including after a rewrite.