Matt O
08/22/2022, 4:52 PMimport 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?chris
08/22/2022, 8:55 PMget_api_endpoint.configured
, which would allow you to directly specify what the API endpoint should be. Would that fit your use case?Matt O
08/24/2022, 2:44 PM