Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[components] Rename dg check component -> dg check yaml #27962

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ We need to update the configuration of the `dagster_components.dbt_project` comp

<CodeExample path="docs_beta_snippets/docs_beta_snippets/guides/components/index/22-project-jdbt-incorrect.yaml" language="YAML" title="jaffle-platform/jaffle_platform/components/jdbt/component.yaml" />

You might notice the typo in the above file--after updating a component file, it's useful to validate that the changes match the component's schema. You can do this by running `dg check component`:
You might notice the typo in the above file--after updating a component file, it's useful to validate that the changes match the component's schema. You can do this by running `dg check yaml`:

<CliInvocationExample path="docs_beta_snippets/docs_beta_snippets/guides/components/index/23-dg-component-check-error.txt" />

You can see that the error message includes the filename, line number, and a code snippet showing the exact nature of the error. Let's fix the typo:

<CodeExample path="docs_beta_snippets/docs_beta_snippets/guides/components/index/24-project-jdbt.yaml" language="YAML" title="jaffle-platform/jaffle_platform/components/jdbt/component.yaml" />

Finally, run `dg check component` again to validate the fix:
Finally, run `dg check yaml` again to validate the fix:

<CliInvocationExample path="docs_beta_snippets/docs_beta_snippets/guides/components/index/25-dg-component-check.txt" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dg check component
dg check yaml

/.../jaffle-platform/jaffle_platform/components/jdbt/component.yaml:8 - Unable to parse YAML: while scanning a quoted scalar, found unexpected end of stream
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dg check component
dg check yaml

All components validated successfully.
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def next_snip_no():
""",
)
run_command_and_snippet_output(
cmd="dg check component",
cmd="dg check yaml",
snippet_path=COMPONENTS_SNIPPETS_DIR
/ f"{next_snip_no()}-dg-component-check-error.txt",
update_snippets=update_snippets,
Expand All @@ -314,7 +314,7 @@ def next_snip_no():
""",
)
run_command_and_snippet_output(
cmd="dg check component",
cmd="dg check yaml",
snippet_path=COMPONENTS_SNIPPETS_DIR
/ f"{next_snip_no()}-dg-component-check.txt",
update_snippets=update_snippets,
Expand Down
4 changes: 3 additions & 1 deletion python_modules/libraries/dagster-dg/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
## 0.1.16

- The entire dg CLI has been changed from noun-first to verb-first, e.g. dg code-location scaffold is now dg scaffold code-location.
- The `info` command has been renamed to `inspect`. Combining this change with the new verb-first orientation, `dg component-type info` is now `dg inspect component-type`.
- Some commands have also been renamed beyond the switch in order:
- The `info` command has been renamed to `inspect`. `dg component-type info` is now `dg inspect component-type`.
- `dg component check` command is now `dg check yaml`.

## 0.1.15

Expand Down
10 changes: 3 additions & 7 deletions python_modules/libraries/dagster-dg/dagster_dg/cli/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def check_group():
}


def _is_local_component(component_name: str) -> bool:
return component_name.endswith(".py")


def _scaffold_value_and_source_position_tree(
filename: str, row: int, col: int
) -> ValueAndSourcePositionTree:
Expand All @@ -65,16 +61,16 @@ class ErrorInput(NamedTuple):
source_position_tree: ValueAndSourcePositionTree


@check_group.command(name="component", cls=DgClickCommand)
@check_group.command(name="yaml", cls=DgClickCommand)
@click.argument("paths", nargs=-1, type=click.Path(exists=True))
@dg_global_options
@click.pass_context
def component_check_command(
def check_yaml_command(
context: click.Context,
paths: Sequence[str],
**global_options: object,
) -> None:
"""Check component files against their schemas, showing validation errors."""
"""Check component.yaml files against their schemas, showing validation errors."""
resolved_paths = [Path(path).absolute() for path in paths]
top_level_component_validator = Draft202012Validator(schema=COMPONENT_FILE_SCHEMA)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_check_component_succeeds_non_default_component_package() -> None:
assert BASIC_VALID_VALUE.component_type_filepath
shutil.copy(BASIC_VALID_VALUE.component_type_filepath, components_dir / "__init__.py")

result = runner.invoke("check", "component")
result = runner.invoke("check", "yaml")
assert_runner_result(result, exit_0=True)


Expand All @@ -115,7 +115,7 @@ def test_validation_cli(test_case: ComponentValidationTestCase) -> None:
) as tmpdir,
):
with pushd(tmpdir):
result = runner.invoke("check", "component")
result = runner.invoke("check", "yaml")
if test_case.should_error:
assert result.exit_code != 0, str(result.stdout)

Expand Down Expand Up @@ -150,7 +150,7 @@ def test_validation_cli_multiple_components(scope_check_run: bool) -> None:
with pushd(str(tmpdir)):
result = runner.invoke(
"check",
"component",
"yaml",
*(
[
str(Path("foo_bar") / "components" / "basic_component_missing_value"),
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_validation_cli_multiple_components_filter() -> None:
with pushd(tmpdir):
result = runner.invoke(
"check",
"component",
"yaml",
str(Path("foo_bar") / "components" / "basic_component_missing_value"),
)
assert result.exit_code != 0, str(result.stdout)
Expand All @@ -206,7 +206,7 @@ def test_validation_cli_local_component_cache() -> None:
) as code_location_dir,
):
with pushd(code_location_dir):
result = runner.invoke("check", "component")
result = runner.invoke("check", "yaml")
assert re.search(
r"CACHE \[write\].*basic_component_success.*local_component_registry", result.stdout
)
Expand All @@ -216,7 +216,7 @@ def test_validation_cli_local_component_cache() -> None:
)

# Local components should all be cached
result = runner.invoke("check", "component")
result = runner.invoke("check", "yaml")
assert not re.search(
r"CACHE \[write\].*basic_component_success.*local_component_registry", result.stdout
)
Expand All @@ -242,7 +242,7 @@ def test_validation_cli_local_component_cache() -> None:
).write_text(contents + "\n")

# basic_component_success local component is now be invalidated and needs to be re-cached, the other one should still be cached
result = runner.invoke("check", "component")
result = runner.invoke("check", "yaml")
assert re.search(
r"CACHE \[write\].*basic_component_success.*local_component_registry", result.stdout
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def to_cli_args(self) -> tuple[str, ...]:

CODE_LOCATION_CONTEXT_COMMANDS = [
CommandSpec(("configure-editor", "code-location"), "vscode"),
CommandSpec(("check", "component")),
CommandSpec(("check", "yaml")),
CommandSpec(("list", "component")),
CommandSpec(("scaffold", "component"), DEFAULT_COMPONENT_TYPE, "foot"),
]
Expand Down