Owen
04/01/2020, 2:17 PMsashank
04/01/2020, 2:24 PMresource
to achieve this: https://dagster.readthedocs.io/en/0.7.5/sections/tutorial/resources.htmlusername
as config, and when initializing the resource create a connection to the the db with the usernameusername
as a property on the resource, you could access it on a solid context through context.resources.my_resource_name.username
Owen
04/01/2020, 2:28 PMsashank
04/01/2020, 2:28 PM@solid(config={'username: str})
def create_db(context):
pass
Owen
04/01/2020, 2:37 PMsashank
04/01/2020, 2:38 PMOutput
of the solidInput
Owen
04/01/2020, 2:44 PMsashank
04/01/2020, 2:48 PMfrom dagster import pipeline, solid, RepositoryDefinition, InputDefinition, OutputDefinition, Output
def create_new_db():
return "generated_db_name"
@solid(
config={'username': str},
output_defs=[OutputDefinition(str, "db_name")],
)
def create_database(context):
name = create_new_db()
yield Output(value=name, output_name="db_name")
@solid(
input_defs=[InputDefinition("db_name", str)]
)
def do_some_action(context, db_name):
context.log(db_name)
@solid(
input_defs=[InputDefinition("db_name", str)]
)
def do_some_other_action(context, db_name):
context.log(db_name)
@pipeline
def my_pipeline():
db_name = create_database()
do_some_action(db_name)
do_some_other_action(db_name)
def define_repository():
return RepositoryDefinition("my_repository", pipeline_defs=[my_pipeline])
solids:
create_database:
config:
username: "owen"
Owen
04/01/2020, 3:19 PM