geeViz.eeAuth.tags

Earth Engine workload-tag helpers.

EE workload tags surface in GCP Billing under the goog-earth-engine-workload-tag label, so tagged calls can be broken down per user / session / source. This module builds well-formed tags from arbitrary string parts (sanitizing each so the result is always accepted by EE).

EE constraints (from ee/_state.py validation):

  • 1 - 63 characters

  • begins and ends with a lowercase alphanumeric [a-z0-9]

  • middle characters: [a-z0-9_-] (lowercase alphanumeric, dash, underscore)

No uppercase, no ., no other punctuation. Anything outside that set (@, spaces, slashes, dots, uppercase, etc.) gets sanitized to -.

Separator: ``__`` (double underscore). Single - already appears inside sanitized parts (e.g. ihousman-redcastleresources-com), so we reserve double underscore as the between-parts delimiter. That makes tags trivially parseable with tag.split("__"):

agent__run_code__ihousman-redcastleresources-com__db208a06-1c49

To keep __ an unambiguous separator, runs of _ within a part get collapsed to a single _ during sanitization (so an input like run__code becomes run_code). Underscores from sources like tool names — run_code, map_control — pass through intact because they’re already singletons.

Functions

build_workload_tag(*parts)

Join sanitized parts with __ and clamp to EE's 63-char limit.

sanitize_workload_tag_part(s)

Sanitize a single component of a workload tag.