Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
76bc550
Refactor GitHub Actions workflow to improve artifact handling and add…
reiase Dec 3, 2025
511ab0c
Bump version to 0.5.12 in Cargo.toml
reiase Dec 3, 2025
74441a0
Remove x86_64 target from macOS build matrix in GitHub Actions workflow
reiase Dec 3, 2025
6820d1d
Add options for verbose output and skip existing packages in PyPI pub…
reiase Dec 3, 2025
e1237cb
Update GitHub Actions workflow to use maturin for package uploads and…
reiase Dec 3, 2025
cd67978
Merge remote-tracking branch 'refs/remotes/origin/master'
reiase Dec 4, 2025
5a154f2
refactor build system
reiase Dec 6, 2025
e2c2c07
refactor KVStorage storage method for clarity and safety
reiase Dec 6, 2025
d1afa9f
refactor: enhance README with quickstart guide and examples; update C…
reiase Dec 6, 2025
9faf2c5
refactor: improve quickstart examples and enhance version fallback wa…
reiase Dec 6, 2025
318cf8b
refactor: enhance storage management with context-aware features and …
reiase Dec 6, 2025
947a01e
refactor: integrate hyperparameter-macros for improved parameter mana…
reiase Dec 9, 2025
cad17f9
feat: add Tokio runtime configuration tests and integrate Tokio as a …
reiase Dec 10, 2025
95fbced
refactor: update parameter management syntax in documentation and exa…
reiase Dec 10, 2025
4be6932
test: add comprehensive tests for with_params! macro edge cases and p…
reiase Dec 10, 2025
1380aac
test: update edge case tests for with_params! macro with English comm…
reiase Dec 10, 2025
4da8a40
feat: enhance TLSKVStorage and KVStorage with thread-local handler ma…
reiase Dec 11, 2025
9b6466e
feat: improve KVStorage and TLSKVStorage for better context isolation…
reiase Dec 11, 2025
26dc51c
feat: add docstring enhancements and improve launch function for bett…
reiase Dec 11, 2025
d81f146
refactor: separate CLI functionality into cli.py and update api.py fo…
reiase Dec 11, 2025
08371d3
feat: implement conditional help action in CLI for advanced parameter…
reiase Dec 11, 2025
4481ef1
feat: enhance parameter parsing in CLI to support multi-line descript…
reiase Dec 11, 2025
12d2e70
feat: refine related parameter function discovery in CLI to include s…
reiase Dec 11, 2025
ebadd76
feat: enhance advanced parameter help formatting in CLI to include ty…
reiase Dec 11, 2025
ee23a4a
feat: update parameter access logic in api.py to raise KeyError for m…
reiase Dec 13, 2025
9c66ab5
feat: update quick start documentation to enhance clarity and usabili…
reiase Dec 13, 2025
286b6b3
chore: bump version to 0.5.14 in pyproject.toml, Cargo.toml for core …
reiase Dec 14, 2025
013968c
chore: update version to 0.5.14 in Cargo.toml to reflect recent changes
reiase Dec 14, 2025
5fadf83
feat: add comprehensive test suite for param_scope and auto_param, in…
reiase Dec 14, 2025
56183e9
feat: add API reference documentation in English and Chinese, enhanci…
reiase Dec 14, 2025
4e2ec60
feat: introduce command line tool 'hp' for hyperparameter analysis, i…
reiase Dec 14, 2025
3a1c803
chore: update Codecov GitHub Action to version 5 for improved coverag…
reiase Dec 14, 2025
1f6b761
refactor: improve code formatting and readability across multiple fil…
reiase Dec 14, 2025
a7e2f0c
chore: update GitHub Actions workflow to correct paths for Rust and P…
reiase Dec 14, 2025
c928672
chore: add pytest-asyncio to Python dependencies in GitHub Actions wo…
reiase Dec 14, 2025
88cc884
chore: adjust directory paths in Codecov workflow for accurate test c…
reiase Dec 14, 2025
d509ce8
chore: add pytest-asyncio to requirements in Codecov workflow to enha…
reiase Dec 14, 2025
a6c4b06
chore: update Codecov workflow to enhance permissions and upgrade act…
reiase Dec 14, 2025
d49bb75
chore: enhance Codecov workflow by adding caching for pip and integra…
reiase Dec 14, 2025
43c1437
refactor: update expected values in recursive tests to reflect correc…
reiase Dec 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: codecov

on: [push, pull_request]

permissions:
contents: read
id-token: write # Required for Codecov tokenless uploads (public repos)

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -10,37 +14,38 @@ jobs:
run:
working-directory: .
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: llvm-tools-preview
cache: 'pip'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2
with:
workspaces: "src/core -> src/core/target"
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install requirements
run: |
pip install pytest pytest-cov && pip install -e .
pip install pytest pytest-cov pytest-asyncio && pip install -e .
- name: Run tests and collect coverage
run: |
cd core/
cd src/core/
source <(cargo llvm-cov show-env --export-prefix)
export CARGO_TARGET_DIR=$CARGO_LLVM_COV_TARGET_DIR
export CARGO_INCREMENTAL=1
cargo llvm-cov clean --workspace
cargo test
cd ..
cd ../..
pytest --cov=./ --cov-report=xml
cd core/
cargo llvm-cov --no-run --lcov --output-path ../coverage.lcov
cd src/core/
cargo llvm-cov --no-run --lcov --output-path ../../coverage.lcov
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
files: coverage.lcov,coverage.xml
token: ${{ secrets.CODECOV }}
token: ${{ secrets.CODECOV_TOKEN || secrets.CODECOV }}
fail_ci_if_error: true
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ jobs:
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
core/target/
hyperparameter/target/
src/core/target/
src/py/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install pytest pytest-cov pytest-asyncio

