ability to share a cache amongst different transfers - #42
Open
swelborn wants to merge 11 commits into
Open
Conversation
This was referenced Jul 12, 2026
Open
Open
Open
There was a problem hiding this comment.
Pull request overview
Adds support for selecting whether transfers use a per-transfer cache or a shared per-experiment cache, and persists enough transfer context (experiment/run + cache mode) to make provisioning and log resolution deterministic without re-parsing request parameters.
Changes:
- Introduces
CacheMode(per_transfervsshared) across API models, DB schema, and provisioning/teardown logic. - Persists
experiment,run, andcache_modeontransfers, including Alembic migrations to backfill existing rows. - Updates fastcache integration to use a string
key, and adjusts log path resolution to account for shared-cache log location; regenerates OpenAPI clients.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/v2/test_transfer_core.py | Updates provisioning progress tests for cache-mode-aware compensation behavior. |
| tests/v2/conftest.py | Minor formatting change (blank line). |
| src/lclstream_api/v2/workflows.py | Implements shared-cache provisioning semantics, cache key selection, and teardown rules. |
| src/lclstream_api/v2/tables.py | Adds experiment, run, and cache_mode columns to transfers. |
| src/lclstream_api/v2/service.py | Extends transfer creation to persist experiment/run/cache_mode; updates log resolution to use stored context. |
| src/lclstream_api/v2/routers/v1/transfer.py | Passes parsed exp/run and requested cache mode into service layer on create. |
| src/lclstream_api/v2/repo.py | Persists experiment/run/cache_mode when inserting transfers. |
| src/lclstream_api/v2/models.py | Adds cache_mode to create request and includes experiment/run/cache_mode in public/detail responses. |
| src/lclstream_api/v2/core/transfer.py | Makes cache compensation conditional on cache mode; adds TransferSetup and cache_mode in resource refs. |
| src/lclstream_api/v2/core/producer.py | Defines CacheMode and adds shared_cache_dir helper. |
| src/lclstream_api/v2/core/logs.py | Adds cache-mode-aware cache log path resolution and refactors log path helpers. |
| src/lclstream_api/v2/clients/fastcache.py | Switches cache creation payload from transfer_id to string key and updates response model. |
| src/lclstream_api/v2/alembic/versions/aa298396d6a0_add_cache_mode_to_transfers.py | Migration to add cache_mode to transfers with default. |
| src/lclstream_api/v2/alembic/versions/0236c97ae695_add_experiment_and_run_to_transfers.py | Migration to add/backfill experiment and run from parameters. |
| openapi.json | Publishes CacheMode schema and adds experiment/run/cache_mode fields to transfer schemas. |
| frontend/src/client/zod.gen.ts | Regenerates frontend zod schemas/types to include CacheMode and new fields. |
| frontend/src/client/types.gen.ts | Regenerates frontend TS types for CacheMode and transfer fields. |
| frontend/src/client/schemas.gen.ts | Regenerates frontend JSON-schema constants to include CacheMode and new fields. |
| frontend/src/client/index.ts | Re-exports new CacheMode type from generated client. |
| client/src/lclstream_api_client/_generated/models/transfer_public.py | Regenerates Python client model to include experiment/run/cache_mode. |
| client/src/lclstream_api_client/_generated/models/transfer_detail.py | Regenerates Python client model to include experiment/run/cache_mode. |
| client/src/lclstream_api_client/_generated/models/transfer_create.py | Regenerates Python client model to include optional cache_mode in request. |
| client/src/lclstream_api_client/_generated/models/cache_mode.py | Adds generated Python enum for CacheMode. |
| client/src/lclstream_api_client/_generated/models/init.py | Exports generated CacheMode model. |
| client/src/lclstream_api_client/_generated/init.py | Exposes generated CacheMode at package root. |
Comments suppressed due to low confidence (1)
src/lclstream_api/v2/workflows.py:303
- In shared cache mode,
cache_log_pathpoints toshared_cache_dir(...), so_create_cacheno longer implies the per-transferwork_direxists. RecordingDeleteWorkDir(work_dir=...)before any IRI operation creates that directory can make rollback attempt to delete a non-existent path and fail compensation. Consider only adding the work_dir compensation after a step that guarantees the directory exists (e.g. after_upload_configfor shared mode).
work_dir = pcore.transfer_work_dir(
config.get_producer(), setup.exp, setup.run, transfer_id
)
# if _create_cache succeeds, then we know the working directory exists
progress = progress.with_work_dir(work_dir).with_cache(
endpoint.cache_id, mode=setup.cache_mode
)
await _save_cache(transfer_id, endpoint)
inputs = await _load_producer_inputs(transfer_id, endpoint)
if inputs is None:
raise LookupError(f"transfer {transfer_id} disappeared during setup")
plan = pcore.plan_producer(inputs, config.get_producer(), transfer_id)
await _upload_config(plan.config_path, plan.config_yaml)
progress = progress.with_config(plan.config_path)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
we have some idempotency now on the fastcache api side. if we send a request for an experiment to the cache, then we should be able to simply join the existing, running cache, if we key by an experiment for example
swelborn
force-pushed
the
shared-cache-mode
branch
from
July 13, 2026 00:32
bcc11b0 to
6fa4242
Compare
added 10 commits
July 13, 2026 12:07
swelborn
force-pushed
the
shared-cache-mode
branch
from
July 13, 2026 16:07
f216f7d to
958d415
Compare
This was referenced Jul 13, 2026
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.
This is part 13 of 23 in a stack made with GitButler: