211 lines
6.6 KiB
Python
Executable file
211 lines
6.6 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""
|
|
@imajin Workspace Script Runner
|
|
|
|
Unified command runner for the @imajin workspace.
|
|
|
|
Usage:
|
|
./run install # Install all dependencies
|
|
./run build # Build TypeScript packages
|
|
./run test # Run tests (default: unit tests)
|
|
./run dev <service> # Start development server
|
|
./run clean # Clean build artifacts and caches
|
|
./run publish # Publish packages to registry
|
|
./run lint # Run linters
|
|
./run format # Format code
|
|
./run check # Type checking validation
|
|
./run generate # Generate a single image
|
|
./run --help # Show all available commands
|
|
./run <command> --help # Show command-specific help
|
|
|
|
Quick start:
|
|
./run install --build --test # Full setup and validation
|
|
./run generate --prompt "anime girl, cyber" --output ./test.png
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from lilith_workspace_runner import ScriptRunner, WorkspaceConfig, load_command
|
|
from lilith_workspace_runner.commands import (
|
|
create_build_command,
|
|
create_check_command,
|
|
create_clean_command,
|
|
create_dev_command,
|
|
create_format_command,
|
|
create_install_command,
|
|
create_lint_command,
|
|
create_prod_command,
|
|
)
|
|
|
|
config = WorkspaceConfig(
|
|
name="@imajin",
|
|
typescript_packages=[
|
|
"packages/imajin-app",
|
|
"packages/imajin-react",
|
|
"packages/imajin-electron",
|
|
"packages/imajin-client",
|
|
"packages/imajin-config",
|
|
],
|
|
python_packages=[
|
|
"services/imajin-aesthetic",
|
|
"services/imajin-diffusion",
|
|
"services/imajin-identity",
|
|
"services/imajin-moderator",
|
|
"services/imajin-processing",
|
|
"services/imajin-prompt",
|
|
"services/imajin-prompt-generator",
|
|
"services/imajin-request-classifier",
|
|
"services/imajin-semantic",
|
|
],
|
|
service_ports_file="ports.yaml",
|
|
service_ports_section="imajin",
|
|
service_dirs={
|
|
"classifier": "services/imajin-request-classifier/service",
|
|
"diffusion": "services/imajin-diffusion/service",
|
|
"prompt": "services/imajin-prompt/service",
|
|
"processing": "services/imajin-processing/service",
|
|
"aesthetic": "services/imajin-aesthetic/service",
|
|
"semantic": "services/imajin-semantic/service",
|
|
"moderator": "services/imajin-moderator/service",
|
|
"identity": "services/imajin-identity/service",
|
|
"image-classifier": "services/imajin-classifier/service",
|
|
"gallery": "services/imajin-media-gallery/service",
|
|
"gallery-ui": "services/imajin-media-gallery/frontend",
|
|
"studio": "studio",
|
|
},
|
|
service_apps={
|
|
"classifier": "src.api.main:app",
|
|
"diffusion": "src.api.main:app",
|
|
"prompt": "src.api.main:app",
|
|
"aesthetic": "src.api.main:app",
|
|
"semantic": "src.api.main:app",
|
|
"moderator": "src.api.main:app",
|
|
"identity": "api.app:app",
|
|
"image-classifier": "src.api.main:app",
|
|
},
|
|
service_types={
|
|
"processing": "typescript",
|
|
"gallery": "typescript",
|
|
"gallery-ui": "typescript",
|
|
"studio": "bun",
|
|
},
|
|
service_env={
|
|
"identity": {
|
|
"PYTHONPATH": "src",
|
|
},
|
|
"image-classifier": {
|
|
"LD_PRELOAD": "/var/home/lilith/Code/@applications/@imajin/services/imajin-identity/service/.venv/lib/python3.12/site-packages/nvidia/nvjitlink/lib/libnvJitLink.so.12",
|
|
},
|
|
"studio": {
|
|
"COREPACK_ENABLE_STRICT": "0",
|
|
},
|
|
},
|
|
ts_lint_packages=[
|
|
"imagen-app",
|
|
"react",
|
|
"electron",
|
|
"image-generation/types",
|
|
"image-generation/client",
|
|
"imagegen-assistant/types",
|
|
"imagegen-assistant/client",
|
|
"image-processing/types",
|
|
"image-processing/service",
|
|
],
|
|
py_lint_packages=[
|
|
"imagegen-assistant/service",
|
|
"image-generation/service",
|
|
"image-pipeline",
|
|
"image-compression",
|
|
],
|
|
ts_format_packages=[
|
|
"imagen-app",
|
|
"react",
|
|
"electron",
|
|
"image-generation/types",
|
|
"image-generation/client",
|
|
"imagegen-assistant/types",
|
|
"imagegen-assistant/client",
|
|
"image-processing/types",
|
|
"image-processing/service",
|
|
],
|
|
py_format_packages=[
|
|
"imagegen-assistant/service",
|
|
"image-generation/service",
|
|
"image-pipeline",
|
|
"image-compression",
|
|
],
|
|
ts_check_packages=[
|
|
"imagen-app",
|
|
"react",
|
|
"electron",
|
|
"image-generation/types",
|
|
"image-generation/client",
|
|
"imagegen-assistant/types",
|
|
"imagegen-assistant/client",
|
|
"image-processing/types",
|
|
"image-processing/service",
|
|
],
|
|
py_check_packages=[
|
|
"imagegen-assistant/service",
|
|
"image-generation/service",
|
|
"image-pipeline",
|
|
"image-compression",
|
|
],
|
|
ts_build_packages=[
|
|
"imagen-app",
|
|
"react",
|
|
"electron",
|
|
"image-generation/types",
|
|
"image-generation/client",
|
|
"imagegen-assistant/types",
|
|
"imagegen-assistant/client",
|
|
"image-processing/types",
|
|
"image-processing/service",
|
|
],
|
|
)
|
|
|
|
|
|
def main():
|
|
"""Main entry point."""
|
|
script_path = Path(__file__).resolve()
|
|
workspace_root = script_path.parent.parent.parent
|
|
|
|
runner = ScriptRunner(workspace_root, config.name)
|
|
|
|
# Register shared commands from workspace-runner package
|
|
for register in [
|
|
create_install_command(config),
|
|
create_build_command(config),
|
|
create_dev_command(config),
|
|
create_prod_command(config),
|
|
create_clean_command(config),
|
|
create_lint_command(config),
|
|
create_format_command(config),
|
|
create_check_command(config),
|
|
]:
|
|
register(runner)
|
|
|
|
# Register project-specific commands that remain local
|
|
scripts_dir = workspace_root / "scripts" / "run"
|
|
local_commands = [
|
|
("test_command.py", "register_test_command"),
|
|
("test_command.py", "register_tests_command"),
|
|
("publish_command.py", "register_publish_command"),
|
|
("generate_command.py", "register_generate_command"),
|
|
("repaint_command.py", "register_repaint_command"),
|
|
("shoot_command.py", "register_shoot_command"),
|
|
("setup_gpu_command.py", "register_setup_gpu_command"),
|
|
]
|
|
|
|
for cmd_file, register_func in local_commands:
|
|
cmd_path = scripts_dir / cmd_file
|
|
if cmd_path.exists():
|
|
cmd_module = load_command(cmd_path)
|
|
getattr(cmd_module, register_func)(runner)
|
|
|
|
sys.exit(runner.run())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|