Henry Tareque
02/27/2024, 8:09 PMScout
02/27/2024, 8:09 PMDagsterGraphQLClient
to send a GraphQL request to the Dagster instance, which triggers the desired pipeline run. Here's a basic example provided in the documentation: python from dagster import DagsterGraphQLClient # Set up the GraphQL client to communicate with your Dagster instance dagster_client = DagsterGraphQLClient('<http://localhost:3000/graphql>') # Replace with your Dagster instance URL # Define a function to trigger a Dagster job def trigger_dagster_job(pipeline_name, environment_dict): try: response = dagster_client.execute_plan( pipeline_name=pipeline_name, environment_dict=environment_dict, ) # Process the response if needed print(response) return response except Exception as e: # Handle exceptions print(f"Error triggering job: {e}") return None # Call the function to trigger the Dagster job result = trigger_dagster_job('your_pipeline_name', {'config_key': 'config_value'})
In this example, you need to replace '<http://localhost:3000/graphql>'
with the actual URL where your Dagster instance is running. Also, replace 'your_pipeline_name'
with the name of the pipeline you want to trigger, and provide the appropriate environment configuration in the form of a dictionary as needed by your pipeline. Please ensure that your web server or the system from which you are making the API call has appropriate permissions and network access to communicate with the Dagster instance.Scout
02/27/2024, 8:09 PM