Skip to content

Commit 01e8275

Browse files
OwenKephartclaude
authored andcommitted
[cloud] refresh defs state pins when app-managed component mutations reload (#25834)
## Summary Stacked on #25833. On host cloud, code locations load with defs state versions pinned on `CodeLocationDeployData.defs_state_info`, and a plain reload does not refresh those pins — only the explicit `refreshDefsState` mutation does. The Components-tab mutations (`setAppManagedComponent` / `deleteAppManagedComponent`) write new state and then trigger a plain reload, so the reloaded location loads against stale pins and the just-written component doesn't appear until a separate "refresh definitions state" click. In OSS/local dev this problem doesn't exist because a reload always observes the latest state versions. This PR makes the pin refresh part of the reload, scoped to the app-managed component mutation path only: - **`BaseWorkspaceRequestContext.reload_code_location_with_latest_defs_state`** (OSS): new hook whose default implementation is a plain `reload_code_location` — correct for OSS, where reload already pulls latest state. - The OSS **`setAppManagedComponent` / `deleteAppManagedComponent`** resolvers call the new hook instead of `reload_code_location`. - **`CloudDagitWorkspaceRequestContext`** overrides the hook to first replace the location's pinned `defs_state_info` with `defs_state_storage.get_latest_defs_state_info()` (same logic as the `refreshDefsState` mutation) via `cloud_storage.update_location`, then trigger the reload — so the pins and the reload land together. All other reload endpoints are unchanged. ## How I tested - New test `test_set_app_managed_component_updates_defs_state_pins` in the cloud dagit workspace graphql tests asserts the mutation repins the location's `defs_state_info` to include the new component's state key. - OSS graphql app-managed component e2e tests pass (exercise the new hook through its default implementation). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Internal-RevId: 547a0bc854ef1259060f76102ad537f41ca520f9
1 parent eddfd4e commit 01e8275

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

python_modules/dagster-graphql/dagster_graphql/implementation/fetch_app_managed_components.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def set_app_managed_component(
7474
storage = _require_storage(graphene_info)
7575
entry = AppManagedComponentEntry(component_type=component_type, attributes=attributes)
7676
write_app_managed_component_entry(storage, location_name, component_id, entry)
77-
graphene_info.context.reload_code_location(location_name)
77+
graphene_info.context.reload_code_location_with_latest_defs_state(location_name)
7878
return GrapheneSetAppManagedComponentSuccess(
7979
component=_to_graphene_component(component_id, entry)
8080
)
@@ -92,7 +92,7 @@ def delete_app_managed_component(
9292
)
9393
storage = _require_storage(graphene_info)
9494
delete_app_managed_component_entry(storage, location_name, component_id)
95-
graphene_info.context.reload_code_location(location_name)
95+
graphene_info.context.reload_code_location_with_latest_defs_state(location_name)
9696
return GrapheneDeleteAppManagedComponentSuccess(
9797
locationName=location_name, componentId=component_id
9898
)

python_modules/dagster/dagster/_core/workspace/context.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,16 @@ def reload_code_location(self, name: str) -> "BaseWorkspaceRequestContext":
383383
self.process_context.reload_code_location(name)
384384
return self.process_context.create_request_context()
385385

386+
def reload_code_location_with_latest_defs_state(
387+
self, name: str
388+
) -> "BaseWorkspaceRequestContext":
389+
"""Reloads a code location such that the reloaded location observes the latest
390+
defs state versions. The default reload already loads the latest state versions,
391+
so this is a plain reload; subclasses that pin defs state versions at load time
392+
must override this to refresh the pins as part of the reload.
393+
"""
394+
return self.reload_code_location(name)
395+
386396
def shutdown_code_location(self, name: str):
387397
self.process_context.shutdown_code_location(name)
388398

0 commit comments

Comments
 (0)