scalebox-sdk 0.1.14__py3-none-any.whl → 0.1.16__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.
- scalebox/__init__.py +1 -1
- scalebox/code_interpreter/code_interpreter_async.py +370 -369
- scalebox/code_interpreter/code_interpreter_sync.py +318 -317
- scalebox/csx_desktop/main.py +8 -8
- scalebox/test/CODE_INTERPRETER_TESTS_READY.md +256 -256
- scalebox/test/README.md +164 -164
- scalebox/version.py +2 -2
- {scalebox_sdk-0.1.14.dist-info → scalebox_sdk-0.1.16.dist-info}/METADATA +98 -95
- {scalebox_sdk-0.1.14.dist-info → scalebox_sdk-0.1.16.dist-info}/RECORD +13 -13
- {scalebox_sdk-0.1.14.dist-info → scalebox_sdk-0.1.16.dist-info}/WHEEL +0 -0
- {scalebox_sdk-0.1.14.dist-info → scalebox_sdk-0.1.16.dist-info}/entry_points.txt +0 -0
- {scalebox_sdk-0.1.14.dist-info → scalebox_sdk-0.1.16.dist-info}/licenses/LICENSE +0 -0
- {scalebox_sdk-0.1.14.dist-info → scalebox_sdk-0.1.16.dist-info}/top_level.txt +0 -0
scalebox/test/README.md
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
# ScaleBox Sandbox
|
|
1
|
+
# ScaleBox Sandbox Verification Test Suite
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This test suite contains comprehensive validation examples for the `sandbox_async` and `sandbox_sync` modules, covering everything from basic functionality to advanced use cases.
|
|
4
4
|
|
|
5
|
-
## 📋
|
|
5
|
+
## 📋 Test Files Overview
|
|
6
6
|
|
|
7
|
-
### 1.
|
|
7
|
+
### 1. Basic Functionality Verification
|
|
8
8
|
|
|
9
9
|
#### `test_sandbox_async_comprehensive.py`
|
|
10
|
-
|
|
11
|
-
- ✅
|
|
12
|
-
- ✅
|
|
13
|
-
- ✅
|
|
14
|
-
- ✅
|
|
15
|
-
- ✅
|
|
16
|
-
- ✅
|
|
17
|
-
- ✅
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
**Asynchronous Sandbox Comprehensive Verification Tests**
|
|
11
|
+
- ✅ Sandbox lifecycle management (create, connect, destroy)
|
|
12
|
+
- ✅ Filesystem operations (read/write, list, delete, rename, etc.)
|
|
13
|
+
- ✅ Command execution (foreground, background, PTY)
|
|
14
|
+
- ✅ Static methods and class methods
|
|
15
|
+
- ✅ Error handling and exception cases
|
|
16
|
+
- ✅ Performance testing and concurrent operations
|
|
17
|
+
- ✅ Context manager usage
|
|
18
|
+
|
|
19
|
+
**Run with:**
|
|
20
20
|
```bash
|
|
21
21
|
cd /home/ubuntu/git_home/scalebox/test
|
|
22
22
|
python test_sandbox_async_comprehensive.py
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
#### `test_sandbox_sync_comprehensive.py`
|
|
26
|
-
|
|
27
|
-
- ✅
|
|
28
|
-
- ✅
|
|
29
|
-
- ✅
|
|
30
|
-
- ✅
|
|
26
|
+
**Synchronous Sandbox Comprehensive Verification Tests**
|
|
27
|
+
- ✅ Same functionality coverage as async version
|
|
28
|
+
- ✅ Synchronous-specific operation modes
|
|
29
|
+
- ✅ Thread pool concurrent processing
|
|
30
|
+
- ✅ Directory monitoring functionality
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
**Run with:**
|
|
33
33
|
```bash
|
|
34
34
|
cd /home/ubuntu/git_home/scalebox/test
|
|
35
35
|
python test_sandbox_sync_comprehensive.py
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
### 2.
|
|
38
|
+
### 2. Stress Testing and Edge Cases
|
|
39
39
|
|
|
40
40
|
#### `test_sandbox_stress_and_edge_cases.py`
|
|
41
|
-
|
|
42
|
-
- 🔥
|
|
43
|
-
- 🔥
|
|
44
|
-
- 🔥
|
|
45
|
-
- 🔥
|
|
46
|
-
- 🔥
|
|
47
|
-
- 🔥
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
**Stress Testing and Edge Case Verification**
|
|
42
|
+
- 🔥 Large file handling (10MB+ files)
|
|
43
|
+
- 🔥 High concurrency operations (sync and async)
|
|
44
|
+
- 🔥 Memory stress testing (1000+ file operations)
|
|
45
|
+
- 🔥 Edge case testing (empty files, special characters, deep directories)
|
|
46
|
+
- 🔥 Error recovery capability testing
|
|
47
|
+
- 🔥 Resource management testing (multiple sandbox instances)
|
|
48
|
+
|
|
49
|
+
**Run with:**
|
|
50
50
|
```bash
|
|
51
51
|
cd /home/ubuntu/git_home/scalebox/test
|
|
52
52
|
python test_sandbox_stress_and_edge_cases.py
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
### 3.
|
|
55
|
+
### 3. Real-World Application Examples
|
|
56
56
|
|
|
57
57
|
#### `test_sandbox_usage_examples.py`
|
|
58
|
-
|
|
59
|
-
- 💡
|
|
60
|
-
- 💡
|
|
61
|
-
- 💡
|
|
62
|
-
- 💡
|
|
63
|
-
- 💡
|
|
64
|
-
- 💡
|
|
65
|
-
- 💡
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
**Usage Examples and Best Practices**
|
|
59
|
+
- 💡 Code execution service implementation
|
|
60
|
+
- 💡 File processing service implementation
|
|
61
|
+
- 💡 Interactive session management
|
|
62
|
+
- 💡 Performance optimization techniques
|
|
63
|
+
- 💡 Resource management best practices
|
|
64
|
+
- 💡 Error handling strategies
|
|
65
|
+
- 💡 Concurrency and asynchronous programming patterns
|
|
66
|
+
|
|
67
|
+
**Run with:**
|
|
68
68
|
```bash
|
|
69
69
|
cd /home/ubuntu/git_home/scalebox/test
|
|
70
70
|
python test_sandbox_usage_examples.py
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
## 🏗️
|
|
73
|
+
## 🏗️ Test Architecture Design
|
|
74
74
|
|
|
75
|
-
###
|
|
76
|
-
|
|
75
|
+
### Test Result Recording System
|
|
76
|
+
Each test suite includes a complete test result recording system:
|
|
77
77
|
```python
|
|
78
78
|
class TestValidator:
|
|
79
79
|
def log_test_result(self, test_name: str, success: bool, message: str = "", duration: float = 0)
|
|
@@ -81,8 +81,8 @@ class TestValidator:
|
|
|
81
81
|
def print_summary(self)
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
###
|
|
85
|
-
|
|
84
|
+
### Resource Management System
|
|
85
|
+
Intelligent sandbox resource management:
|
|
86
86
|
```python
|
|
87
87
|
class SandboxManager:
|
|
88
88
|
@contextmanager
|
|
@@ -93,116 +93,116 @@ class AsyncSandboxManager:
|
|
|
93
93
|
async def get_sandbox(self, sandbox_id: Optional[str] = None)
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
###
|
|
97
|
-
|
|
96
|
+
### Retry Mechanism
|
|
97
|
+
Built-in retry decorators:
|
|
98
98
|
```python
|
|
99
99
|
@retry_on_failure(max_retries=3, delay=1.0)
|
|
100
100
|
def your_function():
|
|
101
|
-
#
|
|
101
|
+
# Auto-retry failed operations
|
|
102
102
|
pass
|
|
103
103
|
|
|
104
104
|
@async_retry_on_failure(max_retries=3, delay=1.0)
|
|
105
105
|
async def your_async_function():
|
|
106
|
-
#
|
|
106
|
+
# Asynchronous retry mechanism
|
|
107
107
|
pass
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
## 📊
|
|
111
|
-
|
|
112
|
-
###
|
|
113
|
-
|
|
|
114
|
-
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
| PTY
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
124
|
-
###
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
131
|
-
|
|
132
|
-
## 🚀
|
|
133
|
-
|
|
134
|
-
### 1.
|
|
135
|
-
|
|
110
|
+
## 📊 Test Coverage
|
|
111
|
+
|
|
112
|
+
### Functionality Coverage
|
|
113
|
+
| Functional Module | Sync Tests | Async Tests | Stress Tests | Usage Examples |
|
|
114
|
+
|-------------------|------------|-------------|--------------|----------------|
|
|
115
|
+
| Sandbox Create/Destroy | ✅ | ✅ | ✅ | ✅ |
|
|
116
|
+
| Filesystem Operations | ✅ | ✅ | ✅ | ✅ |
|
|
117
|
+
| Command Execution | ✅ | ✅ | ✅ | ✅ |
|
|
118
|
+
| PTY Operations | ✅ | ✅ | ✅ | ✅ |
|
|
119
|
+
| Static Methods | ✅ | ✅ | ✅ | ✅ |
|
|
120
|
+
| Error Handling | ✅ | ✅ | ✅ | ✅ |
|
|
121
|
+
| Performance Optimization | ✅ | ✅ | ✅ | ✅ |
|
|
122
|
+
| Concurrent Processing | ✅ | ✅ | ✅ | ✅ |
|
|
123
|
+
|
|
124
|
+
### Test Scenarios
|
|
125
|
+
- **Basic Functionality**: Correctness verification of single operations
|
|
126
|
+
- **Batch Operations**: Batch processing capability for large amounts of data
|
|
127
|
+
- **Concurrent Processing**: Multi-task parallel execution
|
|
128
|
+
- **Error Recovery**: System stability under exceptional circumstances
|
|
129
|
+
- **Resource Management**: Effective management of memory and connections
|
|
130
|
+
- **Performance Benchmarks**: Performance metrics for various operations
|
|
131
|
+
|
|
132
|
+
## 🚀 Quick Start
|
|
133
|
+
|
|
134
|
+
### 1. Environment Preparation
|
|
135
|
+
Ensure necessary dependencies are installed in your environment:
|
|
136
136
|
```bash
|
|
137
|
-
#
|
|
137
|
+
# Ensure module path is correct
|
|
138
138
|
export PYTHONPATH=/home/ubuntu/git_home/scalebox:$PYTHONPATH
|
|
139
139
|
|
|
140
|
-
#
|
|
140
|
+
# Install dependencies (if needed)
|
|
141
141
|
pip install -r requirements.txt
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
### 2.
|
|
144
|
+
### 2. Run Individual Tests
|
|
145
145
|
```bash
|
|
146
|
-
#
|
|
146
|
+
# Run async comprehensive tests
|
|
147
147
|
python test_sandbox_async_comprehensive.py
|
|
148
148
|
|
|
149
|
-
#
|
|
149
|
+
# Run sync comprehensive tests
|
|
150
150
|
python test_sandbox_sync_comprehensive.py
|
|
151
151
|
|
|
152
|
-
#
|
|
152
|
+
# Run stress tests
|
|
153
153
|
python test_sandbox_stress_and_edge_cases.py
|
|
154
154
|
|
|
155
|
-
#
|
|
155
|
+
# Run usage examples
|
|
156
156
|
python test_sandbox_usage_examples.py
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
### 3.
|
|
159
|
+
### 3. Run All Tests in Batch
|
|
160
160
|
```bash
|
|
161
|
-
#
|
|
161
|
+
# Create run script
|
|
162
162
|
cat > run_all_tests.sh << 'EOF'
|
|
163
163
|
#!/bin/bash
|
|
164
164
|
|
|
165
|
-
echo "
|
|
165
|
+
echo "Starting all sandbox tests..."
|
|
166
166
|
|
|
167
|
-
echo "===
|
|
167
|
+
echo "=== Async Comprehensive Tests ==="
|
|
168
168
|
python test_sandbox_async_comprehensive.py
|
|
169
169
|
|
|
170
|
-
echo "===
|
|
170
|
+
echo "=== Sync Comprehensive Tests ==="
|
|
171
171
|
python test_sandbox_sync_comprehensive.py
|
|
172
172
|
|
|
173
|
-
echo "===
|
|
173
|
+
echo "=== Stress Tests and Edge Cases ==="
|
|
174
174
|
python test_sandbox_stress_and_edge_cases.py
|
|
175
175
|
|
|
176
|
-
echo "===
|
|
176
|
+
echo "=== Usage Examples and Best Practices ==="
|
|
177
177
|
python test_sandbox_usage_examples.py
|
|
178
178
|
|
|
179
|
-
echo "
|
|
179
|
+
echo "All tests completed!"
|
|
180
180
|
EOF
|
|
181
181
|
|
|
182
182
|
chmod +x run_all_tests.sh
|
|
183
183
|
./run_all_tests.sh
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
## 📈
|
|
186
|
+
## 📈 Performance Benchmarks
|
|
187
187
|
|
|
188
|
-
###
|
|
188
|
+
### Sync vs Async Performance Comparison
|
|
189
189
|
|
|
190
|
-
|
|
|
191
|
-
|
|
192
|
-
|
|
|
193
|
-
|
|
|
194
|
-
|
|
|
195
|
-
| PTY
|
|
190
|
+
| Operation Type | Sync Version | Async Version | Performance Improvement |
|
|
191
|
+
|----------------|--------------|---------------|------------------------|
|
|
192
|
+
| Single File Operation | ~0.1s | ~0.1s | Equal |
|
|
193
|
+
| Batch File Operations (100) | ~2.0s | ~0.5s | **4x faster** |
|
|
194
|
+
| Concurrent Command Execution (10) | ~1.5s | ~0.3s | **5x faster** |
|
|
195
|
+
| PTY Interactive Session | ~0.2s | ~0.2s | Equal |
|
|
196
196
|
|
|
197
|
-
###
|
|
198
|
-
-
|
|
199
|
-
- **CPU
|
|
200
|
-
-
|
|
197
|
+
### Resource Usage
|
|
198
|
+
- **Memory Usage**: Async version uses memory more efficiently during large batch operations
|
|
199
|
+
- **CPU Utilization**: Async version better utilizes multi-core CPUs
|
|
200
|
+
- **Network Connections**: Async version supports more concurrent connections
|
|
201
201
|
|
|
202
|
-
## 🛠️
|
|
202
|
+
## 🛠️ Custom Testing
|
|
203
203
|
|
|
204
|
-
###
|
|
205
|
-
1.
|
|
204
|
+
### Adding New Tests
|
|
205
|
+
1. **Inherit Test Base Class**:
|
|
206
206
|
```python
|
|
207
207
|
class YourTestValidator:
|
|
208
208
|
def __init__(self):
|
|
@@ -210,32 +210,32 @@ class YourTestValidator:
|
|
|
210
210
|
self.failed_tests = []
|
|
211
211
|
|
|
212
212
|
def log_test_result(self, test_name: str, success: bool, message: str = "", duration: float = 0):
|
|
213
|
-
#
|
|
213
|
+
# Implement test result recording
|
|
214
214
|
pass
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
-
2.
|
|
217
|
+
2. **Write Test Methods**:
|
|
218
218
|
```python
|
|
219
219
|
def test_your_feature(self):
|
|
220
|
-
"""
|
|
221
|
-
#
|
|
220
|
+
"""Test your functionality"""
|
|
221
|
+
# Test logic
|
|
222
222
|
pass
|
|
223
223
|
|
|
224
224
|
async def test_your_async_feature(self):
|
|
225
|
-
"""
|
|
226
|
-
#
|
|
225
|
+
"""Test your async functionality"""
|
|
226
|
+
# Async test logic
|
|
227
227
|
pass
|
|
228
228
|
```
|
|
229
229
|
|
|
230
|
-
3.
|
|
230
|
+
3. **Run Tests**:
|
|
231
231
|
```python
|
|
232
232
|
def run_all_tests(self):
|
|
233
233
|
self.run_test(self.test_your_feature, "Your Feature Test")
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
###
|
|
236
|
+
### Configure Test Parameters
|
|
237
237
|
```python
|
|
238
|
-
#
|
|
238
|
+
# Configure at top of test file
|
|
239
239
|
TEST_CONFIG = {
|
|
240
240
|
'debug_mode': True,
|
|
241
241
|
'max_concurrent': 10,
|
|
@@ -245,85 +245,85 @@ TEST_CONFIG = {
|
|
|
245
245
|
}
|
|
246
246
|
```
|
|
247
247
|
|
|
248
|
-
## 🐛
|
|
248
|
+
## 🐛 Troubleshooting
|
|
249
249
|
|
|
250
|
-
###
|
|
250
|
+
### Common Issues
|
|
251
251
|
|
|
252
|
-
1.
|
|
253
|
-
-
|
|
254
|
-
-
|
|
255
|
-
-
|
|
252
|
+
1. **Sandbox Creation Failure**
|
|
253
|
+
- Check network connection
|
|
254
|
+
- Verify API key configuration
|
|
255
|
+
- Confirm server status
|
|
256
256
|
|
|
257
|
-
2.
|
|
258
|
-
-
|
|
259
|
-
-
|
|
260
|
-
-
|
|
257
|
+
2. **File Operation Failure**
|
|
258
|
+
- Check file path permissions
|
|
259
|
+
- Verify disk space
|
|
260
|
+
- Confirm file format
|
|
261
261
|
|
|
262
|
-
3.
|
|
263
|
-
-
|
|
264
|
-
-
|
|
265
|
-
-
|
|
262
|
+
3. **Command Execution Timeout**
|
|
263
|
+
- Adjust timeout parameters
|
|
264
|
+
- Check command syntax
|
|
265
|
+
- Verify environment variables
|
|
266
266
|
|
|
267
|
-
4.
|
|
268
|
-
-
|
|
269
|
-
-
|
|
270
|
-
-
|
|
267
|
+
4. **Out of Memory Errors**
|
|
268
|
+
- Reduce concurrency count
|
|
269
|
+
- Adjust batch size
|
|
270
|
+
- Increase system memory
|
|
271
271
|
|
|
272
|
-
###
|
|
272
|
+
### Debugging Tips
|
|
273
273
|
|
|
274
|
-
1.
|
|
274
|
+
1. **Enable Debug Logging**:
|
|
275
275
|
```python
|
|
276
276
|
import logging
|
|
277
277
|
logging.basicConfig(level=logging.DEBUG)
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
-
2.
|
|
280
|
+
2. **Use Debug Mode**:
|
|
281
281
|
```python
|
|
282
282
|
sandbox = Sandbox(debug=True)
|
|
283
|
-
#
|
|
283
|
+
# or
|
|
284
284
|
sandbox = await AsyncSandbox.create(debug=True)
|
|
285
285
|
```
|
|
286
286
|
|
|
287
|
-
3.
|
|
287
|
+
3. **Monitor Resource Usage**:
|
|
288
288
|
```python
|
|
289
289
|
import psutil
|
|
290
|
-
print(f"
|
|
291
|
-
print(f"CPU
|
|
290
|
+
print(f"Memory usage: {psutil.virtual_memory().percent}%")
|
|
291
|
+
print(f"CPU usage: {psutil.cpu_percent()}%")
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
## 📝
|
|
294
|
+
## 📝 Contribution Guidelines
|
|
295
295
|
|
|
296
|
-
###
|
|
297
|
-
1. Fork
|
|
298
|
-
2.
|
|
299
|
-
3.
|
|
300
|
-
4.
|
|
301
|
-
5.
|
|
296
|
+
### Adding New Tests
|
|
297
|
+
1. Fork the project
|
|
298
|
+
2. Create a feature branch
|
|
299
|
+
3. Add test cases
|
|
300
|
+
4. Update documentation
|
|
301
|
+
5. Submit a Pull Request
|
|
302
302
|
|
|
303
|
-
###
|
|
304
|
-
-
|
|
305
|
-
-
|
|
306
|
-
-
|
|
307
|
-
-
|
|
308
|
-
-
|
|
303
|
+
### Testing Standards
|
|
304
|
+
- Each test function should have clear docstrings
|
|
305
|
+
- Use assertions to verify results
|
|
306
|
+
- Include appropriate error handling
|
|
307
|
+
- Record performance metrics
|
|
308
|
+
- Clean up test resources
|
|
309
309
|
|
|
310
|
-
## 📚
|
|
310
|
+
## 📚 References
|
|
311
311
|
|
|
312
|
-
### API
|
|
312
|
+
### API Documentation
|
|
313
313
|
- [AsyncSandbox API](../sandbox_async/main.py)
|
|
314
314
|
- [Sandbox API](../sandbox_sync/main.py)
|
|
315
|
-
- [
|
|
316
|
-
- [
|
|
315
|
+
- [Filesystem API](../sandbox/filesystem/)
|
|
316
|
+
- [Command Execution API](../sandbox/commands/)
|
|
317
317
|
|
|
318
|
-
###
|
|
319
|
-
-
|
|
320
|
-
-
|
|
321
|
-
-
|
|
322
|
-
-
|
|
323
|
-
-
|
|
318
|
+
### Best Practices
|
|
319
|
+
- Always use context managers to manage sandbox resources
|
|
320
|
+
- Batch operations are better than individual operations
|
|
321
|
+
- Async version is suitable for I/O-intensive tasks
|
|
322
|
+
- Sync version is suitable for CPU-intensive tasks
|
|
323
|
+
- Implement appropriate retry and error recovery mechanisms
|
|
324
324
|
|
|
325
325
|
---
|
|
326
326
|
|
|
327
327
|
**Happy Testing! 🎉**
|
|
328
328
|
|
|
329
|
-
|
|
329
|
+
For questions or suggestions, please submit an Issue or contact the maintenance team.
|