Differential D8508 Diff 40125 python_modules/dagster-graphql/dagster_graphql/schema/roots/mutation.py
Changeset View
Changeset View
Standalone View
Standalone View
python_modules/dagster-graphql/dagster_graphql/schema/roots/mutation.py
Show First 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | class Meta: | ||||
GrapheneReloadNotSupported, | GrapheneReloadNotSupported, | ||||
GrapheneRepositoryLocationNotFound, | GrapheneRepositoryLocationNotFound, | ||||
GrapheneReadOnlyError, | GrapheneReadOnlyError, | ||||
GraphenePythonError, | GraphenePythonError, | ||||
) | ) | ||||
name = "ReloadRepositoryLocationMutationResult" | name = "ReloadRepositoryLocationMutationResult" | ||||
class GrapheneShutdownRepositoryLocationSuccess(graphene.ObjectType): | |||||
repositoryLocationName = graphene.NonNull(graphene.String) | |||||
class Meta: | |||||
name = "ShutdownRepositoryLocationSuccess" | |||||
class GrapheneShutdownRepositoryLocationMutationResult(graphene.Union): | |||||
class Meta: | |||||
types = ( | |||||
GrapheneShutdownRepositoryLocationSuccess, | |||||
GrapheneRepositoryLocationNotFound, | |||||
GrapheneReadOnlyError, | |||||
GraphenePythonError, | |||||
) | |||||
name = "ShutdownRepositoryLocationMutationResult" | |||||
class GrapheneReloadRepositoryLocationMutation(graphene.Mutation): | class GrapheneReloadRepositoryLocationMutation(graphene.Mutation): | ||||
Output = graphene.NonNull(GrapheneReloadRepositoryLocationMutationResult) | Output = graphene.NonNull(GrapheneReloadRepositoryLocationMutationResult) | ||||
class Arguments: | class Arguments: | ||||
repositoryLocationName = graphene.NonNull(graphene.String) | repositoryLocationName = graphene.NonNull(graphene.String) | ||||
class Meta: | class Meta: | ||||
name = "ReloadRepositoryLocationMutation" | name = "ReloadRepositoryLocationMutation" | ||||
@capture_error | @capture_error | ||||
@check_read_only | @check_read_only | ||||
def mutate(self, graphene_info, **kwargs): | def mutate(self, graphene_info, **kwargs): | ||||
location_name = kwargs["repositoryLocationName"] | location_name = kwargs["repositoryLocationName"] | ||||
if not graphene_info.context.has_repository_location( | if not graphene_info.context.has_repository_location_name(location_name): | ||||
location_name | |||||
) and not graphene_info.context.has_repository_location_error(location_name): | |||||
return GrapheneRepositoryLocationNotFound(location_name) | return GrapheneRepositoryLocationNotFound(location_name) | ||||
if not graphene_info.context.is_reload_supported(location_name): | if not graphene_info.context.is_reload_supported(location_name): | ||||
return GrapheneReloadNotSupported(location_name) | return GrapheneReloadNotSupported(location_name) | ||||
# The current workspace context is a WorkspaceRequestContext, which contains a reference to the | # The current workspace context is a WorkspaceRequestContext, which contains a reference to the | ||||
# repository locations that were present in the root IWorkspaceProcessContext the start of the | # repository locations that were present in the root IWorkspaceProcessContext the start of the | ||||
# request. Reloading a repository location modifies the IWorkspaceProcessContext, rendeirng | # request. Reloading a repository location modifies the IWorkspaceProcessContext, rendeirng | ||||
# our current WorkspaceRequestContext outdated. Therefore, `reload_repository_location` returns | # our current WorkspaceRequestContext outdated. Therefore, `reload_repository_location` returns | ||||
# an updated WorkspaceRequestContext for us to use. | # an updated WorkspaceRequestContext for us to use. | ||||
new_context = graphene_info.context.reload_repository_location(location_name) | new_context = graphene_info.context.reload_repository_location(location_name) | ||||
return GrapheneWorkspaceLocationEntry(new_context.workspace_snapshot[location_name]) | return GrapheneWorkspaceLocationEntry(new_context.workspace_snapshot[location_name]) | ||||
class GrapheneShutdownRepositoryLocationMutation(graphene.Mutation): | |||||
Output = graphene.NonNull(GrapheneShutdownRepositoryLocationMutationResult) | |||||
class Arguments: | |||||
repositoryLocationName = graphene.NonNull(graphene.String) | |||||
class Meta: | |||||
name = "ShutdownRepositoryLocationMutation" | |||||
@capture_error | |||||
@check_read_only | |||||
def mutate(self, graphene_info, **kwargs): | |||||
location_name = kwargs["repositoryLocationName"] | |||||
if not graphene_info.context.has_repository_location_name(location_name): | |||||
return GrapheneRepositoryLocationNotFound(location_name) | |||||
if not graphene_info.context.is_shutdown_supported(location_name): | |||||
raise Exception(f"Location {location_name} does not support shutting down via GraphQL") | |||||
graphene_info.context.shutdown_repository_location(location_name) | |||||
return GrapheneShutdownRepositoryLocationSuccess(repositoryLocationName=location_name) | |||||
class GrapheneReloadWorkspaceMutationResult(graphene.Union): | class GrapheneReloadWorkspaceMutationResult(graphene.Union): | ||||
class Meta: | class Meta: | ||||
types = ( | types = ( | ||||
GrapheneWorkspace, | GrapheneWorkspace, | ||||
GrapheneReadOnlyError, | GrapheneReadOnlyError, | ||||
GraphenePythonError, | GraphenePythonError, | ||||
) | ) | ||||
name = "ReloadWorkspaceMutationResult" | name = "ReloadWorkspaceMutationResult" | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | class GrapheneMutation(graphene.ObjectType): | ||||
start_schedule = GrapheneStartScheduleMutation.Field() | start_schedule = GrapheneStartScheduleMutation.Field() | ||||
stop_running_schedule = GrapheneStopRunningScheduleMutation.Field() | stop_running_schedule = GrapheneStopRunningScheduleMutation.Field() | ||||
start_sensor = GrapheneStartSensorMutation.Field() | start_sensor = GrapheneStartSensorMutation.Field() | ||||
stop_sensor = GrapheneStopSensorMutation.Field() | stop_sensor = GrapheneStopSensorMutation.Field() | ||||
terminate_pipeline_execution = GrapheneTerminatePipelineExecutionMutation.Field() | terminate_pipeline_execution = GrapheneTerminatePipelineExecutionMutation.Field() | ||||
delete_pipeline_run = GrapheneDeleteRunMutation.Field() | delete_pipeline_run = GrapheneDeleteRunMutation.Field() | ||||
reload_repository_location = GrapheneReloadRepositoryLocationMutation.Field() | reload_repository_location = GrapheneReloadRepositoryLocationMutation.Field() | ||||
reload_workspace = GrapheneReloadWorkspaceMutation.Field() | reload_workspace = GrapheneReloadWorkspaceMutation.Field() | ||||
shutdown_repository_location = GrapheneShutdownRepositoryLocationMutation.Field() | |||||
wipe_assets = GrapheneAssetWipeMutation.Field() | wipe_assets = GrapheneAssetWipeMutation.Field() | ||||
launch_partition_backfill = GrapheneLaunchBackfillMutation.Field() | launch_partition_backfill = GrapheneLaunchBackfillMutation.Field() | ||||
resume_partition_backfill = GrapheneResumeBackfillMutation.Field() | resume_partition_backfill = GrapheneResumeBackfillMutation.Field() | ||||
cancel_partition_backfill = GrapheneCancelBackfillMutation.Field() | cancel_partition_backfill = GrapheneCancelBackfillMutation.Field() | ||||
class Meta: | class Meta: | ||||
name = "Mutation" | name = "Mutation" |