https://dagster.io/ logo
j

Josh Taylor

04/07/2021, 1:30 PM
with dynamic pipelines, I'm trying to get a dynamic schedule to work, and it renders okay. but i'm trying to render a dynamic pipeline as follows:
Copy code
@schedule(
                    pipeline_name=yaml_file["name"],
                    name=yaml_file["name"] + "_schedule",
                    cron_schedule="* * * * *",
                    mode="prod",
                    execution_timezone="UTC",
                )
                def _foobar_schedule(date):
                    name = eval(yaml_file["name"])
                    name.get_preset("prod").run_config
but I get an error that
NameError: name 'mypipelinename' is not defined
Is it possible to call a dynamic pipeline to execute?
d

daniel

04/07/2021, 1:37 PM
Hi josh - is there an @pipeline or PipelineDefinition for the pipeline as well? Dynamically defining a schedule in code should work, but you’d also need to define the pipeline separately
j

Josh Taylor

04/07/2021, 1:39 PM
Yep, I dynamically define it in code as well. The reason for this is because we have a directory of files that are basically define config for schedules and dagster is a great fit for this. I define it like this:
Copy code
@pipeline(
    name=yaml_file["name"],
so they all show up correctly in dagit and can be executed manually using the UI/CLI, just unsure how to call the dynamic pipeline by name in the schedule to be executed
d

daniel

04/07/2021, 1:44 PM
oh I see. It's the "name = eval(yaml_file["name"])" line
let's see
There isn't a function in dagster that can take in just the name of a pipeline and return the PipelineDefinition for it (one reason for this is that pipeline names are repository-scoped). You could load the repository within the schedule function and get it that way though? So something like:
Copy code
def _foobar_schedule(date):
   from your_module import your_repository
   pipeline_definition = your_repository.get_pipeline(yaml_file["name"])
   return pipeline_definition.get_preset("prod").run_config
Bit strange, but I can't think of a reason it wouldn't work
j

Josh Taylor

04/08/2021, 12:49 AM
Fantastic! This works great, thanks!
condagster 1