Skip to content

Commit 1127425

Browse files
committed
[dg] Remove dg list component-type
1 parent 232a875 commit 1127425

File tree

6 files changed

+68
-58
lines changed

6 files changed

+68
-58
lines changed

python_modules/libraries/dagster-dg/dagster_dg/cli/list.py

+23-29
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,6 @@ def _all_plugins_object_table(
145145
type=click.Choice(["component", "scaffold-target"]),
146146
help="Filter by object type.",
147147
)
148-
@dg_global_options
149-
@cli_telemetry_wrapper
150-
def list_plugins_command(
151-
name_only: bool,
152-
package: Optional[str],
153-
feature: Optional[PluginObjectFeature],
154-
**global_options: object,
155-
) -> None:
156-
"""List dg plugins and their corresponding objects in the current Python environment."""
157-
cli_config = normalize_cli_config(global_options, click.get_current_context())
158-
dg_context = DgContext.for_defined_registry_environment(Path.cwd(), cli_config)
159-
registry = RemotePluginRegistry.from_dg_context(dg_context)
160-
161-
if package:
162-
table = _plugin_object_table(registry.get_objects(package, feature))
163-
else:
164-
table = _all_plugins_object_table(registry, name_only, feature=feature)
165-
Console().print(table)
166-
167-
168-
@list_group.command(name="component-type", cls=DgClickCommand)
169148
@click.option(
170149
"--json",
171150
"output_json",
@@ -175,21 +154,36 @@ def list_plugins_command(
175154
)
176155
@dg_global_options
177156
@cli_telemetry_wrapper
178-
def list_component_type_command(output_json: bool, **global_options: object) -> None:
179-
"""List registered Dagster components in the current project environment."""
157+
def list_plugins_command(
158+
name_only: bool,
159+
plugin: Optional[str],
160+
feature: Optional[PluginObjectFeature],
161+
output_json: bool,
162+
**global_options: object,
163+
) -> None:
164+
"""List dg plugins and their corresponding objects in the current Python environment."""
180165
cli_config = normalize_cli_config(global_options, click.get_current_context())
181166
dg_context = DgContext.for_defined_registry_environment(Path.cwd(), cli_config)
182167
registry = RemotePluginRegistry.from_dg_context(dg_context)
183168

184169
if output_json:
170+
objects = registry.get_objects(feature=feature) if plugin else registry.get_objects()
185171
output: list[dict[str, object]] = []
186-
for entry in sorted(
187-
registry.get_objects(feature="component"), key=lambda x: x.key.to_typename()
188-
):
189-
output.append({"key": entry.key.to_typename(), "summary": entry.summary})
172+
for entry in sorted(objects, key=lambda x: x.key.to_typename()):
173+
output.append(
174+
{
175+
"key": entry.key.to_typename(),
176+
"summary": entry.summary,
177+
"features": entry.features,
178+
}
179+
)
190180
click.echo(json.dumps(output, indent=4))
191-
else:
192-
Console().print(_all_plugins_object_table(registry, False, "component"))
181+
else: # table output
182+
if plugin:
183+
table = _plugin_object_table(registry.get_objects(plugin, feature))
184+
else:
185+
table = _all_plugins_object_table(registry, name_only, feature=feature)
186+
Console().print(table)
193187

194188

195189
# ########################

python_modules/libraries/dagster-dg/dagster_dg/utils/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def format_multiline_str(message: str) -> str:
346346

347347
def generate_missing_component_type_error_message(component_key_str: str) -> str:
348348
return f"""
349-
No component type `{component_key_str}` is registered. Use 'dg list component-type'
349+
No component type `{component_key_str}` is registered. Use `dg list plugins --feature component`
350350
to see the registered component types in your environment. You may need to install a package
351351
that provides `{component_key_str}` into your environment.
352352
"""

python_modules/libraries/dagster-dg/dagster_dg_tests/cli_tests/test_environment_validation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def to_cli_args(self) -> tuple[str, ...]:
5555
REGISTRY_CONTEXT_COMMANDS = [
5656
CommandSpec(tuple(), "--rebuild-component-registry"),
5757
CommandSpec(("docs", "serve")),
58-
CommandSpec(("list", "component-type")),
58+
CommandSpec(("list", "plugins")),
5959
CommandSpec(("utils", "inspect-component-type"), DEFAULT_COMPONENT_TYPE),
6060
]
6161

python_modules/libraries/dagster-dg/dagster_dg_tests/cli_tests/test_list_commands.py

+26-10
Original file line numberDiff line numberDiff line change
@@ -102,44 +102,60 @@ def test_list_components_success():
102102
[
103103
{
104104
"key": "dagster_test.components.AllMetadataEmptyComponent",
105-
"summary": null
105+
"summary": null,
106+
"features": [
107+
"component",
108+
"scaffold-target"
109+
]
106110
},
107111
{
108112
"key": "dagster_test.components.ComplexAssetComponent",
109-
"summary": "An asset that has a complex schema."
113+
"summary": "An asset that has a complex schema.",
114+
"features": [
115+
"component",
116+
"scaffold-target"
117+
]
110118
},
111119
{
112120
"key": "dagster_test.components.SimpleAssetComponent",
113-
"summary": "A simple asset that returns a constant string value."
121+
"summary": "A simple asset that returns a constant string value.",
122+
"features": [
123+
"component",
124+
"scaffold-target"
125+
]
114126
},
115127
{
116128
"key": "dagster_test.components.SimplePipesScriptComponent",
117-
"summary": "A simple asset that runs a Python script with the Pipes subprocess client."
129+
"summary": "A simple asset that runs a Python script with the Pipes subprocess client.",
130+
"features": [
131+
"component",
132+
"scaffold-target"
133+
]
118134
}
119135
]
120136
121137
""").strip()
122138

123139

124-
def test_list_component_types_success():
140+
def test_list_plugins_success():
125141
with (
126142
ProxyRunner.test(use_fixed_test_components=True) as runner,
127143
isolated_components_venv(runner),
128144
):
129145
with fixed_panel_width(width=120):
130-
result = runner.invoke("list", "component-type")
146+
result = runner.invoke("list", "plugins")
131147
assert_runner_result(result)
132148
# strip the first line of logging output
133149
output = "\n".join(result.output.split("\n")[1:])
134150
match_terminal_box_output(output.strip(), _EXPECTED_COMPONENT_TYPES)
135151

136152

137-
def test_list_component_type_json_success():
153+
def test_list_plugins_json_success():
138154
with (
139155
ProxyRunner.test(use_fixed_test_components=True) as runner,
140156
isolated_components_venv(runner),
141157
):
142-
result = runner.invoke("list", "component-type", "--json")
158+
result = runner.invoke("list", "plugins", "--json")
143159
assert_runner_result(result)
144160
# strip the first line of logging output
145161
output = "\n".join(result.output.split("\n")[1:])
@@ -149,7 +165,7 @@ def test_list_component_type_json_success():
149165
# Need to use capfd here to capture stderr from the subprocess invoked by the `list component-type`
150166
# command. This subprocess inherits stderr from the parent process, for whatever reason `capsys` does
151167
# not work.
152-
def test_list_component_type_bad_entry_point_fails(capfd):
168+
def test_list_plugins_bad_entry_point_fails(capfd):
153169
with (
154170
ProxyRunner.test() as runner,
155171
isolated_example_component_library_foo_bar(runner),
@@ -158,7 +174,7 @@ def test_list_component_type_bad_entry_point_fails(capfd):
158174
shutil.rmtree("src/foo_bar/lib")
159175

160176
# Disable cache to force re-discovery of deleted entry point
161-
result = runner.invoke("list", "component-type", "--disable-cache", "--json")
177+
result = runner.invoke("list", "plugins", "--disable-cache")
162178
assert_runner_result(result, exit_0=False)
163179

164180
expected_error_message = format_error_message("""

python_modules/libraries/dagster-dg/dagster_dg_tests/cli_tests/test_scaffold_commands.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ def test_scaffold_project_inside_workspace_success(monkeypatch) -> None:
123123

124124
# Populate cache
125125
with pushd("projects/foo-bar"):
126-
result = runner.invoke("list", "component-type", "--verbose")
126+
result = runner.invoke("list", "plugins", "--verbose")
127127
assert_runner_result(result)
128128
assert "CACHE [miss]" in result.output
129129

130130
# Check cache was populated
131131
with pushd("projects/foo-bar"):
132-
result = runner.invoke("list", "component-type", "--verbose")
132+
result = runner.invoke("list", "plugins", "--verbose")
133133
assert_runner_result(result)
134134
assert "CACHE [hit]" in result.output
135135

@@ -308,7 +308,7 @@ def test_scaffold_project_no_populate_cache_success(monkeypatch) -> None:
308308
assert Path("foo-bar/uv.lock").exists()
309309

310310
with pushd("foo-bar"):
311-
result = runner.invoke("list", "component-type", "--verbose")
311+
result = runner.invoke("list", "plugins", "--verbose")
312312
assert_runner_result(result)
313313
assert "CACHE [miss]" in result.output
314314

python_modules/libraries/dagster-dg/dagster_dg_tests/test_cache.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -20,62 +20,62 @@
2020

2121
def test_load_from_cache():
2222
with ProxyRunner.test(**cache_runner_args) as runner, example_project(runner):
23-
result = runner.invoke("list", "component-type")
23+
result = runner.invoke("list", "plugins")
2424
assert_runner_result(result)
2525
assert "CACHE [miss]" in result.output
2626
assert "CACHE [write]" in result.output
27-
result = runner.invoke("list", "component-type")
27+
result = runner.invoke("list", "plugins")
2828
assert_runner_result(result)
2929
assert "CACHE [hit]" in result.output
3030

3131

3232
def test_cache_invalidation_uv_lock():
3333
with ProxyRunner.test(**cache_runner_args) as runner, example_project(runner):
34-
result = runner.invoke("list", "component-type")
34+
result = runner.invoke("list", "plugins")
3535
assert_runner_result(result)
3636
assert "CACHE [miss]" in result.output
3737
assert "CACHE [write]" in result.output
3838

3939
subprocess.run(["uv", "add", "dagster-dbt"], check=True)
4040

41-
result = runner.invoke("list", "component-type")
41+
result = runner.invoke("list", "plugins")
4242
assert_runner_result(result)
4343
assert "CACHE [miss]" in result.output
4444

4545

4646
def test_cache_invalidation_modified_lib():
4747
with ProxyRunner.test(**cache_runner_args) as runner, example_project(runner):
48-
result = runner.invoke("list", "component-type")
48+
result = runner.invoke("list", "plugins")
4949
assert_runner_result(result)
5050
assert "CACHE [miss]" in result.output
5151
assert "CACHE [write]" in result.output
5252

53-
result = runner.invoke("scaffold", "component-type", "my_component")
53+
result = runner.invoke("scaffold", "plugins", "my_component")
5454
assert_runner_result(result)
5555

56-
result = runner.invoke("list", "component-type")
56+
result = runner.invoke("list", "plugins")
5757
assert_runner_result(result)
5858
assert "CACHE [miss]" in result.output
5959

6060

6161
def test_cache_no_invalidation_modified_pkg():
6262
with ProxyRunner.test(**cache_runner_args) as runner, example_project(runner):
63-
result = runner.invoke("list", "component-type")
63+
result = runner.invoke("list", "plugins")
6464
assert_runner_result(result)
6565
assert "CACHE [miss]" in result.output
6666
assert "CACHE [write]" in result.output
6767

6868
Path("src/foo_bar/submodule.py").write_text("print('hello')")
6969

70-
result = runner.invoke("list", "component-type")
70+
result = runner.invoke("list", "plugins")
7171
assert_runner_result(result)
7272
assert "CACHE [hit]" in result.output
7373

7474

7575
@pytest.mark.parametrize("clear_outside_project", [True, False])
7676
def test_clear_cache(clear_outside_project: bool):
7777
with ProxyRunner.test(**cache_runner_args) as runner, example_project(runner):
78-
result = runner.invoke("list", "component-type")
78+
result = runner.invoke("list", "plugins")
7979
assert_runner_result(result)
8080
assert "CACHE [miss]" in result.output
8181
assert "CACHE [write]" in result.output
@@ -85,7 +85,7 @@ def test_clear_cache(clear_outside_project: bool):
8585
assert_runner_result(result)
8686
assert "CACHE [clear-all]" in result.output
8787

88-
result = runner.invoke("list", "component-type")
88+
result = runner.invoke("list", "plugins")
8989
assert_runner_result(result)
9090
assert "CACHE [miss]" in result.output
9191

@@ -100,7 +100,7 @@ def test_rebuild_component_registry_success():
100100
assert_runner_result(result)
101101
assert "CACHE [clear-key]" in result.output
102102

103-
result = runner.invoke("list", "component-type")
103+
result = runner.invoke("list", "plugins")
104104
assert_runner_result(result)
105105
assert "CACHE [hit]" in result.output
106106

@@ -110,7 +110,7 @@ def test_rebuild_component_registry_fails_with_subcommand():
110110
ProxyRunner.test(**cache_runner_args) as runner,
111111
isolated_example_project_foo_bar(runner),
112112
):
113-
result = runner.invoke("--rebuild-component-registry", "list", "component-type")
113+
result = runner.invoke("--rebuild-component-registry", "list", "plugins")
114114
assert_runner_result(result, exit_0=False)
115115
assert "Cannot specify --rebuild-component-registry with a subcommand." in result.output
116116

@@ -134,6 +134,6 @@ def test_cache_disabled():
134134
ProxyRunner.test(**cache_runner_args, disable_cache=True) as runner,
135135
example_project(runner),
136136
):
137-
result = runner.invoke("list", "component-type")
137+
result = runner.invoke("list", "plugins")
138138
assert_runner_result(result)
139139
assert "CACHE" not in result.output

0 commit comments

Comments
 (0)