llamactl 0.3.0a23__tar.gz → 0.3.0a24__tar.gz

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.
Files changed (37) hide show
  1. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/PKG-INFO +3 -3
  2. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/pyproject.toml +3 -3
  3. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/commands/auth.py +53 -0
  4. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/commands/serve.py +27 -3
  5. llamactl-0.3.0a24/src/llama_deploy/cli/utils/env_inject.py +23 -0
  6. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/README.md +0 -0
  7. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/__init__.py +0 -0
  8. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/app.py +0 -0
  9. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/auth/client.py +0 -0
  10. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/client.py +0 -0
  11. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/commands/aliased_group.py +0 -0
  12. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/commands/deployment.py +0 -0
  13. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/commands/env.py +0 -0
  14. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/commands/init.py +0 -0
  15. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/config/_config.py +0 -0
  16. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/config/_migrations.py +0 -0
  17. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/config/auth_service.py +0 -0
  18. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/config/env_service.py +0 -0
  19. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/config/migrations/0001_init.sql +0 -0
  20. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/config/migrations/0002_add_auth_fields.sql +0 -0
  21. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/config/migrations/__init__.py +0 -0
  22. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/config/schema.py +0 -0
  23. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/debug.py +0 -0
  24. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/env.py +0 -0
  25. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/interactive_prompts/session_utils.py +0 -0
  26. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/interactive_prompts/utils.py +0 -0
  27. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/options.py +0 -0
  28. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/py.typed +0 -0
  29. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/styles.py +0 -0
  30. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/textual/deployment_form.py +0 -0
  31. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/textual/deployment_help.py +0 -0
  32. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/textual/deployment_monitor.py +0 -0
  33. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/textual/git_validation.py +0 -0
  34. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/textual/github_callback_server.py +0 -0
  35. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/textual/llama_loader.py +0 -0
  36. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/textual/secrets_form.py +0 -0
  37. {llamactl-0.3.0a23 → llamactl-0.3.0a24}/src/llama_deploy/cli/textual/styles.tcss +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: llamactl
3
- Version: 0.3.0a23
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.0a23,<0.4.0
9
- Requires-Dist: llama-deploy-appserver>=0.3.0a23,<0.4.0
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "llamactl"
3
- version = "0.3.0a23"
3
+ version = "0.3.0a24"
4
4
  description = "A command-line interface for managing LlamaDeploy projects and deployments"
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -9,8 +9,8 @@ authors = [
9
9
  ]
10
10
  requires-python = ">=3.11, <4"
11
11
  dependencies = [
12
- "llama-deploy-core[client]>=0.3.0a23,<0.4.0",
13
- "llama-deploy-appserver>=0.3.0a23,<0.4.0",
12
+ "llama-deploy-core[client]>=0.3.0a24,<0.4.0",
13
+ "llama-deploy-appserver>=0.3.0a24,<0.4.0",
14
14
  "httpx>=0.24.0,<1.0.0",
15
15
  "rich>=13.0.0",
16
16
  "questionary>=2.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(deployment_file, interactive)
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
File without changes