Skip to content

init

kedro_dagster.cli.commands.init(env, force, silent)

Scaffold or refresh Dagster integration files for the current Kedro project.

Creates or updates the Dagster configuration and entry points so the project can be run from Dagster. Existing files are preserved unless --force is used. The Python package name is inferred from the Kedro project metadata.

Created/updated templates: * conf/<env>/dagster.yml: Dagster run parametrization for Kedro-Dagster. * src/<python_package>/definitions.py: Dagster Definitions entry-point. * dg.toml: Dagster dg CLI configuration (Dagster >= 1.10.6 only).

Parameters

Name Type Description Default
env str

Kedro environment under conf where dagster.yml is written. Defaults to "base".

required
force bool

Overwrite existing files without prompting. Defaults to False.

required
silent bool

Suppress success messages for a quieter output. Defaults to False.

required

Examples

Basic initialization in the base config environment:

>>> kedro dagster init --env base

Force overwrite existing integration files:

>>> kedro dagster init -e base --force

Run silently (no success messages):

>>> kedro dagster init -e base --silent

Source Code

Show/Hide source
@dagster_commands.command()
@click.option(
    "--env",
    "-e",
    default="base",
    help="The name of the kedro environment where the 'dagster.yml' should be created. Default to 'local'",
)
@click.option(
    "--force",
    "-f",
    is_flag=True,
    default=False,
    help="Update the template without any checks.",
)
@click.option(
    "--silent",
    "-s",
    is_flag=True,
    default=False,
    help="Should message be logged when files are modified?",
)
def init(env: str, force: bool, silent: bool) -> None:
    """Scaffold or refresh Dagster integration files for the current Kedro project.

    Creates or updates the Dagster configuration and entry points so the project
    can be run from Dagster. Existing files are preserved unless ``--force`` is used.
    The Python package name is inferred from the Kedro project metadata.

    Created/updated templates:
    * ``conf/<env>/dagster.yml``: Dagster run parametrization for Kedro-Dagster.
    * ``src/<python_package>/definitions.py``: Dagster ``Definitions`` entry-point.
    * ``dg.toml``: Dagster ``dg`` CLI configuration (Dagster >= 1.10.6 only).

    Parameters
    ----------
    env : str
        Kedro environment under ``conf`` where ``dagster.yml`` is written. Defaults to ``"base"``.
    force : bool
        Overwrite existing files without prompting. Defaults to ``False``.
    silent : bool
        Suppress success messages for a quieter output. Defaults to ``False``.

    Examples
    --------
    Basic initialization in the base config environment:

    >>> kedro dagster init --env base

    Force overwrite existing integration files:

    >>> kedro dagster init -e base --force

    Run silently (no success messages):

    >>> kedro dagster init -e base --silent
    """
    scaffold_dagster_files(env=env, force=force, silent=silent)