https://dagster.io/ logo
#ask-community
Title
# ask-community
s

Samuel Shi

07/19/2023, 9:09 PM
Hey all! We're running a launch run mutation using dagster graphql and am having trouble with the mutation. It works when I hard code the variable values and it was working earlier. But it doesn't work when introducing variables, and I'm almost confident it has the correct graphql formatting.
Mutation:
Copy code
mutation 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
      }
    }
  }
Query vars:
Copy code
{
  "election_results_id": 1,
  "old_vote_count": 1,
  "new_vote_count": 1
}
Anyone have any ideas? This seems like it might be a bug.
The error is a runconfigvalidationinvalid error
The weirdest part is that removing these variables and hardcoding the config data ends up working
i

Iain Kennedy

07/19/2023, 10:30 PM
What's the message in the
RunConfigValidationInvalid
- are you using the graphql playground to test?
If not, could be you are passing a string "1" rather than int? The graphql looks good to me
s

Samuel Shi

07/20/2023, 2:41 PM
I am using the playground to test
Message:
It might be how I'm defining my config, but unsure:
Copy code
class 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()
Does that seem right to you?
i

Iain Kennedy

07/20/2023, 2:47 PM
Well, I'm inclined to think it's a graphql / variable error that is going wrong, rather than the config side, as it's graphql that replaces the variables
s

Samuel Shi

07/20/2023, 2:48 PM
Yeah, that's why I'm very confused. I've went over the graphql code many times and had people on my team look at it. Also we ran a different launch run mutation this way and it worked
If it worked for a different job / mutation it leads me to believe that it's a problem with the config set up i have
i

Iain Kennedy

07/20/2023, 2:56 PM
Beyond trying setting the default values on the declarations and not passing any variables, I don't know what else to suggest. Certainly does seem odd.
s

Samuel Shi

07/20/2023, 3:03 PM
This might be a bug with dagster. I might have someone else on the team try to recreate the error to confirm
Do you think it's worth it to try using an asset instead of ops (for the job)?
i

Iain Kennedy

07/20/2023, 3:05 PM
I'm not sure about that
s

Samuel Shi

07/20/2023, 3:42 PM
I was able to fix it by removing the config parameter from the targeted op, but now I'm unsure of the proper way to pass configs from the job to the op.
Looking at the docs it looks like you can just define the op as having the config as one of its parameters, but this was what I originally had that was giving me issues
Copy code
@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 ^
c

claire

07/20/2023, 9:44 PM
Hi Samuel. Looks like the
launchRun
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:
Copy code
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:
Copy code
{
  "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:
Copy code
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()
s

Samuel Shi

07/21/2023, 2:32 PM
That seemed to have worked. Is passing in executionParams documented anywhere? Because here: https://docs.dagster.io/concepts/webserver/graphql#launch-a-run , it makes no mention of that
Or does this come with a new update of dagster that hasn't been updated yet?
c

claire

07/21/2023, 4:18 PM
Hm... I'd expect it to be documented on the page that you sent. Seems like the documented example isn't working--would you mind filing a issue to report this so I can forward it to our docs team?