-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[components] Split out dg-cli from dagster-components (#26364)
## Summary & Motivation Splits out `dg-cli` from `dagster-components`. `dg-cli` does not depend on any other dagster package. All possible generation logic is moved to `dg-cli`. However, `dg-cli` sometimes needs to run commands in a code location environment: - Querying the environment to see the defined components - Running the `generate_files` routine to generate a new component This functionality is exposed from `dagster-components` via a new `dagster-components` CLI, that is basically a backend for `dg`. It's not intended to be called by users. The plumbing between the two packages could be improved but this is a working first implementation. Other comments: - `dagster-components` no longer has any concept of a "deployment"-- the `DeploymentProjectContext` has been moved to `dg`. However, both `dg-cli` and `dagster-components` have slightly differing versions of `CodeLocationProjectContext`. The `dg-cli` version uses a new `RemoteComponentRegistry` and `RemoteComponentType` class to represent the contents of the component registry in the code location. - `dg generate component` will forward the `-- extra args` or `--json-params` untouched onto `dagster-components generate component` - `dagster-components` doesn't have any _direct_ CLI testing right now-- the testing is done via the higher level calls from `dg` ## How I Tested These Changes Unit tests.
- Loading branch information
Showing
35 changed files
with
1,044 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# dagster-components | ||
|
||
Experimental API for defining Dagster definitions factories ("components"). | ||
Includes the `dg` CLI tool. | ||
Experimental Python API for defining Dagster definitions factories ("components"). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
python_modules/libraries/dagster-components/dagster_components/cli/list.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import json | ||
import sys | ||
from pathlib import Path | ||
from typing import Any, Dict | ||
|
||
import click | ||
|
||
from dagster_components import __component_registry__ | ||
from dagster_components.core.component import ComponentRegistry | ||
from dagster_components.core.deployment import ( | ||
CodeLocationProjectContext, | ||
is_inside_code_location_project, | ||
) | ||
|
||
|
||
@click.group(name="generate") | ||
def list_cli(): | ||
"""Commands for listing Dagster components and related entities.""" | ||
|
||
|
||
@list_cli.command(name="component-types") | ||
def list_component_types_command() -> None: | ||
"""List registered Dagster components.""" | ||
if not is_inside_code_location_project(Path.cwd()): | ||
click.echo( | ||
click.style( | ||
"This command must be run inside a Dagster code location project.", fg="red" | ||
) | ||
) | ||
sys.exit(1) | ||
|
||
context = CodeLocationProjectContext.from_path( | ||
Path.cwd(), ComponentRegistry(__component_registry__) | ||
) | ||
output: Dict[str, Any] = {} | ||
for component_type in context.list_component_types(): | ||
# package, name = component_type.rsplit(".", 1) | ||
output[component_type] = { | ||
"name": component_type, | ||
} | ||
click.echo(json.dumps(output)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.