Skip to content

Commit

Permalink
[externals] Rename dagster-external -> dagster-externals
Browse files Browse the repository at this point in the history
  • Loading branch information
smackesey committed Aug 22, 2023
1 parent 6149c01 commit d69716b
Show file tree
Hide file tree
Showing 37 changed files with 78 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

from dagster_external import init_dagster_external
from dagster_externals import init_dagster_external


class SomeSqlClient:
Expand Down
2 changes: 1 addition & 1 deletion examples/experimental/assets_yaml_dsl/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ download = True
passenv = CI_* COVERALLS_REPO_TOKEN BUILDKITE*
deps =
-e ../../../python_modules/dagster[test]
-e ../../../python_modules/dagster-external
-e ../../../python_modules/dagster-externals
-e ../../../python_modules/dagster-webserver
-e ../../../python_modules/dagster-graphql
-e .
Expand Down
2 changes: 1 addition & 1 deletion pyright/master/requirements-pinned.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ cryptography==41.0.2
cycler==0.11.0
-e python_modules/dagit
-e python_modules/dagster
-e python_modules/dagster-external
-e python_modules/dagster-externals
-e python_modules/libraries/dagster-airbyte
-e python_modules/libraries/dagster-airflow
-e python_modules/libraries/dagster-aws
Expand Down
2 changes: 1 addition & 1 deletion pyright/master/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
-e python_modules/dagit
-e python_modules/dagster-graphql
-e python_modules/dagster-test
-e python_modules/dagster-external
-e python_modules/dagster-externals
-e python_modules/dagster-webserver
-e python_modules/libraries/dagster-airbyte/
-e python_modules/libraries/dagster-airflow[test_airflow_2]
Expand Down
4 changes: 0 additions & 4 deletions python_modules/dagster-external/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions python_modules/dagster-external/dagster_external/__init__.py

This file was deleted.

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions python_modules/dagster-externals/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# dagster-externals

