Skip to content

Commit a913424

Browse files
authored
Merge pull request #40 from SeaCelo/uv-migration
Migrate from conda to uv
2 parents 42410a2 + 901d25c commit a913424

24 files changed

Lines changed: 3487 additions & 258 deletions

.github/workflows/build_and_test.yml

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ on:
44
paths:
55
- '**.yml'
66
- '**.toml'
7-
- '**.ini'
87
- '**.py'
98
- '**.json'
109
- '**.csv'
1110
- '**.pkl'
11+
- '**.pbz2'
12+
- '**.lock'
1213
pull_request:
1314
paths:
1415
- '**.yml'
1516
- '**.toml'
16-
- '**.ini'
1717
- '**.py'
1818
- '**.json'
1919
- '**.csv'
2020
- '**.pkl'
21+
- '**.pbz2'
22+
- '**.lock'
2123
jobs:
2224
build:
2325
runs-on: ${{ matrix.os }}
@@ -28,36 +30,53 @@ jobs:
2830

2931
steps:
3032
- name: Checkout
31-
uses: actions/checkout@v4
33+
uses: actions/checkout@v6
3234
with:
3335
persist-credentials: false
34-
35-
- name: Setup Miniconda using Python ${{ matrix.python-version }}
36-
uses: conda-incubator/setup-miniconda@v3
36+
- name: Install uv
37+
uses: astral-sh/setup-uv@v7
3738
with:
38-
miniconda-version: "latest"
39-
auto-update-conda: true
40-
activate-environment: ogidn-dev
41-
environment-file: environment.yml
4239
python-version: ${{ matrix.python-version }}
43-
auto-activate-base: false
44-
45-
- name: Build
46-
shell: bash -l {0}
47-
run: |
48-
pip install -e .
40+
- name: Install package and dependencies
41+
run: uv sync --extra dev
4942
- name: Test
50-
shell: bash -l {0}
51-
working-directory: ./
52-
run: |
53-
python -m pytest -m 'not local' --cov=./ --cov-report=xml
43+
run: uv run python -m pytest -m "not local" --cov=./ --cov-report=xml
5444
- name: Upload coverage to Codecov
55-
if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'EAPD-DRB/OG-IDN')
56-
uses: codecov/codecov-action@v4
45+
if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'EAPD-DRB/OG-IDN') && github.actor != 'dependabot[bot]'
46+
uses: codecov/codecov-action@v6
5747
with:
5848
files: ./coverage.xml
5949
flags: unittests
6050
name: codecov-umbrella
6151
token: ${{ secrets.CODECOV_TOKEN }}
6252
fail_ci_if_error: true
6353
verbose: true
54+
pip-import-smoke:
55+
runs-on: ubuntu-latest
56+
strategy:
57+
matrix:
58+
python-version: ["3.12", "3.13"]
59+
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v6
63+
with:
64+
persist-credentials: false
65+
66+
- name: Setup Python ${{ matrix.python-version }}
67+
uses: actions/setup-python@v5
68+
with:
69+
python-version: ${{ matrix.python-version }}
70+
71+
- name: Install package and pytest
72+
run: |
73+
python -m pip install --upgrade pip
74+
python -m pip install . pytest
75+
76+
- name: Run import smoke tests outside checkout
77+
shell: bash
78+
run: |
79+
tmpdir="$(mktemp -d)"
80+
cp "${{ github.workspace }}/tests/test_import_smoke.py" "$tmpdir/test_import_smoke.py"
81+
cd "$tmpdir"
82+
python -m pytest "$tmpdir/test_import_smoke.py"

.github/workflows/check_format.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/check_ruff.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Check Ruff formatting and linting
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v6
10+
- uses: astral-sh/setup-uv@v7
11+
- name: Check formatting with Ruff
12+
run: uvx ruff format --check .
13+
- name: Check linting with Ruff
14+
run: uvx ruff check .

.github/workflows/deploy_docs.yml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ on:
44
branches:
55
- main
66
paths:
7+
- '**.md'
8+
- './docs/**.py'
79
- './docs/**.png'
8-
- './docs/book/content/calibration/images/**.png'
9-
- './docs/README.md'
1010
- './docs/book/**.yml'
1111
- './docs/book/**.bib'
12-
- '**.md'
12+
- './docs/book/content/calibration/images/**.png'
1313
- './docs/book/content/api/**.rst'
1414
- './ogidn/**.py'
1515
jobs:
@@ -18,30 +18,23 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Checkout
21-
uses: actions/checkout@v4
21+
uses: actions/checkout@v6
2222
with:
2323
persist-credentials: false
2424

