<#7555 feat(storage): multi-scheme DataStore with ...
# flyte-github
a
#7555 feat(storage): multi-scheme DataStore with lazy per-scheme backend routing Pull request opened by EngHabu Summary Generalizes the storage layer's scheme routing so a single
DataStore
can serve any URL scheme and container, instead of being pinned to one configured backend. • The configured
Type
is built eagerly as the primary backend — it owns the
InitContainer
and
GetBaseContainerFQN
. • Every other scheme (
s3://
,
gs://
,
abfs://
,
redis://
, ...) is dialed lazily the first time a matching reference is seen and memoized for reuse (creation is serialized so each scheme is dialed at most once under concurrency). • A new optional
Config.Schemes
map allows per-scheme backend overrides (kind, stow config, redis connection). Schemes absent from the map are dialed with ambient credentials (provider default credential chain — IAM/instance profile, GCP ADC, workload identity, env vars). • Unknown schemes fall back to the primary store, preserving pre-routing behavior. • Cross-scheme
CopyRaw
(e.g.
redis -> s3
,
s3 -> gs
) routes through the router itself via plain `ReadRaw`/`WriteRaw`. This replaces the previous single-purpose
scheme_routing_store.go
(which only split redis from a blob store) with a general
routing_store.go
.
RegisterStowScheme
is added alongside
RegisterStowKind
so out-of-tree stow backends can be taught to the router. Changes •
routing_store.go
(new) — lazy, memoizing, scheme-dispatching
RawStore
•
scheme_routing_store.go
(removed) — superseded •
config.go
—
Schemes map[string]SchemeConfig
+
SchemeConfig
•
stow_store.go
— `schemeToStowKind`/`kindToScheme` maps,
primarySchemeForConfig
,
RegisterStowScheme
,
stowFactory
•
redis_store.go
—
redisFactory
for lazy redis dialing •
rawstores.go
—
RefreshConfig
wires the routing store and threads the configured HTTP client •
routing_store_internal_test.go
(new) — routing/lazy-creation/fallback coverage Test plan •
go test ./flytestdlib/storage/...
• Verify primary scheme resolves to the eager store (no second dial) • Verify ambient-credential dial for an unconfigured scheme Verified with
Copy code
import flyte
from flyte.io import File

env = flyte.TaskEnvironment(
    name="storage_smoke",
    image=flyte.Image.from_debian_base(python_version=(3, 12)),
)


@env.task
async def make_blob(n: int) -> File:
    """Write a sizeable file and hand back a reference. Forces a raw-data write
    (WriteRaw) into the blob store through the routing store."""
    path = "/tmp/blob.txt"
    with open(path, "w") as f:
        for i in range(n):
            f.write(f"line {i}\n")
    # Uploads the local file to the run's raw-data prefix (s3:// in the devbox).
    return await File.from_local(path)


@env.task
async def count_lines(blob: File) -> int:
    """Read the offloaded file back (ReadRaw) and count its lines."""
    async with blob.open("rb") as f:
        content = bytes(await f.read())
    return content.decode("utf-8").count("\n")


@env.task
async def main(n: int = 2000) -> int:
    blob = await make_blob.aio(n)
    return await count_lines.aio(blob)
🤖 Generated with Claude Code flyteorg/flyte