Skip to content

Commit 4be0e00

Browse files
committed
[dg] Rename PackageObject* -> PluginObject*
1 parent e88974e commit 4be0e00

File tree

29 files changed

+184
-154
lines changed

29 files changed

+184
-154
lines changed
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: 'Configuring dg'
3+
sidebar_position: 500
4+
---
5+
6+
import Preview from '@site/docs/partials/\_Preview.md';
7+
8+
<Preview />
9+
10+
`dg` is primarily configured using
11+
12+
13+
14+
## Default `dg` behavior (`uv run`)
15+
16+
`dg` itself is installed globally and always executes in an isolated environment. However, many `dg` commands need to spawn subprocesses in environments scoped to specific projects. For example, when you run `dg list component-type` in a project directory, `dg` only lists the component types available in that project.
17+
18+
When using `dg` with default settings, the Python subprocess is spawned after detecting a virtual environment in the project directory. This means that, rather than finding the first `python` executable on your shell `PATH`, it will instead use the Python executable from a locally detected virtual environment even if that virtual environment is not currently activated.
19+
20+
By default, `dg` uses a special `uv` command called `uv run` for environment detection and command execution. `uv run` resolves a local virtual environment (`.venv` in an ancestor directory) before running a command, and additionally makes sure that the environment is up to date with the project's specified dependencies before running the command.
21+
22+
`dg`'s use of `uv run` means you don't need to manage global shell state by activating and deactivating virtual environments during development. Instead, `dg` expects (and will scaffold for you) a `.venv` directory in the root of each project, and will use that virtual environment when executing commands (such as `dg scaffold defs` or `dg list component-type`) against that project.
23+
24+
## Disabling use of `uv run`
25+
26+
You can disable `dg`'s use of `uv run` by passing the `--no-use-dg-managed-environment` flag to `dg` commands. This will cause `dg` to still try to resolve local virtual environments by looking up the ancestor tree for `.venv`, but instead launch Python processes directly rather than going through `uv run`.
27+
28+
If you want to opt out of virtual environment detection entirely and just use your ambient Python environment (system Python or an activated virtual env), you should also (a) set `--no-require-local-venv`, and (b) ensure there are no `.venv` directories in
29+
the ancestor tree of your project.
30+
31+
:::info
32+
33+
Disabling `uv` integration with `--no-use-dg-managed-environment` will
34+
currently disable the `dg cache`. This will make some operations noticeably slower.
35+
36+
:::

examples/docs_snippets/docs_snippets/guides/components/index/17-dg-list-component-types.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dg list component-type
22

33
Using /.../jaffle-platform/.venv/bin/dagster-components
44
┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
5-
Package ┃ Objects ┃
5+
Plugin ┃ Objects ┃
66
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
77
│ dagster │ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓ │
88
│ │ ┃ Symbol ┃ Summary ┃ Features ┃ │

examples/docs_snippets/docs_snippets/guides/components/index/7-dg-list-component-types.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dg list component-type
22

33
┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
4-
Package ┃ Objects ┃
4+
Plugin ┃ Objects ┃
55
┡━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
66
│ dagster │ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓ │
77
│ │ ┃ Symbol ┃ Summary ┃ Features ┃ │

examples/docs_snippets/docs_snippets/guides/components/index/8-dg-list-component-types.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dg list component-type
22

33
Using /.../jaffle-platform/.venv/bin/dagster-components
44
┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
5-
Package ┃ Objects ┃
5+
Plugin ┃ Objects ┃
66
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
77
│ dagster │ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓ │
88
│ │ ┃ Symbol ┃ Summary ┃ Features ┃ │

examples/docs_snippets/docs_snippets/guides/components/shell-script-component/3-dg-list-component-types.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dg list component-type
22

33
Using /.../my-component-library/.venv/bin/dagster-components
44
┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
5-
Package ┃ Objects ┃
5+
Plugin ┃ Objects ┃
66
┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
77
│ dagster │ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓ │
88
│ │ ┃ Symbol ┃ Summary ┃ Features ┃ │

python_modules/dagster/dagster/components/cli/list.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Literal, Optional, Union
33