25-
- name: Setup Miniconda
26-
uses: conda-incubator/setup-miniconda@v3
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v7
2727
with:
28-
miniconda-version: "latest"
29-
activate-environment: ogidn-dev
30-
environment-file: environment.yml
3128
python-version: "3.13"
32-
auto-activate-base: false
29+
30+
- name: Install package and dependencies
31+
run: uv sync --extra dev --extra docs
3332

3433
- name: Build # Build Jupyter Book
35-
shell: bash -l {0}
36-
run: |
37-
pip install jupyter-book>=0.11.3
38-
pip install sphinxcontrib-bibtex>=2.0.0
39-
pip install -e .
40-
python -m ipykernel install --user --name=ogidn-dev
41-
jb build ./docs/book
34+
run: uv run make documentation
4235

4336
- name: Deploy
44-
uses: JamesIves/github-pages-deploy-action@releases/v4
37+
uses: JamesIves/github-pages-deploy-action@v4
4538
with:
4639
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4740
BRANCH: gh-pages # The branch the action should deploy to.

.github/workflows/docs_check.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ name: Check that docs build
22
on:
33
pull_request:
44
paths:
5+
- '**.md'
6+
- './docs/**.py'
57
- './docs/**.png'
6-
- './docs/README.md'
78
- './docs/book/**.yml'
89
- './docs/book/**.bib'
910
- './docs/book/content/calibration/images/**.png'
10-
- '**.md'
1111
- './docs/book/content/api/**.rst'
1212
- './ogidn/**.py'
1313

@@ -16,24 +16,17 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v6
2020
with:
2121
persist-credentials: false
2222

23-
- name: Setup Miniconda
24-
uses: conda-incubator/setup-miniconda@v3
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v7
2525
with:
26-
miniconda-version: "latest"
27-
activate-environment: ogidn-dev
28-
environment-file: environment.yml
2926
python-version: "3.13"
30-
auto-activate-base: false
27+
28+
- name: Install package and dependencies
29+
run: uv sync --extra dev --extra docs
3130

3231
- name: Build # Build Jupyter Book
33-
shell: bash -l {0}
34-
run: |
35-
pip install "jupyter-book<2.0.0"
36-
pip install "sphinxcontrib-bibtex>=2.0.0"
37-
pip install -e .
38-
python -m ipykernel install --user --name=ogidn-dev
39-
jb build ./docs/book
32+
run: uv run make documentation

.github/workflows/publish_to_pypi.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout repo
15-
uses: actions/checkout@v4
16-
- name: Setup Python
17-
uses: actions/setup-python@v4
15+
uses: actions/checkout@v6
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v7
1818
with:
1919
python-version: "3.13"
2020
- name: Build package
21-
shell: bash -l {0}
22-
run: |
23-
pip install wheel
24-
python setup.py sdist bdist_wheel
21+
run: uv build
2522
- name: Publish a Python distribution to PyPI
2623
uses: pypa/gh-action-pypi-publish@release/v1
2724
with:

AGENTS.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
## Workflow
22

3-
- Read-only inspection does not require prior approval. This includes actions like checking status, listing branches or worktrees, inspecting tracking refs, reviewing merged status, reading files, and preparing a proposed cleanup list.
4-
- Present a plan and wait for explicit approval before making changes to repo state. This includes file edits, branch deletion, pruning refs or worktrees, rebases, merges, commits, pushes, and similar mutating actions.
3+
- Read-only actions don't need prior approvalstatus, log, branch listing, file reads, drafting.
4+
- Mutating actions need a plan and explicit approval before running — file edits, commits, pushes, branch/ref/worktree deletion, rebases, merges.
55

66
## Project: OG-IDN
77

88
OG-IDN is an Indonesia country calibration of the OG-Core overlapping-generations model of demographics and fiscal policy.
99

1010
## Environment
1111

