llamactl 0.3.0a13__py3-none-any.whl → 0.3.0a15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  from llama_deploy.cli.commands.auth import auth
2
2
  from llama_deploy.cli.commands.deployment import deployments
3
+ from llama_deploy.cli.commands.env import env_group
3
4
  from llama_deploy.cli.commands.init import init
4
5
  from llama_deploy.cli.commands.serve import serve
5
6
 
@@ -11,7 +12,7 @@ def main() -> None:
11
12
  app()
12
13
 
13
14
 
14
- __all__ = ["app", "deployments", "auth", "serve", "init"]
15
+ __all__ = ["app", "deployments", "auth", "serve", "init", "env_group"]
15
16
 
16
17
 
17
18
  if __name__ == "__main__":
llama_deploy/cli/app.py CHANGED
@@ -1,11 +1,9 @@
1
- import asyncio
2
1
  from importlib.metadata import PackageNotFoundError
3
2
  from importlib.metadata import version as pkg_version
4
3
 
5
4
  import click
6
- from llama_deploy.cli.client import get_control_plane_client
7
5
  from llama_deploy.cli.commands.aliased_group import AliasedGroup
8
- from llama_deploy.cli.config import config_manager
6
+ from llama_deploy.cli.config.env_service import service
9
7
  from llama_deploy.cli.options import global_options
10
8
  from rich import print as rprint
11
9
  from rich.console import Console
@@ -23,11 +21,10 @@ def print_version(ctx: click.Context, param: click.Option, value: bool) -> None:
23
21
  console.print(Text.assemble("client version: ", (ver, "green")))
24
22
 
25
23
  # If there is an active profile, attempt to query server version
26
- profile = config_manager.get_current_profile()
27
- if profile and profile.api_url:
24
+ auth_service = service.current_auth_service()
25
+ if auth_service:
28
26
  try:
29
- cp_client = get_control_plane_client()
30
- data = asyncio.run(cp_client.server_version())
27
+ data = auth_service.fetch_server_version()
31
28
  server_ver = data.version
32
29
  console.print(
33
30
  Text.assemble(
@@ -1,46 +1,32 @@
1
1
  from contextlib import asynccontextmanager
2
2
  from typing import AsyncGenerator
3
3
 
4
- from llama_deploy.cli.config import config_manager
4
+ from llama_deploy.cli.config.env_service import service
5
5
  from llama_deploy.core.client.manage_client import ControlPlaneClient, ProjectClient
6
6
  from rich import print as rprint
7
7
 
8
8
 
9
- def get_control_plane_client(
10
- base_url: str | None = None, api_key: str | None = None
11
- ) -> ControlPlaneClient:
12
- profile = config_manager.get_current_profile()
13
- if not profile and not base_url:
14
- rprint("\n[bold red]No profile configured![/bold red]")
15
- rprint("\nTo get started, create a profile with:")
16
- rprint("[cyan]llamactl profile create[/cyan]")
17
- raise SystemExit(1)
18
- resolved_base_url = (base_url or (profile.api_url if profile else "")).rstrip("/")
19
- if not resolved_base_url:
20
- raise ValueError("API URL is required")
21
- resolved_api_key = api_key or (profile.api_key_auth_token if profile else None)
22
- return ControlPlaneClient(resolved_base_url, resolved_api_key)
23
-
24
-
25
- def get_project_client(
26
- base_url: str | None = None,
27
- project_id: str | None = None,
28
- api_key: str | None = None,
29
- ) -> ProjectClient:
30
- profile = config_manager.get_current_profile()
9
+ def get_control_plane_client() -> ControlPlaneClient:
10
+ profile = service.current_auth_service().get_current_profile()
11
+ if profile:
12
+ resolved_base_url = profile.api_url.rstrip("/")
13
+ resolved_api_key = profile.api_key
14
+ return ControlPlaneClient(resolved_base_url, resolved_api_key)
15
+
16
+ # Fallback: allow env-scoped client construction for env operations
17
+ env = service.get_current_environment()
18
+ resolved_base_url = env.api_url.rstrip("/")
19
+ return ControlPlaneClient(resolved_base_url, None)
20
+
21
+
22
+ def get_project_client() -> ProjectClient:
23
+ profile = service.current_auth_service().get_current_profile()
31
24
  if not profile:
32
25
  rprint("\n[bold red]No profile configured![/bold red]")
33
26
  rprint("\nTo get started, create a profile with:")
34
- rprint("[cyan]llamactl profile create[/cyan]")
27
+ rprint("[cyan]llamactl auth token[/cyan]")
35
28
  raise SystemExit(1)
36
- resolved_base_url = (base_url or profile.api_url or "").rstrip("/")
37
- if not resolved_base_url:
38
- raise ValueError("API URL is required")
39
- resolved_project_id = project_id or profile.project_id
40
- if not resolved_project_id:
41
- raise ValueError("Project ID is required")
42
- resolved_api_key = api_key or profile.api_key_auth_token
43
- return ProjectClient(resolved_base_url, resolved_project_id, resolved_api_key)
29
+ return ProjectClient(profile.api_url, profile.project_id, profile.api_key)
44
30
 
45
31
 
46
32
  @asynccontextmanager