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

Matt O

08/22/2022, 4:52 PM
Given I have the below graph definition:
Copy code
import requests
import json

@op
def get_api_endpoint(context):
	api_endpoint = context.op_config["api_endpoint"]
	resp = requests.get(api_endpoint)
    return resp.json()

@op
def save_json_data(json_data):
	with open("data.json", "w") as f:
		f.write(json.dumps(json_data))

graph_def = GraphDefinition(
    name='basic_api_call',
    node_defs=[get_api_endpoint, read_json_data],
    dependencies={'save_json_data': {'json_data': DependencyDefinition('get_api_endpoint')}},
)
How do i configure the api endpoint with the context using the graph definition class?
c

chris

08/22/2022, 8:55 PM
the easiest way would be calling
get_api_endpoint.configured
, which would allow you to directly specify what the API endpoint should be. Would that fit your use case?
m

Matt O

08/24/2022, 2:44 PM
interesting, ill try this out
2 Views