- name: Build and install hyperparameter
run: |
pip install -e .

- name: Run Rust tests
run: |
cd core
cd src/core
cargo test --lib

- name: Run Python tests
Expand Down
42 changes: 33 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@

Hyperparameter is a versatile library designed to streamline the management and control of hyperparameters in machine learning algorithms and system development. Tailored for AI researchers and Machine Learning Systems (MLSYS) developers, Hyperparameter offers a unified solution with a focus on ease of use in Python, high-performance access in Rust and C++, and a set of macros for seamless hyperparameter management.

## 5-Minute Try

```bash
pip install hyperparameter

# Run a ready-to-use demo
python -m hyperparameter.examples.quickstart

# Try the @auto_param CLI: override defaults from the command line
python -m hyperparameter.examples.quickstart --define greet.name=Alice --enthusiasm=3

# Inspect params and defaults
python -m hyperparameter.examples.quickstart -lps
python -m hyperparameter.examples.quickstart -ep greet.name

# Running from source? Use module mode or install editable
# python -m hyperparameter.examples.quickstart
# or: pip install -e .
```

What it shows:
- default values vs scoped overrides (`param_scope`)
- `@auto_param` + `launch` exposing a CLI with `-D/--define` for quick overrides

## Key Features

### For Python Users
Expand Down Expand Up @@ -60,7 +84,7 @@ with param_scope(**{"foo.x": 2}):
```rust
fn foo() -> i32 {
with_params! {
get x = foo.x or 1i32; // Read hyperparameter with default value
@get x = foo.x or 1i32; // Read hyperparameter with default value

println!("x={}", x);
}
Expand All @@ -70,7 +94,7 @@ fn main() {
foo(); // x=1

with_params! {
set foo.x = 2i32; // Set hyperparameter
@set foo.x = 2i32; // Set hyperparameter

foo(); // x=2
}
Expand Down Expand Up @@ -106,7 +130,7 @@ x = param_scope.foo.x | "default value"
#### Rust

```rust
get x = foo.x or "default value";
@get x = foo.x or "default value";
```

### Scope Control of Parameter Values
Expand All @@ -126,10 +150,10 @@ with param_scope() as ps: # 1st scope start

```rust
with_params!{ // 1st scope start
set foo.x=1;
@set foo.x=1;

with_params!{ //2nd scope start
set foo.y=2
@set foo.y=2

...
} // 2nd scope end
Expand Down Expand Up @@ -157,15 +181,15 @@ with param_scope() as ps:
```rust
fn foo() { // Print hyperparameter foo.x
with_params!{
get x = foo.x or 1;
@get x = foo.x or 1;

println!("foo.x={}", x);
}
}

fn main() {
with_params!{
set foo.x = 2; // Modify foo.x in the current thread
@set foo.x = 2; // Modify foo.x in the current thread

foo(); // foo.x=2
thread::spawn(foo); // foo.x=1, new thread's hyperparameter value is not affected by the main thread
Expand Down Expand Up @@ -223,8 +247,8 @@ fn main() {

fn foo() {
with_params! {
get a = example.a or 0;
get b = example.b or 1;
@get a = example.a or 0;
@get b = example.b or 1;

println!("example.a={}, example.b={}",a ,b);
}
Expand Down
18 changes: 9 additions & 9 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ with param_scope(**{"foo.x": 2}):
```rust
fn foo() -> i32 {
with_params! {
get x = foo.x or 1i32; // 读取带有默认值的超参数
@get x = foo.x or 1i32; // 读取带有默认值的超参数

println!("x={}", x);
}
Expand All @@ -70,7 +70,7 @@ fn main() {
foo(); // x=1

with_params! {
set foo.x = 2i32; // 设置超参数
@set foo.x = 2i32; // 设置超参数

foo(); // x=2
}
Expand Down Expand Up @@ -106,7 +106,7 @@ x = param_scope.foo.x | "default value"
#### Rust

```rust
get x = foo.x or "default value";
@get x = foo.x or "default value";
```

### 控制参数值的作用域
Expand All @@ -126,10 +126,10 @@ with param_scope() as ps: # 第1个作用域开始

```rust
with_params!{ // 第1个作用域开始
set foo.x=1;
@set foo.x=1;

with_params!{ //第2个作用域开始
set foo.y=2
@set foo.y=2

...
} // 第2个作用域结束
Expand Down Expand Up @@ -159,15 +159,15 @@ with param_scope() as ps:
```rust
fn foo() { // 打印超参数 foo.x
with_params!{
get x = foo.x or 1;
@get x = foo.x or 1;

println!("foo.x={}", x);
}
}

fn main() {
with_params!{
set foo.x = 2; // 在当前线程中修改 foo.x
@set foo.x = 2; // 在当前线程中修改 foo.x

foo(); // foo.x=2
thread::spawn(foo); // foo.x=1,新线程的超参数值不受主线程的影响
Expand Down Expand Up @@ -225,8 +225,8 @@ fn main() {

fn foo() {
with_params! {
get a = example.a or 0;
get b = example.b or 1;
@get a = example.a or 0;
@get b = example.b or 1;

println!("example.a={}, example.b={}",a ,b);
}
Expand Down
22 changes: 0 additions & 22 deletions core/tests/with_params_expr.rs

This file was deleted.

Loading
Loading