blaxel 0.1.11rc44__py3-none-any.whl → 0.1.12rc46__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.
- blaxel/client/models/preview_spec.py +9 -0
- blaxel/client/models/preview_token_spec.py +0 -9
- blaxel/sandbox/base.py +4 -2
- blaxel/sandbox/client/api/filesystem/get_watch_filesystem_path.py +165 -0
- blaxel/sandbox/client/api/filesystem/get_ws_watch_filesystem_path.py +161 -0
- blaxel/sandbox/client/api/process/get_process_identifier_logs.py +1 -22
- blaxel/sandbox/client/api/process/get_process_identifier_logs_stream.py +26 -51
- blaxel/sandbox/client/api/process/get_ws_process_identifier_logs_stream.py +165 -0
- blaxel/sandbox/client/models/__init__.py +0 -4
- blaxel/sandbox/client/models/process_request.py +0 -9
- blaxel/sandbox/preview.py +146 -0
- blaxel/sandbox/sandbox.py +2 -0
- {blaxel-0.1.11rc44.dist-info → blaxel-0.1.12rc46.dist-info}/METADATA +3 -2
- {blaxel-0.1.11rc44.dist-info → blaxel-0.1.12rc46.dist-info}/RECORD +16 -13
- blaxel/sandbox/client/models/get_process_identifier_logs_stream_response_200.py +0 -45
- {blaxel-0.1.11rc44.dist-info → blaxel-0.1.12rc46.dist-info}/WHEEL +0 -0
- {blaxel-0.1.11rc44.dist-info → blaxel-0.1.12rc46.dist-info}/licenses/LICENSE +0 -0
@@ -14,11 +14,13 @@ class PreviewSpec:
|
|
14
14
|
|
15
15
|
Attributes:
|
16
16
|
port (Union[Unset, int]): Port of the preview
|
17
|
+
prefix_url (Union[Unset, str]): Prefix URL
|
17
18
|
public (Union[Unset, bool]): Whether the preview is public
|
18
19
|
url (Union[Unset, str]): URL of the preview
|
19
20
|
"""
|
20
21
|
|
21
22
|
port: Union[Unset, int] = UNSET
|
23
|
+
prefix_url: Union[Unset, str] = UNSET
|
22
24
|
public: Union[Unset, bool] = UNSET
|
23
25
|
url: Union[Unset, str] = UNSET
|
24
26
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
@@ -26,6 +28,8 @@ class PreviewSpec:
|
|
26
28
|
def to_dict(self) -> dict[str, Any]:
|
27
29
|
port = self.port
|
28
30
|
|
31
|
+
prefix_url = self.prefix_url
|
32
|
+
|
29
33
|
public = self.public
|
30
34
|
|
31
35
|
url = self.url
|
@@ -35,6 +39,8 @@ class PreviewSpec:
|
|
35
39
|
field_dict.update({})
|
36
40
|
if port is not UNSET:
|
37
41
|
field_dict["port"] = port
|
42
|
+
if prefix_url is not UNSET:
|
43
|
+
field_dict["prefixUrl"] = prefix_url
|
38
44
|
if public is not UNSET:
|
39
45
|
field_dict["public"] = public
|
40
46
|
if url is not UNSET:
|
@@ -49,12 +55,15 @@ class PreviewSpec:
|
|
49
55
|
d = src_dict.copy()
|
50
56
|
port = d.pop("port", UNSET)
|
51
57
|
|
58
|
+
prefix_url = d.pop("prefixUrl", UNSET)
|
59
|
+
|
52
60
|
public = d.pop("public", UNSET)
|
53
61
|
|
54
62
|
url = d.pop("url", UNSET)
|
55
63
|
|
56
64
|
preview_spec = cls(
|
57
65
|
port=port,
|
66
|
+
prefix_url=prefix_url,
|
58
67
|
public=public,
|
59
68
|
url=url,
|
60
69
|
)
|
@@ -15,13 +15,11 @@ class PreviewTokenSpec:
|
|
15
15
|
Attributes:
|
16
16
|
expired (Union[Unset, bool]): Whether the token is expired
|
17
17
|
expires_at (Union[Unset, str]): Expiration time of the token
|
18
|
-
public (Union[Unset, bool]): Whether the token is public
|
19
18
|
token (Union[Unset, str]): Token
|
20
19
|
"""
|
21
20
|
|
22
21
|
expired: Union[Unset, bool] = UNSET
|
23
22
|
expires_at: Union[Unset, str] = UNSET
|
24
|
-
public: Union[Unset, bool] = UNSET
|
25
23
|
token: Union[Unset, str] = UNSET
|
26
24
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
27
25
|
|
@@ -30,8 +28,6 @@ class PreviewTokenSpec:
|
|
30
28
|
|
31
29
|
expires_at = self.expires_at
|
32
30
|
|
33
|
-
public = self.public
|
34
|
-
|
35
31
|
token = self.token
|
36
32
|
|
37
33
|
field_dict: dict[str, Any] = {}
|
@@ -41,8 +37,6 @@ class PreviewTokenSpec:
|
|
41
37
|
field_dict["expired"] = expired
|
42
38
|
if expires_at is not UNSET:
|
43
39
|
field_dict["expiresAt"] = expires_at
|
44
|
-
if public is not UNSET:
|
45
|
-
field_dict["public"] = public
|
46
40
|
if token is not UNSET:
|
47
41
|
field_dict["token"] = token
|
48
42
|
|
@@ -57,14 +51,11 @@ class PreviewTokenSpec:
|
|
57
51
|
|
58
52
|
expires_at = d.pop("expiresAt", UNSET)
|
59
53
|
|
60
|
-
public = d.pop("public", UNSET)
|
61
|
-
|
62
54
|
token = d.pop("token", UNSET)
|
63
55
|
|
64
56
|
preview_token_spec = cls(
|
65
57
|
expired=expired,
|
66
58
|
expires_at=expires_at,
|
67
|
-
public=public,
|
68
59
|
token=token,
|
69
60
|
)
|
70
61
|
|
blaxel/sandbox/base.py
CHANGED
@@ -58,8 +58,10 @@ class SandboxHandleBase:
|
|
58
58
|
def url(self):
|
59
59
|
if self.forced_url:
|
60
60
|
return self.forced_url
|
61
|
-
|
62
|
-
|
61
|
+
# Uncomment and use this when agent and mcp are available in mk3
|
62
|
+
# Update all requests made in this package to use fallbackUrl when internalUrl is not working
|
63
|
+
# if settings.run_internal_hostname:
|
64
|
+
# return self.internal_url
|
63
65
|
return self.external_url
|
64
66
|
|
65
67
|
def handle_response(self, response: Response):
|
@@ -0,0 +1,165 @@
|
|
1
|
+
from http import HTTPStatus
|
2
|
+
from typing import Any, Optional, Union
|
3
|
+
|
4
|
+
import httpx
|
5
|
+
|
6
|
+
from ... import errors
|
7
|
+
from ...client import Client
|
8
|
+
from ...models.error_response import ErrorResponse
|
9
|
+
from ...types import Response
|
10
|
+
|
11
|
+
|
12
|
+
def _get_kwargs(
|
13
|
+
path: str,
|
14
|
+
) -> dict[str, Any]:
|
15
|
+
_kwargs: dict[str, Any] = {
|
16
|
+
"method": "get",
|
17
|
+
"url": f"/watch/filesystem/{path}",
|
18
|
+
}
|
19
|
+
|
20
|
+
return _kwargs
|
21
|
+
|
22
|
+
|
23
|
+
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[ErrorResponse, str]]:
|
24
|
+
if response.status_code == 200:
|
25
|
+
response_200 = response.text
|
26
|
+
return response_200
|
27
|
+
if response.status_code == 400:
|
28
|
+
response_400 = ErrorResponse.from_dict(response.text)
|
29
|
+
|
30
|
+
return response_400
|
31
|
+
if response.status_code == 500:
|
32
|
+
response_500 = ErrorResponse.from_dict(response.text)
|
33
|
+
|
34
|
+
return response_500
|
35
|
+
if client.raise_on_unexpected_status:
|
36
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
37
|
+
else:
|
38
|
+
return None
|
39
|
+
|
40
|
+
|
41
|
+
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ErrorResponse, str]]:
|
42
|
+
return Response(
|
43
|
+
status_code=HTTPStatus(response.status_code),
|
44
|
+
content=response.content,
|
45
|
+
headers=response.headers,
|
46
|
+
parsed=_parse_response(client=client, response=response),
|
47
|
+
)
|
48
|
+
|
49
|
+
|
50
|
+
def sync_detailed(
|
51
|
+
path: str,
|
52
|
+
*,
|
53
|
+
client: Union[Client],
|
54
|
+
) -> Response[Union[ErrorResponse, str]]:
|
55
|
+
"""Stream file modification events in a directory
|
56
|
+
|
57
|
+
Streams the path of modified files (one per line) in the given directory. Closes when the client
|
58
|
+
disconnects.
|
59
|
+
|
60
|
+
Args:
|
61
|
+
path (str):
|
62
|
+
|
63
|
+
Raises:
|
64
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
65
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
66
|
+
|
67
|
+
Returns:
|
68
|
+
Response[Union[ErrorResponse, str]]
|
69
|
+
"""
|
70
|
+
|
71
|
+
kwargs = _get_kwargs(
|
72
|
+
path=path,
|
73
|
+
)
|
74
|
+
|
75
|
+
response = client.get_httpx_client().request(
|
76
|
+
**kwargs,
|
77
|
+
)
|
78
|
+
|
79
|
+
return _build_response(client=client, response=response)
|
80
|
+
|
81
|
+
|
82
|
+
def sync(
|
83
|
+
path: str,
|
84
|
+
*,
|
85
|
+
client: Union[Client],
|
86
|
+
) -> Optional[Union[ErrorResponse, str]]:
|
87
|
+
"""Stream file modification events in a directory
|
88
|
+
|
89
|
+
Streams the path of modified files (one per line) in the given directory. Closes when the client
|
90
|
+
disconnects.
|
91
|
+
|
92
|
+
Args:
|
93
|
+
path (str):
|
94
|
+
|
95
|
+
Raises:
|
96
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
97
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
98
|
+
|
99
|
+
Returns:
|
100
|
+
Union[ErrorResponse, str]
|
101
|
+
"""
|
102
|
+
|
103
|
+
return sync_detailed(
|
104
|
+
path=path,
|
105
|
+
client=client,
|
106
|
+
).parsed
|
107
|
+
|
108
|
+
|
109
|
+
async def asyncio_detailed(
|
110
|
+
path: str,
|
111
|
+
*,
|
112
|
+
client: Union[Client],
|
113
|
+
) -> Response[Union[ErrorResponse, str]]:
|
114
|
+
"""Stream file modification events in a directory
|
115
|
+
|
116
|
+
Streams the path of modified files (one per line) in the given directory. Closes when the client
|
117
|
+
disconnects.
|
118
|
+
|
119
|
+
Args:
|
120
|
+
path (str):
|
121
|
+
|
122
|
+
Raises:
|
123
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
124
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
125
|
+
|
126
|
+
Returns:
|
127
|
+
Response[Union[ErrorResponse, str]]
|
128
|
+
"""
|
129
|
+
|
130
|
+
kwargs = _get_kwargs(
|
131
|
+
path=path,
|
132
|
+
)
|
133
|
+
|
134
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
135
|
+
|
136
|
+
return _build_response(client=client, response=response)
|
137
|
+
|
138
|
+
|
139
|
+
async def asyncio(
|
140
|
+
path: str,
|
141
|
+
*,
|
142
|
+
client: Union[Client],
|
143
|
+
) -> Optional[Union[ErrorResponse, str]]:
|
144
|
+
"""Stream file modification events in a directory
|
145
|
+
|
146
|
+
Streams the path of modified files (one per line) in the given directory. Closes when the client
|
147
|
+
disconnects.
|
148
|
+
|
149
|
+
Args:
|
150
|
+
path (str):
|
151
|
+
|
152
|
+
Raises:
|
153
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
154
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
155
|
+
|
156
|
+
Returns:
|
157
|
+
Union[ErrorResponse, str]
|
158
|
+
"""
|
159
|
+
|
160
|
+
return (
|
161
|
+
await asyncio_detailed(
|
162
|
+
path=path,
|
163
|
+
client=client,
|
164
|
+
)
|
165
|
+
).parsed
|
@@ -0,0 +1,161 @@
|
|
1
|
+
from http import HTTPStatus
|
2
|
+
from typing import Any, Optional, Union, cast
|
3
|
+
|
4
|
+
import httpx
|
5
|
+
|
6
|
+
from ... import errors
|
7
|
+
from ...client import Client
|
8
|
+
from ...models.error_response import ErrorResponse
|
9
|
+
from ...types import Response
|
10
|
+
|
11
|
+
|
12
|
+
def _get_kwargs(
|
13
|
+
path: str,
|
14
|
+
) -> dict[str, Any]:
|
15
|
+
_kwargs: dict[str, Any] = {
|
16
|
+
"method": "get",
|
17
|
+
"url": f"/ws/watch/filesystem/{path}",
|
18
|
+
}
|
19
|
+
|
20
|
+
return _kwargs
|
21
|
+
|
22
|
+
|
23
|
+
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[ErrorResponse, str]]:
|
24
|
+
if response.status_code == 101:
|
25
|
+
response_101 = cast(str, response.json())
|
26
|
+
return response_101
|
27
|
+
if response.status_code == 400:
|
28
|
+
response_400 = ErrorResponse.from_dict(response.json())
|
29
|
+
|
30
|
+
return response_400
|
31
|
+
if response.status_code == 500:
|
32
|
+
response_500 = ErrorResponse.from_dict(response.json())
|
33
|
+
|
34
|
+
return response_500
|
35
|
+
if client.raise_on_unexpected_status:
|
36
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
37
|
+
else:
|
38
|
+
return None
|
39
|
+
|
40
|
+
|
41
|
+
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ErrorResponse, str]]:
|
42
|
+
return Response(
|
43
|
+
status_code=HTTPStatus(response.status_code),
|
44
|
+
content=response.content,
|
45
|
+
headers=response.headers,
|
46
|
+
parsed=_parse_response(client=client, response=response),
|
47
|
+
)
|
48
|
+
|
49
|
+
|
50
|
+
def sync_detailed(
|
51
|
+
path: str,
|
52
|
+
*,
|
53
|
+
client: Union[Client],
|
54
|
+
) -> Response[Union[ErrorResponse, str]]:
|
55
|
+
"""Stream file modification events in a directory via WebSocket
|
56
|
+
|
57
|
+
Streams JSON events of modified files in the given directory. Closes when the client disconnects.
|
58
|
+
|
59
|
+
Args:
|
60
|
+
path (str):
|
61
|
+
|
62
|
+
Raises:
|
63
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
64
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
65
|
+
|
66
|
+
Returns:
|
67
|
+
Response[Union[ErrorResponse, str]]
|
68
|
+
"""
|
69
|
+
|
70
|
+
kwargs = _get_kwargs(
|
71
|
+
path=path,
|
72
|
+
)
|
73
|
+
|
74
|
+
response = client.get_httpx_client().request(
|
75
|
+
**kwargs,
|
76
|
+
)
|
77
|
+
|
78
|
+
return _build_response(client=client, response=response)
|
79
|
+
|
80
|
+
|
81
|
+
def sync(
|
82
|
+
path: str,
|
83
|
+
*,
|
84
|
+
client: Union[Client],
|
85
|
+
) -> Optional[Union[ErrorResponse, str]]:
|
86
|
+
"""Stream file modification events in a directory via WebSocket
|
87
|
+
|
88
|
+
Streams JSON events of modified files in the given directory. Closes when the client disconnects.
|
89
|
+
|
90
|
+
Args:
|
91
|
+
path (str):
|
92
|
+
|
93
|
+
Raises:
|
94
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
95
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
96
|
+
|
97
|
+
Returns:
|
98
|
+
Union[ErrorResponse, str]
|
99
|
+
"""
|
100
|
+
|
101
|
+
return sync_detailed(
|
102
|
+
path=path,
|
103
|
+
client=client,
|
104
|
+
).parsed
|
105
|
+
|
106
|
+
|
107
|
+
async def asyncio_detailed(
|
108
|
+
path: str,
|
109
|
+
*,
|
110
|
+
client: Union[Client],
|
111
|
+
) -> Response[Union[ErrorResponse, str]]:
|
112
|
+
"""Stream file modification events in a directory via WebSocket
|
113
|
+
|
114
|
+
Streams JSON events of modified files in the given directory. Closes when the client disconnects.
|
115
|
+
|
116
|
+
Args:
|
117
|
+
path (str):
|
118
|
+
|
119
|
+
Raises:
|
120
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
121
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
122
|
+
|
123
|
+
Returns:
|
124
|
+
Response[Union[ErrorResponse, str]]
|
125
|
+
"""
|
126
|
+
|
127
|
+
kwargs = _get_kwargs(
|
128
|
+
path=path,
|
129
|
+
)
|
130
|
+
|
131
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
132
|
+
|
133
|
+
return _build_response(client=client, response=response)
|
134
|
+
|
135
|
+
|
136
|
+
async def asyncio(
|
137
|
+
path: str,
|
138
|
+
*,
|
139
|
+
client: Union[Client],
|
140
|
+
) -> Optional[Union[ErrorResponse, str]]:
|
141
|
+
"""Stream file modification events in a directory via WebSocket
|
142
|
+
|
143
|
+
Streams JSON events of modified files in the given directory. Closes when the client disconnects.
|
144
|
+
|
145
|
+
Args:
|
146
|
+
path (str):
|
147
|
+
|
148
|
+
Raises:
|
149
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
150
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
151
|
+
|
152
|
+
Returns:
|
153
|
+
Union[ErrorResponse, str]
|
154
|
+
"""
|
155
|
+
|
156
|
+
return (
|
157
|
+
await asyncio_detailed(
|
158
|
+
path=path,
|
159
|
+
client=client,
|
160
|
+
)
|
161
|
+
).parsed
|
@@ -7,24 +7,15 @@ from ... import errors
|
|
7
7
|
from ...client import Client
|
8
8
|
from ...models.error_response import ErrorResponse
|
9
9
|
from ...models.get_process_identifier_logs_response_200 import GetProcessIdentifierLogsResponse200
|
10
|
-
from ...types import
|
10
|
+
from ...types import Response
|
11
11
|
|
12
12
|
|
13
13
|
def _get_kwargs(
|
14
14
|
identifier: str,
|
15
|
-
*,
|
16
|
-
stream: Union[Unset, bool] = UNSET,
|
17
15
|
) -> dict[str, Any]:
|
18
|
-
params: dict[str, Any] = {}
|
19
|
-
|
20
|
-
params["stream"] = stream
|
21
|
-
|
22
|
-
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
23
|
-
|
24
16
|
_kwargs: dict[str, Any] = {
|
25
17
|
"method": "get",
|
26
18
|
"url": f"/process/{identifier}/logs",
|
27
|
-
"params": params,
|
28
19
|
}
|
29
20
|
|
30
21
|
return _kwargs
|
@@ -66,7 +57,6 @@ def sync_detailed(
|
|
66
57
|
identifier: str,
|
67
58
|
*,
|
68
59
|
client: Union[Client],
|
69
|
-
stream: Union[Unset, bool] = UNSET,
|
70
60
|
) -> Response[Union[ErrorResponse, GetProcessIdentifierLogsResponse200]]:
|
71
61
|
"""Get process logs
|
72
62
|
|
@@ -74,7 +64,6 @@ def sync_detailed(
|
|
74
64
|
|
75
65
|
Args:
|
76
66
|
identifier (str):
|
77
|
-
stream (Union[Unset, bool]):
|
78
67
|
|
79
68
|
Raises:
|
80
69
|
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
@@ -86,7 +75,6 @@ def sync_detailed(
|
|
86
75
|
|
87
76
|
kwargs = _get_kwargs(
|
88
77
|
identifier=identifier,
|
89
|
-
stream=stream,
|
90
78
|
)
|
91
79
|
|
92
80
|
response = client.get_httpx_client().request(
|
@@ -100,7 +88,6 @@ def sync(
|
|
100
88
|
identifier: str,
|
101
89
|
*,
|
102
90
|
client: Union[Client],
|
103
|
-
stream: Union[Unset, bool] = UNSET,
|
104
91
|
) -> Optional[Union[ErrorResponse, GetProcessIdentifierLogsResponse200]]:
|
105
92
|
"""Get process logs
|
106
93
|
|
@@ -108,7 +95,6 @@ def sync(
|
|
108
95
|
|
109
96
|
Args:
|
110
97
|
identifier (str):
|
111
|
-
stream (Union[Unset, bool]):
|
112
98
|
|
113
99
|
Raises:
|
114
100
|
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
@@ -121,7 +107,6 @@ def sync(
|
|
121
107
|
return sync_detailed(
|
122
108
|
identifier=identifier,
|
123
109
|
client=client,
|
124
|
-
stream=stream,
|
125
110
|
).parsed
|
126
111
|
|
127
112
|
|
@@ -129,7 +114,6 @@ async def asyncio_detailed(
|
|
129
114
|
identifier: str,
|
130
115
|
*,
|
131
116
|
client: Union[Client],
|
132
|
-
stream: Union[Unset, bool] = UNSET,
|
133
117
|
) -> Response[Union[ErrorResponse, GetProcessIdentifierLogsResponse200]]:
|
134
118
|
"""Get process logs
|
135
119
|
|
@@ -137,7 +121,6 @@ async def asyncio_detailed(
|
|
137
121
|
|
138
122
|
Args:
|
139
123
|
identifier (str):
|
140
|
-
stream (Union[Unset, bool]):
|
141
124
|
|
142
125
|
Raises:
|
143
126
|
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
@@ -149,7 +132,6 @@ async def asyncio_detailed(
|
|
149
132
|
|
150
133
|
kwargs = _get_kwargs(
|
151
134
|
identifier=identifier,
|
152
|
-
stream=stream,
|
153
135
|
)
|
154
136
|
|
155
137
|
response = await client.get_async_httpx_client().request(**kwargs)
|
@@ -161,7 +143,6 @@ async def asyncio(
|
|
161
143
|
identifier: str,
|
162
144
|
*,
|
163
145
|
client: Union[Client],
|
164
|
-
stream: Union[Unset, bool] = UNSET,
|
165
146
|
) -> Optional[Union[ErrorResponse, GetProcessIdentifierLogsResponse200]]:
|
166
147
|
"""Get process logs
|
167
148
|
|
@@ -169,7 +150,6 @@ async def asyncio(
|
|
169
150
|
|
170
151
|
Args:
|
171
152
|
identifier (str):
|
172
|
-
stream (Union[Unset, bool]):
|
173
153
|
|
174
154
|
Raises:
|
175
155
|
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
@@ -183,6 +163,5 @@ async def asyncio(
|
|
183
163
|
await asyncio_detailed(
|
184
164
|
identifier=identifier,
|
185
165
|
client=client,
|
186
|
-
stream=stream,
|
187
166
|
)
|
188
167
|
).parsed
|
@@ -6,45 +6,30 @@ import httpx
|
|
6
6
|
from ... import errors
|
7
7
|
from ...client import Client
|
8
8
|
from ...models.error_response import ErrorResponse
|
9
|
-
from ...
|
10
|
-
GetProcessIdentifierLogsStreamResponse200,
|
11
|
-
)
|
12
|
-
from ...types import UNSET, Response, Unset
|
9
|
+
from ...types import Response
|
13
10
|
|
14
11
|
|
15
12
|
def _get_kwargs(
|
16
13
|
identifier: str,
|
17
|
-
*,
|
18
|
-
stream: Union[Unset, bool] = UNSET,
|
19
14
|
) -> dict[str, Any]:
|
20
|
-
params: dict[str, Any] = {}
|
21
|
-
|
22
|
-
params["stream"] = stream
|
23
|
-
|
24
|
-
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
25
|
-
|
26
15
|
_kwargs: dict[str, Any] = {
|
27
16
|
"method": "get",
|
28
17
|
"url": f"/process/{identifier}/logs/stream",
|
29
|
-
"params": params,
|
30
18
|
}
|
31
19
|
|
32
20
|
return _kwargs
|
33
21
|
|
34
22
|
|
35
|
-
def _parse_response(
|
36
|
-
*, client: Client, response: httpx.Response
|
37
|
-
) -> Optional[Union[ErrorResponse, GetProcessIdentifierLogsStreamResponse200]]:
|
23
|
+
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[ErrorResponse, str]]:
|
38
24
|
if response.status_code == 200:
|
39
|
-
response_200 =
|
40
|
-
|
25
|
+
response_200 = response.text
|
41
26
|
return response_200
|
42
27
|
if response.status_code == 404:
|
43
|
-
response_404 = ErrorResponse.from_dict(response.
|
28
|
+
response_404 = ErrorResponse.from_dict(response.text)
|
44
29
|
|
45
30
|
return response_404
|
46
31
|
if response.status_code == 500:
|
47
|
-
response_500 = ErrorResponse.from_dict(response.
|
32
|
+
response_500 = ErrorResponse.from_dict(response.text)
|
48
33
|
|
49
34
|
return response_500
|
50
35
|
if client.raise_on_unexpected_status:
|
@@ -53,9 +38,7 @@ def _parse_response(
|
|
53
38
|
return None
|
54
39
|
|
55
40
|
|
56
|
-
def _build_response(
|
57
|
-
*, client: Client, response: httpx.Response
|
58
|
-
) -> Response[Union[ErrorResponse, GetProcessIdentifierLogsStreamResponse200]]:
|
41
|
+
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ErrorResponse, str]]:
|
59
42
|
return Response(
|
60
43
|
status_code=HTTPStatus(response.status_code),
|
61
44
|
content=response.content,
|
@@ -68,27 +51,25 @@ def sync_detailed(
|
|
68
51
|
identifier: str,
|
69
52
|
*,
|
70
53
|
client: Union[Client],
|
71
|
-
|
72
|
-
|
73
|
-
"""Get process logs in realtime
|
54
|
+
) -> Response[Union[ErrorResponse, str]]:
|
55
|
+
"""Stream process logs in real time
|
74
56
|
|
75
|
-
|
57
|
+
Streams the stdout and stderr output of a process in real time, one line per log, prefixed with
|
58
|
+
'stdout:' or 'stderr:'. Closes when the process exits or the client disconnects.
|
76
59
|
|
77
60
|
Args:
|
78
61
|
identifier (str):
|
79
|
-
stream (Union[Unset, bool]):
|
80
62
|
|
81
63
|
Raises:
|
82
64
|
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
83
65
|
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
84
66
|
|
85
67
|
Returns:
|
86
|
-
Response[Union[ErrorResponse,
|
68
|
+
Response[Union[ErrorResponse, str]]
|
87
69
|
"""
|
88
70
|
|
89
71
|
kwargs = _get_kwargs(
|
90
72
|
identifier=identifier,
|
91
|
-
stream=stream,
|
92
73
|
)
|
93
74
|
|
94
75
|
response = client.get_httpx_client().request(
|
@@ -102,28 +83,26 @@ def sync(
|
|
102
83
|
identifier: str,
|
103
84
|
*,
|
104
85
|
client: Union[Client],
|
105
|
-
|
106
|
-
|
107
|
-
"""Get process logs in realtime
|
86
|
+
) -> Optional[Union[ErrorResponse, str]]:
|
87
|
+
"""Stream process logs in real time
|
108
88
|
|
109
|
-
|
89
|
+
Streams the stdout and stderr output of a process in real time, one line per log, prefixed with
|
90
|
+
'stdout:' or 'stderr:'. Closes when the process exits or the client disconnects.
|
110
91
|
|
111
92
|
Args:
|
112
93
|
identifier (str):
|
113
|
-
stream (Union[Unset, bool]):
|
114
94
|
|
115
95
|
Raises:
|
116
96
|
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
117
97
|
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
118
98
|
|
119
99
|
Returns:
|
120
|
-
Union[ErrorResponse,
|
100
|
+
Union[ErrorResponse, str]
|
121
101
|
"""
|
122
102
|
|
123
103
|
return sync_detailed(
|
124
104
|
identifier=identifier,
|
125
105
|
client=client,
|
126
|
-
stream=stream,
|
127
106
|
).parsed
|
128
107
|
|
129
108
|
|
@@ -131,27 +110,25 @@ async def asyncio_detailed(
|
|
131
110
|
identifier: str,
|
132
111
|
*,
|
133
112
|
client: Union[Client],
|
134
|
-
|
135
|
-
|
136
|
-
"""Get process logs in realtime
|
113
|
+
) -> Response[Union[ErrorResponse, str]]:
|
114
|
+
"""Stream process logs in real time
|
137
115
|
|
138
|
-
|
116
|
+
Streams the stdout and stderr output of a process in real time, one line per log, prefixed with
|
117
|
+
'stdout:' or 'stderr:'. Closes when the process exits or the client disconnects.
|
139
118
|
|
140
119
|
Args:
|
141
120
|
identifier (str):
|
142
|
-
stream (Union[Unset, bool]):
|
143
121
|
|
144
122
|
Raises:
|
145
123
|
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
146
124
|
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
147
125
|
|
148
126
|
Returns:
|
149
|
-
Response[Union[ErrorResponse,
|
127
|
+
Response[Union[ErrorResponse, str]]
|
150
128
|
"""
|
151
129
|
|
152
130
|
kwargs = _get_kwargs(
|
153
131
|
identifier=identifier,
|
154
|
-
stream=stream,
|
155
132
|
)
|
156
133
|
|
157
134
|
response = await client.get_async_httpx_client().request(**kwargs)
|
@@ -163,28 +140,26 @@ async def asyncio(
|
|
163
140
|
identifier: str,
|
164
141
|
*,
|
165
142
|
client: Union[Client],
|
166
|
-
|
167
|
-
|
168
|
-
"""Get process logs in realtime
|
143
|
+
) -> Optional[Union[ErrorResponse, str]]:
|
144
|
+
"""Stream process logs in real time
|
169
145
|
|
170
|
-
|
146
|
+
Streams the stdout and stderr output of a process in real time, one line per log, prefixed with
|
147
|
+
'stdout:' or 'stderr:'. Closes when the process exits or the client disconnects.
|
171
148
|
|
172
149
|
Args:
|
173
150
|
identifier (str):
|
174
|
-
stream (Union[Unset, bool]):
|
175
151
|
|
176
152
|
Raises:
|
177
153
|
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
178
154
|
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
179
155
|
|
180
156
|
Returns:
|
181
|
-
Union[ErrorResponse,
|
157
|
+
Union[ErrorResponse, str]
|
182
158
|
"""
|
183
159
|
|
184
160
|
return (
|
185
161
|
await asyncio_detailed(
|
186
162
|
identifier=identifier,
|
187
163
|
client=client,
|
188
|
-
stream=stream,
|
189
164
|
)
|
190
165
|
).parsed
|
@@ -0,0 +1,165 @@
|
|
1
|
+
from http import HTTPStatus
|
2
|
+
from typing import Any, Optional, Union, cast
|
3
|
+
|
4
|
+
import httpx
|
5
|
+
|
6
|
+
from ... import errors
|
7
|
+
from ...client import Client
|
8
|
+
from ...models.error_response import ErrorResponse
|
9
|
+
from ...types import Response
|
10
|
+
|
11
|
+
|
12
|
+
def _get_kwargs(
|
13
|
+
identifier: str,
|
14
|
+
) -> dict[str, Any]:
|
15
|
+
_kwargs: dict[str, Any] = {
|
16
|
+
"method": "get",
|
17
|
+
"url": f"/ws/process/{identifier}/logs/stream",
|
18
|
+
}
|
19
|
+
|
20
|
+
return _kwargs
|
21
|
+
|
22
|
+
|
23
|
+
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Union[ErrorResponse, str]]:
|
24
|
+
if response.status_code == 101:
|
25
|
+
response_101 = cast(str, response.json())
|
26
|
+
return response_101
|
27
|
+
if response.status_code == 404:
|
28
|
+
response_404 = ErrorResponse.from_dict(response.json())
|
29
|
+
|
30
|
+
return response_404
|
31
|
+
if response.status_code == 500:
|
32
|
+
response_500 = ErrorResponse.from_dict(response.json())
|
33
|
+
|
34
|
+
return response_500
|
35
|
+
if client.raise_on_unexpected_status:
|
36
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
37
|
+
else:
|
38
|
+
return None
|
39
|
+
|
40
|
+
|
41
|
+
def _build_response(*, client: Client, response: httpx.Response) -> Response[Union[ErrorResponse, str]]:
|
42
|
+
return Response(
|
43
|
+
status_code=HTTPStatus(response.status_code),
|
44
|
+
content=response.content,
|
45
|
+
headers=response.headers,
|
46
|
+
parsed=_parse_response(client=client, response=response),
|
47
|
+
)
|
48
|
+
|
49
|
+
|
50
|
+
def sync_detailed(
|
51
|
+
identifier: str,
|
52
|
+
*,
|
53
|
+
client: Union[Client],
|
54
|
+
) -> Response[Union[ErrorResponse, str]]:
|
55
|
+
"""Stream process logs in real time via WebSocket
|
56
|
+
|
57
|
+
Streams the stdout and stderr output of a process in real time as JSON messages. Closes when the
|
58
|
+
process exits or the client disconnects.
|
59
|
+
|
60
|
+
Args:
|
61
|
+
identifier (str):
|
62
|
+
|
63
|
+
Raises:
|
64
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
65
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
66
|
+
|
67
|
+
Returns:
|
68
|
+
Response[Union[ErrorResponse, str]]
|
69
|
+
"""
|
70
|
+
|
71
|
+
kwargs = _get_kwargs(
|
72
|
+
identifier=identifier,
|
73
|
+
)
|
74
|
+
|
75
|
+
response = client.get_httpx_client().request(
|
76
|
+
**kwargs,
|
77
|
+
)
|
78
|
+
|
79
|
+
return _build_response(client=client, response=response)
|
80
|
+
|
81
|
+
|
82
|
+
def sync(
|
83
|
+
identifier: str,
|
84
|
+
*,
|
85
|
+
client: Union[Client],
|
86
|
+
) -> Optional[Union[ErrorResponse, str]]:
|
87
|
+
"""Stream process logs in real time via WebSocket
|
88
|
+
|
89
|
+
Streams the stdout and stderr output of a process in real time as JSON messages. Closes when the
|
90
|
+
process exits or the client disconnects.
|
91
|
+
|
92
|
+
Args:
|
93
|
+
identifier (str):
|
94
|
+
|
95
|
+
Raises:
|
96
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
97
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
98
|
+
|
99
|
+
Returns:
|
100
|
+
Union[ErrorResponse, str]
|
101
|
+
"""
|
102
|
+
|
103
|
+
return sync_detailed(
|
104
|
+
identifier=identifier,
|
105
|
+
client=client,
|
106
|
+
).parsed
|
107
|
+
|
108
|
+
|
109
|
+
async def asyncio_detailed(
|
110
|
+
identifier: str,
|
111
|
+
*,
|
112
|
+
client: Union[Client],
|
113
|
+
) -> Response[Union[ErrorResponse, str]]:
|
114
|
+
"""Stream process logs in real time via WebSocket
|
115
|
+
|
116
|
+
Streams the stdout and stderr output of a process in real time as JSON messages. Closes when the
|
117
|
+
process exits or the client disconnects.
|
118
|
+
|
119
|
+
Args:
|
120
|
+
identifier (str):
|
121
|
+
|
122
|
+
Raises:
|
123
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
124
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
125
|
+
|
126
|
+
Returns:
|
127
|
+
Response[Union[ErrorResponse, str]]
|
128
|
+
"""
|
129
|
+
|
130
|
+
kwargs = _get_kwargs(
|
131
|
+
identifier=identifier,
|
132
|
+
)
|
133
|
+
|
134
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
135
|
+
|
136
|
+
return _build_response(client=client, response=response)
|
137
|
+
|
138
|
+
|
139
|
+
async def asyncio(
|
140
|
+
identifier: str,
|
141
|
+
*,
|
142
|
+
client: Union[Client],
|
143
|
+
) -> Optional[Union[ErrorResponse, str]]:
|
144
|
+
"""Stream process logs in real time via WebSocket
|
145
|
+
|
146
|
+
Streams the stdout and stderr output of a process in real time as JSON messages. Closes when the
|
147
|
+
process exits or the client disconnects.
|
148
|
+
|
149
|
+
Args:
|
150
|
+
identifier (str):
|
151
|
+
|
152
|
+
Raises:
|
153
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
154
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
155
|
+
|
156
|
+
Returns:
|
157
|
+
Union[ErrorResponse, str]
|
158
|
+
"""
|
159
|
+
|
160
|
+
return (
|
161
|
+
await asyncio_detailed(
|
162
|
+
identifier=identifier,
|
163
|
+
client=client,
|
164
|
+
)
|
165
|
+
).parsed
|
@@ -10,9 +10,6 @@ from .file_request import FileRequest
|
|
10
10
|
from .file_with_content import FileWithContent
|
11
11
|
from .get_network_process_pid_ports_response_200 import GetNetworkProcessPidPortsResponse200
|
12
12
|
from .get_process_identifier_logs_response_200 import GetProcessIdentifierLogsResponse200
|
13
|
-
from .get_process_identifier_logs_stream_response_200 import (
|
14
|
-
GetProcessIdentifierLogsStreamResponse200,
|
15
|
-
)
|
16
13
|
from .port_monitor_request import PortMonitorRequest
|
17
14
|
from .post_network_process_pid_monitor_response_200 import PostNetworkProcessPidMonitorResponse200
|
18
15
|
from .process_kill_request import ProcessKillRequest
|
@@ -30,7 +27,6 @@ __all__ = (
|
|
30
27
|
"FileWithContent",
|
31
28
|
"GetNetworkProcessPidPortsResponse200",
|
32
29
|
"GetProcessIdentifierLogsResponse200",
|
33
|
-
"GetProcessIdentifierLogsStreamResponse200",
|
34
30
|
"PortMonitorRequest",
|
35
31
|
"PostNetworkProcessPidMonitorResponse200",
|
36
32
|
"ProcessKillRequest",
|
@@ -14,7 +14,6 @@ class ProcessRequest:
|
|
14
14
|
Attributes:
|
15
15
|
command (str): Example: ls -la.
|
16
16
|
name (Union[Unset, str]): Example: my-process.
|
17
|
-
stream_logs (Union[Unset, bool]): Example: True.
|
18
17
|
timeout (Union[Unset, int]): Example: 30.
|
19
18
|
wait_for_completion (Union[Unset, bool]):
|
20
19
|
wait_for_ports (Union[Unset, list[int]]): Example: [3000, 8080].
|
@@ -23,7 +22,6 @@ class ProcessRequest:
|
|
23
22
|
|
24
23
|
command: str
|
25
24
|
name: Union[Unset, str] = UNSET
|
26
|
-
stream_logs: Union[Unset, bool] = UNSET
|
27
25
|
timeout: Union[Unset, int] = UNSET
|
28
26
|
wait_for_completion: Union[Unset, bool] = UNSET
|
29
27
|
wait_for_ports: Union[Unset, list[int]] = UNSET
|
@@ -35,8 +33,6 @@ class ProcessRequest:
|
|
35
33
|
|
36
34
|
name = self.name
|
37
35
|
|
38
|
-
stream_logs = self.stream_logs
|
39
|
-
|
40
36
|
timeout = self.timeout
|
41
37
|
|
42
38
|
wait_for_completion = self.wait_for_completion
|
@@ -56,8 +52,6 @@ class ProcessRequest:
|
|
56
52
|
)
|
57
53
|
if name is not UNSET:
|
58
54
|
field_dict["name"] = name
|
59
|
-
if stream_logs is not UNSET:
|
60
|
-
field_dict["streamLogs"] = stream_logs
|
61
55
|
if timeout is not UNSET:
|
62
56
|
field_dict["timeout"] = timeout
|
63
57
|
if wait_for_completion is not UNSET:
|
@@ -78,8 +72,6 @@ class ProcessRequest:
|
|
78
72
|
|
79
73
|
name = d.pop("name", UNSET)
|
80
74
|
|
81
|
-
stream_logs = d.pop("streamLogs", UNSET)
|
82
|
-
|
83
75
|
timeout = d.pop("timeout", UNSET)
|
84
76
|
|
85
77
|
wait_for_completion = d.pop("waitForCompletion", UNSET)
|
@@ -91,7 +83,6 @@ class ProcessRequest:
|
|
91
83
|
process_request = cls(
|
92
84
|
command=command,
|
93
85
|
name=name,
|
94
|
-
stream_logs=stream_logs,
|
95
86
|
timeout=timeout,
|
96
87
|
wait_for_completion=wait_for_completion,
|
97
88
|
wait_for_ports=wait_for_ports,
|
@@ -0,0 +1,146 @@
|
|
1
|
+
from dataclasses import dataclass
|
2
|
+
from datetime import datetime, timezone
|
3
|
+
from typing import List, Optional
|
4
|
+
|
5
|
+
from ..client.api.compute.create_sandbox_preview import \
|
6
|
+
asyncio as create_sandbox_preview
|
7
|
+
from ..client.api.compute.create_sandbox_preview_token import \
|
8
|
+
asyncio as create_sandbox_preview_token
|
9
|
+
from ..client.api.compute.delete_sandbox_preview import \
|
10
|
+
asyncio as delete_sandbox_preview
|
11
|
+
from ..client.api.compute.delete_sandbox_preview_token import \
|
12
|
+
asyncio as delete_sandbox_preview_token
|
13
|
+
from ..client.api.compute.get_sandbox_preview import \
|
14
|
+
asyncio as get_sandbox_preview
|
15
|
+
from ..client.api.compute.list_sandbox_preview_tokens import \
|
16
|
+
asyncio as list_sandbox_preview_tokens
|
17
|
+
from ..client.api.compute.list_sandbox_previews import \
|
18
|
+
asyncio as list_sandbox_previews
|
19
|
+
from ..client.client import client
|
20
|
+
from ..client.models import (Preview, PreviewSpec, PreviewToken,
|
21
|
+
PreviewTokenSpec, Sandbox)
|
22
|
+
|
23
|
+
|
24
|
+
@dataclass
|
25
|
+
class SandboxPreviewToken:
|
26
|
+
"""Represents a preview token with its value and expiration."""
|
27
|
+
preview_token: PreviewToken
|
28
|
+
|
29
|
+
@property
|
30
|
+
def value(self) -> str:
|
31
|
+
return self.preview_token.spec.token if self.preview_token.spec else ""
|
32
|
+
|
33
|
+
@property
|
34
|
+
def expires_at(self) -> datetime:
|
35
|
+
return self.preview_token.spec.expires_at if self.preview_token.spec else datetime.now()
|
36
|
+
|
37
|
+
class SandboxPreviewTokens:
|
38
|
+
"""Manages preview tokens for a sandbox preview."""
|
39
|
+
def __init__(self, preview: Preview):
|
40
|
+
self.preview = preview
|
41
|
+
|
42
|
+
@property
|
43
|
+
def preview_name(self) -> str:
|
44
|
+
return self.preview.metadata.name if self.preview.metadata else ""
|
45
|
+
|
46
|
+
@property
|
47
|
+
def resource_name(self) -> str:
|
48
|
+
return self.preview.metadata.resource_name if self.preview.metadata else ""
|
49
|
+
|
50
|
+
async def create(self, expires_at: datetime) -> SandboxPreviewToken:
|
51
|
+
"""Create a new preview token."""
|
52
|
+
response: PreviewToken = await create_sandbox_preview_token(
|
53
|
+
self.resource_name,
|
54
|
+
self.preview_name,
|
55
|
+
body=PreviewToken(
|
56
|
+
spec=PreviewTokenSpec(
|
57
|
+
expires_at=to_utc_z(expires_at),
|
58
|
+
)
|
59
|
+
),
|
60
|
+
client=client,
|
61
|
+
)
|
62
|
+
return SandboxPreviewToken(response)
|
63
|
+
|
64
|
+
async def list(self) -> List[SandboxPreviewToken]:
|
65
|
+
"""List all preview tokens."""
|
66
|
+
response: List[PreviewToken] = await list_sandbox_preview_tokens(
|
67
|
+
self.resource_name,
|
68
|
+
self.preview_name,
|
69
|
+
client=client,
|
70
|
+
)
|
71
|
+
return [SandboxPreviewToken(token) for token in response]
|
72
|
+
|
73
|
+
async def delete(self, token_name: str) -> dict:
|
74
|
+
"""Delete a preview token."""
|
75
|
+
response: PreviewToken = await delete_sandbox_preview_token(
|
76
|
+
self.resource_name,
|
77
|
+
self.preview_name,
|
78
|
+
token_name,
|
79
|
+
client=client,
|
80
|
+
)
|
81
|
+
return response
|
82
|
+
|
83
|
+
class SandboxPreview:
|
84
|
+
"""Represents a sandbox preview with its metadata and tokens."""
|
85
|
+
def __init__(self, preview: Preview):
|
86
|
+
self.preview = preview
|
87
|
+
self.tokens = SandboxPreviewTokens(self)
|
88
|
+
|
89
|
+
@property
|
90
|
+
def name(self) -> str:
|
91
|
+
return self.preview.metadata.name if self.preview.metadata else ""
|
92
|
+
|
93
|
+
@property
|
94
|
+
def metadata(self) -> Optional[dict]:
|
95
|
+
return self.preview.metadata
|
96
|
+
|
97
|
+
@property
|
98
|
+
def spec(self) -> Optional[PreviewSpec]:
|
99
|
+
return self.preview.spec
|
100
|
+
|
101
|
+
class SandboxPreviews:
|
102
|
+
"""Manages sandbox previews."""
|
103
|
+
def __init__(self, sandbox: Sandbox):
|
104
|
+
self.sandbox = sandbox
|
105
|
+
|
106
|
+
@property
|
107
|
+
def sandbox_name(self) -> str:
|
108
|
+
return self.sandbox.metadata.name if self.sandbox.metadata else ""
|
109
|
+
|
110
|
+
async def list(self) -> List[SandboxPreview]:
|
111
|
+
"""List all previews for the sandbox."""
|
112
|
+
response: List[Preview] = await list_sandbox_previews(
|
113
|
+
self.sandbox_name,
|
114
|
+
client=client,
|
115
|
+
)
|
116
|
+
return [SandboxPreview(preview) for preview in response]
|
117
|
+
|
118
|
+
async def create(self, preview: Preview) -> SandboxPreview:
|
119
|
+
"""Create a new preview."""
|
120
|
+
response: Preview = await create_sandbox_preview(
|
121
|
+
self.sandbox_name,
|
122
|
+
body=preview,
|
123
|
+
client=client,
|
124
|
+
)
|
125
|
+
return SandboxPreview(response)
|
126
|
+
|
127
|
+
async def get(self, preview_name: str) -> SandboxPreview:
|
128
|
+
"""Get a specific preview by name."""
|
129
|
+
response: Preview = await get_sandbox_preview(
|
130
|
+
self.sandbox_name,
|
131
|
+
preview_name,
|
132
|
+
client=client,
|
133
|
+
)
|
134
|
+
return SandboxPreview(response)
|
135
|
+
|
136
|
+
async def delete(self, preview_name: str) -> dict:
|
137
|
+
"""Delete a preview."""
|
138
|
+
response: Preview = await delete_sandbox_preview(
|
139
|
+
self.sandbox_name,
|
140
|
+
preview_name,
|
141
|
+
client=client,
|
142
|
+
)
|
143
|
+
return response
|
144
|
+
|
145
|
+
def to_utc_z(dt: datetime) -> str:
|
146
|
+
return dt.isoformat(timespec="milliseconds").replace("+00:00", "Z")
|
blaxel/sandbox/sandbox.py
CHANGED
@@ -10,6 +10,7 @@ from ..client.api.compute.list_sandboxes import asyncio as list_sandboxes
|
|
10
10
|
from ..client.client import client
|
11
11
|
from ..client.models import Sandbox
|
12
12
|
from .filesystem import SandboxFileSystem
|
13
|
+
from .preview import SandboxPreviews
|
13
14
|
from .process import SandboxProcess
|
14
15
|
|
15
16
|
logger = logging.getLogger(__name__)
|
@@ -19,6 +20,7 @@ class SandboxInstance:
|
|
19
20
|
self.sandbox = sandbox
|
20
21
|
self.fs = SandboxFileSystem(sandbox)
|
21
22
|
self.process = SandboxProcess(sandbox)
|
23
|
+
self.previews = SandboxPreviews(sandbox)
|
22
24
|
|
23
25
|
@property
|
24
26
|
def metadata(self):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: blaxel
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.12rc46
|
4
4
|
Summary: Add your description here
|
5
5
|
Author-email: cploujoux <cploujoux@blaxel.ai>
|
6
6
|
License-File: LICENSE
|
@@ -40,7 +40,8 @@ Requires-Dist: langgraph<0.3.0,>=0.2.40; extra == 'langchain'
|
|
40
40
|
Requires-Dist: opentelemetry-instrumentation-langchain>=0.35.0; extra == 'langchain'
|
41
41
|
Requires-Dist: pillow>=10.0.0; extra == 'langchain'
|
42
42
|
Provides-Extra: livekit
|
43
|
-
Requires-Dist: livekit-agents[anthropic,groq,openai]~=1.0; extra == 'livekit'
|
43
|
+
Requires-Dist: livekit-agents[anthropic,cartesia,deepgram,elevenlabs,groq,openai,silero,turn-detector]~=1.0; extra == 'livekit'
|
44
|
+
Requires-Dist: livekit-plugins-noise-cancellation~=0.2; extra == 'livekit'
|
44
45
|
Provides-Extra: llamaindex
|
45
46
|
Requires-Dist: llama-index-llms-anthropic>=0.6.10; extra == 'llamaindex'
|
46
47
|
Requires-Dist: llama-index-llms-cerebras>=0.2.2; extra == 'llamaindex'
|
@@ -203,10 +203,10 @@ blaxel/client/models/policy_spec.py,sha256=A6LX0Q4HbealhZP6O0mtT6SrhfnvQHBf_3bNH
|
|
203
203
|
blaxel/client/models/port.py,sha256=3mMRcMnQsrDWA07O6DmeOPzHY4z-knugDcMd0wZtYgw,2107
|
204
204
|
blaxel/client/models/preview.py,sha256=CF493_n0Gwgd3HDwI7c4fKeZmywY0fLp-J_JCzU06LQ,3024
|
205
205
|
blaxel/client/models/preview_metadata.py,sha256=vka-rLcyn7XHQfcz0HWSg7sVD4EzP340iBeLHwQCt08,4231
|
206
|
-
blaxel/client/models/preview_spec.py,sha256=
|
206
|
+
blaxel/client/models/preview_spec.py,sha256=u2UcCb5KmRgOEtsjLbmEmW1bQr3Y5XNLYpIPmNlr5Kc,2386
|
207
207
|
blaxel/client/models/preview_token.py,sha256=eSJ5ZmR-_Pu8CDNhz67KBpHiGkMeKDQsUQEqrYUTg4A,3142
|
208
208
|
blaxel/client/models/preview_token_metadata.py,sha256=x7Enkor1L96AoTwrzHMTBh2PdlI1K07iOHA_Nd8t1R8,2902
|
209
|
-
blaxel/client/models/preview_token_spec.py,sha256=
|
209
|
+
blaxel/client/models/preview_token_spec.py,sha256=vpuT9b36fO4cyNPhvsp-FGElM8_Smc2W0ZSDfv9Uh8A,2210
|
210
210
|
blaxel/client/models/private_cluster.py,sha256=7n5GIgiCBbD9HDNlnZNHuIIf5-nr6wZb2DSi-25O9v0,6519
|
211
211
|
blaxel/client/models/private_location.py,sha256=EhXB6EcQMnMbe4-RMBNlawJhx9a0T5i0xebrbVFjlrE,1609
|
212
212
|
blaxel/client/models/repository.py,sha256=y179VzQivkOSXq2zW-z0mGxVwIG-rZWSs_JRxxfSBhE,1791
|
@@ -284,10 +284,11 @@ blaxel/models/pydantic.py,sha256=4_z2KtaeEiRMt_Zz6Ghy6il-QiaXzE3yizDJnCBcWO8,332
|
|
284
284
|
blaxel/models/custom/langchain/gemini.py,sha256=AkhpuVMXnh1CyJ0zR2NMTtxQFPPHtAdHf_cyNzV3EsA,55421
|
285
285
|
blaxel/models/custom/llamaindex/cohere.py,sha256=Igj5Y1ozf1V4feIXfBHDdaTFU7od_wuOhm0yChZNxMY,19109
|
286
286
|
blaxel/models/custom/pydantic/gemini.py,sha256=rbsunh-M7EEKlD5ir3GlA-8a12JzPFcvsf6NISjzE5I,1052
|
287
|
-
blaxel/sandbox/base.py,sha256=
|
287
|
+
blaxel/sandbox/base.py,sha256=J5rd2uJ8N9vrti97EU4D21TaEzP7Jyfwf7s0248XIZw,2285
|
288
288
|
blaxel/sandbox/filesystem.py,sha256=3dvg92owjHypv0aFmBdx6i9QfMSfp6z9Z0D93yKfeiQ,4653
|
289
|
+
blaxel/sandbox/preview.py,sha256=go0DbOao5FrVkIMsDZr9y4XU9XvvAFGzfBqKDniFW48,4958
|
289
290
|
blaxel/sandbox/process.py,sha256=EWI6UctxdWo4Vd4VUSilABJME3g3x3ceuSuBN2mDfhM,2519
|
290
|
-
blaxel/sandbox/sandbox.py,sha256=
|
291
|
+
blaxel/sandbox/sandbox.py,sha256=xKxNmD3mNBWw48eHWCtBghNta8MGQIEl2rEnK50Zo00,3078
|
291
292
|
blaxel/sandbox/client/__init__.py,sha256=N26bD5o1jsTb48oExow6Rgivd8ylaU9jaWZfZsVilP8,128
|
292
293
|
blaxel/sandbox/client/client.py,sha256=tcP8cJ4Q3dV9aB3yQ01dDXO-ekfsa3WGGFz4DQAEf8I,7079
|
293
294
|
blaxel/sandbox/client/errors.py,sha256=gO8GBmKqmSNgAg-E5oT-oOyxztvp7V_6XG7OUTT15q0,546
|
@@ -297,6 +298,8 @@ blaxel/sandbox/client/api/__init__.py,sha256=zTSiG_ujSjAqWPyc435YXaX9XTlpMjiJWBb
|
|
297
298
|
blaxel/sandbox/client/api/filesystem/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
298
299
|
blaxel/sandbox/client/api/filesystem/delete_filesystem_path.py,sha256=PVm-a_nacy6QQb6mh_HIDx-JkiFYeUOypHZq0AtE6dA,4782
|
299
300
|
blaxel/sandbox/client/api/filesystem/get_filesystem_path.py,sha256=Hp8pM8xvi5zAjO5xujAbKxALUBJHH-JdyvWIEJ8dHo0,5010
|
301
|
+
blaxel/sandbox/client/api/filesystem/get_watch_filesystem_path.py,sha256=boA7oRe-1D5mRM088-QzQabek4fQvM-eYidTsSKntU0,4316
|
302
|
+
blaxel/sandbox/client/api/filesystem/get_ws_watch_filesystem_path.py,sha256=9odJ6wWJBjk5kiONo1f-n8A6E6smJaFL2U5ZbZcAgHo,4334
|
300
303
|
blaxel/sandbox/client/api/filesystem/put_filesystem_path.py,sha256=GIqwjevow7sRw5Po9iraYY1Yl5UXqgv2pjUw9nle97E,4759
|
301
304
|
blaxel/sandbox/client/api/network/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
302
305
|
blaxel/sandbox/client/api/network/delete_network_process_pid_monitor.py,sha256=nhQe7a4PqBhFQ6pZxSPilcvg-tt3jP0tmuX3Po8bd9g,4581
|
@@ -307,10 +310,11 @@ blaxel/sandbox/client/api/process/delete_process_identifier.py,sha256=7ihlG9_R7p
|
|
307
310
|
blaxel/sandbox/client/api/process/delete_process_identifier_kill.py,sha256=1x_KMc7uJD_fap8uoTmZkWIDTgLJKmCTGcOP1Mr6X1E,4858
|
308
311
|
blaxel/sandbox/client/api/process/get_process.py,sha256=XWf_hNFZLkS14eWjBjir22QwdtV313_llrQGExJ7lZo,3588
|
309
312
|
blaxel/sandbox/client/api/process/get_process_identifier.py,sha256=OqmxuKKHDGX6rwS0Mavn6nnL0X_7AasPUdS5RS04URc,4159
|
310
|
-
blaxel/sandbox/client/api/process/get_process_identifier_logs.py,sha256=
|
311
|
-
blaxel/sandbox/client/api/process/get_process_identifier_logs_stream.py,sha256=
|
313
|
+
blaxel/sandbox/client/api/process/get_process_identifier_logs.py,sha256=m34pQjMLpEUJsqkjEh0OafdNaMbDhR0NhzaJ1jWLJVk,4513
|
314
|
+
blaxel/sandbox/client/api/process/get_process_identifier_logs_stream.py,sha256=M4PnwNsDLWiIqG9C6NVgPEGU6wFHUAHiAx8Ueedu8vk,4639
|
315
|
+
blaxel/sandbox/client/api/process/get_ws_process_identifier_logs_stream.py,sha256=rWHLq_zFZLIgUXedzxnM0t6y6EIdyou4n7y7C8DnHkE,4565
|
312
316
|
blaxel/sandbox/client/api/process/post_process.py,sha256=cemvWEtrZ24RBx3QHusE9Al_yrgQip9nBSkaQhSGUkI,4527
|
313
|
-
blaxel/sandbox/client/models/__init__.py,sha256=
|
317
|
+
blaxel/sandbox/client/models/__init__.py,sha256=lbBeSRgo6_VBXgGQNXGwsFIwKvvvxI8UeMB5Hwpn-GE,1347
|
314
318
|
blaxel/sandbox/client/models/delete_network_process_pid_monitor_response_200.py,sha256=9cQgKDjG98sMridjXKgeR2oZzFKcQ0G9QIojhwYFosI,1376
|
315
319
|
blaxel/sandbox/client/models/directory.py,sha256=ApgBGjZApuhbTD6HKEzOIwk1IurrhpjuyupKlZcBj4c,3597
|
316
320
|
blaxel/sandbox/client/models/error_response.py,sha256=lI15zKBoD2X9yHzSiEaYGUn5TPTxWM7j1Tu5crtd23M,1581
|
@@ -319,11 +323,10 @@ blaxel/sandbox/client/models/file_request.py,sha256=xOZSru-fae-En-_2YBgkHa_6iGbq
|
|
319
323
|
blaxel/sandbox/client/models/file_with_content.py,sha256=Fou1vfbdPPOg2l2YTU2Q2M23V7iaFy3BFVKSGQ3jvN8,3131
|
320
324
|
blaxel/sandbox/client/models/get_network_process_pid_ports_response_200.py,sha256=x4uv80kK0GVroWO98l5sE84a6uwZ8pnUKTpGg81ipWA,1351
|
321
325
|
blaxel/sandbox/client/models/get_process_identifier_logs_response_200.py,sha256=pEs9vxD29oxrojOgeyppXXmFVvem7beWzm5_i4TkgDc,1343
|
322
|
-
blaxel/sandbox/client/models/get_process_identifier_logs_stream_response_200.py,sha256=EZndHWB9OhAv9PNC_NCOSEF0vZjDQfJibjCXi3l76pw,1376
|
323
326
|
blaxel/sandbox/client/models/port_monitor_request.py,sha256=LK7sjAK1TF1ojgG4vGytaKLVtV6-SNXxfZ3sxew1cRE,1698
|
324
327
|
blaxel/sandbox/client/models/post_network_process_pid_monitor_response_200.py,sha256=Y8BvNGKU8SlzTGqhaQZk_WWIrmFpNU0LVcmLFjNvqhA,1366
|
325
328
|
blaxel/sandbox/client/models/process_kill_request.py,sha256=TqhuOmVPm_yKZj52YFv3yyu2UA8eVgXEio4sgCVAR-0,1614
|
326
|
-
blaxel/sandbox/client/models/process_request.py,sha256=
|
329
|
+
blaxel/sandbox/client/models/process_request.py,sha256=7iWyPgIiV7HKO2IopPGyKoUFMYhOOUIWi05NQPdYGmU,3281
|
327
330
|
blaxel/sandbox/client/models/process_response.py,sha256=WMfxuNTrL5wo5QT7HOR4_CTyf9XztO5cPvmtlHMdNd8,3624
|
328
331
|
blaxel/sandbox/client/models/subdirectory.py,sha256=nJxyF6vc3iHK-36uR3oi-yhuBCJfmoLo8-4dwBjJJLU,1537
|
329
332
|
blaxel/sandbox/client/models/success_response.py,sha256=JQbCUIdVJy_TJ3mp8IuvCGbKgCm_iZQMMrqn8uZkxCk,1874
|
@@ -337,7 +340,7 @@ blaxel/tools/llamaindex.py,sha256=-gQ-C9V_h9a11J4ItsbWjXrCJOg0lRKsb98v9rVsNak,71
|
|
337
340
|
blaxel/tools/openai.py,sha256=GuFXkj6bXEwldyVr89jEsRAi5ihZUVEVe327QuWiGNs,653
|
338
341
|
blaxel/tools/pydantic.py,sha256=CvnNbAG_J4yBtA-XFI4lQrq3FYKjNd39hu841vZT004,1801
|
339
342
|
blaxel/tools/types.py,sha256=YPCGJ4vZDhqR0X2H_TWtc5chQScsC32nGTQdRKJlO8Y,707
|
340
|
-
blaxel-0.1.
|
341
|
-
blaxel-0.1.
|
342
|
-
blaxel-0.1.
|
343
|
-
blaxel-0.1.
|
343
|
+
blaxel-0.1.12rc46.dist-info/METADATA,sha256=Vls3XAm2xj7jVST-6TS5Hu8ts1dh7SSShn8kp_hZOgo,11776
|
344
|
+
blaxel-0.1.12rc46.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
345
|
+
blaxel-0.1.12rc46.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
|
346
|
+
blaxel-0.1.12rc46.dist-info/RECORD,,
|
@@ -1,45 +0,0 @@
|
|
1
|
-
from typing import Any, TypeVar
|
2
|
-
|
3
|
-
from attrs import define as _attrs_define
|
4
|
-
from attrs import field as _attrs_field
|
5
|
-
|
6
|
-
T = TypeVar("T", bound="GetProcessIdentifierLogsStreamResponse200")
|
7
|
-
|
8
|
-
|
9
|
-
@_attrs_define
|
10
|
-
class GetProcessIdentifierLogsStreamResponse200:
|
11
|
-
""" """
|
12
|
-
|
13
|
-
additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict)
|
14
|
-
|
15
|
-
def to_dict(self) -> dict[str, Any]:
|
16
|
-
field_dict: dict[str, Any] = {}
|
17
|
-
field_dict.update(self.additional_properties)
|
18
|
-
|
19
|
-
return field_dict
|
20
|
-
|
21
|
-
@classmethod
|
22
|
-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
|
23
|
-
if not src_dict:
|
24
|
-
return None
|
25
|
-
d = src_dict.copy()
|
26
|
-
get_process_identifier_logs_stream_response_200 = cls()
|
27
|
-
|
28
|
-
get_process_identifier_logs_stream_response_200.additional_properties = d
|
29
|
-
return get_process_identifier_logs_stream_response_200
|
30
|
-
|
31
|
-
@property
|
32
|
-
def additional_keys(self) -> list[str]:
|
33
|
-
return list(self.additional_properties.keys())
|
34
|
-
|
35
|
-
def __getitem__(self, key: str) -> str:
|
36
|
-
return self.additional_properties[key]
|
37
|
-
|
38
|
-
def __setitem__(self, key: str, value: str) -> None:
|
39
|
-
self.additional_properties[key] = value
|
40
|
-
|
41
|
-
def __delitem__(self, key: str) -> None:
|
42
|
-
del self.additional_properties[key]
|
43
|
-
|
44
|
-
def __contains__(self, key: str) -> bool:
|
45
|
-
return key in self.additional_properties
|
File without changes
|
File without changes
|