The docs for `dagster-externals ` can be found
[here](https://docs.dagster.io/_apidocs/libraries/dagster-externals).
15 changes: 15 additions & 0 deletions python_modules/dagster-externals/dagster_externals/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from dagster_externals._context import (
ExternalExecutionContext as ExternalExecutionContext,
init_dagster_external as init_dagster_external,
is_dagster_orchestration_active as is_dagster_orchestration_active,
)
from dagster_externals._protocol import (
DAGSTER_EXTERNALS_DEFAULT_INPUT_FILENAME as DAGSTER_EXTERNALS_DEFAULT_INPUT_FILENAME,
DAGSTER_EXTERNALS_DEFAULT_OUTPUT_FILENAME as DAGSTER_EXTERNALS_DEFAULT_OUTPUT_FILENAME,
DAGSTER_EXTERNALS_ENV_KEYS as DAGSTER_EXTERNALS_ENV_KEYS,
ExternalDataProvenance as ExternalDataProvenance,
ExternalExecutionContextData as ExternalExecutionContextData,
ExternalPartitionKeyRange as ExternalPartitionKeyRange,
ExternalTimeWindow as ExternalTimeWindow,
Notification as Notification,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

from typing_extensions import Self

from dagster_external.params import get_external_execution_params

from .protocol import (
DAGSTER_EXTERNAL_ENV_KEYS,
from ._params import get_external_execution_params
from ._protocol import (
DAGSTER_EXTERNALS_ENV_KEYS,
ExternalDataProvenance,
ExternalExecutionContextData,
ExternalPartitionKeyRange,
Expand All @@ -28,7 +27,7 @@


def is_dagster_orchestration_active() -> bool:
return bool(os.getenv(DAGSTER_EXTERNAL_ENV_KEYS["is_orchestration_active"]))
return bool(os.getenv(DAGSTER_EXTERNALS_ENV_KEYS["is_orchestration_active"]))


def init_dagster_external() -> "ExternalExecutionContext":
Expand All @@ -46,7 +45,7 @@ def init_dagster_external() -> "ExternalExecutionContext":

warnings.warn(
"This process was not launched by a Dagster orchestration process. All calls to the"
" `dagster-external` context are no-ops."
" `dagster-externals` context are no-ops."
)
context = MagicMock()
ExternalExecutionContext.set(context)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os
from dataclasses import dataclass

from dagster_external.protocol import (
DAGSTER_EXTERNAL_ENV_KEYS,
from ._protocol import (
DAGSTER_EXTERNALS_ENV_KEYS,
)


def get_external_execution_params() -> "ExternalExecutionParams":
input_path = os.getenv(DAGSTER_EXTERNAL_ENV_KEYS["input"])
output_path = os.getenv(DAGSTER_EXTERNAL_ENV_KEYS["output"])
input_path = os.getenv(DAGSTER_EXTERNALS_ENV_KEYS["input"])
output_path = os.getenv(DAGSTER_EXTERNALS_ENV_KEYS["output"])
assert input_path, "input_path must be set"
assert output_path, "output_path must be set"
return ExternalExecutionParams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

# ##### PARAMETERS

DAGSTER_EXTERNAL_DEFAULT_INPUT_FILENAME: Final = "dagster_external_input"
DAGSTER_EXTERNAL_DEFAULT_OUTPUT_FILENAME: Final = "dagster_external_output"
DAGSTER_EXTERNALS_DEFAULT_INPUT_FILENAME: Final = "dagster_external_input"
DAGSTER_EXTERNALS_DEFAULT_OUTPUT_FILENAME: Final = "dagster_external_output"

DAGSTER_EXTERNAL_ENV_KEYS: Final = {
"is_orchestration_active": "DAGSTER_EXTERNAL_IS_ORCHESTRATION_ACTIVE",
"input": "DAGSTER_EXTERNAL_INPUT",
"output": "DAGSTER_EXTERNAL_OUTPUT",
DAGSTER_EXTERNALS_ENV_KEYS: Final = {
"is_orchestration_active": "DAGSTER_EXTERNALS_IS_ORCHESTRATION_ACTIVE",
"input": "DAGSTER_EXTERNALS_INPUT",
"output": "DAGSTER_EXTERNALS_OUTPUT",
}

# ##### NOTIFICATION
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from typing import Any, Optional, Sequence, TypeVar

from dagster_external.protocol import ExternalExecutionContextData, ExternalExecutionExtras
from ._protocol import ExternalExecutionContextData, ExternalExecutionExtras

T = TypeVar("T")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_external_subprocess_asset(input_file_spec: str, output_file_spec: str,
output_path = None if output_file_spec == "auto" else str(tmpdir.join("output"))

def script_fn():
from dagster_external import ExternalExecutionContext, init_dagster_external
from dagster_externals import ExternalExecutionContext, init_dagster_external

init_dagster_external()
context = ExternalExecutionContext.get()
Expand Down Expand Up @@ -99,7 +99,7 @@ def foo(context: AssetExecutionContext, ext: SubprocessExecutionResource):

def test_external_execution_asset_invocation():
def script_fn():
from dagster_external import init_dagster_external
from dagster_externals import init_dagster_external

context = init_dagster_external()
context.log("hello world")
Expand Down Expand Up @@ -146,7 +146,7 @@ def foo(context: AssetExecutionContext, ext: SubprocessExecutionResource):

def test_external_execution_no_orchestration():
def script_fn():
from dagster_external import (
from dagster_externals import (
ExternalExecutionContext,
init_dagster_external,
is_dagster_orchestration_active,
Expand All @@ -167,6 +167,6 @@ def script_fn():
).communicate()
assert re.search(
r"This process was not launched by a Dagster orchestration process. All calls to the"
r" `dagster-external` context are no-ops.",
r" `dagster-externals` context are no-ops.",
stderr.decode(),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dagster_externals.version import __version__


def test_version():
assert __version__
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def get_version() -> str:
version: Dict[str, str] = {}
with open(Path(__file__).parent / "dagster_external/version.py", encoding="utf8") as fp:
with open(Path(__file__).parent / "dagster_externals/version.py", encoding="utf8") as fp:
exec(fp.read(), version)

return version["__version__"]
Expand All @@ -16,13 +16,13 @@ def get_version() -> str:
# dont pin dev installs to avoid pip dep resolver issues
pin = "" if ver == "1!0+dev" else f"=={ver}"
setup(
name="dagster_external",
name="dagster-externals",
version=get_version(),
author="Elementl",
author_email="[email protected]",
license="Apache-2.0",
description="Toolkit for Dagster integrations with transform logic outside of Dagster",
url="https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-external",
url="https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-externals",
classifiers=[
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ allowlist_externals =
/bin/bash
commands =
!windows: /bin/bash -c '! pip list --exclude-editable | grep -e dagster'
pytest -c ../../pyproject.toml -vv ./dagster_external_tests
pytest -c ../../pyproject.toml -vv ./dagster_externals_tests
2 changes: 1 addition & 1 deletion python_modules/dagster-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN pip install \
-e modules/dagster-docker \
-e modules/dagster-airflow \
-e modules/dagstermill \
-e modules/dagster-external \
-e modules/dagster-externals \
-e . \
pyparsing\<3.0.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ alias copy_py="rsync -av \
copy_py $ROOT/python_modules/dagster \
$ROOT/python_modules/dagster-webserver \
$ROOT/python_modules/dagster-graphql \
$ROOT/python_modules/dagster-external \
$ROOT/python_modules/dagster-externals \
$ROOT/python_modules/libraries/dagster-airflow \
$ROOT/python_modules/libraries/dagster-aws \
$ROOT/python_modules/libraries/dagster-celery \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dagster_external import init_dagster_external
from dagster_externals import init_dagster_external

from .util import compute_data_version, load_asset_value, store_asset_value

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dagster_external import init_dagster_external
from dagster_externals import init_dagster_external

from .util import compute_data_version, store_asset_value

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from dagster_external import init_dagster_external
from dagster_externals import init_dagster_external

from .util import compute_data_version, store_asset_value

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from dagster_external.protocol import (
from dagster_externals import (
ExternalDataProvenance,
ExternalExecutionContextData,
ExternalExecutionExtras,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABC, abstractmethod
from typing import Optional

from dagster_external.protocol import ExternalExecutionExtras
from dagster_externals import ExternalExecutionExtras
from pydantic import Field

from dagster._config.pythonic_config import ConfigurableResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from threading import Event
from typing import ContextManager, Iterator, Mapping, Optional, Sequence, Union

from dagster_external.protocol import (
DAGSTER_EXTERNAL_ENV_KEYS,
from dagster_externals import (
DAGSTER_EXTERNALS_ENV_KEYS,
ExternalExecutionExtras,
)
from pydantic import Field
Expand Down Expand Up @@ -74,7 +74,7 @@ def _input_context_manager(
@contextmanager
def _file_input(self, tempdir: str) -> Iterator[SubprocessTaskIOParams]:
path = self._prepare_io_path(self._input_path, "input", tempdir)
env = {DAGSTER_EXTERNAL_ENV_KEYS["input"]: path}
env = {DAGSTER_EXTERNALS_ENV_KEYS["input"]: path}
try:
self._write_input(path)
yield SubprocessTaskIOParams(env=env)
Expand All @@ -90,7 +90,7 @@ def _output_context_manager(
@contextmanager
def _file_output(self, tempdir: str) -> Iterator[SubprocessTaskIOParams]:
path = self._prepare_io_path(self._output_path, "output", tempdir)
env = {DAGSTER_EXTERNAL_ENV_KEYS["output"]: path}
env = {DAGSTER_EXTERNALS_ENV_KEYS["output"]: path}
is_task_complete = Event()
thread = None
try:
Expand Down
14 changes: 7 additions & 7 deletions python_modules/dagster/dagster/_core/external_execution/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
Union,
)

from dagster_external.protocol import (
DAGSTER_EXTERNAL_DEFAULT_INPUT_FILENAME,
DAGSTER_EXTERNAL_DEFAULT_OUTPUT_FILENAME,
DAGSTER_EXTERNAL_ENV_KEYS,
from dagster_externals import (
DAGSTER_EXTERNALS_DEFAULT_INPUT_FILENAME,
DAGSTER_EXTERNALS_DEFAULT_OUTPUT_FILENAME,
DAGSTER_EXTERNALS_ENV_KEYS,
ExternalExecutionExtras,
)
from typing_extensions import Literal, TypeAlias, TypeVar
Expand Down Expand Up @@ -74,7 +74,7 @@ def run(self, params: T_TaskParams) -> None:
def get_base_env(self) -> Mapping[str, str]:
return {
**os.environ,
DAGSTER_EXTERNAL_ENV_KEYS["is_orchestration_active"]: "1",
DAGSTER_EXTERNALS_ENV_KEYS["is_orchestration_active"]: "1",
}

# ########################
Expand Down Expand Up @@ -167,9 +167,9 @@ def _prepare_io_path(
) -> str:
if path is None:
if target == "input":
filename = DAGSTER_EXTERNAL_DEFAULT_INPUT_FILENAME
filename = DAGSTER_EXTERNALS_DEFAULT_INPUT_FILENAME
else: # output
filename = DAGSTER_EXTERNAL_DEFAULT_OUTPUT_FILENAME
filename = DAGSTER_EXTERNALS_DEFAULT_OUTPUT_FILENAME
assert tempdir is not None, "Must define tempdir when path is None"
return os.path.join(tempdir, filename)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
ExternalTaskParams,
SocketAddress,
)
from dagster_external.protocol import (
DAGSTER_EXTERNAL_ENV_KEYS,
from dagster_externals import (
DAGSTER_EXTERNALS_ENV_KEYS,
ExternalExecutionExtras,
)
from dagster_external.util import DagsterExternalError
from dagster_externals.util import DagsterExternalError


@dataclass
Expand Down Expand Up @@ -95,7 +95,7 @@ def _input_context_manager(
@contextmanager
def _file_input(self, tempdir: str) -> Iterator[DockerTaskIOParams]:
path = self._prepare_io_path(self._input_path, "input", tempdir)
env = {DAGSTER_EXTERNAL_ENV_KEYS["input"]: path}
env = {DAGSTER_EXTERNALS_ENV_KEYS["input"]: path}
try:
self._write_input(path)
path_dir = os.path.dirname(path)
Expand All @@ -113,7 +113,7 @@ def _output_context_manager(
@contextmanager
def _file_output(self, tempdir: str) -> Iterator[DockerTaskIOParams]:
path = self._prepare_io_path(self._output_path, "output", tempdir)
env = {DAGSTER_EXTERNAL_ENV_KEYS["output"]: path}
env = {DAGSTER_EXTERNALS_ENV_KEYS["output"]: path}
output_file_dir = os.path.dirname(path)
volume_mounts = {output_file_dir: {"bind": output_file_dir, "mode": "rw"}}
is_task_complete = Event()
Expand Down
4 changes: 2 additions & 2 deletions python_modules/libraries/dagster-docker/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ download = True
passenv = HOME CI_* COVERALLS_REPO_TOKEN BUILDKITE* AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID DAGSTER_DOCKER_* DOCKER_* GOOGLE_* POSTGRES_TEST_DB_HOST
deps =
-e ../../dagster[test]
-e ../../dagster-external
-e ../../dagster-externals
-e ../../dagster-graphql
-e ../../dagster-test
-e ../dagster-aws
Expand All @@ -17,7 +17,7 @@ deps =
-e ../dagster-k8s
-e ../dagster-celery-k8s
-e ../dagster-postgres
-e ../../dagster-external
-e ../../dagster-externals
-e .
allowlist_externals =
/bin/bash
Expand Down
Loading

0 comments on commit d69716b

Please sign in to comment.