Define routines as structured algorithmic workflows
Project description
routix
routix is a lightweight Python toolkit for designing, executing, and analyzing structured algorithmic workflows.
It is designed to systematically manage complex experiments and enhance reproducibility.
Key Features
- Subroutine-based Execution Control: Flexibly manage workflows with
SubroutineControllerand support detailed logging by tracking context withMethodContextManager. - Structured Flow Validation: Validate workflow definitions in advance using
SubroutineFlowValidator. - Dynamic Data Objects: Conveniently manage hierarchical data and configurations as dot-accessible objects with
DynamicDataObject. - Accurate Time Measurement: Accurately measure and manage the execution time of experiments and each subroutine with
ElapsedTimer. - Time Series Data Management: Collect and store various metrics generated during experiments as time series data using
MetricTimeSeriesandNamedTimeSeriesStore. - Solution Management: Systematically manage solutions found during the optimization process and track the incumbent solution with
SolutionManager. - Experiment Reporting and Statistics: A modular system to record, analyze, and serialize experiment results.
- Extensible Runners: Abstract base classes to easily implement various experimental patterns (e.g., single, multiple, concurrent execution).
- File I/O Utilities: Simplified serialization of Python objects to YAML or JSON, and creation of timestamped directories for experiment outputs.
Subroutine Flow Data Format
routix executes workflows defined as a structured list of dictionaries. Each step is clearly specified with a method name and parameters.
- method: initialize
- method: repeat
params:
n_repeats: 3
routine_data:
- method: sample_method
params:
value: 42
For more details, see subroutine_flow_data.md.
Report System
routix provides a modular and extensible reporting system designed with the Single Responsibility Principle in mind.
SubroutineReport: An immutabledataclassthat records the results of a single subroutine execution, including elapsed time, objective value, and objective bound.SubroutineReportRecorder: CollectsSubroutineReportinstances and tracks method call counts during a workflow run.SubroutineReportStatistics: Computes summary statistics (e.g., total time, best objective, improvement ratio) from the reports collected by a recorder.SubroutineReportStatisticsSerializer: Serializes a collection ofSubroutineReportStatisticsobjects into various formats, including dictionaries, CSV, JSON, and YAML, making it easy to export and analyze results from multiple runs.
Runner Base Classes
Build custom workflow runners by extending these abstract base classes to fit your experimental patterns.
SingleInstanceRunner: The foundation for running a workflow on a single problem instance. Subclasses must implementget_controller()to set up theSubroutineControllerandpost_run_process()to handle results.MultiInstanceRunner: Orchestrates running a set of instances sequentially. It uses a specifiedSingleInstanceRunnersubclass for each instance.MultiInstanceConcurrentRunner: ExtendsMultiInstanceRunnerto execute multiple instances in parallel using a process pool, significantly speeding up large-scale experiments.MultiScenarioRunner: Manages experiments across multiple scenarios, where each scenario may have a different configuration (e.g., a different subroutine flow). It uses aMultiInstanceRunnersubclass to execute the instances within each scenario.
File I/O Utilities
routix includes helper functions to streamline file I/O for experiments.
dump_yaml/dump_json: Serialize Python objects into clean and readable YAML or JSON files.- Objects should primarily be composed of standard JSON-serializable types (e.g., dicts, lists, numbers, strings).
dump_jsonadditionally supportspathlib.PurePath(serialized asstr) and objects exposing a callableto_dict()method; other non-serializable objects should be converted (e.g., viato_dict()orstr()) before calling these functions.
init_timestamped_working_dir: Creates a unique, timestamped directory for storing experiment outputs, helping to keep results organized.
Installation
pip install routix
Testing
Unit tests for all major components of the project are included in the tests/ directory. You can run all tests using pytest.
pytest
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 routix-0.0.16.tar.gz.
File metadata
- Download URL: routix-0.0.16.tar.gz
- Upload date:
- Size: 28.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c577737ed2515aeb39864016659249056501ba0c9cf55e004c00e563ab9957b
|
|
| MD5 |
76dd8ec44c94ee41e029444d25b21183
|
|
| BLAKE2b-256 |
dacd85053ae3ef7f545695db0bd99d4b8d2462363cf1f0198864ff447d72a1bd
|
File details
Details for the file routix-0.0.16-py3-none-any.whl.
File metadata
- Download URL: routix-0.0.16-py3-none-any.whl
- Upload date:
- Size: 41.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86a32770571dfb9a189229392731ab66616f854f0226427f5aa4bc1aa9d998aa
|
|
| MD5 |
2c3172237dbe8683ab74491d58088607
|
|
| BLAKE2b-256 |
cf0a81cc72785515d24cb6f62cc4d096f6392d598ccd0918a1a17870f4121e86
|