No project description provided
Project description
Judge Micro ๐
A modern, configuration-driven online judge microservice system built for competitive programming evaluation.
โจ Features
- ๐ฏ Configuration-Driven: Define test cases through JSON config files
- ๐ง Microservice Architecture: Stateless, containerized evaluation engines
- ๐ณ Docker Native: Full containerization with remote Docker support
- ๐ก๏ธ Resource Isolation: Secure sandboxed execution environment
- โก High Performance: Efficient container lifecycle management
- ๐ Python SDK: Easy-to-use Python API for integration
- ๐ Remote Support: Execute on remote Docker hosts via SSH
- ๐ Detailed Reporting: Comprehensive performance metrics and error analysis
๐๏ธ System Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Judge Micro System โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ โ
โ โ Client Code โ โ Python SDK โ โ Docker Manager โ โ
โ โ - Submit Code โโโโโถโ - JudgeMicro โโโโโถโ - Local/Remote โ โ
โ โ - Get Results โ โ - Validation โ โ - SSH Support โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Execution Containers โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ C Container โ โ C++ Container โ โ โ
โ โ โ - GCC Compiler โ โ - G++ Compiler โ โ โ
โ โ โ - cJSON Libraryโ โ - JSON Library โ โ โ
โ โ โ - Test Harness โ โ - Test Harness โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โ โ โ
โ โ โผ โผ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Config.json โ โ Config.json โ โ โ
โ โ โ User Code โ โ User Code โ โ โ
โ โ โ Test Cases โ โ Test Cases โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โ โ โ
โ โ โผ โผ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Result.json โ โ Result.json โ โ โ
โ โ โ - Status โ โ - Status โ โ โ
โ โ โ - Performance โ โ - Performance โ โ โ
โ โ โ - Errors โ โ - Errors โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฏ Core Design Principles
1. Configuration-Driven Evaluation ๐
- Zero Code Modification: The evaluation harness never needs changes
- Pure Function Interface: User functions operate on parameters without global state
- JSON Configuration: Test cases defined through structured configuration files
- Flexible Parameters: Support for arbitrary function signatures and types
2. Microservice Architecture ๐ง
- Stateless Execution: Each evaluation runs in isolation
- Container Lifecycle: Create โ Execute โ Destroy pattern
- Resource Management: CPU, memory, and time limits enforced
- Scalable Design: Horizontal scaling through container orchestration
3. Multi-Language Support ๐ป
- C Language: GCC with cJSON library support
- C++ Language: G++ with modern standards (C++11 to C++23)
- Extensible Framework: Easy addition of new language containers
4. Comprehensive Error Detection ๐ก๏ธ
- Compilation Errors: Automatic detection of syntax and type errors
- Runtime Errors: Segmentation faults, exceptions, and crashes
- Logic Errors: Output validation against expected results
- Resource Monitoring: CPU time, memory usage, and execution metrics
๐ ๏ธ System Requirements
- Operating System: Linux (Ubuntu/Debian recommended)
- Container Runtime: Docker Engine 20.10+
- Python: 3.8+ for SDK usage
- Network: Internet access for Docker image pulls
๐ Quick Start
Docker Compose
git clone https://github.com/TsukiSama9292/judge_micro.git
docker compose up -d
Installation
# Install from PyPI
pip install judge_micro
# Or install from source
git clone https://github.com/TsukiSama9292/judge_micro.git
cd judge_micro
pip install -e .
Basic Usage
from judge_micro.services.efficient import judge_micro
# C language example
c_code = '''
#include <stdio.h>
int solve(int *a, int *b) {
*a = *a * 2; // 3 * 2 = 6
*b = *b * 2 + 1; // 4 * 2 + 1 = 9
return 0;
}
'''
# Configuration
config = {
"solve_params": [
{"name": "a", "type": "int", "input_value": 3},
{"name": "b", "type": "int", "input_value": 4}
],
"expected": {"a": 6, "b": 9},
"function_type": "int"
}
# Execute
result = judge_micro.run_microservice(
language='c',
user_code=c_code,
config=config
)
print(f"Status: {result['status']}")
if result['status'] == 'SUCCESS':
print(f"โ
Match: {result.get('match', True)}")
print(f"โฑ๏ธ Execution time: {result['time_ms']:.3f}ms")
elif result['status'] == 'COMPILE_ERROR':
print(f"โ Compilation failed: {result['stderr']}")
elif result['status'] == 'RUNTIME_ERROR':
print(f"โ Runtime error: {result['stderr']}")
elif result['status'] == 'WRONG_ANSWER':
print(f"โ Wrong answer - Expected: {result['expected']}, Got: {result['actual']}")
๐ Example Output
Successful Execution
{
"status": "SUCCESS",
"match": true,
"time_ms": 1.234,
"cpu_utime": 0.0012,
"cpu_stime": 0.0008,
"maxrss_mb": 2.1,
"compile_time_ms": 145.6,
"expected": {"a": 6, "b": 9},
"actual": {"a": 6, "b": 9},
"stdout": "Debug output from user code",
"stderr": ""
}
Compilation Error
{
"status": "COMPILE_ERROR",
"error": "Compilation failed",
"stderr": "error: expected ';' before '}' token",
"exit_code": 1,
"compile_time_ms": 89.3
}
Runtime Error
{
"status": "RUNTIME_ERROR",
"error": "Execution failed",
"stderr": "Segmentation fault (core dumped)",
"exit_code": 139,
"time_ms": 23.1,
"compile_time_ms": 156.7
}
Wrong Answer
{
"status": "WRONG_ANSWER",
"match": false,
"expected": {"a": 6, "b": 9},
"actual": {"a": 6, "b": 8},
"time_ms": 2.1,
"cpu_utime": 0.002,
"cpu_stime": 0.001,
"maxrss_mb": 1.3,
"compile_time_ms": 128.5,
"stdout": "Debug: Processing values...",
"stderr": ""
}
๐ง Advanced Configuration
Remote Docker Support
# Configure remote Docker host via SSH
import os
os.environ['DOCKER_SSH_REMOTE'] = 'true'
os.environ['DOCKER_SSH_HOST'] = '192.168.1.100'
os.environ['DOCKER_SSH_USER'] = 'docker'
os.environ['DOCKER_SSH_KEY_PATH'] = '/path/to/ssh/key'
Resource Limits
# Set container resource limits
os.environ['CONTAINER_CPU'] = '1.0' # CPU limit
os.environ['CONTAINER_MEM'] = '256m' # Memory limit
os.environ['CONTAINER_COUNT'] = '5' # Max containers
๐ Use Cases
- Online Judge Platforms: Competitive programming websites
- Educational Systems: Automated assignment grading
- Coding Interviews: Technical assessment platforms
- Code Quality Tools: Automated testing and validation
- Research Projects: Algorithm performance evaluation
๐ Documentation
- C/C++ Usage Examples
- API Reference
- Configuration Guide
- Error Handling & Status Codes
- Python SDK Guide
- Deployment Guide
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
๐ Acknowledgments
- Built with modern DevOps practices
- Inspired by competitive programming judge systems
- Powered by Docker containerization technology
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file judge_micro-0.0.0.dev0.tar.gz.
File metadata
- Download URL: judge_micro-0.0.0.dev0.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f36b1bb58ca299a1d871324ab850ac56f812537cca918e86c3c623c1c9f4e7f
|
|
| MD5 |
d88477b90ad59d637c82e26f2f25e1ad
|
|
| BLAKE2b-256 |
a40350838c3c4fc0849f7a5dab7fb6fcdd00c07c7cda8c2900139b6b709a922e
|
File details
Details for the file judge_micro-0.0.0.dev0-py3-none-any.whl.
File metadata
- Download URL: judge_micro-0.0.0.dev0-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9604548df5353befe4bab14b686a12ddf3cab2f6a4ba85a1bea229d274188e07
|
|
| MD5 |
52315cd4f56ff34d3f231872678483ca
|
|
| BLAKE2b-256 |
3add277fa51e511b49242426e15f2d5055d3a65a56d8b7acdf4771fb00727616
|