Amar Litim
01/21/2023, 3:48 PMresource with key 'api_resource' required by op 'get_sfr_phones' was not provided. Please provide a <class 'dagster._core.definitions.resource_definition.ResourceDefinition'> to key 'api_resource'
Here is my resource file :
#%%
import requests
import json
import pandas as pd
from dagster import resource
#%%
class Api_Caller :
def query(self, api_endpoint: str, parameters: dict) -> dict :
response = requests.get(api_endpoint,
params=parameters
)
if response.status_code == 200:
return response.json()
else:
print("No data from API")
return response
#%%
@resource
def api_query(init_context) :
return Api_Caller()
and this is how i used it with my asset :
from dagster import asset
@asset(required_resource_keys={"api_query"})
def get_sfr_phones() -> dict :
sfr_api_endpoint = 'deleted'
params = {
'universe': 'GP',
'act': 'OPEN',
'brand': 'SFR'
}
sfr_response = context.resources.api_query.query(sfr_api_endpoint, params)
return sfr_response
As I have an error, this is not the good to use Resource. Can someone help me ? 🙂 I'll appreciate it a lot. Thank you !Emmanuel Ogunwede
01/21/2023, 5:36 PMAmar Litim
01/21/2023, 8:18 PMEmmanuel Ogunwede
01/21/2023, 8:28 PM