Jean Gonzalez
03/09/2023, 4:32 PMjob_name
as a parameter. I am trying to get the JobDefinitions from my repo using the job name
, all nice when working in a single file (see example below). But I want to be able to organize my code better the problem is that I need my_repo.get_job()
function to get the actual JobDefinition. If I move my job or op within another folder I get this circular dependency error basically because I am using my_repo
reference. Is there a better way to do this? or another way to get the instance of my repository? Would be nice if the op context got a reference to my repository
from dagster import (
job,
repository,
OpExecutionContext,
Field,
op,
)
# *****************************************************
# *****************************************************
# NOTE: This job and op need to here, for a technical problem about circular importing.
# In the future we need to find a way to move this code to their own folders
@op(
config_schema={
"job_name": Field(str),
}
)
def my_op(context: OpExecutionContext):
job_name = context.op_config["job_name"]
job = my_repo.get_job(job_name)
job.execute_in_process(
instance=context.instance,
)
@job(
config={
"ops": {
"my_op": {
"config": {
"job_name": "my_assets_job",
}
}
}
}
)
def my_job():
my_op()
# *****************************************************
# *****************************************************
@repository
def my_repo():
return [my_job, myOtherDefinitions...]
Jean Gonzalez
03/09/2023, 7:54 PMchris
03/09/2023, 11:36 PMOpExecutionContext
and I don’t think we will… however, perhaps you could achieve what you want by nesting the import within the actual op definition itself. That should avoid circular importsJean Gonzalez
03/10/2023, 12:18 AMJean Gonzalez
03/10/2023, 12:19 AMchris
03/10/2023, 12:19 AM