buildfunctions 0.2.1__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.
- buildfunctions/cpu_sandbox.py +2 -3
- buildfunctions/types.py +4 -2
- {buildfunctions-0.2.1.dist-info → buildfunctions-0.2.2.dist-info}/METADATA +49 -69
- {buildfunctions-0.2.1.dist-info → buildfunctions-0.2.2.dist-info}/RECORD +5 -5
- {buildfunctions-0.2.1.dist-info → buildfunctions-0.2.2.dist-info}/WHEEL +0 -0
buildfunctions/cpu_sandbox.py
CHANGED
|
@@ -183,9 +183,8 @@ async def _wait_for_endpoint(endpoint: str, max_attempts: int = 60, delay_ms: in
|
|
|
183
183
|
result = await _https_get_with_ip(ip, hostname, path)
|
|
184
184
|
if 200 <= result["status"] < 500:
|
|
185
185
|
return
|
|
186
|
-
except Exception
|
|
187
|
-
|
|
188
|
-
print(f" Waiting... (attempt {attempt}/{max_attempts})")
|
|
186
|
+
except Exception:
|
|
187
|
+
pass
|
|
189
188
|
|
|
190
189
|
await asyncio.sleep(delay_ms / 1000.0)
|
|
191
190
|
|
buildfunctions/types.py
CHANGED
|
@@ -4,6 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import Any, Awaitable, Callable, Literal, TypedDict
|
|
6
6
|
|
|
7
|
+
from buildfunctions.dotdict import DotDict
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
# Scalar types
|
|
9
11
|
Language = Literal["javascript", "typescript", "python", "go", "shell"]
|
|
@@ -150,8 +152,8 @@ class GPUSandboxConfig(TypedDict, total=False):
|
|
|
150
152
|
model: str | dict[str, str]
|
|
151
153
|
|
|
152
154
|
|
|
153
|
-
# Run result
|
|
154
|
-
class RunResult(
|
|
155
|
+
# Run result - uses DotDict so both result["response"] and result.response work
|
|
156
|
+
class RunResult(DotDict):
|
|
155
157
|
response: Any # The response (parsed JSON object, or raw string if not JSON)
|
|
156
158
|
status: int # HTTP status code
|
|
157
159
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: buildfunctions
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: The Buildfunctions SDK for Agents: Hardware-isolated CPU and GPU Sandboxes for untrusted AI actions
|
|
5
5
|
Project-URL: Homepage, https://www.buildfunctions.com
|
|
6
6
|
Project-URL: Documentation, https://www.buildfunctions.com/docs/sdk/quickstart
|
|
@@ -68,109 +68,89 @@ Get your API token at [buildfunctions.com/settings](https://www.buildfunctions.c
|
|
|
68
68
|
### 2. CPU Function
|
|
69
69
|
|
|
70
70
|
```python
|
|
71
|
-
import asyncio
|
|
72
|
-
import os
|
|
73
71
|
from buildfunctions import Buildfunctions, CPUFunction
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
|
|
73
|
+
client = await Buildfunctions({"apiToken": API_TOKEN})
|
|
77
74
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
deployed_function = await CPUFunction.create({
|
|
76
|
+
"name": "my-cpu-function",
|
|
77
|
+
"code": "./cpu_function_code.py",
|
|
78
|
+
"language": "python",
|
|
79
|
+
"memory": 128,
|
|
80
|
+
"timeout": 30,
|
|
81
|
+
})
|
|
85
82
|
|
|
86
|
-
|
|
83
|
+
print(f"Endpoint: {deployed_function.endpoint}")
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
asyncio.run(main())
|
|
85
|
+
await deployed_function.delete()
|
|
91
86
|
```
|
|
92
87
|
|
|
93
88
|
### 3. CPU Sandbox
|
|
94
89
|
|
|
95
90
|
```python
|
|
96
|
-
import asyncio
|
|
97
|
-
import os
|
|
98
91
|
from buildfunctions import Buildfunctions, CPUSandbox
|
|
99
92
|
|
|
100
|
-
|
|
101
|
-
client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
|
|
102
|
-
|
|
103
|
-
sandbox = await CPUSandbox.create({
|
|
104
|
-
"name": "my-cpu-sandbox",
|
|
105
|
-
"language": "python",
|
|
106
|
-
"code": "/path/to/code/cpu_sandbox_code.py",
|
|
107
|
-
"memory": 128,
|
|
108
|
-
"timeout": 30,
|
|
109
|
-
})
|
|
93
|
+
client = await Buildfunctions({"apiToken": API_TOKEN})
|
|
110
94
|
|
|
111
|
-
|
|
112
|
-
|
|
95
|
+
sandbox = await CPUSandbox.create({
|
|
96
|
+
"name": "my-cpu-sandbox",
|
|
97
|
+
"language": "python",
|
|
98
|
+
"code": "/path/to/code/cpu_sandbox_code.py",
|
|
99
|
+
"memory": 128,
|
|
100
|
+
"timeout": 30,
|
|
101
|
+
})
|
|
113
102
|
|
|
114
|
-
|
|
103
|
+
result = await sandbox.run()
|
|
104
|
+
print(f"Result: {result}")
|
|
115
105
|
|
|
116
|
-
|
|
106
|
+
await sandbox.delete()
|
|
117
107
|
```
|
|
118
108
|
|
|
119
109
|
### 4. GPU Function
|
|
120
110
|
|
|
121
111
|
```python
|
|
122
|
-
import asyncio
|
|
123
|
-
import os
|
|
124
112
|
from buildfunctions import Buildfunctions, GPUFunction
|
|
125
113
|
|
|
126
|
-
|
|
127
|
-
client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
|
|
114
|
+
client = await Buildfunctions({"apiToken": API_TOKEN})
|
|
128
115
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
116
|
+
deployed_function = await GPUFunction.create({
|
|
117
|
+
"name": "my-gpu-function",
|
|
118
|
+
"code": "/path/to/code/gpu_function_code.py",
|
|
119
|
+
"language": "python",
|
|
120
|
+
"gpu": "T4",
|
|
121
|
+
"vcpus": 30,
|
|
122
|
+
"memory": "50000MB",
|
|
123
|
+
"timeout": 300,
|
|
124
|
+
"requirements": ["transformers==4.47.1", "torch", "accelerate"],
|
|
125
|
+
})
|
|
139
126
|
|
|
140
|
-
|
|
127
|
+
print(f"Endpoint: {deployed_function.endpoint}")
|
|
141
128
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
asyncio.run(main())
|
|
129
|
+
await deployed_function.delete()
|
|
145
130
|
```
|
|
146
131
|
|
|
147
132
|
### 5. GPU Sandbox with Local Model
|
|
148
133
|
|
|
149
134
|
```python
|
|
150
|
-
import asyncio
|
|
151
|
-
import os
|
|
152
135
|
from buildfunctions import Buildfunctions, GPUSandbox
|
|
153
136
|
|
|
154
|
-
|
|
155
|
-
client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})
|
|
156
|
-
|
|
157
|
-
sandbox = await GPUSandbox.create({
|
|
158
|
-
"name": "my-gpu-sandbox",
|
|
159
|
-
"language": "python",
|
|
160
|
-
"memory": 10000,
|
|
161
|
-
"timeout": 300,
|
|
162
|
-
"vcpus": 6,
|
|
163
|
-
"code": "./gpu_sandbox_code.py",
|
|
164
|
-
"model": "/path/to/models/Qwen/Qwen3-8B",
|
|
165
|
-
"requirements": "torch",
|
|
166
|
-
})
|
|
137
|
+
client = await Buildfunctions({"apiToken": API_TOKEN})
|
|
167
138
|
|
|
168
|
-
|
|
169
|
-
|
|
139
|
+
sandbox = await GPUSandbox.create({
|
|
140
|
+
"name": "my-gpu-sandbox",
|
|
141
|
+
"language": "python",
|
|
142
|
+
"memory": 10000,
|
|
143
|
+
"timeout": 300,
|
|
144
|
+
"vcpus": 6,
|
|
145
|
+
"code": "./gpu_sandbox_code.py",
|
|
146
|
+
"model": "/path/to/models/Qwen/Qwen3-8B",
|
|
147
|
+
"requirements": "torch",
|
|
148
|
+
})
|
|
170
149
|
|
|
171
|
-
|
|
150
|
+
result = await sandbox.run()
|
|
151
|
+
print(f"Response: {result}")
|
|
172
152
|
|
|
173
|
-
|
|
153
|
+
await sandbox.delete()
|
|
174
154
|
```
|
|
175
155
|
|
|
176
156
|
The SDK is currently in beta.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
buildfunctions/__init__.py,sha256=Pw0XXoJ2DiEw8wSiAsc5FrJXjPmRt9EPSo4Q5_io8K4,3400
|
|
2
2
|
buildfunctions/client.py,sha256=y9_eFe4a9YDdh7IdhAiEDIiwAAnrUJ8-Wl0lZkKI16E,10892
|
|
3
3
|
buildfunctions/cpu_function.py,sha256=PceEsSOqZG58gUoWDJcoo_hzvsY_ZW6WqWNV_j5ZptA,5475
|
|
4
|
-
buildfunctions/cpu_sandbox.py,sha256=
|
|
4
|
+
buildfunctions/cpu_sandbox.py,sha256=QYdYg3y7vcA-jIqN2o4JUMJjzGHOQFGEBG8nQ50UH-w,12469
|
|
5
5
|
buildfunctions/dotdict.py,sha256=0mDiVtLlpRIs9nqY2oUsZQe_tMyMxt8jpznDZFeLX_c,1215
|
|
6
6
|
buildfunctions/errors.py,sha256=WTyodRf2OXpjWICIhIldAFhAMrus95neRTvv3d14Cp8,2769
|
|
7
7
|
buildfunctions/framework.py,sha256=A0DcbLaGlDwh_DrwGbwDc6D2DfyhmtY9sxGct16wKNU,519
|
|
@@ -11,8 +11,8 @@ buildfunctions/http_client.py,sha256=k6mE-0_-JGM1ccx6F0gW7nAJ2S_2iyDGjIa5UtFJS9s
|
|
|
11
11
|
buildfunctions/memory.py,sha256=2R_fgABNfHIc5ImDSlVqTK3theoiFC1zSv6Sls-p5WQ,639
|
|
12
12
|
buildfunctions/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
buildfunctions/resolve_code.py,sha256=zIfNpMqbq9HeJXH4Hp0wsxADR-ZJot5BxaoiATVBFjI,3572
|
|
14
|
-
buildfunctions/types.py,sha256=
|
|
14
|
+
buildfunctions/types.py,sha256=1RkpIBf1XRoPtcozIoKMe2V5ul94xi_x4ApnvsE3x2U,5565
|
|
15
15
|
buildfunctions/uploader.py,sha256=5j99KsgQcZsgl7oaa2zNjYmyZkumSZArAtZ-K47qheA,7016
|
|
16
|
-
buildfunctions-0.2.
|
|
17
|
-
buildfunctions-0.2.
|
|
18
|
-
buildfunctions-0.2.
|
|
16
|
+
buildfunctions-0.2.2.dist-info/METADATA,sha256=xGQUfq51KJpyQDzGMRiJwazdi9sX9aHRSQ6pCmbykeg,4025
|
|
17
|
+
buildfunctions-0.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
18
|
+
buildfunctions-0.2.2.dist-info/RECORD,,
|
|
File without changes
|