Repository navigation
Remove _is_ground wrapper; guard metering lifespan with config.is_cloud() - #7
Merged
Merged
Conversation
…ud() _is_ground() wrapped config.is_ground() in a try/except whose fallback read SPARKMETER_MODE, an env var that no deployment sets. The config already determines ground vs cloud (via the HEROKU key), so metering_lifespan now guards its cloud no-op directly with config.is_cloud(), and _is_ground is deleted.
Diff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
|
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
Remove the
_is_ground()helper insparkmeter/metering/lifespan.pyand guard the metering lifespan's cloud no-op directly withconfig.is_cloud().Details
_is_ground()wrappedconfig.is_ground()in atry/exceptwhose fallback reados.environ.get("SPARKMETER_MODE", "ground").SPARKMETER_MODEis not set by any deployment, compose file, Dockerfile, or run script, so that fallback was dead code that always resolved to "ground", while shadowing the real ground/cloud switch.Ground vs cloud is already determined by
config(theHEROKUkey, populated fromSM_HEROKU). Becauselocal_systemis binary,is_cloud()andis_ground()are strict complements, sometering_lifespannow guards its no-op withconfig.is_cloud()— matching the function's "no-op on cloud" docstring — and_is_ground()is deleted.Behavior is unchanged: the primary path was already
config.is_ground(), and the only removed branch (theSPARKMETER_MODEfallback) was never reachable in practice.config.is_cloud()is safe here — it's a plain dict lookup on the config, loaded during app bootstrap before the lifespan runs.Test
Adds
test_metering_lifespan_is_noop_on_cloud: withconfig.is_cloud()true,metering_lifespansetsapp.state.metering = Noneand starts no metering runtime.