Jordan
03/15/2023, 10:37 PMrepository
in my workspace using an asset generator. Currently, my code looks like this:
@repository
def A():
return build_assets("A")
@repository
def B() :
return build_assets("B")
@repository
def C() :
return build_assets("C")
...
I'm looking for a more concise code by having something like this:
for repository_name in ["A", "B", "C"]:
@repository(name=repository_name)
def repo():
return build_assets(repository_name)
The problem I'm having here is that I'm only getting the last built repository. Is there a way to do this cleanly? Thanks in advancesri raghavan
03/15/2023, 10:38 PMrepo
function name to vary as well based on repository_name
sri raghavan
03/15/2023, 10:38 PMJordan
03/15/2023, 11:04 PMyuhan
03/15/2023, 11:05 PMreturn RepositoryDefinition(...)
directly
https://docs.dagster.io/_apidocs/repositories#dagster.repositoryJordan
03/16/2023, 5:55 PMRepositoryDefinition
. It seems I have to go through RepositoryData
which is an internal object and complex to handle.
The only alternative I see is this one:
TEMPLATE = """
@repository
def {0}():
return build_asset("{0}")
"""
for repo_name in ["A", "B", "C"]:
exec(TEMPLATE.format(repo_name))