Changeset View
Changeset View
Standalone View
Standalone View
python_modules/dagster/dagster/core/host_representation/origin.py
import os | import os | ||||
from abc import ABCMeta | from abc import ABCMeta | ||||
from collections import namedtuple | from collections import namedtuple | ||||
import six | import six | ||||
from dagster import check | from dagster import check | ||||
from dagster.core.code_pointer import CodePointer | from dagster.core.definitions.reconstructable import ReconstructableRepository | ||||
from dagster.core.types.loadable_target_origin import LoadableTargetOrigin | from dagster.core.types.loadable_target_origin import LoadableTargetOrigin | ||||
from dagster.serdes import whitelist_for_serdes | from dagster.serdes import 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 | ||||
# users to load user code into a host process as well. We want | # users to load user code into a host process as well. We want | ||||
# to encourage the user code to be in user processes as much | # to encourage the user code to be in user processes as much | ||||
# as possible since that it how this system will be used in prod. | # as possible since that it how this system will be used in prod. | ||||
Show All 37 Lines | |||||
class RepositoryLocationOrigin(six.with_metaclass(ABCMeta)): | class RepositoryLocationOrigin(six.with_metaclass(ABCMeta)): | ||||
"""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. | ||||
""" | """ | ||||
@whitelist_for_serdes | @whitelist_for_serdes | ||||
class InProcessRepositoryLocationOrigin( | class InProcessRepositoryLocationOrigin( | ||||
namedtuple("_InProcessRepositoryLocationOrigin", "code_pointer"), RepositoryLocationOrigin, | namedtuple("_InProcessRepositoryLocationOrigin", "recon_repo"), RepositoryLocationOrigin, | ||||
): | ): | ||||
"""Identifies a repository location constructed in the host process. Should only be | """Identifies a repository location constructed in the host process. Should only be | ||||
used in tests. | used in tests. | ||||
""" | """ | ||||
def __new__(cls, code_pointer): | def __new__(cls, recon_repo): | ||||
return super(InProcessRepositoryLocationOrigin, cls).__new__( | return super(InProcessRepositoryLocationOrigin, cls).__new__( | ||||
cls, check.inst_param(code_pointer, "code_pointer", CodePointer,) | cls, check.inst_param(recon_repo, "recon_repo", ReconstructableRepository) | ||||
) | ) | ||||
@property | @property | ||||
def location_name(self): | def location_name(self): | ||||
return IN_PROCESS_NAME | return IN_PROCESS_NAME | ||||
@whitelist_for_serdes | @whitelist_for_serdes | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |