-
Notifications
You must be signed in to change notification settings - Fork 5
/
factory_launcher.py
35 lines (31 loc) · 1.18 KB
/
factory_launcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import logging
from typing import Dict
from antarest.core.config import Config
from antarest.core.interfaces.cache import ICache
from antarest.core.interfaces.eventbus import IEventBus
from antarest.launcher.adapters.abstractlauncher import AbstractLauncher, LauncherCallbacks
from antarest.launcher.adapters.local_launcher.local_launcher import LocalLauncher
from antarest.launcher.adapters.slurm_launcher.slurm_launcher import SlurmLauncher
logger = logging.getLogger(__name__)
class FactoryLauncher:
def build_launcher(
self,
config: Config,
callbacks: LauncherCallbacks,
event_bus: IEventBus,
cache: ICache,
) -> Dict[str, AbstractLauncher]:
dict_launchers: Dict[str, AbstractLauncher] = dict()
if config.launcher.local is not None:
dict_launchers["local"] = LocalLauncher(
config, callbacks, event_bus, cache
)
if config.launcher.slurm is not None:
dict_launchers["slurm"] = SlurmLauncher(
config,
callbacks,
event_bus,
cache,
retrieve_existing_jobs=True,
)
return dict_launchers