llamactl 0.3.0a22__py3-none-any.whl → 0.3.0a24__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.
- llama_deploy/cli/commands/auth.py +53 -0
- llama_deploy/cli/commands/serve.py +27 -3
- llama_deploy/cli/utils/env_inject.py +23 -0
- {llamactl-0.3.0a22.dist-info → llamactl-0.3.0a24.dist-info}/METADATA +3 -3
- {llamactl-0.3.0a22.dist-info → llamactl-0.3.0a24.dist-info}/RECORD +7 -6
- {llamactl-0.3.0a22.dist-info → llamactl-0.3.0a24.dist-info}/WHEEL +0 -0
- {llamactl-0.3.0a22.dist-info → llamactl-0.3.0a24.dist-info}/entry_points.txt +0 -0
|
@@ -5,10 +5,12 @@ import platform
|
|
|
5
5
|
import subprocess
|
|
6
6
|
import sys
|
|
7
7
|
import webbrowser
|
|
8
|
+
from pathlib import Path
|
|
8
9
|
|
|
9
10
|
import click
|
|
10
11
|
import httpx
|
|
11
12
|
import questionary
|
|
13
|
+
from dotenv import set_key
|
|
12
14
|
from llama_deploy.cli.auth.client import (
|
|
13
15
|
DeviceAuthorizationRequest,
|
|
14
16
|
OIDCClient,
|
|
@@ -28,6 +30,7 @@ from llama_deploy.cli.styles import (
|
|
|
28
30
|
PRIMARY_COL,
|
|
29
31
|
WARNING,
|
|
30
32
|
)
|
|
33
|
+
from llama_deploy.cli.utils.env_inject import env_vars_from_profile
|
|
31
34
|
from llama_deploy.core.client.manage_client import (
|
|
32
35
|
ControlPlaneClient,
|
|
33
36
|
)
|
|
@@ -314,6 +317,56 @@ def change_project(project_id: str | None, interactive: bool) -> None:
|
|
|
314
317
|
raise click.Abort()
|
|
315
318
|
|
|
316
319
|
|
|
320
|
+
@auth.command("inject")
|
|
321
|
+
@global_options
|
|
322
|
+
@click.option(
|
|
323
|
+
"--env-file",
|
|
324
|
+
"env_file",
|
|
325
|
+
default=Path(".env"),
|
|
326
|
+
type=click.Path(dir_okay=False, resolve_path=True, path_type=Path),
|
|
327
|
+
help="Path to the .env file to write",
|
|
328
|
+
)
|
|
329
|
+
@interactive_option
|
|
330
|
+
def inject_env_vars(
|
|
331
|
+
env_file: Path,
|
|
332
|
+
interactive: bool,
|
|
333
|
+
) -> None:
|
|
334
|
+
"""Inject auth environment variables into a .env file.
|
|
335
|
+
|
|
336
|
+
Writes LLAMA_CLOUD_API_KEY, LLAMA_CLOUD_BASE_URL, and LLAMA_DEPLOY_PROJECT_ID
|
|
337
|
+
based on the current profile. Always overwrites and creates the file if missing.
|
|
338
|
+
"""
|
|
339
|
+
try:
|
|
340
|
+
auth_svc = service.current_auth_service()
|
|
341
|
+
profile = auth_svc.get_current_profile()
|
|
342
|
+
if not profile:
|
|
343
|
+
if interactive:
|
|
344
|
+
profile = validate_authenticated_profile(True)
|
|
345
|
+
else:
|
|
346
|
+
raise click.ClickException(
|
|
347
|
+
"No profile configured. Run `llamactl auth token` to create a profile."
|
|
348
|
+
)
|
|
349
|
+
if not profile.api_key:
|
|
350
|
+
raise click.ClickException(
|
|
351
|
+
"Current profile is unauthenticated (missing API key)"
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
vars = env_vars_from_profile(profile)
|
|
355
|
+
if not vars:
|
|
356
|
+
rprint(f"[{WARNING}]No variables to inject[/]")
|
|
357
|
+
return
|
|
358
|
+
env_file.parent.mkdir(parents=True, exist_ok=True)
|
|
359
|
+
for key, value in vars.items():
|
|
360
|
+
set_key(str(env_file), key, value)
|
|
361
|
+
rel = os.path.relpath(env_file, Path.cwd())
|
|
362
|
+
rprint(
|
|
363
|
+
f"[green]Wrote environment variables: {', '.join(vars.keys())} to {rel}[/green]"
|
|
364
|
+
)
|
|
365
|
+
except Exception as e:
|
|
366
|
+
rprint(f"[red]Error: {e}[/red]")
|
|
367
|
+
raise click.Abort()
|
|
368
|
+
|
|
369
|
+
|
|
317
370
|
def _auto_device_name() -> str:
|
|
318
371
|
try:
|
|
319
372
|
if sys.platform == "darwin": # macOS
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
from typing import Literal
|
|
4
5
|
|
|
5
6
|
import click
|
|
6
7
|
import questionary
|
|
@@ -8,6 +9,7 @@ from llama_deploy.appserver.app import (
|
|
|
8
9
|
prepare_server,
|
|
9
10
|
start_server_in_target_venv,
|
|
10
11
|
)
|
|
12
|
+
from llama_deploy.appserver.deployment_config_parser import get_deployment_config
|
|
11
13
|
from llama_deploy.appserver.workflow_loader import parse_environment_variables
|
|
12
14
|
from llama_deploy.cli.commands.auth import validate_authenticated_profile
|
|
13
15
|
from llama_deploy.cli.config.env_service import service
|
|
@@ -61,6 +63,16 @@ logger = logging.getLogger(__name__)
|
|
|
61
63
|
type=click.Choice(["console", "json"], case_sensitive=False),
|
|
62
64
|
help="The format to use for logging",
|
|
63
65
|
)
|
|
66
|
+
@click.option(
|
|
67
|
+
"--persistence",
|
|
68
|
+
type=click.Choice(["memory", "local", "cloud"]),
|
|
69
|
+
help="The persistence mode to use for the workflow server",
|
|
70
|
+
)
|
|
71
|
+
@click.option(
|
|
72
|
+
"--local-persistence-path",
|
|
73
|
+
type=click.Path(dir_okay=True, resolve_path=True, path_type=Path),
|
|
74
|
+
help="The path to the sqlite database to use for the workflow server if using local persistence",
|
|
75
|
+
)
|
|
64
76
|
@interactive_option
|
|
65
77
|
def serve(
|
|
66
78
|
deployment_file: Path,
|
|
@@ -72,6 +84,8 @@ def serve(
|
|
|
72
84
|
ui_port: int | None = None,
|
|
73
85
|
log_level: str | None = None,
|
|
74
86
|
log_format: str | None = None,
|
|
87
|
+
persistence: Literal["memory", "local", "cloud"] | None = None,
|
|
88
|
+
local_persistence_path: Path | None = None,
|
|
75
89
|
interactive: bool = False,
|
|
76
90
|
) -> None:
|
|
77
91
|
"""Run llama_deploy API Server in the foreground. Reads the deployment configuration from the current directory. Can optionally specify a deployment file path."""
|
|
@@ -81,13 +95,16 @@ def serve(
|
|
|
81
95
|
|
|
82
96
|
try:
|
|
83
97
|
# Pre-check: if the template requires llama cloud access, ensure credentials
|
|
84
|
-
_maybe_inject_llama_cloud_credentials(
|
|
98
|
+
_maybe_inject_llama_cloud_credentials(
|
|
99
|
+
deployment_file, interactive, require_cloud=persistence == "cloud"
|
|
100
|
+
)
|
|
85
101
|
|
|
86
102
|
prepare_server(
|
|
87
103
|
deployment_file=deployment_file,
|
|
88
104
|
install=not no_install,
|
|
89
105
|
build=preview,
|
|
90
106
|
)
|
|
107
|
+
deployment_config = get_deployment_config()
|
|
91
108
|
start_server_in_target_venv(
|
|
92
109
|
cwd=Path.cwd(),
|
|
93
110
|
deployment_file=deployment_file,
|
|
@@ -98,6 +115,13 @@ def serve(
|
|
|
98
115
|
ui_port=ui_port,
|
|
99
116
|
log_level=log_level.upper() if log_level else None,
|
|
100
117
|
log_format=log_format.lower() if log_format else None,
|
|
118
|
+
persistence=persistence if persistence else "local",
|
|
119
|
+
local_persistence_path=str(local_persistence_path)
|
|
120
|
+
if local_persistence_path and persistence == "local"
|
|
121
|
+
else None,
|
|
122
|
+
cloud_persistence_name=f"_public:serve_workflows_{deployment_config.name}"
|
|
123
|
+
if persistence == "cloud"
|
|
124
|
+
else None,
|
|
101
125
|
)
|
|
102
126
|
|
|
103
127
|
except KeyboardInterrupt:
|
|
@@ -144,7 +168,7 @@ def _set_project_id_from_profile(profile: Auth):
|
|
|
144
168
|
|
|
145
169
|
|
|
146
170
|
def _maybe_inject_llama_cloud_credentials(
|
|
147
|
-
deployment_file: Path, interactive: bool
|
|
171
|
+
deployment_file: Path, interactive: bool, require_cloud: bool
|
|
148
172
|
) -> None:
|
|
149
173
|
"""If the deployment config indicates Llama Cloud usage, ensure LLAMA_CLOUD_API_KEY is set.
|
|
150
174
|
|
|
@@ -165,7 +189,7 @@ def _maybe_inject_llama_cloud_credentials(
|
|
|
165
189
|
)
|
|
166
190
|
raise click.Abort()
|
|
167
191
|
|
|
168
|
-
if not config.llama_cloud:
|
|
192
|
+
if not config.llama_cloud and not require_cloud:
|
|
169
193
|
return
|
|
170
194
|
|
|
171
195
|
vars = parse_environment_variables(
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Dict
|
|
4
|
+
|
|
5
|
+
from llama_deploy.cli.config.schema import Auth
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def env_vars_from_profile(profile: Auth) -> Dict[str, str]:
|
|
9
|
+
"""Return env var values derived strictly from the given profile.
|
|
10
|
+
|
|
11
|
+
Produces the three keys expected by CLI commands:
|
|
12
|
+
- LLAMA_CLOUD_API_KEY
|
|
13
|
+
- LLAMA_CLOUD_BASE_URL
|
|
14
|
+
- LLAMA_DEPLOY_PROJECT_ID
|
|
15
|
+
"""
|
|
16
|
+
values: Dict[str, str] = {}
|
|
17
|
+
if profile.api_key:
|
|
18
|
+
values["LLAMA_CLOUD_API_KEY"] = profile.api_key
|
|
19
|
+
if profile.api_url:
|
|
20
|
+
values["LLAMA_CLOUD_BASE_URL"] = profile.api_url
|
|
21
|
+
if profile.project_id:
|
|
22
|
+
values["LLAMA_DEPLOY_PROJECT_ID"] = profile.project_id
|
|
23
|
+
return values
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: llamactl
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.0a24
|
|
4
4
|
Summary: A command-line interface for managing LlamaDeploy projects and deployments
|
|
5
5
|
Author: Adrian Lyjak
|
|
6
6
|
Author-email: Adrian Lyjak <adrianlyjak@gmail.com>
|
|
7
7
|
License: MIT
|
|
8
|
-
Requires-Dist: llama-deploy-core[client]>=0.3.
|
|
9
|
-
Requires-Dist: llama-deploy-appserver>=0.3.
|
|
8
|
+
Requires-Dist: llama-deploy-core[client]>=0.3.0a24,<0.4.0
|
|
9
|
+
Requires-Dist: llama-deploy-appserver>=0.3.0a24,<0.4.0
|
|
10
10
|
Requires-Dist: httpx>=0.24.0,<1.0.0
|
|
11
11
|
Requires-Dist: rich>=13.0.0
|
|
12
12
|
Requires-Dist: questionary>=2.0.0
|
|
@@ -3,11 +3,11 @@ llama_deploy/cli/app.py,sha256=9170e4f506c482522bd745eb1cdb700a198cfcfd7204c168c
|
|
|
3
3
|
llama_deploy/cli/auth/client.py,sha256=0673e2fdc71e8cf1f6d79a64e39596e608dc0257b7dddfebcc38e13e1545a2a8,11670
|
|
4
4
|
llama_deploy/cli/client.py,sha256=f4053b5183224cff55c1393e78887d1af2597219135379a851b742c676adc154,1727
|
|
5
5
|
llama_deploy/cli/commands/aliased_group.py,sha256=bc41007c97b7b93981217dbd4d4591df2b6c9412a2d9ed045b0ec5655ed285f2,1066
|
|
6
|
-
llama_deploy/cli/commands/auth.py,sha256=
|
|
6
|
+
llama_deploy/cli/commands/auth.py,sha256=1381eee494c3a0c73253322b4a54af1a857d5b89e5f1685b8afa3422eecc5607,23937
|
|
7
7
|
llama_deploy/cli/commands/deployment.py,sha256=46339e09135521c46ff90235ccf765c37b1a161cec11d92e92a54ceac6528b01,9883
|
|
8
8
|
llama_deploy/cli/commands/env.py,sha256=36cb1b0abb9e3d1c5546d3e8a3c4c7839c4d6c2abf75763e39efb08376b3eae9,6808
|
|
9
9
|
llama_deploy/cli/commands/init.py,sha256=46f9fcdc43880edbd2f244b4c80d5cc5d387a6f8d7407c182f5995c46e41c851,10153
|
|
10
|
-
llama_deploy/cli/commands/serve.py,sha256=
|
|
10
|
+
llama_deploy/cli/commands/serve.py,sha256=309b416bfc0b527cd8c8e041beb36b64e78342545f767af7fde3bc55dbbce961,8448
|
|
11
11
|
llama_deploy/cli/config/_config.py,sha256=654a4b6d06542e3503edab7023fc1c3148de510b3e3f6194e28cd4bd3e7c029a,14230
|
|
12
12
|
llama_deploy/cli/config/_migrations.py,sha256=37055641970e1ea41abc583f270dc8a9dab03076224a02cd5fb08bbab2b9259f,2333
|
|
13
13
|
llama_deploy/cli/config/auth_service.py,sha256=8a61110e18c752bbec5fbca23cd5d35d4ec232a4371f8c8291ba07ad83d30c6c,5208
|
|
@@ -31,7 +31,8 @@ llama_deploy/cli/textual/github_callback_server.py,sha256=3111cc45b3ff2632255a37
|
|
|
31
31
|
llama_deploy/cli/textual/llama_loader.py,sha256=33cb32a46dd40bcf889c553e44f2672c410e26bd1d4b17aa6cca6d0a5d59c2c4,1468
|
|
32
32
|
llama_deploy/cli/textual/secrets_form.py,sha256=df6699de29d2bc2cbcaddd41ad2495ce0e622cdccaadbc8369a6ee09a9e79d34,7251
|
|
33
33
|
llama_deploy/cli/textual/styles.tcss,sha256=c8fa0eec00a97fa6907d223faaad82c6add1ea3f60009f1630be19282ea77e3b,3271
|
|
34
|
-
|
|
35
|
-
llamactl-0.3.
|
|
36
|
-
llamactl-0.3.
|
|
37
|
-
llamactl-0.3.
|
|
34
|
+
llama_deploy/cli/utils/env_inject.py,sha256=01911758bcc3cf22aad0db0d1ade56aece48d6ad6bdb7186ea213337c67f5a89,688
|
|
35
|
+
llamactl-0.3.0a24.dist-info/WHEEL,sha256=66530aef82d5020ef5af27ae0123c71abb9261377c5bc519376c671346b12918,79
|
|
36
|
+
llamactl-0.3.0a24.dist-info/entry_points.txt,sha256=b67e1eb64305058751a651a80f2d2268b5f7046732268421e796f64d4697f83c,52
|
|
37
|
+
llamactl-0.3.0a24.dist-info/METADATA,sha256=f8c96a953953939365f3c16a56bf2d0f418fd951023ae8f4fba166207e4cde46,3261
|
|
38
|
+
llamactl-0.3.0a24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|