Samuel Shi
07/19/2023, 9:09 PMSamuel Shi
07/19/2023, 9:09 PMmutation SlackVoteMutation($election_results_id: Int, $old_vote_count: Int, $new_vote_count: Int) {
launchRun(
executionParams: {
selector: {
repositoryLocationName: "elex_results_pipeline"
repositoryName: "__repository__"
jobName: "slack_vote_update"
}
runConfigData: {
data: {
election_results_id: $election_results_id
old_vote_count: $old_vote_count
new_vote_count: $new_vote_count
}
}
}
) {
__typename
... on LaunchRunSuccess {
run {
runId
}
}
... on RunConfigValidationInvalid {
errors {
message
reason
}
}
... on PythonError {
message
}
}
}
Samuel Shi
07/19/2023, 9:09 PM{
"election_results_id": 1,
"old_vote_count": 1,
"new_vote_count": 1
}
Samuel Shi
07/19/2023, 9:26 PMSamuel Shi
07/19/2023, 9:27 PMSamuel Shi
07/19/2023, 9:29 PMIain Kennedy
07/19/2023, 10:30 PMRunConfigValidationInvalid
- are you using the graphql playground to test?Iain Kennedy
07/19/2023, 10:34 PMSamuel Shi
07/20/2023, 2:41 PMSamuel Shi
07/20/2023, 2:43 PMSamuel Shi
07/20/2023, 2:44 PMclass SlackAlertConfig(Config):
data: dict[str, int]
@config_mapping
def vote_update_config(config: SlackAlertConfig) -> RunConfig:
return RunConfig(
ops={"vote_count_slack_alert": SlackAlertConfig(data=config.data)}
)
@job(config=vote_update_config)
def slack_vote_update():
vote_count_slack_alert()
Samuel Shi
07/20/2023, 2:45 PMIain Kennedy
07/20/2023, 2:47 PMSamuel Shi
07/20/2023, 2:48 PMSamuel Shi
07/20/2023, 2:56 PMIain Kennedy
07/20/2023, 2:56 PMSamuel Shi
07/20/2023, 3:03 PMSamuel Shi
07/20/2023, 3:04 PMIain Kennedy
07/20/2023, 3:05 PMSamuel Shi
07/20/2023, 3:42 PMSamuel Shi
07/20/2023, 3:43 PMSamuel Shi
07/20/2023, 5:26 PM@op
def vote_count_slack_alert(context: OpExecutionContext, vote_feed_bot: ResourceParam[VoteFeedBot]) -> None:
"""This op updates Slack with live vote counts"""
config = context.op_config
message_batch = []
message_batch.append(":alert: Testing vote count bot! :alert:")
<http://context.log.info|context.log.info>(config)
the op ^claire
07/20/2023, 9:44 PMlaunchRun
mutation argument is formatted incorrectly--it expects an executionParams
parameter that has to be provided through the query vars. So I think you need to reformat your mutation and the query vars:
The mutation:
mutation SlackVoteMutation($executionParams: ExecutionParams!) {
launchRun(executionParams: $executionParams) {
... on LaunchRunSuccess {
run {
id
pipelineName
}
}
... on PipelineNotFoundError {
message
}
... on InvalidSubsetError {
message
}
... on RunConfigValidationInvalid {
errors {
message
}
}
}
}
The query vars:
{
"executionParams": {
"selector": {
"repositoryLocationName": "samuel.py",
"repositoryName": "__repository__blah_job",
"jobName": "blah_job"
},
"runConfigData": {
"ops": {
"vote_count_slack_alert": {
"config": {
"election_results_id": 1,
"old_vote_count": 2,
"new_vote_count": 3
}
}
}
}
}
}
The job:
class SimplifiedConfig(Config):
election_results_id: int
old_vote_count: int
new_vote_count: int
@op
def vote_count_slack_alert(context: OpExecutionContext, config: SimplifiedConfig) -> None:
"""This op updates Slack with live vote counts"""
config = context.op_config
message_batch = []
message_batch.append(":alert: Testing vote count bot! :alert:")
<http://context.log.info|context.log.info>(config)
@job
def blah_job():
vote_count_slack_alert()
Samuel Shi
07/21/2023, 2:32 PMSamuel Shi
07/21/2023, 2:32 PMclaire
07/21/2023, 4:18 PM