3

I have been looking all over for the answer, but can't seem to find what I'm looking for

I want to create an api endpoint that can pass information to the dagster assets and trigger a run. For example, I have the following asset in dagster

@asset
def player_already_registered(player_name: str):
    q = text(
            f'''
                SELECT 
                    COUNT(*)
                FROM
                    `player_account_info`
                WHERE
                    summonerName = :player_name
            '''
        )

    result = database.conn.execute(q, player_name=player_name).fetchone()[0]
    return bool(result)

Say that I have an endpoint already made where I can pass the player_name via a get-parameter. How can I pass the parameter to the asset and then run the job itself?

1 Answers1

2
  1. use the instance object provided (https://georgheiler.com/2022/02/02/interactive-dagster-debugging/ ) You can use the python object "instance" like shown in the link to basically access everything, which you could also acces from dagit. ( I have not excessively used it, but mybe the linke helps you.

  2. Using Dagster Graph ql api (https://docs.dagster.io/concepts/dagit/graphql) Nothing done with it yet, so I can only point you to the link

  3. Use partitions (https://docs.dagster.io/_modules/dagster/_core/definitions/partition#dynamic_partitioned_config)

You can use partitions to trigger executing a job for each partition. I am using this often, because it gives you really got control of what assets were materialized with which partitions (parameters). The link leads to an example of a dynamic partition, which is discovered by a sensor, which then executes a job for each partition and also keeps track of the partitions in dagit.

I hope this helps.

Tomafer
  • 21
  • 1