Skip to content

Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.

fix/pipelex-init (#46)

Thomas Hebrardac1366f52dbc
diff --git a/Makefile b/Makefile
index c6d586841..52b79909a 100644
--- a/Makefile
+++ b/Makefile
@@ -61,7 +61,7 @@ make merge-check-pyright - Run pyright merge check without updating files
make rl - Shorthand -> reinitlibraries
make v - Shorthand -> validate
-make init - Run pipelex init
+make init - Run `pipelex init libraries` and `pipelex init config`
make codex-tests - Run tests for Codex (exit on first failure) (no inference, no codex_disabled)
make gha-tests - Run tests for github actions (exit on first failure) (no inference, no gha_disabled)
make test - Run unit tests (no inference)
@@ -126,13 +126,15 @@ env: check-uv
init: env
$(call PRINT_TITLE,"Running pipelex init")
- $(VENV_PIPELEX) init
+ $(VENV_PIPELEX) init libraries
+ $(VENV_PIPELEX) init config
install: env
$(call PRINT_TITLE,"Installing dependencies")
@. $(VIRTUAL_ENV)/bin/activate && \
uv sync --all-extras && \
- $(VENV_PIPELEX) init && \
+ $(VENV_PIPELEX) init libraries && \
+ $(VENV_PIPELEX) init config && \
echo "Installed Pipelex dependencies in ${VIRTUAL_ENV} with all extras and initialized Pipelex";
lock: env
diff --git a/pipelex/cli/_cli.py b/pipelex/cli/_cli.py
index c8a984f25..32f469113 100644
--- a/pipelex/cli/_cli.py
+++ b/pipelex/cli/_cli.py
@@ -35,23 +35,39 @@ app = typer.Typer(
cls=PipelexCLI,
)
+init_app = typer.Typer(
+ help="Initialize pipelex components. Use one of the following subcommands",
+ no_args_is_help=True,
+)
+app.add_typer(init_app, name="init")
-def init(
+
+@init_app.command("libraries")
+def init_libraries(
overwrite: Annotated[bool, typer.Option("--overwrite", "-o", help="Warning: If set, existing files will be overwritten.")] = False,
) -> None:
- """Initialize pipelex configuration in the current directory."""
- LibraryConfig.export_libraries(overwrite=overwrite)
+ """Initialize pipelex libraries in the current directory."""
+ try:
+ LibraryConfig.export_libraries(overwrite=overwrite)
+ typer.echo("Successfully initialized pipelex libraries")
+ except Exception as e:
+ raise PipelexCLIError(f"Failed to initialize libraries: {e}")
+
- pipelex_init_path = os.path.join(config_manager.pipelex_root_dir, "pipelex_init.toml")
+@init_app.command("config")
+def init_config(
+ reset: Annotated[bool, typer.Option("--reset", "-r", help="Warning: If set, existing files will be overwritten.")] = False,
+) -> None:
+ """Initialize pipelex configuration in the current directory."""
+ pipelex_template_path = os.path.join(config_manager.pipelex_root_dir, "pipelex_template.toml")
target_config_path = os.path.join(config_manager.local_root_dir, "pipelex.toml")
- if os.path.exists(target_config_path) and not overwrite:
- typer.echo("Warning: pipelex.toml already exists. Use --overwrite to force creation.")
+ if os.path.exists(target_config_path) and not reset:
+ typer.echo("Warning: pipelex.toml already exists. Use --reset to force creation.")
return
try:
- shutil.copy2(pipelex_init_path, target_config_path)
+ shutil.copy2(pipelex_template_path, target_config_path)
typer.echo(f"Created pipelex.toml at {target_config_path}")
except Exception as e:
raise PipelexCLIError(f"Failed to create pipelex.toml: {e}")
diff --git a/pipelex/pipelex_init.toml b/pipelex/pipelex_template.toml
similarity index 100%
rename from pipelex/pipelex_init.toml
rename to pipelex/pipelex_template.toml
diff --git a/tests/tools/config/test_config_manager.py b/tests/tools/config/test_config_manager.py
index 646fc1acf..9d08c06cf 100644
--- a/tests/tools/config/test_config_manager.py
+++ b/tests/tools/config/test_config_manager.py
@@ -12,4 +12,4 @@ class TestConfigManager:
def test_load_pipelex_init_config(self):
hub = get_pipelex_hub()
- hub.setup_config(config_cls=PipelexConfig, specific_config_path="pipelex/pipelex_init.toml")
+ hub.setup_config(config_cls=PipelexConfig, specific_config_path="pipelex/pipelex_template.toml")