3
3
from typing import TYPE_CHECKING , Dict , Mapping , Optional , Sequence , Set
4
4
5
5
from dagster ._core .instance import DagsterInstance
6
- from dagster ._core .run_coordinator .queued_run_coordinator import ConcurrencyGranularity
6
+ from dagster ._core .run_coordinator .queued_run_coordinator import PoolGranularity
7
7
from dagster ._core .snap .execution_plan_snapshot import ExecutionPlanSnapshot
8
8
from dagster ._core .storage .dagster_run import (
9
9
IN_PROGRESS_RUN_STATUSES ,
@@ -58,14 +58,14 @@ def __init__(
58
58
runs : Sequence [DagsterRun ],
59
59
in_progress_run_records : Sequence [RunRecord ],
60
60
slot_count_offset : int = 0 ,
61
- concurrency_group_granularity : ConcurrencyGranularity = ConcurrencyGranularity .OP ,
61
+ pool_granularity : PoolGranularity = PoolGranularity .OP ,
62
62
):
63
63
self ._root_concurrency_keys_by_run = {}
64
64
self ._concurrency_info_by_key : Dict [str , "ConcurrencyKeyInfo" ] = {}
65
65
self ._launched_concurrency_key_counts = defaultdict (int )
66
66
self ._in_progress_concurrency_key_counts = defaultdict (int )
67
67
self ._slot_count_offset = slot_count_offset
68
- self ._concurrency_group_granularity = concurrency_group_granularity
68
+ self ._pool_granularity = pool_granularity
69
69
self ._in_progress_run_ids : Set [str ] = set (
70
70
[record .dagster_run .run_id for record in in_progress_run_records ]
71
71
)
@@ -91,7 +91,7 @@ def _fetch_concurrency_info(self, instance: DagsterInstance, queued_runs: Sequen
91
91
# if using op granularity, consider only the root keys
92
92
run_concurrency_keys = (
93
93
run .run_op_concurrency .root_key_counts .keys ()
94
- if self ._concurrency_group_granularity == ConcurrencyGranularity .OP
94
+ if self ._pool_granularity == PoolGranularity .OP
95
95
else run .run_op_concurrency .all_keys or []
96
96
)
97
97
all_concurrency_keys .update (run_concurrency_keys )
@@ -115,7 +115,7 @@ def _should_allocate_slots_for_in_progress_run(self, record: RunRecord):
115
115
if status not in IN_PROGRESS_RUN_STATUSES :
116
116
return False
117
117
118
- if self ._concurrency_group_granularity == ConcurrencyGranularity .RUN :
118
+ if self ._pool_granularity == PoolGranularity .RUN :
119
119
return True
120
120
121
121
if status == DagsterRunStatus .STARTING :
@@ -132,11 +132,11 @@ def _slot_counts_for_run(self, run: DagsterRun) -> Mapping[str, int]:
132
132
if not run .run_op_concurrency :
133
133
return {}
134
134
135
- if self ._concurrency_group_granularity == ConcurrencyGranularity .OP :
135
+ if self ._pool_granularity == PoolGranularity .OP :
136
136
return {** run .run_op_concurrency .root_key_counts }
137
137
138
138
else :
139
- assert self ._concurrency_group_granularity == ConcurrencyGranularity .RUN
139
+ assert self ._pool_granularity == PoolGranularity .RUN
140
140
return {concurrency_key : 1 for concurrency_key in run .run_op_concurrency .all_keys or []}
141
141
142
142
def _process_in_progress_runs (self , in_progress_records : Sequence [RunRecord ]):
@@ -154,14 +154,14 @@ def is_blocked(self, run: DagsterRun) -> bool:
154
154
return False
155
155
156
156
if (
157
- self ._concurrency_group_granularity == ConcurrencyGranularity .OP
157
+ self ._pool_granularity == PoolGranularity .OP
158
158
and run .run_op_concurrency .has_unconstrained_root_nodes
159
159
):
160
160
# if the granularity is at the op level and there exists a root node that is not
161
161
# concurrency blocked, we should dequeue.
162
162
return False
163
163
164
- if self ._concurrency_group_granularity == ConcurrencyGranularity .OP :
164
+ if self ._pool_granularity == PoolGranularity .OP :
165
165
# we just need to check all of the root concurrency keys, instead of all the concurrency keys
166
166
# in the run
167
167
for concurrency_key in run .run_op_concurrency .root_key_counts .keys ():
@@ -189,7 +189,7 @@ def is_blocked(self, run: DagsterRun) -> bool:
189
189
return True
190
190
191
191
else :
192
- assert self ._concurrency_group_granularity == ConcurrencyGranularity .RUN
192
+ assert self ._pool_granularity == PoolGranularity .RUN
193
193
194
194
# if the granularity is at the run level, we should check if any of the concurrency
195
195
# keys are blocked
@@ -228,7 +228,7 @@ def get_blocked_run_debug_info(self, run: DagsterRun) -> Mapping:
228
228
continue
229
229
230
230
log_info [concurrency_key ] = {
231
- "granularity" : self ._concurrency_group_granularity .value ,
231
+ "granularity" : self ._pool_granularity .value ,
232
232
"slot_count" : concurrency_info .slot_count ,
233
233
"pending_step_count" : len (concurrency_info .pending_steps ),
234
234
"pending_step_run_ids" : list (
0 commit comments