Skip to content

Commit

Permalink
[components] Add *Component suffix to all component classes (#28082)
Browse files Browse the repository at this point in the history
Internal companion PR: dagster-io/internal#14031

## Summary & Motivation

Add a `*Component` suffix to all of our component classes, and add a
test to make sure this is maintained.

## How I Tested These Changes

Existing test suite.
  • Loading branch information
smackesey authored Feb 27, 2025
1 parent fec9ec0 commit 3c54f50
Show file tree
Hide file tree
Showing 38 changed files with 258 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ attributes:
By convention, most library components have an `execute()` method that defines the core runtime behavior of the component. This can be overridden by subclasses of the component to customize this behavior.

For example, we can create a subclass of the `SlingReplicationCollectioncomponent` that adds a debug log message during execution:
For example, we can create a subclass of the `SlingReplicationCollectionComponent` that adds a debug log message during execution:

<CodeExample path="docs_beta_snippets/docs_beta_snippets/guides/components/custom-subclass/debug-mode.py" language="python" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dagster_components.lib import SlingReplicationCollection
from dagster_components.lib import SlingReplicationCollectionComponent


class CustomSubclass(SlingReplicationCollection): ...
class CustomSubclass(SlingReplicationCollectionComponent): ...
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from collections.abc import Mapping
from typing import Any

from dagster_components.lib import SlingReplicationCollection
from dagster_components.lib import SlingReplicationCollectionComponent

import dagster as dg


class SubclassWithScope(SlingReplicationCollection):
class SubclassWithScope(SlingReplicationCollectionComponent):
def get_additional_scope(self) -> Mapping[str, Any]:
def _custom_cron(cron_schedule: str) -> dg.AutomationCondition:
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from collections.abc import Iterator

from dagster_components.lib import SlingReplicationCollection
from dagster_components.lib import SlingReplicationCollectionComponent
from dagster_sling import SlingResource

import dagster as dg


class DebugSlingReplicationComponent(SlingReplicationCollection):
class DebugSlingReplicationComponent(SlingReplicationCollectionComponent):
def execute(
self, context: dg.AssetExecutionContext, sling: SlingResource
) -> Iterator:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
dg list component-type

Using /.../my-existing-project/.venv/bin/dagster-components
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Component Type ┃ Summary ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ dagster_components.lib.DefinitionsComponent │ Wraps an arbitrary set of │
│ │ Dagster definitions. │
│ dagster_components.lib.PipesSubprocessScriptCollection │ Assets that wrap Python │
│ │ scripts executed with │
│ │ Dagster's │
│ │ PipesSubprocessClient. │
└────────────────────────────────────────────────────────┴───────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ Component Type ┃ Summary ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ dagster_components.lib.DefinitionsComponent │ Wraps an arbitrary │
│ │ set of Dagster │
│ │ definitions. │
│ dagster_components.lib.PipesSubprocessScriptCollectionComponent │ Assets that wrap │
│ │ Python scripts │
│ │ executed with │
│ │ Dagster's │
│ │ PipesSubprocessClie… │
└─────────────────────────────────────────────────────────────────┴──────────────────────┘
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: dagster_components.lib.SlingReplicationCollection
type: dagster_components.lib.SlingReplicationCollectionComponent

attributes:
replications:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
dg list component-type

Using /.../jaffle-platform/.venv/bin/dagster-components
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Component Type ┃ Summary ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ dagster_components.lib.DbtProjectComponent │ Expose a DBT project to │
│ │ Dagster as a set of assets. │
│ dagster_components.lib.DefinitionsComponent │ Wraps an arbitrary set of │
│ │ Dagster definitions. │
│ dagster_components.lib.PipesSubprocessScriptCollection │ Assets that wrap Python │
│ │ scripts executed with │
│ │ Dagster's │
│ │ PipesSubprocessClient. │
│ dagster_components.lib.SlingReplicationCollection │ Expose one or more Sling │
│ │ replications to Dagster as │
│ │ assets. │
└────────────────────────────────────────────────────────┴───────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ Component Type ┃ Summary ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ dagster_components.lib.DbtProjectComponent │ Expose a DBT project │
│ │ to Dagster as a set │
│ │ of assets. │
│ dagster_components.lib.DefinitionsComponent │ Wraps an arbitrary │
│ │ set of Dagster │
│ │ definitions. │
│ dagster_components.lib.PipesSubprocessScriptCollectionComponent │ Assets that wrap │
│ │ Python scripts │
│ │ executed with │
│ │ Dagster's │
│ │ PipesSubprocessClie… │
│ dagster_components.lib.SlingReplicationCollectionComponent │ Expose one or more │
│ │ Sling replications │
│ │ to Dagster as │
│ │ assets. │
└─────────────────────────────────────────────────────────────────┴──────────────────────┘
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
dg list component-type

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Component Type ┃ Summary ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ dagster_components.lib.DefinitionsComponent │ Wraps an arbitrary set of │
│ │ Dagster definitions. │
│ dagster_components.lib.PipesSubprocessScriptCollection │ Assets that wrap Python │
│ │ scripts executed with │
│ │ Dagster's │
│ │ PipesSubprocessClient. │
└────────────────────────────────────────────────────────┴───────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ Component Type ┃ Summary ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ dagster_components.lib.DefinitionsComponent │ Wraps an arbitrary │
│ │ set of Dagster │
│ │ definitions. │
│ dagster_components.lib.PipesSubprocessScriptCollectionComponent │ Assets that wrap │
│ │ Python scripts │
│ │ executed with │
│ │ Dagster's │
│ │ PipesSubprocessClie… │
└─────────────────────────────────────────────────────────────────┴──────────────────────┘
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
dg list component-type

Using /.../jaffle-platform/.venv/bin/dagster-components
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Component Type ┃ Summary ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ dagster_components.lib.DefinitionsComponent │ Wraps an arbitrary set of │
│ │ Dagster definitions. │
│ dagster_components.lib.PipesSubprocessScriptCollection │ Assets that wrap Python │
│ │ scripts executed with │
│ │ Dagster's │
│ │ PipesSubprocessClient. │
│ dagster_components.lib.SlingReplicationCollection │ Expose one or more Sling │
│ │ replications to Dagster as │
│ │ assets. │
└────────────────────────────────────────────────────────┴───────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┓
┃ Component Type ┃ Summary ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━┩
│ dagster_components.lib.DefinitionsComponent │ Wraps an arbitrary │
│ │ set of Dagster │
│ │ definitions. │
│ dagster_components.lib.PipesSubprocessScriptCollectionComponent │ Assets that wrap │
│ │ Python scripts │
│ │ executed with │
│ │ Dagster's │
│ │ PipesSubprocessClie… │
│ dagster_components.lib.SlingReplicationCollectionComponent │ Expose one or more │
│ │ Sling replications │
│ │ to Dagster as │
│ │ assets. │
└─────────────────────────────────────────────────────────────────┴──────────────────────┘
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dg scaffold component 'dagster_components.lib.SlingReplicationCollection' ingest_files
dg scaffold component 'dagster_components.lib.SlingReplicationCollectionComponent' ingest_files

Creating a Dagster component instance folder at /.../jaffle-platform/jaffle_platform/components/ingest_files.
Using /.../jaffle-platform/.venv/bin/dagster-components
Loading

2 comments on commit 3c54f50

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-fa1mah202-elementl.vercel.app

Built with commit 3c54f50.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link

@github-actions github-actions bot commented on 3c54f50 Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagster-docs ready!

✅ Preview
https://dagster-docs-i7g7rv7ds-elementl.vercel.app

Built with commit 3c54f50.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.