Launch job/op with config run via graphql or python client example #21131
theelderbeever
started this conversation in
General
Replies: 1 comment 1 reply
-
Submitting a Partitioned Run over GraphQLAs an addendum to @theelderbeever's answer, you can also submit partitioned runs over GraphQL using tags. from dagster import Config, OpExecutionContext, job, op, DailyPartitionsDefinition, Definitions
daily_partition_def = DailyPartitionsDefinition(start_date="2024-01-01")
class DoSomethingConfig(Config):
config_param: str
@op
def do_something(context: OpExecutionContext, config: DoSomethingConfig):
context.log.info("config_param: " + config.config_param)
@job(partitions_def=daily_partition_def)
def do_it_all_with_default_config():
do_something()
defs = Definitions(jobs=[do_it_all_with_default_config]) Python Clientfrom dagster_graphql import DagsterGraphQLClient
client = DagsterGraphQLClient("localhost", port_number=3000)
client.submit_job_execution(
"do_it_all_with_default_config",
run_config={"ops": {"do_something": {"config": {"config_param": "things"}}}},
tags={"dagster/partition": "2024-01-05"}
) GraphQL Mutationmutation LaunchRunMutation(
$repositoryLocationName: String!
$repositoryName: String!
$jobName: String!
$runConfigData: RunConfigData!
$tags:[ExecutionTag!]
) {
launchRun(
executionParams: {
selector: {
repositoryLocationName: $repositoryLocationName
repositoryName: $repositoryName
jobName: $jobName
}
runConfigData: $runConfigData
executionMetadata: {
tags: $tags
}
}
) {
__typename
... on LaunchRunSuccess {
run {
runId
}
}
... on RunConfigValidationInvalid {
errors {
message
reason
}
}
... on PythonError {
message
}
}
}
with query variables {
"repositoryLocationName": "partition_demo.py",
"repositoryName": "__repository__",
"jobName": "do_it_all_with_default_config",
"tags": {
"key": "dagster/partition",
"value": "2024-05-01"
},
"runConfigData": {
"ops": {
"do_something": {
"config": {
"config_param": "things"
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I found this way too difficult to get a straight answer on via the docs so I figured I would drop an example for future developers (and myself honestly). It is pieced together from various examples in the docs.
Tested against Dagster 1.6.8
Given a job/op definition as follows
You can submit the job programmatically via
Python Client
The dagster python client using the following. You can optionally wrap the
run_config
indagster.RunConfig
GraphQL Mutation
with query variables
Beta Was this translation helpful? Give feedback.
All reactions