44
import click
5-
from dagster_shared.serdes.objects import PackageObjectKey
5+
from dagster_shared.serdes.objects import PluginObjectKey
66
from dagster_shared.serdes.objects.definition_metadata import (
77
DgAssetCheckMetadata,
88
DgAssetMetadata,
@@ -160,7 +160,7 @@ def list_definitions_command(
160160

161161
def _load_library_objects(
162162
entry_points: bool, extra_modules: tuple[str, ...]
163-
) -> dict[PackageObjectKey, object]:
163+
) -> dict[PluginObjectKey, object]:
164164
objects = {}
165165
if entry_points:
166166
objects.update(discover_entry_point_package_objects())
@@ -171,7 +171,7 @@ def _load_library_objects(
171171

172172
def _load_component_types(
173173
entry_points: bool, extra_modules: tuple[str, ...]
174-
) -> dict[PackageObjectKey, type[Component]]:
174+
) -> dict[PluginObjectKey, type[Component]]:
175175
return {
176176
key: obj
177177
for key, obj in _load_library_objects(entry_points, extra_modules).items()

python_modules/dagster/dagster/components/cli/scaffold.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Optional
33

44
import click
5-
from dagster_shared.serdes.objects import PackageObjectKey
5+
from dagster_shared.serdes.objects import PluginObjectKey
66
from pydantic import TypeAdapter
77

88
from dagster.components.component_scaffolding import scaffold_object
@@ -30,7 +30,7 @@ def scaffold_object_command(
3030
json_params: Optional[str],
3131
scaffold_format: str,
3232
) -> None:
33-
key = PackageObjectKey.from_typename(typename)
33+
key = PluginObjectKey.from_typename(typename)
3434
obj = load_package_object(key)
3535

3636
if json_params:

python_modules/dagster/dagster/components/core/defs_module.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pathlib import Path
66
from typing import Any, Optional, TypeVar
77

8-
from dagster_shared.serdes.objects import PackageObjectKey
8+
from dagster_shared.serdes.objects import PluginObjectKey
99
from dagster_shared.yaml_utils import parse_yaml_with_source_positions
1010
from pydantic import BaseModel, ConfigDict, TypeAdapter
1111

@@ -245,7 +245,7 @@ def get_component(cls, context: ComponentLoadContext) -> Component:
245245

246246
# find the component type
247247
type_str = context.normalize_component_type_str(component_file_model.type)
248-
key = PackageObjectKey.from_typename(type_str)
248+
key = PluginObjectKey.from_typename(type_str)
249249
obj = load_package_object(key)
250250
if not isinstance(obj, type) or not issubclass(obj, Component):
251251
raise DagsterInvalidDefinitionError(

python_modules/dagster/dagster/components/core/package_entry.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from collections.abc import Iterable, Sequence
66
from types import ModuleType
77

8-
from dagster_shared.serdes.objects import PackageObjectKey
8+
from dagster_shared.serdes.objects import PluginObjectKey
99

1010
from dagster._core.errors import DagsterError
1111
from dagster.components.utils import format_error_message
@@ -25,7 +25,7 @@ def get_entry_points_from_python_environment(group: str) -> Sequence[importlib.m
2525
return importlib.metadata.entry_points().get(group, [])
2626

2727

28-
def discover_entry_point_package_objects() -> dict[PackageObjectKey, object]:
28+
def discover_entry_point_package_objects() -> dict[PluginObjectKey, object]:
2929
"""Discover package entries registered in the Python environment via the
3030
`dg_library` entry point group.
3131
@@ -34,7 +34,7 @@ def discover_entry_point_package_objects() -> dict[PackageObjectKey, object]:
3434
component types and is loaded by default. Other entry points resolve to various sets of test
3535
component types. This method will only ever load one builtin package.
3636
"""
37-
objects: dict[PackageObjectKey, object] = {}
37+
objects: dict[PluginObjectKey, object] = {}
3838
entry_points = get_entry_points_from_python_environment(DG_LIBRARY_ENTRY_POINT_GROUP)
3939

4040
for entry_point in entry_points:
@@ -54,16 +54,16 @@ def discover_entry_point_package_objects() -> dict[PackageObjectKey, object]:
5454
f"Value expected to be a module, got {root_module}."
5555
)
5656
for name, obj in get_package_objects_in_module(root_module):
57-
key = PackageObjectKey(name=name, namespace=entry_point.value)
57+
key = PluginObjectKey(name=name, namespace=entry_point.value)
5858
objects[key] = obj
5959
return objects
6060

6161

62-
def discover_package_objects(modules: Sequence[str]) -> dict[PackageObjectKey, object]:
63-
objects: dict[PackageObjectKey, object] = {}
62+
def discover_package_objects(modules: Sequence[str]) -> dict[PluginObjectKey, object]:
63+
objects: dict[PluginObjectKey, object] = {}
6464
for extra_module in modules:
6565
for name, obj in get_package_objects_in_module(importlib.import_module(extra_module)):
66-
key = PackageObjectKey(name=name, namespace=extra_module)
66+
key = PluginObjectKey(name=name, namespace=extra_module)
6767
objects[key] = obj
6868
return objects
6969

@@ -77,7 +77,7 @@ def get_package_objects_in_module(
7777
yield attr, value
7878

7979

80-
def load_package_object(key: PackageObjectKey) -> object:
80+
def load_package_object(key: PluginObjectKey) -> object:
8181
module_name, attr = key.namespace, key.name
8282
try:
8383
module = importlib.import_module(module_name)

python_modules/dagster/dagster/components/core/snapshot.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
from dagster_shared.serdes.objects.package_entry import (
55
ComponentFeatureData,
6-
PackageObjectKey,
7-
PackageObjectSnap,
6+
PluginObjectKey,
7+
PluginObjectSnap,
88
ScaffoldTargetTypeData,
99
)
1010

@@ -43,7 +43,7 @@ def _get_scaffold_target_type_data(scaffolder: Scaffolder) -> ScaffoldTargetType
4343
)
4444

4545

46-
def get_package_entry_snap(key: PackageObjectKey, obj: object) -> PackageObjectSnap:
46+
def get_package_entry_snap(key: PluginObjectKey, obj: object) -> PluginObjectSnap:
4747
type_data = []
4848
owners = []
4949
tags = []
@@ -56,7 +56,7 @@ def get_package_entry_snap(key: PackageObjectKey, obj: object) -> PackageObjectS
5656
if isinstance(scaffolder, Scaffolder):
5757
type_data.append(_get_scaffold_target_type_data(scaffolder))
5858
summary, description = _get_summary_and_description(obj)
59-
return PackageObjectSnap(
59+
return PluginObjectSnap(
6060
key=key,
6161
summary=summary,
6262
owners=owners,

python_modules/dagster/dagster_tests/components_tests/cli_tests/test_commands.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from dagster_shared import check
99
from dagster_shared.serdes.objects import (
1010
ComponentFeatureData,
11-
PackageObjectKey,
12-
PackageObjectSnap,
11+
PluginObjectKey,
12+
PluginObjectSnap,
1313
ScaffoldTargetTypeData,
1414
)
1515
from dagster_shared.serdes.serdes import deserialize_value
@@ -40,7 +40,7 @@ def test_list_library_objects_from_module():
4040
# Now check what we get when we load directly from the test library. This has stable results.
4141
result = runner.invoke(cli, ["list", "library", "--no-entry-points", "dagster_test.components"])
4242
assert result.exit_code == 0
43-
result = check.is_list(deserialize_value(result.output), PackageObjectSnap)
43+
result = check.is_list(deserialize_value(result.output), PluginObjectSnap)
4444
assert len(result) > 1
4545

4646
assert [obj.key.to_typename() for obj in result] == [
@@ -50,8 +50,8 @@ def test_list_library_objects_from_module():
5050
"dagster_test.components.SimplePipesScriptComponent",
5151
]
5252

53-
assert result[2] == PackageObjectSnap(
54-
key=PackageObjectKey(namespace="dagster_test.components", name="SimpleAssetComponent"),
53+
assert result[2] == PluginObjectSnap(
54+
key=PluginObjectKey(namespace="dagster_test.components", name="SimpleAssetComponent"),
5555
description="A simple asset that returns a constant string value.",
5656
summary="A simple asset that returns a constant string value.",
5757
@@ -94,10 +94,8 @@ def test_list_library_objects_from_module():
9494
"type": "object",
9595
}
9696

97-
assert result[3] == PackageObjectSnap(
98-
key=PackageObjectKey(
99-
namespace="dagster_test.components", name="SimplePipesScriptComponent"
100-
),
97+
assert result[3] == PluginObjectSnap(
98+
key=PluginObjectKey(namespace="dagster_test.components", name="SimplePipesScriptComponent"),
10199
description="A simple asset that runs a Python script with the Pipes subprocess client.\n\nBecause it is a pipes asset, no value is returned.",
102100
summary="A simple asset that runs a Python script with the Pipes subprocess client.",
103101
owners=[],
@@ -134,7 +132,7 @@ def test_list_library_objects_from_project() -> None:
134132

135133
result = deserialize_value(result.output, list)
136134
assert len(result) == 1
137-
assert result[0].key == PackageObjectKey(
135+
assert result[0].key == PluginObjectKey(
138136
namespace=f"{location_name}.defs.local_component_sample",
139137
name="MyComponent",
140138
)

python_modules/dagster/dagster_tests/components_tests/registry_tests/test_registry.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from dagster.components.core.package_entry import discover_entry_point_package_objects
1414
from dagster.components.core.snapshot import get_package_entry_snap
1515
from dagster_dg.utils import get_venv_executable
16-
from dagster_shared.serdes.objects import PackageObjectKey
16+
from dagster_shared.serdes.objects import PluginObjectKey
1717
from dagster_shared.serdes.serdes import deserialize_value
1818

1919
ensure_dagster_tests_import()
@@ -130,7 +130,7 @@ def test_all_components_have_defined_summary():
130130
for component_name, component_type in registry.items():
131131
if isinstance(component_type, type) and issubclass(component_type, Component):
132132
assert get_package_entry_snap(
133-
PackageObjectKey("a", "a"), component_type
133+
PluginObjectKey("a", "a"), component_type
134134
).summary, f"Component {component_name} has no summary defined"
135135

136136

Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
from pathlib import Path
22

33
import pytest
4-
from dagster_shared.serdes.objects import PackageObjectKey
4+
from dagster_shared.serdes.objects import PluginObjectKey
55

66
dirpath = Path(".")
77

88

99
@pytest.mark.parametrize(
1010
["typename", "key"],
1111
[
12-
("foo.bar", PackageObjectKey("foo", "bar")),
13-
("foo.Bar", PackageObjectKey("foo", "Bar")),
14-
("foo.bar.baz", PackageObjectKey("foo.bar", "baz")),
12+
("foo.bar", PluginObjectKey("foo", "bar")),
13+
("foo.Bar", PluginObjectKey("foo", "Bar")),
14+
("foo.bar.baz", PluginObjectKey("foo.bar", "baz")),
1515
],
1616
)
17-
def test_valid_keys(typename: str, key: PackageObjectKey) -> None:
18-
assert PackageObjectKey.from_typename(typename) == key
17+
def test_valid_keys(typename: str, key: PluginObjectKey) -> None:
18+
assert PluginObjectKey.from_typename(typename) == key
1919

2020

2121
@pytest.mark.parametrize(
@@ -28,4 +28,4 @@ def test_valid_keys(typename: str, key: PackageObjectKey) -> None:
2828
)
2929
def test_invalid_keys(typename: str) -> None:
3030
with pytest.raises(ValueError):
31-
PackageObjectKey.from_typename(typename)
31+
PluginObjectKey.from_typename(typename)

python_modules/libraries/dagster-components/dagster_components/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
ScaffoldRequest as ScaffoldRequest,
3535
)
3636
from dagster_shared.libraries import DagsterLibraryRegistry
37-
from dagster_shared.serdes.objects import PackageObjectKey as PackageObjectKey
37+
from dagster_shared.serdes.objects import PluginObjectKey as PluginObjectKey
3838

3939
from dagster_components.version import __version__ as __version__
4040

0 commit comments

Comments
 (0)