hi! How can I execute a run using a `RunRequest` i...
# ask-community
g
hi! How can I execute a run using a
RunRequest
instance directly from python?
z
I don't think you can use
RunRequest
outside of a running Dagster instance, because the Dagster instance needs to be able to pick up the
RunRequest
event and execute it for you. You can use
job_name.execute_in_process()
or execute_job instead if either of those fit your needs.
1
a
I can only think of Python GraphQL client. Been using it a lot lately.
g
@Zach I guess
execute_job
will do. My use case is testing a single run materialization for a partition range. This can be done by setting the tags argument:
Copy code
execute_job(
    ...,
    tags={
        "dagster/asset_partition_range_start": start_partition_key,
        "dagster/asset_partition_range_end": end_partition_key,
    }
)
Indeed this is how it is tested here: https://github.com/dagster-io/hooli-data-eng-pipelines/blob/master/hooli_data_eng_tests/test_assets.py On function
test_orders_multi_partition_backfill
c
+1 to Zach's comment that the run request needs to be resolved and a run needs to be created and submitted by the instance. There isn't a way to do this in a test environment currently, but you can use
execute_in_process
with the provided tags like in the code snippet you linked