﻿# Dagster SensorResult registers dynamic partitions before run selection

Dagster SensorResult can add dynamic partition keys and request runs together; partition registration and materialization remain separate instructions and outcomes.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/guide-dagster-dynamic-partition-sensor-result/
Language: en

## Discover a key that did not exist at definition time

A new document collection arrives after the processing asset was defined. It should become an independently addressable partition without editing a fixed category list. Dagster's [partitioning guide](https://dagster.io/docs/guides/build/partitions-and-backfills/partitioning-assets) uses `DynamicPartitionsDefinition` for keys discovered at runtime. The discovery process decides what constitutes a collection and supplies its key; the orchestrator does not infer that identity from arbitrary incoming files.

## Register the key and request work explicitly

The guide demonstrates a `SensorResult` containing dynamic partition additions and corresponding run requests. These instructions are distinct. Adding a valid partition name does not itself execute its analysis, and requesting work should identify the intended partition. Keep the association explicit when a discovery pass finds several collections, so a registered but unprocessed collection can be distinguished from a collection that was never discovered.

## Use the documented ordering inside SensorResult

The [sensor API](https://dagster.io/docs/api/dagster/schedules-sensors) states that run requests are evaluated against partition state with the requested changes applied. This permits a sensor result to register newly discovered keys and target them in accompanying requests. It is an ordering rule for interpreting the result, not a claim that every requested run has already executed successfully or that all external writes belonging to those runs are atomic.

## Keep the dynamic registry in the right instance

The [partitions reference](https://dagster.io/docs/api/dagster/partitions) describes named dynamic definitions and the store used to retrieve their keys. A key observed in another instance or environment does not automatically exist in the instance evaluating these requests. Identify the partition definition and instance together during recovery. [Task contracts](/journal/learn-codex-task-contract/) should also specify whether a collection's key denotes a durable identity or a particular revision that requires separate processing.

## Track the collection through production of its artifact

Inspect discovery, registration, requested execution and materialized output separately. [Tool observations](/journal/learn-codex-tool-observation/) can preserve the collection key and run identity across those stages. A visible partition label is useful registry evidence, but the report consumer needs the resulting analysis artifact. This distinction explains why newly added keys may remain unmaterialized and supports deliberate recovery without repeatedly registering the same collection as though registration itself completed the user task.
