Ramon Tanoeiro
04/28/2023, 6:19 AMRamon Tanoeiro
04/28/2023, 6:22 AM@resource
def get_credentials():
"""
This function will be used to get the credentials to make API Requests.
"""
return {
"X-RapidAPI-Key": os.environ["X-RAPIDAPI-KEY"],
"X-RapidAPI-Host": os.environ["X-RAPIDAPI-HOST"],
}
I’m defining the assets in the ___init___.py
from the resources folder like that:
api_credentials = ResourceDefinition(
resource_fn=get_credentials,
config_schema={
"X-RapidAPI-Key": String,
"X-RapidAPI-Host": String,
},
)
RESOURCES = {"credentials": api_credentials}
On my asset, I’m calling my resource like that:
@asset(
required_resource_keys={"credentials"},
)
def get_country_leagues(context: OpExecutionContext):
headers=context.resources.credentials
But when trying to materialise the asset on the UI I have the following warning. Does anyone know how to properly use resources in this case? Thanks in advance 🙂
Adding to that, I’m not sure if the asset is not picking up because the values here are empty:Ramon Tanoeiro
04/28/2023, 6:23 AMRamon Tanoeiro
04/28/2023, 6:23 AMRamon Tanoeiro
04/28/2023, 6:46 AMJakub Zgrzebnicki
04/28/2023, 7:04 AMJakub Zgrzebnicki
04/28/2023, 7:04 AMRESOURCES = {"credentials": get_credentials}
Ramon Tanoeiro
04/28/2023, 7:05 AMJakub Zgrzebnicki
04/28/2023, 7:06 AMRamon Tanoeiro
04/28/2023, 7:08 AMJakub Zgrzebnicki
04/28/2023, 7:16 AMRamon Tanoeiro
04/28/2023, 7:19 AMJakub Zgrzebnicki
04/28/2023, 7:20 AM