OpenGRIS Scaler is an efficient, lightweight, and reliable distributed computation engine.
- Distributed computing across multiple cores and servers
- Python reference client, scheduler and worker implementation
- Portable Cap'n Proto protocol
- Graph scheduling
- Automated load balancing and task recovery
- Support for nested tasks
- Monitoring tools (CLI and GUI)
- Fast network layer written in C++ (YMQ)
- Fast object storage server written in C++
- Python 3.8+: Primary implementation language
- C++20: Performance-critical components
- Cap'n Proto: Serialization and messaging protocol
- asyncio/libuv: Asynchronous event loops (Python / C++)
- CMake: Build system for C++ components
- Python code uses the unittest module while C++ code uses GTest
scaler/
├── src/
│ ├── scaler/ # Python source code
│ │ ├── client/
│ │ ├── scheduler/
│ │ ├── worker/
│ │ ├── entry_points/ # CLI entry points
│ │ ├── protocol/ # Protocol definitions (Cap'n Proto)
│ │ ├── utility/
│ │ ├── worker_manager_adapter/
│ │ └── .../
│ └── cpp/scaler/ # C++ components
│ ├── object_storage/
│ ├── ymq/ # Custom messaging queue protocol
│ └── .../
├── tests/
│ ├── client/
│ ├── scheduler/
│ ├── cpp/ # C++ tests
│ └── .../
└── scripts/ # Build and utility scripts
├── examples/
├── benchmarks/
├── docs/
Both C++ and Python code share these standards:
- 4 spaces for indentation
- Maximum line length is 120 characters
- Traditional OOP inheritance is highly discouraged, composition is preferred. Prefer interfaces, abstract classes and/or mixins
- Explicit naming is preferred. Avoid abbreviations unless widely understood (e.g.,
msg) - Avoid single letter variables (e.g.
c), except fori,jandnwhen used as iteration variables/boundaries - Avoid magic numbers, prefer constants
- Matching of naming of files, tests, namespaces/modules and directories is highly encouraged
-
Style Guide:
- Follow PEP 8
- Always include parameter types and return type hints
-
Imports:
- Organize imports in the following order, then sort alphabetically:
- Standard library imports
- Third-party imports
- Local application imports
- Organize imports in the following order, then sort alphabetically:
-
Naming Conventions:
- Classes:
PascalCase. Capitalize all letters in acronyms (e.g.HTTPRequestnotHttpRequest) - Functions/methods:
snake_case - Constants:
UPPER_SNAKE_CASE - Private members: prefix with
_
- Classes:
-
Style Guide:
- Follow the project's
.clang-format:- Left pointer alignment (
int* ptr) - Break after function declarations/definitions (opening brace on new line)
- One parameter per line for function declarations if it exceeds the max. line length
- Align consecutive assignments
- Left pointer alignment (
- Follow the project's
-
Headers:
-
Use
#pragma once -
Organize includes in the following order, then sort alphabetically:
- Associated header
- C/C++ libraries
- Local includes
// file is my_class.cpp #include "scaler/ymq/my_class.h" #include <cstdint> #include <memory> #include "scaler/error/error.h" #include "scaler/ymq/event_loop_thread.h"
-
-
Naming Conventions:
- Classes:
PascalCase. Capitalize all letters in acronyms (e.g.HTTPRequestnotHttpRequest) - Functions/methods/variables:
camelCase - Class fields:
_camelCase. Prefer private fields accessed through getters/setters. - Follow this ordering:
publicbeforeprivatesection- Nested types then fields, then constructors/destructors, then methods, then static methods
- Classes:
-
Namespaces:
- Use the
scaler::namespace - Try to match the namespace and directory structure
- Avoid
using namespace, use fully qualified names instead
- Use the
-
Modern C++:
- Use C++20 features supported by Clang++, MSVSC++ and GCC
- Use RAII
- Prefer smart pointers
- Prefer the {}-initializer syntax, avoid () initialization
- Prefer
std::optionalover null pointers - Prefer
std::expectedover exceptions
-
Cross-platform code
- Use STL and libuv utilities instead of native syscalls
- Avoid platform-specific
#ifdef, use CMake conditional compilation, e.g:- my_class.h # common interface
- my_class.cpp # common methods
- my_class_windows.cpp # Windows specific
- my_class_unix.cpp # macOS / Linux specific
The devcontainer (.devcontainer/) comes with all C++ dependencies pre-installed (CMake, GCC, Cap'n Proto, Boost,
libuv) as well as uv. You can detect the devcontainer via the REMOTE_CONTAINERS=true environment variable.
When running in the devcontainer, skip the C++ dependency setup steps below.
The C++ components are built automatically by uv pip install -e . via scikit-build-core, so a separate
./scripts/build.sh step is only needed for standalone C++ development or testing.
# Create and activate a virtual environment
uv venv .venv
source .venv/bin/activate
# Install Python package in development mode (also builds C++ components)
uv pip install -e .
# Setup C++ dependencies (skip in devcontainer — already installed)
./scripts/library_tool.sh capnp download
./scripts/library_tool.sh capnp compile
./scripts/library_tool.sh capnp install
# Building C++ components standalone (only if needed outside of pip install)
./scripts/build.shpython -m unittest discover # Python
./scripts/test.sh # C++When writing tests, try to match the directory and module/namespace structure of the code under test.
Developer-specific preferences (e.g. build parallelism limits, preferred tools) should go in a .agents-local.md
file in the project root. This file is gitignored and will not be committed.
IMPORTANT: Agents MUST read .agents-local.md before performing any build, install, or terminal command.
Its contents are mandatory overrides to this file and must always be followed.