Add Client.ensure_database, the idempotent upload lifecycle - #223
Merged
Conversation
ccomb
force-pushed
the
pyvolca-ensure-database
branch
from
July 15, 2026 21:20
52bc861 to
083c854
Compare
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
force-pushed
the
pyvolca-ensure-database
branch
from
July 15, 2026 21:25
083c854 to
8cea85b
Compare
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.
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).