Skip to content

Commit 82a5459

Browse files
committed
refactor installation commands
1 parent 3500a3e commit 82a5459

File tree

4 files changed

+52
-91
lines changed

4 files changed

+52
-91
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,14 @@ OpenEnv uses `pyproject.toml` as the primary dependency specification:
157157

158158
```bash
159159
# Install environment in editable mode
160-
pip install -e ./my_env
160+
cd my_env
161+
pip install -e .
161162

162163
# Or using uv (faster)
163-
uv pip install -e ./my_env
164+
uv pip install -e .
164165

165166
# Run server locally without Docker
166-
uv run --project ./my_env server --host 0.0.0.0 --port 8000
167+
uv run server --host 0.0.0.0 --port 8000
167168
```
168169

169170
**Benefits:**

src/openenv_cli/_validation.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ def validate_multi_mode_deployment(env_path: Path) -> tuple[bool, list[str]]:
2727
4. server/app.py has a main() function
2828
5. Required dependencies are present
2929
30-
Args:
31-
env_path: Path to the environment directory
32-
3330
Returns:
3431
Tuple of (is_valid, list of issues found)
3532
"""
@@ -115,9 +112,6 @@ def get_deployment_modes(env_path: Path) -> dict[str, bool]:
115112
"""
116113
Check which deployment modes are supported by the environment.
117114
118-
Args:
119-
env_path: Path to the environment directory
120-
121115
Returns:
122116
Dictionary with deployment mode names and whether they're supported
123117
"""
@@ -146,11 +140,6 @@ def format_validation_report(env_name: str, is_valid: bool, issues: list[str]) -
146140
"""
147141
Format a validation report for display.
148142
149-
Args:
150-
env_name: Name of the environment
151-
is_valid: Whether validation passed
152-
issues: List of issues found
153-
154143
Returns:
155144
Formatted report string
156145
"""

src/openenv_cli/commands/build.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -338,20 +338,6 @@ def build(
338338
help="Build arguments (can be used multiple times, format: KEY=VALUE)",
339339
),
340340
] = None,
341-
push: Annotated[
342-
bool,
343-
typer.Option(
344-
"--push",
345-
help="Push image to registry after building",
346-
),
347-
] = False,
348-
registry: Annotated[
349-
str | None,
350-
typer.Option(
351-
"--registry",
352-
help="Registry to push to (e.g., docker.io/username)",
353-
),
354-
] = None,
355341
) -> None:
356342
"""
357343
Build Docker images for OpenEnv environments.
@@ -367,9 +353,6 @@ def build(
367353
# Build with custom tag
368354
$ openenv build -t my-custom-tag
369355
370-
# Build and push to registry
371-
$ openenv build --push --registry myregistry.io
372-
373356
# Build without cache
374357
$ openenv build --no-cache
375358
@@ -448,15 +431,4 @@ def build(
448431
raise typer.Exit(1)
449432

450433
console.print("[bold green]✓ Docker build successful[/bold green]")
451-
452-
# Push if requested
453-
if push:
454-
console.print()
455-
tag_to_push = tag or f"openenv-{env_path_obj.name.replace('_env', '')}"
456-
success = _push_docker_image(tag_to_push, registry)
457-
if not success:
458-
print("✗ Docker push failed", file=sys.stderr)
459-
raise typer.Exit(1)
460-
console.print("[bold green]✓ Docker push successful[/bold green]")
461-
462434
console.print("\n[bold green]Done![/bold green]")

src/openenv_cli/commands/push.py

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -325,34 +325,37 @@ def push(
325325
] = False,
326326
) -> None:
327327
"""
328-
Push an OpenEnv environment to Hugging Face Spaces or a custom registry.
328+
Push an OpenEnv environment to Hugging Face Spaces or a custom Docker registry.
329329
330330
This command:
331331
1. Validates that the directory is an OpenEnv environment (openenv.yaml present)
332-
2. Prepares a custom build for deployment (optionally enables web interface)
333-
3. Uploads to Hugging Face or custom registry
332+
2. Builds and pushes to Hugging Face Spaces or custom Docker registry
333+
3. Optionally enables web interface for deployment
334334
335335
The web interface is enabled by default when pushing to HuggingFace Spaces,
336-
but disabled by default when pushing to a custom registry.
336+
but disabled by default when pushing to a custom Docker registry.
337337
338338
Examples:
339-
# Push from current directory with web interface (default)
339+
# Push to HuggingFace Spaces from current directory (web interface enabled)
340340
$ cd my_env
341341
$ openenv push
342342
343-
# Push without web interface
343+
# Push to HuggingFace without web interface
344344
$ openenv push --no-interface
345345
346-
# Push to custom registry (web interface disabled by default)
346+
# Push to Docker Hub
347347
$ openenv push --registry docker.io/myuser
348348
349+
# Push to GitHub Container Registry
350+
$ openenv push --registry ghcr.io/myorg
351+
349352
# Push to custom registry with web interface
350-
$ openenv push --registry docker.io/myuser --interface
353+
$ openenv push --registry myregistry.io/path1/path2 --interface
351354
352355
# Push to specific HuggingFace repo
353356
$ openenv push --repo-id my-org/my-env
354357
355-
# Push with custom base image and private
358+
# Push privately with custom base image
356359
$ openenv push --private --base-image ghcr.io/meta-pytorch/openenv-base:latest
357360
"""
358361
# Handle interface flag logic
@@ -402,49 +405,45 @@ def push(
402405

403406
# Handle custom registry push
404407
if registry:
405-
console.print("[bold cyan]Preparing files for custom registry deployment...[/bold cyan]")
408+
console.print("[bold cyan]Preparing to push to custom registry...[/bold cyan]")
406409
if enable_interface:
407410
console.print("[bold cyan]Web interface will be enabled[/bold cyan]")
408411

409-
with tempfile.TemporaryDirectory() as tmpdir:
410-
staging_dir = Path(tmpdir) / "staging"
411-
_prepare_staging_directory(
412-
env_dir, env_name, staging_dir,
413-
base_image=base_image,
414-
enable_interface=enable_interface
415-
)
416-
417-
# Build Docker image from staging directory
418-
tag = f"{registry}/{env_name}"
419-
console.print(f"[bold cyan]Building Docker image: {tag}[/bold cyan]")
420-
421-
# Use the build logic (could import from build.py or inline)
422-
from .build import _build_docker_image
423-
424-
success = _build_docker_image(
425-
env_path=staging_dir,
426-
tag=tag,
427-
context_path=staging_dir / "server",
428-
)
429-
430-
if not success:
431-
console.print("[bold red]✗ Docker build failed[/bold red]")
432-
raise typer.Exit(1)
433-
434-
console.print("[bold green]✓ Docker build successful[/bold green]")
435-
436-
# Push to registry
437-
console.print(f"[bold cyan]Pushing to registry: {registry}[/bold cyan]")
438-
from .build import _push_docker_image
439-
440-
success = _push_docker_image(tag, registry=None) # Tag already includes registry
441-
442-
if not success:
443-
console.print("[bold red]✗ Docker push failed[/bold red]")
444-
raise typer.Exit(1)
445-
446-
console.print("\n[bold green]✓ Deployment complete![/bold green]")
447-
console.print(f"Image: {tag}")
412+
# Import build functions
413+
from .build import _build_docker_image, _push_docker_image
414+
415+
# Prepare build args for custom registry deployment
416+
build_args = {}
417+
if enable_interface:
418+
build_args["ENABLE_WEB_INTERFACE"] = "true"
419+
420+
# Build Docker image from the environment directory
421+
tag = f"{registry}/{env_name}"
422+
console.print(f"[bold cyan]Building Docker image: {tag}[/bold cyan]")
423+
424+
success = _build_docker_image(
425+
env_path=env_dir,
426+
tag=tag,
427+
build_args=build_args if build_args else None,
428+
)
429+
430+
if not success:
431+
console.print("[bold red]✗ Docker build failed[/bold red]")
432+
raise typer.Exit(1)
433+
434+
console.print("[bold green]✓ Docker build successful[/bold green]")
435+
436+
# Push to registry
437+
console.print(f"[bold cyan]Pushing to registry: {registry}[/bold cyan]")
438+
439+
success = _push_docker_image(tag, registry=None) # Tag already includes registry
440+
441+
if not success:
442+
console.print("[bold red]✗ Docker push failed[/bold red]")
443+
raise typer.Exit(1)
444+
445+
console.print("\n[bold green]✓ Deployment complete![/bold green]")
446+
console.print(f"[bold]Image:[/bold] {tag}")
448447
return
449448

450449
# Ensure authentication for HuggingFace

0 commit comments

Comments
 (0)