Hello. I present this problem that I have trying t...
# ask-community
a
Hello. I present this problem that I have trying to implement a dagster flow: I'm loading all my airbyte assets with this line of code:
airbyte_assets = load_assets_from_airbyte_instance(airbyte_instance)
Additionally, I have defined another asset that executes a stored procedure in SQL SERVER:
Copy code
@asset(
        group_name="sql_server_assets",
        retry_policy=RetryPolicy(max_retries=5, delay=60),
)
def sp_sql_server():
    
    # - Credenciales
    server = 'xxx'
    database = 'xxx'
    username = 'xxx'
    password = 'xxx'
    
    # - Cadena de conexión
    connection_string = f"DRIVER={{ODBC Driver 18 for SQL Server}};SERVER={server};DATABASE={database};UID={username};PWD={password}"

    with pyodbc.connect(connection_string) as connection:
        connection.execute("EXEC dbo.InsertTimestamp")

    return None
My problem lies in the need to define dependencies between assets, that is, I want my
sp_sql_server
asset to be executed first and then, through a dependency, a specific asset that is loaded from airbyte is executed, how can I do this? I reviewed the example by benpankow @ben that is on github and there I see a way to define this dependency but in this example it is done the other way around, that is, first the airbyte asset is executed and then the other assets that are defined under the
"non_argument_deps"
configuration "
"depends_on"
. how to achieve something similar but in reverse way? I thank you in advance for any help.
c
Hi Alejandro. One option here is using
build_airbyte_assets
instead of
load_assets_from_airbyte_instance
, which allows you to pass in an
upstream_assets
param that takes a list of asset keys for non argument deps cc @ben
a
Hi, @claire thanks for your answer. I would ask you to tell me how I can implement this approach to obtain an asset since I try to follow the example in the documentation but I get an error.
c
Maybe you need to do:
Copy code
assets=airbyte_assets
or
Copy code
assets=[*airbyte_assets]
instead? Looks like you're passing a list inside of a list
❤️ 1