blaxel 0.2.1rc76__py3-none-any.whl → 0.2.1rc78__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.
@@ -8,6 +8,7 @@ from .sandbox import (
8
8
  from .types import (
9
9
  CopyResponse,
10
10
  SandboxConfiguration,
11
+ SandboxCreateConfiguration,
11
12
  SandboxFilesystemFile,
12
13
  SessionCreateOptions,
13
14
  SessionWithToken,
@@ -19,6 +20,7 @@ __all__ = [
19
20
  "SessionCreateOptions",
20
21
  "SessionWithToken",
21
22
  "SandboxConfiguration",
23
+ "SandboxCreateConfiguration",
22
24
  "WatchEvent",
23
25
  "SandboxFilesystemFile",
24
26
  "CopyResponse",
@@ -15,7 +15,7 @@ from .network import SandboxNetwork
15
15
  from .preview import SandboxPreviews
16
16
  from .process import SandboxProcess
17
17
  from .session import SandboxSessions
18
- from .types import SandboxConfiguration, SessionWithToken
18
+ from .types import SandboxConfiguration, SandboxCreateConfiguration, SessionWithToken
19
19
 
20
20
  logger = logging.getLogger(__name__)
21
21
 
@@ -69,22 +69,53 @@ class SandboxInstance:
69
69
 
70
70
  @classmethod
71
71
  async def create(
72
- cls, sandbox: Union[Sandbox, Dict[str, Any], None] = None
72
+ cls, sandbox: Union[Sandbox, SandboxCreateConfiguration, Dict[str, Any], None] = None
73
73
  ) -> "SandboxInstance":
74
- if sandbox is None:
75
- sandbox = Sandbox()
76
- if isinstance(sandbox, dict):
77
- sandbox = Sandbox.from_dict(sandbox)
78
- if not sandbox.metadata:
79
- sandbox.metadata = Metadata(name=uuid.uuid4().hex)
80
- if not sandbox.spec:
81
- sandbox.spec = SandboxSpec(runtime=Runtime(image="blaxel/prod-base:latest"))
82
- if not sandbox.spec.runtime:
83
- sandbox.spec.runtime = Runtime(image="blaxel/prod-base:latest")
84
-
85
- sandbox.spec.runtime.image = sandbox.spec.runtime.image or "blaxel/prod-base:latest"
86
- sandbox.spec.runtime.memory = sandbox.spec.runtime.memory or 4096
87
- sandbox.spec.runtime.generation = sandbox.spec.runtime.generation or "mk3"
74
+ # Generate default values
75
+ default_name = f"sandbox-{uuid.uuid4().hex[:8]}"
76
+ default_image = "blaxel/prod-base:latest"
77
+ default_memory = 4096
78
+
79
+ # Handle SandboxCreateConfiguration or simple dict with name/image/memory keys
80
+ if sandbox is None or isinstance(sandbox, (SandboxCreateConfiguration, dict)) and (
81
+ not isinstance(sandbox, Sandbox) and (
82
+ sandbox is None or
83
+ 'name' in (sandbox if isinstance(sandbox, dict) else sandbox.__dict__) or
84
+ 'image' in (sandbox if isinstance(sandbox, dict) else sandbox.__dict__) or
85
+ 'memory' in (sandbox if isinstance(sandbox, dict) else sandbox.__dict__)
86
+ )
87
+ ):
88
+ if sandbox is None:
89
+ sandbox = SandboxCreateConfiguration()
90
+ elif isinstance(sandbox, dict) and not isinstance(sandbox, Sandbox):
91
+ sandbox = SandboxCreateConfiguration.from_dict(sandbox)
92
+
93
+ # Set defaults if not provided
94
+ name = sandbox.name or default_name
95
+ image = sandbox.image or default_image
96
+ memory = sandbox.memory or default_memory
97
+
98
+ # Create full Sandbox object
99
+ sandbox = Sandbox(
100
+ metadata=Metadata(name=name),
101
+ spec=SandboxSpec(runtime=Runtime(image=image, memory=memory, generation="mk3"))
102
+ )
103
+ else:
104
+ # Handle existing Sandbox object or dict conversion
105
+ if isinstance(sandbox, dict):
106
+ sandbox = Sandbox.from_dict(sandbox)
107
+
108
+ # Set defaults for missing fields
109
+ if not sandbox.metadata:
110
+ sandbox.metadata = Metadata(name=uuid.uuid4().hex.replace('-', ''))
111
+ if not sandbox.spec:
112
+ sandbox.spec = SandboxSpec(runtime=Runtime(image=default_image))
113
+ if not sandbox.spec.runtime:
114
+ sandbox.spec.runtime = Runtime(image=default_image, memory=default_memory)
115
+
116
+ sandbox.spec.runtime.image = sandbox.spec.runtime.image or default_image
117
+ sandbox.spec.runtime.memory = sandbox.spec.runtime.memory or default_memory
118
+ sandbox.spec.runtime.generation = sandbox.spec.runtime.generation or "mk3"
88
119
 
89
120
  response = await create_sandbox(
90
121
  client=client,
@@ -115,14 +146,30 @@ class SandboxInstance:
115
146
 
116
147
  @classmethod
117
148
  async def create_if_not_exists(
118
- cls, sandbox: Union[Sandbox, Dict[str, Any]]
149
+ cls, sandbox: Union[Sandbox, SandboxCreateConfiguration, Dict[str, Any]]
119
150
  ) -> "SandboxInstance":
120
151
  """Create a sandbox if it doesn't exist, otherwise return existing."""
121
- if isinstance(sandbox, dict):
122
- sandbox = Sandbox.from_dict(sandbox)
123
-
124
152
  try:
125
- sandbox_instance = await cls.get(sandbox.metadata.name)
153
+ # Extract name from different configuration types
154
+ if isinstance(sandbox, SandboxCreateConfiguration):
155
+ name = sandbox.name
156
+ elif isinstance(sandbox, dict):
157
+ if 'name' in sandbox:
158
+ name = sandbox['name']
159
+ elif 'metadata' in sandbox and isinstance(sandbox['metadata'], dict):
160
+ name = sandbox['metadata'].get('name')
161
+ else:
162
+ # If no name provided, we can't check if it exists, so create new
163
+ return await cls.create(sandbox)
164
+ elif isinstance(sandbox, Sandbox):
165
+ name = sandbox.metadata.name if sandbox.metadata else None
166
+ else:
167
+ name = None
168
+
169
+ if not name:
170
+ raise ValueError("Sandbox name is required")
171
+
172
+ sandbox_instance = await cls.get(name)
126
173
  return sandbox_instance
127
174
  except Exception as e:
128
175
  # Check if it's a 404 error (sandbox not found)
@@ -101,3 +101,24 @@ class CopyResponse:
101
101
  self.message = message
102
102
  self.source = source
103
103
  self.destination = destination
104
+
105
+
106
+ class SandboxCreateConfiguration:
107
+ """Simplified configuration for creating sandboxes with default values."""
108
+ def __init__(
109
+ self,
110
+ name: Optional[str] = None,
111
+ image: Optional[str] = None,
112
+ memory: Optional[int] = None,
113
+ ):
114
+ self.name = name
115
+ self.image = image
116
+ self.memory = memory
117
+
118
+ @classmethod
119
+ def from_dict(cls, data: Dict[str, Any]) -> "SandboxCreateConfiguration":
120
+ return cls(
121
+ name=data.get("name"),
122
+ image=data.get("image"),
123
+ memory=data.get("memory"),
124
+ )
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()]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blaxel
3
- Version: 0.2.1rc76
3
+ Version: 0.2.1rc78
4
4
  Summary: Blaxel - AI development platform SDK
5
5
  Project-URL: Homepage, https://blaxel.ai
6
6
  Project-URL: Documentation, https://docs.blaxel.ai
@@ -304,15 +304,15 @@ blaxel/core/mcp/__init__.py,sha256=5VjkiQFb1QWW5QKRgwPHARlxZJ9Xqaz0diJTpM8LLF0,1
304
304
  blaxel/core/mcp/client.py,sha256=aK3wSnsO8DmT1BZqw4eiCMF71Jwvni6Qga0DhPP806Y,5437
305
305
  blaxel/core/mcp/server.py,sha256=tXySGZKgK3IllYOzYOecp58BixKBkmAIvQp_4nSM_Ww,5919
306
306
  blaxel/core/models/__init__.py,sha256=HbRDsMnUFHkPC-MMkzPXh4mUqkVjqO6p3j7m00N_XSo,1722
307
- blaxel/core/sandbox/__init__.py,sha256=eWTH7PWNQZe9efqParwgXzltc7L4OyPtT_REqCdQybU,551
307
+ blaxel/core/sandbox/__init__.py,sha256=oF3sX5MbwSqfwhOtF5ODYWwapHffbkp2UI78jPBn78U,617
308
308
  blaxel/core/sandbox/action.py,sha256=9Zjkco7YkLzBThD3N2Hr5SpeEiqU_-Ktk8HlKpkpiAg,2802
309
309
  blaxel/core/sandbox/filesystem.py,sha256=dyIvDdlPZO0ijD6mXXX8Yl0t75VijQ6_uMz_9rJd-_4,11317
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=tsRGvkb2dnGM5pmOiIxWvOmT42P9BDXWtW3h6_CIffI,5802
313
+ blaxel/core/sandbox/sandbox.py,sha256=4sG_i_VcuGx_cKEGMY-2eUUuGmtQBYMNIToL7YDuluM,8151
314
314
  blaxel/core/sandbox/session.py,sha256=4SH1tyXcQ9UqJx4lMwxAlp7x9Te_anDrdSEG6AlNkvU,4496
315
- blaxel/core/sandbox/types.py,sha256=gmNAt8x7PrJZHpw2_2aWWDE5uG6H-uEgdIKTYIw4G0g,2981
315
+ blaxel/core/sandbox/types.py,sha256=yaKkp5Sn0b4Ri2_ZbdEjXuA-rjo2_DfDIHYz-cueZCA,3564
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=mgHYc25A82VKYx4VUhV2Nn3XnjSdMgwlBpHJvvq5oEY,2328
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.1rc76.dist-info/METADATA,sha256=9VGgAjrkZM7Xsn5l7Im1K7x2QVwZa8lBcoSiXpmtI2Q,9879
406
- blaxel-0.2.1rc76.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
407
- blaxel-0.2.1rc76.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
408
- blaxel-0.2.1rc76.dist-info/RECORD,,
405
+ blaxel-0.2.1rc78.dist-info/METADATA,sha256=r9IaM_vYSHVywuvDayI47ZwwxFDKCtLXlqGlogLKHps,9879
406
+ blaxel-0.2.1rc78.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
407
+ blaxel-0.2.1rc78.dist-info/licenses/LICENSE,sha256=p5PNQvpvyDT_0aYBDgmV1fFI_vAD2aSV0wWG7VTgRis,1069
408
+ blaxel-0.2.1rc78.dist-info/RECORD,,