plato-sdk-v2 2.0.50__py3-none-any.whl → 2.2.4__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.
Files changed (158) hide show
  1. plato/__init__.py +7 -6
  2. plato/_generated/__init__.py +1 -1
  3. plato/_generated/api/v1/env/evaluate_session.py +3 -3
  4. plato/_generated/api/v1/env/log_state_mutation.py +4 -4
  5. plato/_generated/api/v1/sandbox/checkpoint_vm.py +3 -3
  6. plato/_generated/api/v1/sandbox/save_vm_snapshot.py +3 -3
  7. plato/_generated/api/v1/sandbox/setup_sandbox.py +8 -8
  8. plato/_generated/api/v1/session/__init__.py +2 -0
  9. plato/_generated/api/v1/session/get_sessions_for_archival.py +100 -0
  10. plato/_generated/api/v1/testcases/__init__.py +6 -2
  11. plato/_generated/api/v1/testcases/get_mutation_groups_for_testcase.py +98 -0
  12. plato/_generated/api/v1/testcases/{get_next_output_testcase_for_scoring.py → get_next_testcase_for_scoring.py} +23 -10
  13. plato/_generated/api/v1/testcases/get_testcase_metadata_for_scoring.py +74 -0
  14. plato/_generated/api/v2/__init__.py +2 -1
  15. plato/_generated/api/v2/jobs/__init__.py +4 -0
  16. plato/_generated/api/v2/jobs/checkpoint.py +3 -3
  17. plato/_generated/api/v2/jobs/disk_snapshot.py +3 -3
  18. plato/_generated/api/v2/jobs/log_for_job.py +4 -39
  19. plato/_generated/api/v2/jobs/make.py +4 -4
  20. plato/_generated/api/v2/jobs/setup_sandbox.py +97 -0
  21. plato/_generated/api/v2/jobs/snapshot.py +3 -3
  22. plato/_generated/api/v2/jobs/snapshot_store.py +91 -0
  23. plato/_generated/api/v2/sessions/__init__.py +4 -0
  24. plato/_generated/api/v2/sessions/checkpoint.py +3 -3
  25. plato/_generated/api/v2/sessions/disk_snapshot.py +3 -3
  26. plato/_generated/api/v2/sessions/evaluate.py +3 -3
  27. plato/_generated/api/v2/sessions/log_job_mutation.py +4 -39
  28. plato/_generated/api/v2/sessions/make.py +4 -4
  29. plato/_generated/api/v2/sessions/setup_sandbox.py +98 -0
  30. plato/_generated/api/v2/sessions/snapshot.py +3 -3
  31. plato/_generated/api/v2/sessions/snapshot_store.py +94 -0
  32. plato/_generated/api/v2/user/__init__.py +7 -0
  33. plato/_generated/api/v2/user/get_current_user.py +76 -0
  34. plato/_generated/models/__init__.py +174 -23
  35. plato/_sims_generator/__init__.py +19 -4
  36. plato/_sims_generator/instruction.py +203 -0
  37. plato/_sims_generator/templates/instruction/helpers.py.jinja +161 -0
  38. plato/_sims_generator/templates/instruction/init.py.jinja +43 -0
  39. plato/agents/__init__.py +107 -517
  40. plato/agents/base.py +145 -0
  41. plato/agents/build.py +61 -0
  42. plato/agents/config.py +160 -0
  43. plato/agents/logging.py +401 -0
  44. plato/agents/runner.py +161 -0
  45. plato/agents/trajectory.py +266 -0
  46. plato/chronos/__init__.py +37 -0
  47. plato/chronos/api/__init__.py +3 -0
  48. plato/chronos/api/agents/__init__.py +13 -0
  49. plato/chronos/api/agents/create_agent.py +63 -0
  50. plato/chronos/api/agents/delete_agent.py +61 -0
  51. plato/chronos/api/agents/get_agent.py +62 -0
  52. plato/chronos/api/agents/get_agent_schema.py +72 -0
  53. plato/chronos/api/agents/get_agent_versions.py +62 -0
  54. plato/chronos/api/agents/list_agents.py +57 -0
  55. plato/chronos/api/agents/lookup_agent.py +74 -0
  56. plato/chronos/api/auth/__init__.py +9 -0
  57. plato/chronos/api/auth/debug_auth_api_auth_debug_get.py +43 -0
  58. plato/chronos/api/auth/get_auth_status_api_auth_status_get.py +61 -0
  59. plato/chronos/api/auth/get_current_user_route_api_auth_me_get.py +60 -0
  60. plato/chronos/api/callback/__init__.py +11 -0
  61. plato/chronos/api/callback/push_agent_logs.py +61 -0
  62. plato/chronos/api/callback/update_agent_status.py +57 -0
  63. plato/chronos/api/callback/upload_artifacts.py +59 -0
  64. plato/chronos/api/callback/upload_logs_zip.py +57 -0
  65. plato/chronos/api/callback/upload_trajectory.py +57 -0
  66. plato/chronos/api/default/__init__.py +7 -0
  67. plato/chronos/api/default/health.py +43 -0
  68. plato/chronos/api/jobs/__init__.py +7 -0
  69. plato/chronos/api/jobs/launch_job.py +63 -0
  70. plato/chronos/api/registry/__init__.py +19 -0
  71. plato/chronos/api/registry/get_agent_schema_api_registry_agents__agent_name__schema_get.py +62 -0
  72. plato/chronos/api/registry/get_agent_versions_api_registry_agents__agent_name__versions_get.py +52 -0
  73. plato/chronos/api/registry/get_world_schema_api_registry_worlds__package_name__schema_get.py +68 -0
  74. plato/chronos/api/registry/get_world_versions_api_registry_worlds__package_name__versions_get.py +52 -0
  75. plato/chronos/api/registry/list_registry_agents_api_registry_agents_get.py +44 -0
  76. plato/chronos/api/registry/list_registry_worlds_api_registry_worlds_get.py +44 -0
  77. plato/chronos/api/runtimes/__init__.py +11 -0
  78. plato/chronos/api/runtimes/create_runtime.py +63 -0
  79. plato/chronos/api/runtimes/delete_runtime.py +61 -0
  80. plato/chronos/api/runtimes/get_runtime.py +62 -0
  81. plato/chronos/api/runtimes/list_runtimes.py +57 -0
  82. plato/chronos/api/runtimes/test_runtime.py +67 -0
  83. plato/chronos/api/secrets/__init__.py +11 -0
  84. plato/chronos/api/secrets/create_secret.py +63 -0
  85. plato/chronos/api/secrets/delete_secret.py +61 -0
  86. plato/chronos/api/secrets/get_secret.py +62 -0
  87. plato/chronos/api/secrets/list_secrets.py +57 -0
  88. plato/chronos/api/secrets/update_secret.py +68 -0
  89. plato/chronos/api/sessions/__init__.py +10 -0
  90. plato/chronos/api/sessions/get_session.py +62 -0
  91. plato/chronos/api/sessions/get_session_logs.py +72 -0
  92. plato/chronos/api/sessions/get_session_logs_download.py +62 -0
  93. plato/chronos/api/sessions/list_sessions.py +57 -0
  94. plato/chronos/api/status/__init__.py +8 -0
  95. plato/chronos/api/status/get_status_api_status_get.py +44 -0
  96. plato/chronos/api/status/get_version_info_api_version_get.py +44 -0
  97. plato/chronos/api/templates/__init__.py +11 -0
  98. plato/chronos/api/templates/create_template.py +63 -0
  99. plato/chronos/api/templates/delete_template.py +61 -0
  100. plato/chronos/api/templates/get_template.py +62 -0
  101. plato/chronos/api/templates/list_templates.py +57 -0
  102. plato/chronos/api/templates/update_template.py +68 -0
  103. plato/chronos/api/trajectories/__init__.py +8 -0
  104. plato/chronos/api/trajectories/get_trajectory.py +62 -0
  105. plato/chronos/api/trajectories/list_trajectories.py +62 -0
  106. plato/chronos/api/worlds/__init__.py +10 -0
  107. plato/chronos/api/worlds/create_world.py +63 -0
  108. plato/chronos/api/worlds/delete_world.py +61 -0
  109. plato/chronos/api/worlds/get_world.py +62 -0
  110. plato/chronos/api/worlds/list_worlds.py +57 -0
  111. plato/chronos/client.py +171 -0
  112. plato/chronos/errors.py +141 -0
  113. plato/chronos/models/__init__.py +647 -0
  114. plato/chronos/py.typed +0 -0
  115. plato/sims/cli.py +299 -123
  116. plato/sims/registry.py +77 -4
  117. plato/v1/cli/agent.py +88 -84
  118. plato/v1/cli/main.py +2 -0
  119. plato/v1/cli/pm.py +441 -119
  120. plato/v1/cli/sandbox.py +747 -191
  121. plato/v1/cli/sim.py +11 -0
  122. plato/v1/cli/verify.py +1269 -0
  123. plato/v1/cli/world.py +3 -0
  124. plato/v1/flow_executor.py +21 -17
  125. plato/v1/models/env.py +11 -11
  126. plato/v1/sdk.py +2 -2
  127. plato/v1/sync_env.py +11 -11
  128. plato/v1/sync_flow_executor.py +21 -17
  129. plato/v1/sync_sdk.py +4 -2
  130. plato/v2/__init__.py +2 -0
  131. plato/v2/async_/environment.py +20 -1
  132. plato/v2/async_/session.py +54 -3
  133. plato/v2/sync/environment.py +2 -1
  134. plato/v2/sync/session.py +52 -2
  135. plato/worlds/README.md +218 -0
  136. plato/worlds/__init__.py +54 -18
  137. plato/worlds/base.py +304 -93
  138. plato/worlds/config.py +239 -73
  139. plato/worlds/runner.py +391 -80
  140. {plato_sdk_v2-2.0.50.dist-info → plato_sdk_v2-2.2.4.dist-info}/METADATA +1 -3
  141. {plato_sdk_v2-2.0.50.dist-info → plato_sdk_v2-2.2.4.dist-info}/RECORD +143 -68
  142. {plato_sdk_v2-2.0.50.dist-info → plato_sdk_v2-2.2.4.dist-info}/entry_points.txt +1 -0
  143. plato/_generated/api/v2/interfaces/__init__.py +0 -27
  144. plato/_generated/api/v2/interfaces/v2_interface_browser_create.py +0 -68
  145. plato/_generated/api/v2/interfaces/v2_interface_cdp_url.py +0 -65
  146. plato/_generated/api/v2/interfaces/v2_interface_click.py +0 -64
  147. plato/_generated/api/v2/interfaces/v2_interface_close.py +0 -59
  148. plato/_generated/api/v2/interfaces/v2_interface_computer_create.py +0 -68
  149. plato/_generated/api/v2/interfaces/v2_interface_cursor.py +0 -64
  150. plato/_generated/api/v2/interfaces/v2_interface_key.py +0 -68
  151. plato/_generated/api/v2/interfaces/v2_interface_screenshot.py +0 -65
  152. plato/_generated/api/v2/interfaces/v2_interface_scroll.py +0 -70
  153. plato/_generated/api/v2/interfaces/v2_interface_type.py +0 -64
  154. plato/world/__init__.py +0 -44
  155. plato/world/base.py +0 -267
  156. plato/world/config.py +0 -139
  157. plato/world/types.py +0 -47
  158. {plato_sdk_v2-2.0.50.dist-info → plato_sdk_v2-2.2.4.dist-info}/WHEEL +0 -0
