-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
296 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 5 additions & 51 deletions
56
python_modules/dagster/dagster/_core/run_coordinator/default_run_coordinator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,6 @@ | ||
import logging | ||
from typing import Mapping, Optional | ||
from dagster._core.run_coordinator.immediately_launch_run_coordinator import ( | ||
ImmediatelyLaunchRunCoordinator, | ||
) | ||
|
||
from typing_extensions import Self | ||
|
||
import dagster._check as check | ||
from dagster._config.config_schema import UserConfigSchema | ||
from dagster._core.run_coordinator.base import RunCoordinator, SubmitRunContext | ||
from dagster._core.storage.dagster_run import DagsterRun, DagsterRunStatus | ||
from dagster._serdes import ConfigurableClass, ConfigurableClassData | ||
|
||
|
||
class DefaultRunCoordinator(RunCoordinator, ConfigurableClass): | ||
"""Immediately send runs to the run launcher.""" | ||
|
||
def __init__(self, inst_data: Optional[ConfigurableClassData] = None): | ||
self._inst_data = check.opt_inst_param(inst_data, "inst_data", ConfigurableClassData) | ||
self._logger = logging.getLogger("dagster.run_coordinator.default_run_coordinator") | ||
super().__init__() | ||
|
||
@property | ||
def inst_data(self) -> Optional[ConfigurableClassData]: | ||
return self._inst_data | ||
|
||
@classmethod | ||
def config_type(cls) -> UserConfigSchema: | ||
return {} | ||
|
||
@classmethod | ||
def from_config_value( | ||
cls, inst_data: Optional[ConfigurableClassData], config_value: Mapping[str, object] | ||
) -> Self: | ||
return cls(inst_data=inst_data, **config_value) | ||
|
||
def submit_run(self, context: SubmitRunContext) -> DagsterRun: | ||
dagster_run = context.dagster_run | ||
|
||
if dagster_run.status == DagsterRunStatus.NOT_STARTED: | ||
self._instance.launch_run(dagster_run.run_id, context.workspace) | ||
else: | ||
self._logger.warning( | ||
f"submit_run called for run {dagster_run.run_id} with status " | ||
f"{dagster_run.status.value}, skipping launch." | ||
) | ||
|
||
run = self._instance.get_run_by_id(dagster_run.run_id) | ||
if run is None: | ||
check.failed(f"Failed to reload run {dagster_run.run_id}") | ||
return run | ||
|
||
def cancel_run(self, run_id: str) -> bool: | ||
return self._instance.run_launcher.terminate(run_id) | ||
# for backwards compatibility, we need to keep the old DefaultRunCoordinator | ||
DefaultRunCoordinator = ImmediatelyLaunchRunCoordinator |
52 changes: 52 additions & 0 deletions
52
python_modules/dagster/dagster/_core/run_coordinator/immediately_launch_run_coordinator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import logging | ||
from typing import Mapping, Optional | ||
|
||
from typing_extensions import Self | ||
|
||
import dagster._check as check | ||
from dagster._config.config_schema import UserConfigSchema | ||
from dagster._core.run_coordinator.base import RunCoordinator, SubmitRunContext | ||
from dagster._core.storage.dagster_run import DagsterRun, DagsterRunStatus | ||
from dagster._serdes import ConfigurableClass, ConfigurableClassData | ||
|
||
|
||
class ImmediatelyLaunchRunCoordinator(RunCoordinator, ConfigurableClass): | ||
"""Immediately send runs to the run launcher.""" | ||
|
||
def __init__(self, inst_data: Optional[ConfigurableClassData] = None): | ||
self._inst_data = check.opt_inst_param(inst_data, "inst_data", ConfigurableClassData) | ||
self._logger = logging.getLogger("dagster.run_coordinator.default_run_coordinator") | ||
super().__init__() | ||
|
||
@property | ||
def inst_data(self) -> Optional[ConfigurableClassData]: | ||
return self._inst_data | ||
|
||
@classmethod | ||
def config_type(cls) -> UserConfigSchema: | ||
return {} | ||
|
||
@classmethod | ||
def from_config_value( | ||
cls, inst_data: Optional[ConfigurableClassData], config_value: Mapping[str, object] | ||
) -> Self: | ||
return cls(inst_data=inst_data, **config_value) | ||
|
||
def submit_run(self, context: SubmitRunContext) -> DagsterRun: | ||
dagster_run = context.dagster_run | ||
|
||
if dagster_run.status == DagsterRunStatus.NOT_STARTED: | ||
self._instance.launch_run(dagster_run.run_id, context.workspace) | ||
else: | ||
self._logger.warning( | ||
f"submit_run called for run {dagster_run.run_id} with status " | ||
f"{dagster_run.status.value}, skipping launch." | ||
) | ||
|
||
run = self._instance.get_run_by_id(dagster_run.run_id) | ||
if run is None: | ||
check.failed(f"Failed to reload run {dagster_run.run_id}") | ||
return run | ||
|
||
def cancel_run(self, run_id: str) -> bool: | ||
return self._instance.run_launcher.terminate(run_id) |
Oops, something went wrong.