Tobias Otte
03/03/2023, 12:46 PMdaniel
03/03/2023, 3:46 PMExpoze Dummy
03/03/2023, 3:49 PMdaniel
03/03/2023, 3:50 PMTobias Otte
03/03/2023, 3:52 PMfrom dagster import job, op
from dagster_snowflake import snowflake_resource
@op(required_resource_keys={'snowflake'})
def get_one(context):
context.resources.snowflake.execute_query('SELECT 1')
@job(resource_defs={'snowflake': snowflake_resource})
def my_snowflake_job():
get_one()
my_snowflake_job.execute_in_process(
run_config={
'resources': {
'snowflake': {
'config': {
'account': {'env': 'SNOWFLAKE_ACCOUNT'},
'user': {'env': 'SNOWFLAKE_USER'},
'password': {'env': 'SNOWFLAKE_PASSWORD'},
'database': {'env': 'SNOWFLAKE_DATABASE'},
'schema': {'env': 'SNOWFLAKE_SCHEMA'},
'warehouse': {'env': 'SNOWFLAKE_WAREHOUSE'},
}
}
}
}
)
Expoze Dummy
03/03/2023, 3:54 PMmy_snowflake_job
in dagit (the dagster user interface)Tobias Otte
03/03/2023, 3:56 PMExpoze Dummy
03/03/2023, 3:58 PMDefinitions
object as what daniel has said. You can think of it like registering your job
from dagster import job, op, graph, Definitions
from dagster_snowflake import snowflake_resource
@op(required_resource_keys={'snowflake'})
def get_one(context):
context.resources.snowflake.execute_query('SELECT 1')
@graph
def my_snowflake_graph():
get_one()
resource_defs={
'snowflake': snowflake_resource.configured({
'account': {'env': 'SNOWFLAKE_ACCOUNT'},
'user': {'env': 'SNOWFLAKE_USER'},
'password': {'env': 'SNOWFLAKE_PASSWORD'},
'database': {'env': 'SNOWFLAKE_DATABASE'},
'schema': {'env': 'SNOWFLAKE_SCHEMA'},
'warehouse': {'env': 'SNOWFLAKE_WAREHOUSE'},
})
}
defs = Definitions(jobs=[my_snowflake_graph.to_job(name="my_snowflake_job", resource_defs=resource_defs)])
daniel
03/03/2023, 4:00 PM___init___.py
of that package, or import it from within the init.py file. If you use one of our example projects it should create a structure that works for loading definitions: https://docs.dagster.io/getting-started/create-new-projectExpoze Dummy
03/03/2023, 4:12 PMTobias Otte
03/03/2023, 4:54 PM