Refactor public API around environments
This commit is contained in:
parent
57dae52cc2
commit
5d5243df23
41 changed files with 1301 additions and 459 deletions
|
|
@ -19,13 +19,13 @@ class Pyro:
|
|||
*,
|
||||
backend_name: str | None = None,
|
||||
base_dir: Path | None = None,
|
||||
artifacts_dir: Path | None = None,
|
||||
cache_dir: Path | None = None,
|
||||
max_active_vms: int = 4,
|
||||
) -> None:
|
||||
self._manager = manager or VmManager(
|
||||
backend_name=backend_name,
|
||||
base_dir=base_dir,
|
||||
artifacts_dir=artifacts_dir,
|
||||
cache_dir=cache_dir,
|
||||
max_active_vms=max_active_vms,
|
||||
)
|
||||
|
||||
|
|
@ -33,20 +33,29 @@ class Pyro:
|
|||
def manager(self) -> VmManager:
|
||||
return self._manager
|
||||
|
||||
def list_profiles(self) -> list[dict[str, object]]:
|
||||
return self._manager.list_profiles()
|
||||
def list_environments(self) -> list[dict[str, object]]:
|
||||
return self._manager.list_environments()
|
||||
|
||||
def pull_environment(self, environment: str) -> dict[str, object]:
|
||||
return self._manager.pull_environment(environment)
|
||||
|
||||
def inspect_environment(self, environment: str) -> dict[str, object]:
|
||||
return self._manager.inspect_environment(environment)
|
||||
|
||||
def prune_environments(self) -> dict[str, object]:
|
||||
return self._manager.prune_environments()
|
||||
|
||||
def create_vm(
|
||||
self,
|
||||
*,
|
||||
profile: str,
|
||||
environment: str,
|
||||
vcpu_count: int,
|
||||
mem_mib: int,
|
||||
ttl_seconds: int = 600,
|
||||
network: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
return self._manager.create_vm(
|
||||
profile=profile,
|
||||
environment=environment,
|
||||
vcpu_count=vcpu_count,
|
||||
mem_mib=mem_mib,
|
||||
ttl_seconds=ttl_seconds,
|
||||
|
|
@ -77,7 +86,7 @@ class Pyro:
|
|||
def run_in_vm(
|
||||
self,
|
||||
*,
|
||||
profile: str,
|
||||
environment: str,
|
||||
command: str,
|
||||
vcpu_count: int,
|
||||
mem_mib: int,
|
||||
|
|
@ -86,7 +95,7 @@ class Pyro:
|
|||
network: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
return self._manager.run_vm(
|
||||
profile=profile,
|
||||
environment=environment,
|
||||
command=command,
|
||||
vcpu_count=vcpu_count,
|
||||
mem_mib=mem_mib,
|
||||
|
|
@ -100,7 +109,7 @@ class Pyro:
|
|||
|
||||
@server.tool()
|
||||
async def vm_run(
|
||||
profile: str,
|
||||
environment: str,
|
||||
command: str,
|
||||
vcpu_count: int,
|
||||
mem_mib: int,
|
||||
|
|
@ -110,7 +119,7 @@ class Pyro:
|
|||
) -> dict[str, Any]:
|
||||
"""Create, start, execute, and clean up an ephemeral VM."""
|
||||
return self.run_in_vm(
|
||||
profile=profile,
|
||||
environment=environment,
|
||||
command=command,
|
||||
vcpu_count=vcpu_count,
|
||||
mem_mib=mem_mib,
|
||||
|
|
@ -120,21 +129,21 @@ class Pyro:
|
|||
)
|
||||
|
||||
@server.tool()
|
||||
async def vm_list_profiles() -> list[dict[str, object]]:
|
||||
"""List standard environment profiles and package highlights."""
|
||||
return self.list_profiles()
|
||||
async def vm_list_environments() -> list[dict[str, object]]:
|
||||
"""List curated Linux environments and installation status."""
|
||||
return self.list_environments()
|
||||
|
||||
@server.tool()
|
||||
async def vm_create(
|
||||
profile: str,
|
||||
environment: str,
|
||||
vcpu_count: int,
|
||||
mem_mib: int,
|
||||
ttl_seconds: int = 600,
|
||||
network: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
"""Create an ephemeral VM record with profile and resource sizing."""
|
||||
"""Create an ephemeral VM record with environment and resource sizing."""
|
||||
return self.create_vm(
|
||||
profile=profile,
|
||||
environment=environment,
|
||||
vcpu_count=vcpu_count,
|
||||
mem_mib=mem_mib,
|
||||
ttl_seconds=ttl_seconds,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue