swarmauri_evaluator_subprocess 0.3.0.dev48__tar.gz → 0.11.0.dev1__tar.gz
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.
- {swarmauri_evaluator_subprocess-0.3.0.dev48 → swarmauri_evaluator_subprocess-0.11.0.dev1}/PKG-INFO +15 -12
- {swarmauri_evaluator_subprocess-0.3.0.dev48 → swarmauri_evaluator_subprocess-0.11.0.dev1}/README.md +8 -8
- {swarmauri_evaluator_subprocess-0.3.0.dev48 → swarmauri_evaluator_subprocess-0.11.0.dev1}/pyproject.toml +8 -6
- {swarmauri_evaluator_subprocess-0.3.0.dev48 → swarmauri_evaluator_subprocess-0.11.0.dev1}/swarmauri_evaluator_subprocess/SubprocessEvaluator.py +52 -22
- {swarmauri_evaluator_subprocess-0.3.0.dev48 → swarmauri_evaluator_subprocess-0.11.0.dev1}/LICENSE +0 -0
- {swarmauri_evaluator_subprocess-0.3.0.dev48 → swarmauri_evaluator_subprocess-0.11.0.dev1}/swarmauri_evaluator_subprocess/__init__.py +0 -0
{swarmauri_evaluator_subprocess-0.3.0.dev48 → swarmauri_evaluator_subprocess-0.11.0.dev1}/PKG-INFO
RENAMED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: swarmauri_evaluator_subprocess
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0.dev1
|
|
4
4
|
Summary: A subprocess-based evaluator for executing and measuring program performance in isolated subprocesses
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Keywords: subprocess,evaluation,sandboxing,program execution,resource limits,performance measurement,testing,security,swarm,ai,swarmauri,sdk,standards,evaluator
|
|
8
8
|
Author: Jacob Stewart
|
|
9
9
|
Author-email: jacob@swarmauri.com
|
|
10
|
-
Requires-Python: >=3.10,<3.
|
|
10
|
+
Requires-Python: >=3.10,<3.15
|
|
11
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
12
|
Classifier: Natural Language :: English
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
13
|
Classifier: Development Status :: 3 - Alpha
|
|
17
14
|
Classifier: Intended Audience :: Developers
|
|
18
15
|
Classifier: Topic :: Software Development :: Libraries
|
|
@@ -21,26 +18,30 @@ Classifier: Topic :: System :: Monitoring
|
|
|
21
18
|
Classifier: Programming Language :: Python
|
|
22
19
|
Classifier: Programming Language :: Python :: 3
|
|
23
20
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
26
|
Requires-Dist: swarmauri_base
|
|
25
27
|
Requires-Dist: swarmauri_core
|
|
26
28
|
Description-Content-Type: text/markdown
|
|
27
29
|
|
|
28
|
-

|
|
29
31
|
|
|
30
32
|
<p align="center">
|
|
31
|
-
<a href="https://
|
|
32
|
-
<img src="https://
|
|
33
|
+
<a href="https://pepy.tech/project/swarmauri_evaluator_subprocess/">
|
|
34
|
+
<img src="https://static.pepy.tech/badge/swarmauri_evaluator_subprocess/month" alt="PyPI - Downloads"/></a>
|
|
33
35
|
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_subprocess/">
|
|
34
36
|
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_subprocess.svg"/></a>
|
|
35
37
|
<a href="https://pypi.org/project/swarmauri_evaluator_subprocess/">
|
|
36
|
-
<img src="https://img.shields.io/
|
|
38
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
37
39
|
<a href="https://pypi.org/project/swarmauri_evaluator_subprocess/">
|
|
38
40
|
<img src="https://img.shields.io/pypi/l/swarmauri_evaluator_subprocess" alt="PyPI - License"/></a>
|
|
39
41
|
<a href="https://pypi.org/project/swarmauri_evaluator_subprocess/">
|
|
40
42
|
<img src="https://img.shields.io/pypi/v/swarmauri_evaluator_subprocess?label=swarmauri_evaluator_subprocess&color=green" alt="PyPI - swarmauri_evaluator_subprocess"/></a>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
---
|
|
43
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
44
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
44
45
|
|
|
45
46
|
# Swarmauri Evaluator Subprocess
|
|
46
47
|
|
|
@@ -179,3 +180,5 @@ metadata so callers can evaluate fleet-wide behavior.
|
|
|
179
180
|
If you want to contribute to swarmauri-sdk, read up on our
|
|
180
181
|
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
181
182
|
that will help you get started.
|
|
183
|
+
|
|
184
|
+
|
{swarmauri_evaluator_subprocess-0.3.0.dev48 → swarmauri_evaluator_subprocess-0.11.0.dev1}/README.md
RENAMED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<a href="https://
|
|
5
|
-
<img src="https://
|
|
4
|
+
<a href="https://pepy.tech/project/swarmauri_evaluator_subprocess/">
|
|
5
|
+
<img src="https://static.pepy.tech/badge/swarmauri_evaluator_subprocess/month" alt="PyPI - Downloads"/></a>
|
|
6
6
|
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_subprocess/">
|
|
7
7
|
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_evaluator_subprocess.svg"/></a>
|
|
8
8
|
<a href="https://pypi.org/project/swarmauri_evaluator_subprocess/">
|
|
9
|
-
<img src="https://img.shields.io/
|
|
9
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
10
10
|
<a href="https://pypi.org/project/swarmauri_evaluator_subprocess/">
|
|
11
11
|
<img src="https://img.shields.io/pypi/l/swarmauri_evaluator_subprocess" alt="PyPI - License"/></a>
|
|
12
12
|
<a href="https://pypi.org/project/swarmauri_evaluator_subprocess/">
|
|
13
13
|
<img src="https://img.shields.io/pypi/v/swarmauri_evaluator_subprocess?label=swarmauri_evaluator_subprocess&color=green" alt="PyPI - swarmauri_evaluator_subprocess"/></a>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
---
|
|
14
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
15
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
17
16
|
|
|
18
17
|
# Swarmauri Evaluator Subprocess
|
|
19
18
|
|
|
@@ -151,4 +150,5 @@ metadata so callers can evaluate fleet-wide behavior.
|
|
|
151
150
|
|
|
152
151
|
If you want to contribute to swarmauri-sdk, read up on our
|
|
153
152
|
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
154
|
-
that will help you get started.
|
|
153
|
+
that will help you get started.
|
|
154
|
+
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_evaluator_subprocess"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.11.0.dev1"
|
|
4
4
|
description = "A subprocess-based evaluator for executing and measuring program performance in isolated subprocesses"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
repository = "https://github.com/swarmauri/swarmauri-sdk/pkgs/standards/swarmauri_evaluator_subprocess/"
|
|
8
|
-
requires-python = ">=3.10,<3.
|
|
8
|
+
requires-python = ">=3.10,<3.15"
|
|
9
9
|
classifiers = [
|
|
10
10
|
"License :: OSI Approved :: Apache Software License",
|
|
11
11
|
"Natural Language :: English",
|
|
12
|
-
"Programming Language :: Python :: 3.10",
|
|
13
|
-
"Programming Language :: Python :: 3.11",
|
|
14
|
-
"Programming Language :: Python :: 3.12",
|
|
15
12
|
"Development Status :: 3 - Alpha",
|
|
16
13
|
"Intended Audience :: Developers",
|
|
17
14
|
"Topic :: Software Development :: Libraries",
|
|
@@ -20,6 +17,11 @@ classifiers = [
|
|
|
20
17
|
"Programming Language :: Python",
|
|
21
18
|
"Programming Language :: Python :: 3",
|
|
22
19
|
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
23
25
|
]
|
|
24
26
|
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
25
27
|
keywords = [
|
|
@@ -70,7 +72,7 @@ dev = [
|
|
|
70
72
|
"pytest-xdist>=3.6.1",
|
|
71
73
|
"pytest-json-report>=1.5.0",
|
|
72
74
|
"python-dotenv",
|
|
73
|
-
"
|
|
75
|
+
"httpx>=0.27",
|
|
74
76
|
"flake8>=7.0",
|
|
75
77
|
"pytest-timeout>=2.3.1",
|
|
76
78
|
"ruff>=0.9.9",
|
|
@@ -20,11 +20,15 @@ logger = logging.getLogger(__name__)
|
|
|
20
20
|
@ComponentBase.register_model()
|
|
21
21
|
class SubprocessEvaluator(EvaluatorBase):
|
|
22
22
|
"""
|
|
23
|
-
Evaluator that runs programs in isolated subprocesses and measures their
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
Evaluator that runs programs in isolated subprocesses and measures their
|
|
24
|
+
performance.
|
|
25
|
+
|
|
26
|
+
This evaluator executes programs in sandboxed subprocesses, capturing
|
|
27
|
+
stdout, stderr,
|
|
28
|
+
exit code, and runtime metrics. It provides security through resource
|
|
29
|
+
limits and
|
|
30
|
+
timeout constraints to prevent malicious or poorly written code from
|
|
31
|
+
affecting
|
|
28
32
|
the host system.
|
|
29
33
|
"""
|
|
30
34
|
|
|
@@ -34,14 +38,21 @@ class SubprocessEvaluator(EvaluatorBase):
|
|
|
34
38
|
timeout: float = Field(
|
|
35
39
|
default=30.0, description="Maximum execution time in seconds"
|
|
36
40
|
)
|
|
37
|
-
max_memory_mb: int = Field(
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
max_memory_mb: int = Field(
|
|
42
|
+
default=512, description="Maximum memory usage in MB"
|
|
43
|
+
)
|
|
44
|
+
max_processes: int = Field(
|
|
45
|
+
default=64, description="Maximum number of processes"
|
|
46
|
+
)
|
|
47
|
+
max_file_size_mb: int = Field(
|
|
48
|
+
default=10, description="Maximum file size in MB"
|
|
49
|
+
)
|
|
40
50
|
working_dir: Optional[str] = Field(
|
|
41
51
|
default=None, description="Working directory for execution"
|
|
42
52
|
)
|
|
43
53
|
env_vars: Dict[str, str] = Field(
|
|
44
|
-
default_factory=dict,
|
|
54
|
+
default_factory=dict,
|
|
55
|
+
description="Environment variables for the subprocess",
|
|
45
56
|
)
|
|
46
57
|
|
|
47
58
|
# Scoring parameters
|
|
@@ -59,7 +70,8 @@ class SubprocessEvaluator(EvaluatorBase):
|
|
|
59
70
|
self, program: Program, **kwargs
|
|
60
71
|
) -> Tuple[float, Dict[str, Any]]:
|
|
61
72
|
"""
|
|
62
|
-
Execute the program in a subprocess and compute a score based on its
|
|
73
|
+
Execute the program in a subprocess and compute a score based on its
|
|
74
|
+
performance.
|
|
63
75
|
|
|
64
76
|
Args:
|
|
65
77
|
program: The program to evaluate
|
|
@@ -71,8 +83,10 @@ class SubprocessEvaluator(EvaluatorBase):
|
|
|
71
83
|
|
|
72
84
|
Returns:
|
|
73
85
|
A tuple containing:
|
|
74
|
-
- float: A scalar fitness score (1.0 for success, lower for
|
|
75
|
-
|
|
86
|
+
- float: A scalar fitness score (1.0 for success, lower for
|
|
87
|
+
failures)
|
|
88
|
+
- Dict[str, Any]: Metadata about the execution including
|
|
89
|
+
stdout, stderr,
|
|
76
90
|
exit code, and runtime information
|
|
77
91
|
"""
|
|
78
92
|
# Extract additional parameters
|
|
@@ -132,7 +146,9 @@ class SubprocessEvaluator(EvaluatorBase):
|
|
|
132
146
|
# Clean up temporary directory if we created one
|
|
133
147
|
if use_temp_dir:
|
|
134
148
|
temp_dir.cleanup()
|
|
135
|
-
logger.debug(
|
|
149
|
+
logger.debug(
|
|
150
|
+
f"Cleaned up temporary working directory: {working_dir}"
|
|
151
|
+
)
|
|
136
152
|
|
|
137
153
|
def _prepare_command(self, program: Program, args: List[str]) -> List[str]:
|
|
138
154
|
"""
|
|
@@ -193,7 +209,8 @@ class SubprocessEvaluator(EvaluatorBase):
|
|
|
193
209
|
working_dir: Working directory for the subprocess
|
|
194
210
|
|
|
195
211
|
Returns:
|
|
196
|
-
Dictionary containing execution results including stdout, stderr,
|
|
212
|
+
Dictionary containing execution results including stdout, stderr,
|
|
213
|
+
and exit code
|
|
197
214
|
"""
|
|
198
215
|
|
|
199
216
|
# Set resource limits in a preexec function
|
|
@@ -206,7 +223,9 @@ class SubprocessEvaluator(EvaluatorBase):
|
|
|
206
223
|
|
|
207
224
|
# Set memory limit
|
|
208
225
|
memory_bytes = self.max_memory_mb * 1024 * 1024
|
|
209
|
-
resource.setrlimit(
|
|
226
|
+
resource.setrlimit(
|
|
227
|
+
resource.RLIMIT_AS, (memory_bytes, memory_bytes)
|
|
228
|
+
)
|
|
210
229
|
|
|
211
230
|
# Set file size limit
|
|
212
231
|
file_size_bytes = self.max_file_size_mb * 1024 * 1024
|
|
@@ -262,10 +281,13 @@ class SubprocessEvaluator(EvaluatorBase):
|
|
|
262
281
|
# Kill the process and all its children
|
|
263
282
|
try:
|
|
264
283
|
process.kill()
|
|
265
|
-
# Attempt to collect any output that was produced before
|
|
284
|
+
# Attempt to collect any output that was produced before
|
|
285
|
+
# timeout
|
|
266
286
|
stdout_data, stderr_data = process.communicate()
|
|
267
287
|
except Exception as e:
|
|
268
|
-
logger.warning(
|
|
288
|
+
logger.warning(
|
|
289
|
+
f"Error while killing timed-out process: {e}"
|
|
290
|
+
)
|
|
269
291
|
|
|
270
292
|
timed_out = True
|
|
271
293
|
exit_code = -1 # Use -1 to indicate timeout
|
|
@@ -346,11 +368,13 @@ class SubprocessEvaluator(EvaluatorBase):
|
|
|
346
368
|
"""
|
|
347
369
|
Aggregate multiple evaluation scores and their metadata.
|
|
348
370
|
|
|
349
|
-
This implementation extends the base aggregation with
|
|
371
|
+
This implementation extends the base aggregation with
|
|
372
|
+
subprocess-specific metrics.
|
|
350
373
|
|
|
351
374
|
Args:
|
|
352
375
|
scores: List of individual scores to aggregate
|
|
353
|
-
metadata_list: List of metadata dictionaries corresponding to each
|
|
376
|
+
metadata_list: List of metadata dictionaries corresponding to each
|
|
377
|
+
score
|
|
354
378
|
|
|
355
379
|
Returns:
|
|
356
380
|
A tuple containing:
|
|
@@ -374,16 +398,22 @@ class SubprocessEvaluator(EvaluatorBase):
|
|
|
374
398
|
timeout_count = sum(
|
|
375
399
|
1 for meta in metadata_list if meta.get("timed_out", False)
|
|
376
400
|
)
|
|
377
|
-
timeout_rate =
|
|
401
|
+
timeout_rate = (
|
|
402
|
+
timeout_count / len(metadata_list) if metadata_list else 0
|
|
403
|
+
)
|
|
378
404
|
|
|
379
405
|
# Calculate exit code statistics
|
|
380
406
|
exit_codes = [
|
|
381
|
-
meta.get("exit_code")
|
|
407
|
+
meta.get("exit_code")
|
|
408
|
+
for meta in metadata_list
|
|
409
|
+
if "exit_code" in meta
|
|
382
410
|
]
|
|
383
411
|
success_exit_count = sum(
|
|
384
412
|
1 for code in exit_codes if code in self.success_exit_codes
|
|
385
413
|
)
|
|
386
|
-
success_rate =
|
|
414
|
+
success_rate = (
|
|
415
|
+
success_exit_count / len(exit_codes) if exit_codes else 0
|
|
416
|
+
)
|
|
387
417
|
|
|
388
418
|
# Add to aggregated metadata
|
|
389
419
|
aggregated_metadata.update(
|
{swarmauri_evaluator_subprocess-0.3.0.dev48 → swarmauri_evaluator_subprocess-0.11.0.dev1}/LICENSE
RENAMED
|
File without changes
|