12-
- Conda environment: `ogidn-dev`
12+
- Package manager: [`uv`](https://docs.astral.sh/uv/). Install via your package manager (e.g. `brew install uv`) or `pip install uv`.
13+
- Local virtualenv: `.venv` at the repo root, created by `uv sync --extra dev`.
14+
- Run Python/pytest/etc. via `uv run <cmd>` (preferred — uses the project venv without activation) or activate first with `source .venv/bin/activate`.
15+
- For docs/Jupyter Book work, also pass `--extra docs`: `uv sync --extra dev --extra docs`.
1316

14-
## Python formatting
17+
## Python formatting and linting
1518

16-
- Run `black` on all touched `.py` files before staging and pushing.
17-
- Do not run `black` on non-Python files (e.g. README.md will fail to parse).
18-
- Re-run tests after formatting to confirm nothing broke.
19-
- Format command: `conda run -n ogidn-dev python -m black <files>`
19+
- Sequence: edit → format → test → stage → commit → push.
20+
- Format + auto-fix: `make format` (runs `uv run ruff format .` + `uv run ruff check . --fix` + `uv run linecheck . --fix`).
21+
- CI check (no changes): `make lint` (runs `uv run ruff format --check .` + `uv run ruff check .`).
22+
- Ruff config lives in `pyproject.toml` under `[tool.ruff]`; matches OG-Core.
23+
- Re-run tests after formatting — ruff can change line breaks that affect string literals and assertions.
2024

2125
## Testing
2226

23-
- Full suite: `conda run -n ogidn-dev python -m pytest tests/ -q`
24-
- Targeted: `conda run -n ogidn-dev python -m pytest tests/test_calibrate.py tests/test_input_output.py tests/test_macro_params.py -q`
27+
- Default suite (matches CI, skips the long example run): `uv run python -m pytest -m 'not local' -q` (or `make test`).
28+
- Targeted (fast): `uv run python -m pytest tests/test_macro_params.py tests/test_income.py tests/test_input_output.py tests/test_calibrate.py -q`.
29+
- Full example run (slow, ~35 min – 2 hr): `uv run python examples/run_og_idn.py`.
2530

2631
## Repo conventions
2732

33+
- `pyproject.toml` is the source of truth for dependencies. `uv.lock` pins exact versions across machines and is checked in.
2834
- The packaged JSON default parameters are the standard baseline input for offline/default runs.
29-
- Calibration-related changes can affect macro parameters, demographics, earnings distribution, and industry I/O behavior.
30-
- Changes in calibration or data-source behavior should be validated with targeted tests and, where feasible, the relevant example flows.
35+
- Calibration or data-source changes (macro parameters, demographics, earnings, industry I/O) should be validated with targeted tests and, where feasible, the relevant example flow.

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## [0.1.0] - 2026-06-03 12:00:00
10+
11+
### Changed
12+
13+
- Migrated the project from conda to uv. Install with `uv sync --extra dev`; `pyproject.toml` is the single source of truth for dependencies and `uv.lock` pins exact versions.
14+
- CI uses `astral-sh/setup-uv`, and ruff replaces black for formatting and linting (`check_format.yml` -> `check_ruff.yml`).
15+
- Updated the README, `AGENTS.md`, and the Makefile to the uv workflow.
16+
- Bumps `__version__` from `0.0.7` to `0.1.0`, syncing with the package version (the prior `__init__.py` was lagging behind `setup.py`).
17+
18+
### Removed
19+
20+
- `setup.py`, `environment.yml`, `pytest.ini`, and `MANIFEST.in` (their settings moved into `pyproject.toml`).
21+
922
## [0.0.8] - 2025-08-15 21:00:00
1023

1124
### Added
@@ -55,6 +68,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5568

5669
- This version is a pre-release alpha. The example run script OG-IDN/examples/run_og_idn.py runs, but the model is not currently calibrated to represent the Indonesian economy and population.
5770

71+
[0.1.0]: https://github.com/EAPD-DRB/OG-IDN/compare/v0.0.8...v0.1.0
5872
[0.0.8]: https://github.com/EAPD-DRB/OG-IDN/compare/v0.0.7...v0.0.8
5973
[0.0.7]: https://github.com/EAPD-DRB/OG-IDN/compare/v0.0.6...v0.0.7
6074
[0.0.6]: https://github.com/EAPD-DRB/OG-IDN/compare/v0.0.5...v0.0.6

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)