# ask-community

Anoop Sharma

05/04/2022, 1:18 PM
I am trying to create a few repositories dynamically using a for loop. For each repository, I have one job in each pipeline. When I am trying to do this using the
decorator, it is only creating the repository for the last iteration of the loop. Not sure why that is happening. Probably have something to do with the decorated function namespace. Wondering if there is a better way to achieve this e.g. creating a repository using
or something. Following is a glimpse of what I am trying to do:
Copy code
# pipelines = ["preprocessing","training","inference"]
for pipeline in pipelines:
    # creating ops and dependencies for that pipeline dynamically here 

    job = GraphDefinition(name=pipeline, node_defs=ops, dependencies=deps).to_job()

    def my_repository():
        return [job]

    my_repository.__name__ = pipeline
Currently, it is only showing the repository for
pipeline in the
ui. Is it even possible to load multiple repositories from a single python file?
daggy success 1


05/04/2022, 2:32 PM
you certainly can have multiple repos in a python file. the way you have it right now though you're saving over your repository variable
every loop, so you only ever have one repository. I don't know exactly how to do it, but it does seem like you might need to use
to do this dynamically, as the
decorator is going to assign to an object with the name of the function it's wrapping, and function names / signatures can't be changed dynamically.

Anoop Sharma

05/04/2022, 2:36 PM
Agreed. Although, I thought since I was explicitly mentioning the
of pipeline as a parameter of
decorator and also changing the
attribute of
function object, the namespace and overwriting issues would be taken care of. But I guess not.