-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
__init__.py
25 lines (21 loc) · 1004 Bytes
/
__init__.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
from enum import Enum
from lightning_app.core.constants import APP_SERVER_IN_CLOUD
from lightning_app.runners.backends.backend import Backend
from lightning_app.runners.backends.cloud import CloudBackend
from lightning_app.runners.backends.docker import DockerBackend
from lightning_app.runners.backends.mp_process import CloudMultiProcessingBackend, MultiProcessingBackend
class BackendType(Enum):
MULTIPROCESSING = "multiprocessing"
DOCKER = "docker"
CLOUD = "cloud"
def get_backend(self, entrypoint_file: str) -> "Backend":
if self == BackendType.MULTIPROCESSING:
if APP_SERVER_IN_CLOUD:
return CloudMultiProcessingBackend(entrypoint_file)
return MultiProcessingBackend(entrypoint_file)
elif self == BackendType.DOCKER:
return DockerBackend(entrypoint_file)
elif self == BackendType.CLOUD:
return CloudBackend(entrypoint_file)
else:
raise ValueError("Unknown client type")