Changeset View
Changeset View
Standalone View
Standalone View
python_modules/dagster/dagster/core/host_representation/origin.py
import os | import os | ||||||||
import sys | import sys | ||||||||
from abc import ABC, abstractmethod, abstractproperty | from abc import ABC, abstractmethod, abstractproperty | ||||||||
from collections import namedtuple | from collections import namedtuple | ||||||||
from contextlib import contextmanager | from contextlib import contextmanager | ||||||||
from typing import Set | from typing import Set | ||||||||
import grpc | |||||||||
from dagster import check | from dagster import check | ||||||||
from dagster.core.definitions.reconstructable import ReconstructableRepository | from dagster.core.definitions.reconstructable import ReconstructableRepository | ||||||||
from dagster.core.errors import DagsterInvariantViolationError | from dagster.core.errors import DagsterInvariantViolationError | ||||||||
from dagster.core.types.loadable_target_origin import LoadableTargetOrigin | from dagster.core.types.loadable_target_origin import LoadableTargetOrigin | ||||||||
from dagster.serdes import DefaultNamedTupleSerializer, create_snapshot_id, whitelist_for_serdes | from dagster.serdes import DefaultNamedTupleSerializer, create_snapshot_id, whitelist_for_serdes | ||||||||
# This is a hard-coded name for the special "in-process" location. | # This is a hard-coded name for the special "in-process" location. | ||||||||
# This is typically only used for test, although we may allow | # This is typically only used for test, although we may allow | ||||||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | class RepositoryLocationOrigin(ABC): | ||||||||
"""Serializable representation of a RepositoryLocation that can be used to | """Serializable representation of a RepositoryLocation that can be used to | ||||||||
uniquely identify the location or reload it in across process boundaries. | uniquely identify the location or reload it in across process boundaries. | ||||||||
""" | """ | ||||||||
@property | @property | ||||||||
def is_reload_supported(self): | def is_reload_supported(self): | ||||||||
return True | return True | ||||||||
@property | |||||||||
def is_shutdown_supported(self): | |||||||||
return False | |||||||||
def shutdown_server(self): | |||||||||
raise NotImplementedError | |||||||||
@abstractmethod | @abstractmethod | ||||||||
def get_cli_args(self): | def get_cli_args(self): | ||||||||
pass | pass | ||||||||
@abstractmethod | @abstractmethod | ||||||||
def get_display_metadata(self): | def get_display_metadata(self): | ||||||||
pass | pass | ||||||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | def create_client(self): | ||||||||
return DagsterGrpcClient( | return DagsterGrpcClient( | ||||||||
port=self.port, | port=self.port, | ||||||||
socket=self.socket, | socket=self.socket, | ||||||||
host=self.host, | host=self.host, | ||||||||
use_ssl=bool(self.use_ssl), | use_ssl=bool(self.use_ssl), | ||||||||
) | ) | ||||||||
@property | |||||||||
def is_shutdown_supported(self): | |||||||||
return True | |||||||||
def shutdown_server(self): | |||||||||
try: | |||||||||
self.create_client().shutdown_server() | |||||||||
except grpc._channel._InactiveRpcError: # pylint: disable=protected-access | |||||||||
# Serever already shutdown | |||||||||
johannUnsubmitted Not Done Inline Actions
johann: | |||||||||
Not Done Inline ActionsIs this a safe assumption to make? johann: Is this a safe assumption to make? | |||||||||
pass | |||||||||
@whitelist_for_serdes | @whitelist_for_serdes | ||||||||
class ExternalRepositoryOrigin( | class ExternalRepositoryOrigin( | ||||||||
namedtuple("_ExternalRepositoryOrigin", "repository_location_origin repository_name") | namedtuple("_ExternalRepositoryOrigin", "repository_location_origin repository_name") | ||||||||
): | ): | ||||||||
"""Serializable representation of an ExternalRepository that can be used to | """Serializable representation of an ExternalRepository that can be used to | ||||||||
uniquely it or reload it in across process boundaries. | uniquely it or reload it in across process boundaries. | ||||||||
""" | """ | ||||||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |