https://dagster.io/ logo
#ask-ai
Title
# ask-ai
c

Chris Roth

03/04/2024, 9:44 PM
@Scout how do I add a dynamic partition?
s

Scout

03/04/2024, 9:44 PM
You can add a dynamic partition by using the
add_dynamic_partitions
method on the
DagsterInstance
. Here's how you can do it according to the documentation:
Copy code
python from dagster import DagsterInstance, DynamicPartitionsDefinition  # Define your dynamic partitions definition dynamic_partitions_def = DynamicPartitionsDefinition(name="my_partitions_def")  # Get your Dagster instance instance = DagsterInstance.get()  # Add a dynamic partition instance.add_dynamic_partitions(dynamic_partitions_def.name, ["your_partition_key"])
This code snippet demonstrates how to define a
DynamicPartitionsDefinition
and then add a dynamic partition to it using the
add_dynamic_partitions
method. Replace
"your_partition_key"
with the actual key you want to use for your partition.