Skip to content
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
27 changes: 27 additions & 0 deletions architecture/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,33 @@ The CLI is built on Typer with lazy command loading to keep startup fast. Config

`create_lazy_typer_group` and `_LazyCommand` stubs defer importing command modules until a command is actually invoked. This keeps `data-designer --help` fast — only the command names and descriptions are loaded eagerly; the full module (and its dependencies) loads on first use.

The root group also discovers optional command groups from the `data_designer.cli`
entry-point group. The entry-point name is the top-level command name. Its target
must be a zero-argument callable that returns a `click.Command`, normally a Click
group produced from a Typer application. Root help uses the providing
distribution's `Summary` metadata and does not load the target.

```toml
[project.entry-points."data_designer.cli"]
slurm = "data_designer.slurm.cli:create_cli"
```

Extension distributions must declare a compatible dependency on
`data-designer`. Compatibility and the loaded object are validated only when the
extension command is selected. The entry-point name is authoritative and is
assigned to the returned command. Built-in command names are reserved. A
built-in collision makes that command unavailable with a targeted error rather
than allowing the extension to replace it. A duplicate extension name remains
visible as unavailable in root help and fails deterministically without loading
any conflicting target. Invalid extension names and discovery failures are
reported as warnings without disabling built-in commands.

The installed-wheel smoke test measures nine warm root-help subprocesses for a
base-only environment and an environment with the Slurm extension. The accepted
base median is at most one second, and the median overhead from installing the
extension is at most 100 ms. It also verifies that root help does not import the
extension or compatibility-checking modules.

### Layering Pattern (Setup Workflows)

Config management commands (models, providers, MCP providers, tools) follow a consistent four-layer pattern:
Expand Down
3 changes: 3 additions & 0 deletions packages/data-designer-slurm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ classifiers = [
"Programming Language :: Python :: 3.14",
]

[project.entry-points."data_designer.cli"]
slurm = "data_designer.slurm.cli:create_cli"

[build-system]
requires = ["hatchling", "uv-dynamic-versioning>=0.7.0"]
build-backend = "hatchling.build"
Expand Down
23 changes: 23 additions & 0 deletions packages/data-designer-slurm/src/data_designer/slurm/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import click
import typer

app = typer.Typer(
name="slurm",
help="Run Data Designer workloads on Slurm",
no_args_is_help=True,
)


@app.callback()
def slurm_callback() -> None:
pass


def create_cli() -> click.Command:
"""Create the Slurm CLI group."""
return typer.main.get_command(app)
12 changes: 12 additions & 0 deletions packages/data-designer-slurm/tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from __future__ import annotations

import importlib.metadata
from pathlib import Path

import data_designer
Expand All @@ -20,3 +21,14 @@ def test_slurm_is_published_before_base_extra() -> None:
publish_script = (REPO_ROOT / "scripts" / "publish.sh").read_text()

assert publish_script.index('"packages/data-designer-slurm"') < publish_script.index('"packages/data-designer"')


def test_slurm_registers_lazy_cli_extension() -> None:
entry_points = importlib.metadata.entry_points(group="data_designer.cli")
slurm_entry_point = next(
entry_point
for entry_point in entry_points
if entry_point.name == "slurm" and entry_point.dist.name == "data-designer-slurm"
)

assert slurm_entry_point.value == "data_designer.slurm.cli:create_cli"
Loading
Loading