@@ -0,0 +1,57 @@
1
+ """List Agents"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import AgentListResponse
11
+
12
+
13
+ def _build_request_args(
14
+ x_api_key: str | None = None,
15
+ ) -> dict[str, Any]:
16
+ """Build request arguments."""
17
+ url = "/api/agents"
18
+
19
+ headers: dict[str, str] = {}
20
+ if x_api_key is not None:
21
+ headers["X-API-Key"] = x_api_key
22
+
23
+ return {
24
+ "method": "GET",
25
+ "url": url,
26
+ "headers": headers,
27
+ }
28
+
29
+
30
+ def sync(
31
+ client: httpx.Client,
32
+ x_api_key: str | None = None,
33
+ ) -> AgentListResponse:
34
+ """List all agents for the org."""
35
+
36
+ request_args = _build_request_args(
37
+ x_api_key=x_api_key,
38
+ )
39
+
40
+ response = client.request(**request_args)
41
+ raise_for_status(response)
42
+ return AgentListResponse.model_validate(response.json())
43
+
44
+
45
+ async def asyncio(
46
+ client: httpx.AsyncClient,
47
+ x_api_key: str | None = None,
48
+ ) -> AgentListResponse:
49
+ """List all agents for the org."""
50
+
51
+ request_args = _build_request_args(
52
+ x_api_key=x_api_key,
53
+ )
54
+
55
+ response = await client.request(**request_args)
56
+ raise_for_status(response)
57
+ return AgentListResponse.model_validate(response.json())
@@ -0,0 +1,74 @@
1
+ """Lookup Agent"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import AgentLookupResponse
11
+
12
+
13
+ def _build_request_args(
14
+ name: str,
15
+ version: str | None = None,
16
+ x_api_key: str | None = None,
17
+ ) -> dict[str, Any]:
18
+ """Build request arguments."""
19
+ url = "/api/agents/lookup"
20
+
21
+ params: dict[str, Any] = {}
22
+ if name is not None:
23
+ params["name"] = name
24
+ if version is not None:
25
+ params["version"] = version
26
+
27
+ headers: dict[str, str] = {}
28
+ if x_api_key is not None:
29
+ headers["X-API-Key"] = x_api_key
30
+
31
+ return {
32
+ "method": "GET",
33
+ "url": url,
34
+ "params": params,
35
+ "headers": headers,
36
+ }
37
+
38
+
39
+ def sync(
40
+ client: httpx.Client,
41
+ name: str,
42
+ version: str | None = None,
43
+ x_api_key: str | None = None,
44
+ ) -> AgentLookupResponse:
45
+ """Lookup an agent by name and optional version. Returns the artifact info."""
46
+
47
+ request_args = _build_request_args(
48
+ name=name,
49
+ version=version,
50
+ x_api_key=x_api_key,
51
+ )
52
+
53
+ response = client.request(**request_args)
54
+ raise_for_status(response)
55
+ return AgentLookupResponse.model_validate(response.json())
56
+
57
+
58
+ async def asyncio(
59
+ client: httpx.AsyncClient,
60
+ name: str,
61
+ version: str | None = None,
62
+ x_api_key: str | None = None,
63
+ ) -> AgentLookupResponse:
64
+ """Lookup an agent by name and optional version. Returns the artifact info."""
65
+
66
+ request_args = _build_request_args(
67
+ name=name,
68
+ version=version,
69
+ x_api_key=x_api_key,
70
+ )
71
+
72
+ response = await client.request(**request_args)
73
+ raise_for_status(response)
74
+ return AgentLookupResponse.model_validate(response.json())
@@ -0,0 +1,9 @@
1
+ """API endpoints."""
2
+
3
+ from . import debug_auth_api_auth_debug_get, get_auth_status_api_auth_status_get, get_current_user_route_api_auth_me_get
4
+
5
+ __all__ = [
6
+ "get_auth_status_api_auth_status_get",
7
+ "get_current_user_route_api_auth_me_get",
8
+ "debug_auth_api_auth_debug_get",
9
+ ]
@@ -0,0 +1,43 @@
1
+ """Debug Auth"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+
11
+
12
+ def _build_request_args() -> dict[str, Any]:
13
+ """Build request arguments."""
14
+ url = "/api/auth/debug"
15
+
16
+ return {
17
+ "method": "GET",
18
+ "url": url,
19
+ }
20
+
21
+
22
+ def sync(
23
+ client: httpx.Client,
24
+ ) -> dict[str, Any]:
25
+ """Debug endpoint to see what auth info is being received."""
26
+
27
+ request_args = _build_request_args()
28
+
29
+ response = client.request(**request_args)
30
+ raise_for_status(response)
31
+ return response.json()
32
+
33
+
34
+ async def asyncio(
35
+ client: httpx.AsyncClient,
36
+ ) -> dict[str, Any]:
37
+ """Debug endpoint to see what auth info is being received."""
38
+
39
+ request_args = _build_request_args()
40
+
41
+ response = await client.request(**request_args)
42
+ raise_for_status(response)
43
+ return response.json()
@@ -0,0 +1,61 @@
1
+ """Get Auth Status"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import AuthStatusResponse
11
+
12
+
13
+ def _build_request_args(
14
+ x_api_key: str | None = None,
15
+ ) -> dict[str, Any]:
16
+ """Build request arguments."""
17
+ url = "/api/auth/status"
18
+
19
+ headers: dict[str, str] = {}
20
+ if x_api_key is not None:
21
+ headers["X-API-Key"] = x_api_key
22
+
23
+ return {
24
+ "method": "GET",
25
+ "url": url,
26
+ "headers": headers,
27
+ }
28
+
29
+
30
+ def sync(
31
+ client: httpx.Client,
32
+ x_api_key: str | None = None,
33
+ ) -> AuthStatusResponse:
34
+ """Check authentication status.
35
+
36
+ Pass API key via X-API-Key header to authenticate."""
37
+
38
+ request_args = _build_request_args(
39
+ x_api_key=x_api_key,
40
+ )
41
+
42
+ response = client.request(**request_args)
43
+ raise_for_status(response)
44
+ return AuthStatusResponse.model_validate(response.json())
45
+
46
+
47
+ async def asyncio(
48
+ client: httpx.AsyncClient,
49
+ x_api_key: str | None = None,
50
+ ) -> AuthStatusResponse:
51
+ """Check authentication status.
52
+
53
+ Pass API key via X-API-Key header to authenticate."""
54
+
55
+ request_args = _build_request_args(
56
+ x_api_key=x_api_key,
57
+ )
58
+
59
+ response = await client.request(**request_args)
60
+ raise_for_status(response)
61
+ return AuthStatusResponse.model_validate(response.json())
@@ -0,0 +1,60 @@
1
+ """Get Current User Route"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+
11
+
12
+ def _build_request_args(
13
+ x_api_key: str | None = None,
14
+ ) -> dict[str, Any]:
15
+ """Build request arguments."""
16
+ url = "/api/auth/me"
17
+
18
+ headers: dict[str, str] = {}
19
+ if x_api_key is not None:
20
+ headers["X-API-Key"] = x_api_key
21
+
22
+ return {
23
+ "method": "GET",
24
+ "url": url,
25
+ "headers": headers,
26
+ }
27
+
28
+
29
+ def sync(
30
+ client: httpx.Client,
31
+ x_api_key: str | None = None,
32
+ ) -> dict[str, Any]:
33
+ """Get current authenticated user.
34
+
35
+ Requires X-API-Key header."""
36
+
37
+ request_args = _build_request_args(
38
+ x_api_key=x_api_key,
39
+ )
40
+
41
+ response = client.request(**request_args)
42
+ raise_for_status(response)
43
+ return response.json()
44
+
45
+
46
+ async def asyncio(
47
+ client: httpx.AsyncClient,
48
+ x_api_key: str | None = None,
49
+ ) -> dict[str, Any]:
50
+ """Get current authenticated user.
51
+
52
+ Requires X-API-Key header."""
53
+
54
+ request_args = _build_request_args(
55
+ x_api_key=x_api_key,
56
+ )
57
+
58
+ response = await client.request(**request_args)
59
+ raise_for_status(response)
60
+ return response.json()
@@ -0,0 +1,11 @@
1
+ """API endpoints."""
2
+
3
+ from . import push_agent_logs, update_agent_status, upload_artifacts, upload_logs_zip, upload_trajectory
4
+
5
+ __all__ = [
6
+ "push_agent_logs",
7
+ "update_agent_status",
8
+ "upload_trajectory",
9
+ "upload_logs_zip",
10
+ "upload_artifacts",
11
+ ]
@@ -0,0 +1,61 @@
1
+ """Push Agent Logs"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import AgentLogsRequest, AgentLogsResponse
11
+
12
+
13
+ def _build_request_args(
14
+ body: AgentLogsRequest,
15
+ ) -> dict[str, Any]:
16
+ """Build request arguments."""
17
+ url = "/api/callback/logs"
18
+
19
+ return {
20
+ "method": "POST",
21
+ "url": url,
22
+ "json": body.model_dump(mode="json", exclude_none=True),
23
+ }
24
+
25
+
26
+ def sync(
27
+ client: httpx.Client,
28
+ body: AgentLogsRequest,
29
+ ) -> AgentLogsResponse:
30
+ """Receive logs from an agent running in a VM.
31
+
32
+ This endpoint acknowledges log receipt for real-time streaming.
33
+ Logs are NOT stored in the database - they're uploaded to S3 as a zip
34
+ at the end of the session via the /artifacts endpoint."""
35
+
36
+ request_args = _build_request_args(
37
+ body=body,
38
+ )
39
+
40
+ response = client.request(**request_args)
41
+ raise_for_status(response)
42
+ return AgentLogsResponse.model_validate(response.json())
43
+
44
+
45
+ async def asyncio(
46
+ client: httpx.AsyncClient,
47
+ body: AgentLogsRequest,
48
+ ) -> AgentLogsResponse:
49
+ """Receive logs from an agent running in a VM.
50
+
51
+ This endpoint acknowledges log receipt for real-time streaming.
52
+ Logs are NOT stored in the database - they're uploaded to S3 as a zip
53
+ at the end of the session via the /artifacts endpoint."""
54
+
55
+ request_args = _build_request_args(
56
+ body=body,
57
+ )
58
+
59
+ response = await client.request(**request_args)
60
+ raise_for_status(response)
61
+ return AgentLogsResponse.model_validate(response.json())
@@ -0,0 +1,57 @@
1
+ """Update Agent Status"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import AgentLogsResponse, AgentStatusRequest
11
+
12
+
13
+ def _build_request_args(
14
+ body: AgentStatusRequest,
15
+ ) -> dict[str, Any]:
16
+ """Build request arguments."""
17
+ url = "/api/callback/status"
18
+
19
+ return {
20
+ "method": "POST",
21
+ "url": url,
22
+ "json": body.model_dump(mode="json", exclude_none=True),
23
+ }
24
+
25
+
26
+ def sync(
27
+ client: httpx.Client,
28
+ body: AgentStatusRequest,
29
+ ) -> AgentLogsResponse:
30
+ """Update the status of a running session.
31
+
32
+ Called by agents to report completion or failure."""
33
+
34
+ request_args = _build_request_args(
35
+ body=body,
36
+ )
37
+
38
+ response = client.request(**request_args)
39
+ raise_for_status(response)
40
+ return AgentLogsResponse.model_validate(response.json())
41
+
42
+
43
+ async def asyncio(
44
+ client: httpx.AsyncClient,
45
+ body: AgentStatusRequest,
46
+ ) -> AgentLogsResponse:
47
+ """Update the status of a running session.
48
+
49
+ Called by agents to report completion or failure."""
50
+
51
+ request_args = _build_request_args(
52
+ body=body,
53
+ )
54
+
55
+ response = await client.request(**request_args)
56
+ raise_for_status(response)
57
+ return AgentLogsResponse.model_validate(response.json())
@@ -0,0 +1,59 @@
1
+ """Upload Artifacts Endpoint"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import ArtifactsUploadRequest, ArtifactsUploadResponse
11
+
12
+
13
+ def _build_request_args(
14
+ body: ArtifactsUploadRequest,
15
+ ) -> dict[str, Any]:
16
+ """Build request arguments."""
17
+ url = "/api/callback/artifacts"
18
+
19
+ return {
20
+ "method": "POST",
21
+ "url": url,
22
+ "json": body.model_dump(mode="json", exclude_none=True),
23
+ }
24
+
25
+
26
+ def sync(
27
+ client: httpx.Client,
28
+ body: ArtifactsUploadRequest,
29
+ ) -> ArtifactsUploadResponse:
30
+ """Upload trajectory and/or logs for a session.
31
+
32
+ Convenience endpoint to upload both artifacts in one request.
33
+ Trajectory is stored in DB, logs are uploaded to S3."""
34
+
35
+ request_args = _build_request_args(
36
+ body=body,
37
+ )
38
+
39
+ response = client.request(**request_args)
40
+ raise_for_status(response)
41
+ return ArtifactsUploadResponse.model_validate(response.json())
42
+
43
+
44
+ async def asyncio(
45
+ client: httpx.AsyncClient,
46
+ body: ArtifactsUploadRequest,
47
+ ) -> ArtifactsUploadResponse:
48
+ """Upload trajectory and/or logs for a session.
49
+
50
+ Convenience endpoint to upload both artifacts in one request.
51
+ Trajectory is stored in DB, logs are uploaded to S3."""
52
+
53
+ request_args = _build_request_args(
54
+ body=body,
55
+ )
56
+
57
+ response = await client.request(**request_args)
58
+ raise_for_status(response)
59
+ return ArtifactsUploadResponse.model_validate(response.json())
@@ -0,0 +1,57 @@
1
+ """Upload Logs Zip Endpoint"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import LogsUploadRequest, LogsUploadResponse
11
+
12
+
13
+ def _build_request_args(
14
+ body: LogsUploadRequest,
15
+ ) -> dict[str, Any]:
16
+ """Build request arguments."""
17
+ url = "/api/callback/logs-zip"
18
+
19
+ return {
20
+ "method": "POST",
21
+ "url": url,
22
+ "json": body.model_dump(mode="json", exclude_none=True),
23
+ }
24
+
25
+
26
+ def sync(
27
+ client: httpx.Client,
28
+ body: LogsUploadRequest,
29
+ ) -> LogsUploadResponse:
30
+ """Upload zipped logs for a session.
31
+
32
+ Accepts base64-encoded zip file and uploads to S3."""
33
+
34
+ request_args = _build_request_args(
35
+ body=body,
36
+ )
37
+
38
+ response = client.request(**request_args)
39
+ raise_for_status(response)
40
+ return LogsUploadResponse.model_validate(response.json())
41
+
42
+
43
+ async def asyncio(
44
+ client: httpx.AsyncClient,
45
+ body: LogsUploadRequest,
46
+ ) -> LogsUploadResponse:
47
+ """Upload zipped logs for a session.
48
+
49
+ Accepts base64-encoded zip file and uploads to S3."""
50
+
51
+ request_args = _build_request_args(
52
+ body=body,
53
+ )
54
+
55
+ response = await client.request(**request_args)
56
+ raise_for_status(response)
57
+ return LogsUploadResponse.model_validate(response.json())
@@ -0,0 +1,57 @@
1
+ """Upload Trajectory Endpoint"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+ from plato.chronos.models import TrajectoryUploadRequest, TrajectoryUploadResponse
11
+
12
+
13
+ def _build_request_args(
14
+ body: TrajectoryUploadRequest,
15
+ ) -> dict[str, Any]:
16
+ """Build request arguments."""
17
+ url = "/api/callback/trajectory"
18
+
19
+ return {
20
+ "method": "POST",
21
+ "url": url,
22
+ "json": body.model_dump(mode="json", exclude_none=True),
23
+ }
24
+
25
+
26
+ def sync(
27
+ client: httpx.Client,
28
+ body: TrajectoryUploadRequest,
29
+ ) -> TrajectoryUploadResponse:
30
+ """Upload AITF trajectory for a session.
31
+
32
+ Accepts an AITF-formatted trajectory and stores it in the database."""
33
+
34
+ request_args = _build_request_args(
35
+ body=body,
36
+ )
37
+
38
+ response = client.request(**request_args)
39
+ raise_for_status(response)
40
+ return TrajectoryUploadResponse.model_validate(response.json())
41
+
42
+
43
+ async def asyncio(
44
+ client: httpx.AsyncClient,
45
+ body: TrajectoryUploadRequest,
46
+ ) -> TrajectoryUploadResponse:
47
+ """Upload AITF trajectory for a session.
48
+
49
+ Accepts an AITF-formatted trajectory and stores it in the database."""
50
+
51
+ request_args = _build_request_args(
52
+ body=body,
53
+ )
54
+
55
+ response = await client.request(**request_args)
56
+ raise_for_status(response)
57
+ return TrajectoryUploadResponse.model_validate(response.json())
@@ -0,0 +1,7 @@
1
+ """API endpoints."""
2
+
3
+ from . import health
4
+
5
+ __all__ = [
6
+ "health",
7
+ ]
@@ -0,0 +1,43 @@
1
+ """Health"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import httpx
8
+
9
+ from plato.chronos.errors import raise_for_status
10
+
11
+
12
+ def _build_request_args() -> dict[str, Any]:
13
+ """Build request arguments."""
14
+ url = "/health"
15
+
16
+ return {
17
+ "method": "GET",
18
+ "url": url,
19
+ }
20
+
21
+
22
+ def sync(
23
+ client: httpx.Client,
24
+ ) -> Any:
25
+ """Health check endpoint."""
26
+
27
+ request_args = _build_request_args()
28
+
29
+ response = client.request(**request_args)
30
+ raise_for_status(response)
31
+ return response.json()
32
+
33
+
34
+ async def asyncio(
35
+ client: httpx.AsyncClient,
36
+ ) -> Any:
37
+ """Health check endpoint."""
38
+
39
+ request_args = _build_request_args()
40
+
41
+ response = await client.request(**request_args)
42
+ raise_for_status(response)
43
+ return response.json()
@@ -0,0 +1,7 @@
1
+ """API endpoints."""
2
+
3
+ from . import launch_job
4
+
5
+ __all__ = [
6
+ "launch_job",
7
+ ]