Skip to content

Add Client.ensure_database, the idempotent upload lifecycle - #223

Merged
ccomb merged 2 commits into
mainfrom
pyvolca-ensure-database
Jul 15, 2026
Merged

Add Client.ensure_database, the idempotent upload lifecycle#223
ccomb merged 2 commits into
mainfrom
pyvolca-ensure-database

Conversation

@ccomb

@ccomb ccomb commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Every script that feeds the engine its own data hand-rolls the same state machine: list databases, match by display name, upload when absent, finalize the staged copy, load when unloaded. Three copies of it exist in the wild (two in ecobalyse-method-tooling, one in the canonical converter's ancestry) and each re-uploads or half-configures in some corner case.

ensure_database(source, name=…) is that state machine as one call, returning the slug it converged on. A staged archive that is not ready to finalize (unresolved dependencies) raises with the missing names instead of finalizing a broken database.

Verified end-to-end against a locally built v0.9.3: first call uploads, finalizes and loads an EcoSpold 2 fixture (status loaded, activities queryable); the second call returns the same slug without re-uploading. 236 tests green (6 new orchestration specs).

@ccomb
ccomb force-pushed the pyvolca-ensure-database branch from 52bc861 to 083c854 Compare July 15, 2026 21:20
ccomb added 2 commits July 15, 2026 23:24
Every script that feeds the engine its own data hand-rolls the same
state machine: list databases, match by display name, upload when
absent, finalize the staged copy, load when unloaded. Three copies of
it exist in the wild and each one re-uploads or half-configures in some
corner case.

ensure_database(source, name=...) is that state machine as one call,
returning the slug it converged on. A staged archive that is not ready
to finalize (unresolved dependencies) raises with the missing names
instead of finalizing a broken database.

Verified against a locally built v0.9.3: first call uploads, finalizes
and loads an EcoSpold 2 fixture; the second call returns the same slug
without touching the network beyond the listing.
Uploads register in the engine's database list immediately, before
finalize — so when an earlier run uploaded a database but never got to
finalize it (its own unresolved-dependency error is the common cause),
the next ensure_database call matched it as unloaded and blind-loaded
it. Loading from config bypasses the finalize gate, so the result was a
partially linked database that silently undercounts: the first run
refused to finalize the broken copy, the second run loaded it anyway.

Matched unloaded uploads now go through the same get_setup readiness
gate as fresh uploads: finalize when ready, raise otherwise. The error
also names the actual blocker instead of always claiming unresolved
dependencies — the wire's unresolvedLinks is a count, not a list, and a
wrong data path (zero activities parsed) needs set_data_path, not
add_dependency.
@ccomb
ccomb force-pushed the pyvolca-ensure-database branch from 083c854 to 8cea85b Compare July 15, 2026 21:25
@ccomb
ccomb merged commit b1fb12d into main Jul 15, 2026
11 checks passed
@ccomb
ccomb deleted the pyvolca-ensure-database branch July 15, 2026 21:27
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