blaxel 0.2.1rc77__py3-none-any.whl → 0.2.2__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/core/sandbox/sandbox.py +25 -13
- blaxel/core/sandbox/types.py +50 -2
- blaxel/googleadk/tools.py +0 -1
- {blaxel-0.2.1rc77.dist-info → blaxel-0.2.2.dist-info}/METADATA +1 -1
- {blaxel-0.2.1rc77.dist-info → blaxel-0.2.2.dist-info}/RECORD +7 -7
- {blaxel-0.2.1rc77.dist-info → blaxel-0.2.2.dist-info}/WHEEL +0 -0
- {blaxel-0.2.1rc77.dist-info → blaxel-0.2.2.dist-info}/licenses/LICENSE +0 -0
blaxel/core/sandbox/sandbox.py
CHANGED
@@ -10,6 +10,7 @@ from ..client.api.compute.get_sandbox import asyncio as get_sandbox
|
|
10
10
|
from ..client.api.compute.list_sandboxes import asyncio as list_sandboxes
|
11
11
|
from ..client.client import client
|
12
12
|
from ..client.models import Metadata, Runtime, Sandbox, SandboxSpec
|
13
|
+
from ..client.types import UNSET
|
13
14
|
from .filesystem import SandboxFileSystem
|
14
15
|
from .network import SandboxNetwork
|
15
16
|
from .preview import SandboxPreviews
|
@@ -76,13 +77,20 @@ class SandboxInstance:
|
|
76
77
|
default_image = "blaxel/prod-base:latest"
|
77
78
|
default_memory = 4096
|
78
79
|
|
79
|
-
# Handle SandboxCreateConfiguration or simple dict with name/image/memory keys
|
80
|
-
if
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
# Handle SandboxCreateConfiguration or simple dict with name/image/memory/ports/envs keys
|
81
|
+
if (
|
82
|
+
sandbox is None
|
83
|
+
or isinstance(sandbox, SandboxCreateConfiguration | dict)
|
84
|
+
and (
|
85
|
+
not isinstance(sandbox, Sandbox)
|
86
|
+
and (
|
87
|
+
sandbox is None
|
88
|
+
or "name" in (sandbox if isinstance(sandbox, dict) else sandbox.__dict__)
|
89
|
+
or "image" in (sandbox if isinstance(sandbox, dict) else sandbox.__dict__)
|
90
|
+
or "memory" in (sandbox if isinstance(sandbox, dict) else sandbox.__dict__)
|
91
|
+
or "ports" in (sandbox if isinstance(sandbox, dict) else sandbox.__dict__)
|
92
|
+
or "envs" in (sandbox if isinstance(sandbox, dict) else sandbox.__dict__)
|
93
|
+
)
|
86
94
|
)
|
87
95
|
):
|
88
96
|
if sandbox is None:
|
@@ -94,11 +102,15 @@ class SandboxInstance:
|
|
94
102
|
name = sandbox.name or default_name
|
95
103
|
image = sandbox.image or default_image
|
96
104
|
memory = sandbox.memory or default_memory
|
105
|
+
ports = sandbox._normalize_ports() or UNSET
|
106
|
+
envs = sandbox._normalize_envs() or UNSET
|
97
107
|
|
98
108
|
# Create full Sandbox object
|
99
109
|
sandbox = Sandbox(
|
100
110
|
metadata=Metadata(name=name),
|
101
|
-
spec=SandboxSpec(
|
111
|
+
spec=SandboxSpec(
|
112
|
+
runtime=Runtime(image=image, memory=memory, ports=ports, envs=envs, generation="mk3")
|
113
|
+
),
|
102
114
|
)
|
103
115
|
else:
|
104
116
|
# Handle existing Sandbox object or dict conversion
|
@@ -107,7 +119,7 @@ class SandboxInstance:
|
|
107
119
|
|
108
120
|
# Set defaults for missing fields
|
109
121
|
if not sandbox.metadata:
|
110
|
-
sandbox.metadata = Metadata(name=uuid.uuid4().hex.replace(
|
122
|
+
sandbox.metadata = Metadata(name=uuid.uuid4().hex.replace("-", ""))
|
111
123
|
if not sandbox.spec:
|
112
124
|
sandbox.spec = SandboxSpec(runtime=Runtime(image=default_image))
|
113
125
|
if not sandbox.spec.runtime:
|
@@ -154,10 +166,10 @@ class SandboxInstance:
|
|
154
166
|
if isinstance(sandbox, SandboxCreateConfiguration):
|
155
167
|
name = sandbox.name
|
156
168
|
elif isinstance(sandbox, dict):
|
157
|
-
if
|
158
|
-
name = sandbox[
|
159
|
-
elif
|
160
|
-
name = sandbox[
|
169
|
+
if "name" in sandbox:
|
170
|
+
name = sandbox["name"]
|
171
|
+
elif "metadata" in sandbox and isinstance(sandbox["metadata"], dict):
|
172
|
+
name = sandbox["metadata"].get("name")
|
161
173
|
else:
|
162
174
|
# If no name provided, we can't check if it exists, so create new
|
163
175
|
return await cls.create(sandbox)
|
blaxel/core/sandbox/types.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
from datetime import datetime
|
2
|
-
from typing import Any, Dict, Optional
|
2
|
+
from typing import Any, Dict, List, Optional, Union
|
3
3
|
|
4
|
-
from ..client.models import Sandbox
|
4
|
+
from ..client.models import Port, Sandbox
|
5
|
+
from ..client.types import UNSET
|
5
6
|
|
6
7
|
|
7
8
|
class SessionCreateOptions:
|
@@ -105,15 +106,20 @@ class CopyResponse:
|
|
105
106
|
|
106
107
|
class SandboxCreateConfiguration:
|
107
108
|
"""Simplified configuration for creating sandboxes with default values."""
|
109
|
+
|
108
110
|
def __init__(
|
109
111
|
self,
|
110
112
|
name: Optional[str] = None,
|
111
113
|
image: Optional[str] = None,
|
112
114
|
memory: Optional[int] = None,
|
115
|
+
ports: Optional[Union[List[Port], List[Dict[str, Any]]]] = None,
|
116
|
+
envs: Optional[List[Dict[str, str]]] = None,
|
113
117
|
):
|
114
118
|
self.name = name
|
115
119
|
self.image = image
|
116
120
|
self.memory = memory
|
121
|
+
self.ports = ports
|
122
|
+
self.envs = envs
|
117
123
|
|
118
124
|
@classmethod
|
119
125
|
def from_dict(cls, data: Dict[str, Any]) -> "SandboxCreateConfiguration":
|
@@ -121,4 +127,46 @@ class SandboxCreateConfiguration:
|
|
121
127
|
name=data.get("name"),
|
122
128
|
image=data.get("image"),
|
123
129
|
memory=data.get("memory"),
|
130
|
+
ports=data.get("ports"),
|
131
|
+
envs=data.get("envs"),
|
124
132
|
)
|
133
|
+
|
134
|
+
def _normalize_ports(self) -> Optional[List[Port]]:
|
135
|
+
"""Convert ports to Port objects with default protocol HTTP if not specified."""
|
136
|
+
if not self.ports:
|
137
|
+
return None
|
138
|
+
|
139
|
+
port_objects = []
|
140
|
+
for port in self.ports:
|
141
|
+
if isinstance(port, Port):
|
142
|
+
# If it's already a Port object, ensure protocol defaults to HTTP
|
143
|
+
if port.protocol is UNSET or not port.protocol:
|
144
|
+
port.protocol = "HTTP"
|
145
|
+
port_objects.append(port)
|
146
|
+
elif isinstance(port, dict):
|
147
|
+
# Convert dict to Port object with HTTP as default protocol
|
148
|
+
port_dict = port.copy()
|
149
|
+
if "protocol" not in port_dict or not port_dict["protocol"]:
|
150
|
+
port_dict["protocol"] = "HTTP"
|
151
|
+
port_objects.append(Port.from_dict(port_dict))
|
152
|
+
else:
|
153
|
+
raise ValueError(f"Invalid port type: {type(port)}. Expected Port object or dict.")
|
154
|
+
|
155
|
+
return port_objects
|
156
|
+
|
157
|
+
def _normalize_envs(self) -> Optional[List[Dict[str, str]]]:
|
158
|
+
"""Convert envs to list of dicts with name and value keys."""
|
159
|
+
if not self.envs:
|
160
|
+
return None
|
161
|
+
|
162
|
+
env_objects = []
|
163
|
+
for env in self.envs:
|
164
|
+
if isinstance(env, dict):
|
165
|
+
# Validate that the dict has the required keys
|
166
|
+
if "name" not in env or "value" not in env:
|
167
|
+
raise ValueError(f"Environment variable dict must have 'name' and 'value' keys: {env}")
|
168
|
+
env_objects.append({"name": env["name"], "value": env["value"]})
|
169
|
+
else:
|
170
|
+
raise ValueError(f"Invalid env type: {type(env)}. Expected dict with 'name' and 'value' keys.")
|
171
|
+
|
172
|
+
return env_objects
|
blaxel/googleadk/tools.py
CHANGED
@@ -69,4 +69,3 @@ async def bl_tools(tools_names: list[str], **kwargs: Any) -> list[BaseTool]:
|
|
69
69
|
tools = bl_tools_core(tools_names, **kwargs)
|
70
70
|
await tools.initialize()
|
71
71
|
return [GoogleADKTool(tool) for tool in tools.get_tools()]
|
72
|
-
return [GoogleADKTool(tool) for tool in tools.get_tools()]
|
@@ -310,9 +310,9 @@ blaxel/core/sandbox/filesystem.py,sha256=dyIvDdlPZO0ijD6mXXX8Yl0t75VijQ6_uMz_9rJ
|
|
310
310
|
blaxel/core/sandbox/network.py,sha256=P5jLd4AAg1zgyIK4qGWvZaDZ5BzIcxRx2ffz_JLsLMI,357
|
311
311
|
blaxel/core/sandbox/preview.py,sha256=M6FulOxPghUBpb5fLxu1Rd3ekLeCbZ_dgt4s1X2Cneo,5354
|
312
312
|
blaxel/core/sandbox/process.py,sha256=7zEngDTs2XiNsMm9TZ4lEDUiRpS3af8dw60pEvRuHDY,8357
|
313
|
-
blaxel/core/sandbox/sandbox.py,sha256=
|
313
|
+
blaxel/core/sandbox/sandbox.py,sha256=y6mV2-i6TsSZGQsvBBGptR514OfgvhV0hXBMEsOBcsY,8648
|
314
314
|
blaxel/core/sandbox/session.py,sha256=4SH1tyXcQ9UqJx4lMwxAlp7x9Te_anDrdSEG6AlNkvU,4496
|
315
|
-
blaxel/core/sandbox/types.py,sha256=
|
315
|
+
blaxel/core/sandbox/types.py,sha256=nsbvZLUxvDZkg2oExE3HdXx2qIpPaaoa7_lGYBzQ8Xk,5638
|
316
316
|
blaxel/core/sandbox/client/__init__.py,sha256=N26bD5o1jsTb48oExow6Rgivd8ylaU9jaWZfZsVilP8,128
|
317
317
|
blaxel/core/sandbox/client/client.py,sha256=tcP8cJ4Q3dV9aB3yQ01dDXO-ekfsa3WGGFz4DQAEf8I,7079
|
318
318
|
blaxel/core/sandbox/client/errors.py,sha256=gO8GBmKqmSNgAg-E5oT-oOyxztvp7V_6XG7OUTT15q0,546
|
@@ -365,7 +365,7 @@ blaxel/crewai/tools.py,sha256=wMMZvSrmhuoFRFux2j31PeSVMbElhs5e49jtvRNxZxY,848
|
|
365
365
|
blaxel/googleadk/__init__.py,sha256=WfYZvtkh5IF042qWLaiWjbDarJZCX9ghHGiTrat8eps,127
|
366
366
|
blaxel/googleadk/model.py,sha256=ZSBGapgcrhRogc1kBFKfuLS36UUkcQL6nZD22yVUEJM,2236
|
367
367
|
blaxel/googleadk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
368
|
-
blaxel/googleadk/tools.py,sha256=
|
368
|
+
blaxel/googleadk/tools.py,sha256=cyV_vRSYYBNw-5zdXQYTeb62ElyCrdGPTj3yUu6pMwU,2265
|
369
369
|
blaxel/langgraph/__init__.py,sha256=lw9d7bl5TsYbemToCtus5P6XnhzR4SAcBWM-1Pffc_U,126
|
370
370
|
blaxel/langgraph/model.py,sha256=B0onMzIRZEc5P6oa3SxLcI42M5_736NLez64lng61DU,2286
|
371
371
|
blaxel/langgraph/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -402,7 +402,7 @@ blaxel/telemetry/instrumentation/map.py,sha256=PCzZJj39yiYVYJrxLBNP-NW-tjjYyTijw
|
|
402
402
|
blaxel/telemetry/instrumentation/utils.py,sha256=KInMYZH-mu9_wvetmf0EmgrfN3Sw8IWk2Y95v2u90_U,1901
|
403
403
|
blaxel/telemetry/log/log.py,sha256=RvQByRjZMoP_dRaAZu8oK6DTegsHs-xV4W-UIqis6CA,2461
|
404
404
|
blaxel/telemetry/log/logger.py,sha256=NPAS3g82ryROjvc_DEZaTIfrcehoLEZoP-JkLxADxc0,4113
|
405
|
-
blaxel-0.2.
|
406
|
-
blaxel-0.2.
|
407
|
-
blaxel-0.2.
|
408
|
-
blaxel-0.2.
|
405
|
+
blaxel-0.2.2.dist-info/METADATA,sha256=PH7unMpL-kREYXRqTdJwkNB7Xkb2sbRh6e2Y09c0BWk,9875
|
406
|
+
blaxel-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
407
|
+
blaxel-0.2.2.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
|
408
|
+
blaxel-0.2.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|