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
Lines changed: 36 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 8 additions & 8 deletions
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

Lines changed: 4 additions & 4 deletions
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,

0 commit comments

Comments
 (0)