Fix missing app initialization in skyvern init (#4038)
This commit is contained in:
committed by
GitHub
parent
895d553d0e
commit
d5a7485d45
@@ -8,6 +8,7 @@ from rich.panel import Panel
|
|||||||
from rich.progress import Progress, SpinnerColumn, TextColumn
|
from rich.progress import Progress, SpinnerColumn, TextColumn
|
||||||
from rich.prompt import Confirm, Prompt
|
from rich.prompt import Confirm, Prompt
|
||||||
|
|
||||||
|
from skyvern.forge.forge_app_initializer import start_forge_app
|
||||||
from skyvern.utils import migrate_db
|
from skyvern.utils import migrate_db
|
||||||
from skyvern.utils.env_paths import resolve_backend_env_path
|
from skyvern.utils.env_paths import resolve_backend_env_path
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ def init(
|
|||||||
console.print("✅ [green]Database migration complete.[/green]")
|
console.print("✅ [green]Database migration complete.[/green]")
|
||||||
|
|
||||||
console.print("🔑 [bold blue]Generating local organization API key...[/bold blue]")
|
console.print("🔑 [bold blue]Generating local organization API key...[/bold blue]")
|
||||||
|
start_forge_app()
|
||||||
api_key = asyncio.run(setup_local_organization())
|
api_key = asyncio.run(setup_local_organization())
|
||||||
if api_key:
|
if api_key:
|
||||||
console.print("✅ [green]Local organization API key generated.[/green]")
|
console.print("✅ [green]Local organization API key generated.[/green]")
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ def _get_client(api_key: str | None = None) -> Skyvern:
|
|||||||
|
|
||||||
def _list_workflow_tasks(client: Skyvern, run_id: str) -> list[dict]:
|
def _list_workflow_tasks(client: Skyvern, run_id: str) -> list[dict]:
|
||||||
"""Return tasks for the given workflow run."""
|
"""Return tasks for the given workflow run."""
|
||||||
resp = client.agent._client_wrapper.httpx_client.request(
|
resp = client._client_wrapper.httpx_client.request(
|
||||||
"api/v1/tasks",
|
"api/v1/tasks",
|
||||||
method="GET",
|
method="GET",
|
||||||
params={"workflow_run_id": run_id, "page_size": 100, "page": 1},
|
params={"workflow_run_id": run_id, "page_size": 100, "page": 1},
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ def run_workflow(
|
|||||||
raise typer.Exit(code=1)
|
raise typer.Exit(code=1)
|
||||||
|
|
||||||
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
|
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
|
||||||
run_resp = client.agent.run_workflow(
|
run_resp = client.run_workflow(
|
||||||
workflow_id=workflow_id,
|
workflow_id=workflow_id,
|
||||||
parameters=params_dict,
|
parameters=params_dict,
|
||||||
title=title,
|
title=title,
|
||||||
@@ -77,7 +77,7 @@ def cancel_workflow(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Cancel a running workflow."""
|
"""Cancel a running workflow."""
|
||||||
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
|
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
|
||||||
client.agent.cancel_run(run_id=run_id)
|
client.cancel_run(run_id=run_id)
|
||||||
console.print(Panel(f"Cancel signal sent for run {run_id}", border_style="red"))
|
console.print(Panel(f"Cancel signal sent for run {run_id}", border_style="red"))
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ def workflow_status(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Retrieve status information for a workflow run."""
|
"""Retrieve status information for a workflow run."""
|
||||||
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
|
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
|
||||||
run = client.agent.get_run(run_id=run_id)
|
run = client.get_run(run_id=run_id)
|
||||||
console.print(Panel(run.model_dump_json(indent=2), border_style="cyan"))
|
console.print(Panel(run.model_dump_json(indent=2), border_style="cyan"))
|
||||||
if tasks:
|
if tasks:
|
||||||
task_list = _list_workflow_tasks(client, run_id)
|
task_list = _list_workflow_tasks(client, run_id)
|
||||||
@@ -105,7 +105,7 @@ def list_workflows(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""List workflows for the organization."""
|
"""List workflows for the organization."""
|
||||||
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
|
client = _get_client(ctx.obj.get("api_key") if ctx.obj else None)
|
||||||
resp = client.agent._client_wrapper.httpx_client.request(
|
resp = client._client_wrapper.httpx_client.request(
|
||||||
"api/v1/workflows",
|
"api/v1/workflows",
|
||||||
method="GET",
|
method="GET",
|
||||||
params={"page": page, "page_size": page_size, "template": template},
|
params={"page": page, "page_size": page_size, "template": template},
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ class AppHolder:
|
|||||||
def __getattr__(self, name: str) -> Any:
|
def __getattr__(self, name: str) -> Any:
|
||||||
inst = object.__getattribute__(self, "_inst")
|
inst = object.__getattribute__(self, "_inst")
|
||||||
if inst is None:
|
if inst is None:
|
||||||
raise RuntimeError("ForgeApp is not initialized, start_forge_app should be called")
|
raise RuntimeError("ForgeApp is not initialized. Call start_forge_app() before accessing app properties.")
|
||||||
|
|
||||||
return getattr(inst, name)
|
return getattr(inst, name)
|
||||||
|
|
||||||
def __setattr__(self, name: str, value: Any) -> None:
|
def __setattr__(self, name: str, value: Any) -> None:
|
||||||
inst = object.__getattribute__(self, "_inst")
|
inst = object.__getattribute__(self, "_inst")
|
||||||
if inst is None:
|
if inst is None:
|
||||||
raise RuntimeError("ForgeApp is not initialized, start_forge_app should be called")
|
raise RuntimeError("ForgeApp is not initialized. Call start_forge_app() before accessing app properties.")
|
||||||
|
|
||||||
setattr(inst, name, value)
|
setattr(inst, name, value)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user