Skip to content

Commit

Permalink
Merge branch 'development' into feat/color488
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranra committed Dec 23, 2024
2 parents f2ef4a3 + 4277973 commit 34bb330
Show file tree
Hide file tree
Showing 35 changed files with 2,228 additions and 325 deletions.
94 changes: 60 additions & 34 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
ignore-nothing-to-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/requirements*.txt
**/uv.lock
- name: Remove conflicting README.md
run: |
if [ -f crates/pecos-python/README.md ]; then
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
echo "Moved conflicting README.md to README.md.bak"
else
echo "No conflicting README.md found"
fi
- name: Build pecos-rslib SDist
Expand All @@ -87,15 +94,13 @@ jobs:
run: |
if [ -f crates/pecos-python/README.md.bak ]; then
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
echo "Restored README.md from backup"
else
echo "No README.md backup found"
fi
- name: Test pecos-rslib SDist
- name: Install and test pecos-rslib SDist
run: |
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.tar.gz
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
uv sync --project .
uv pip install --force-reinstall python/pecos-rslib/dist/*.tar.gz
uv run python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
- name: Upload pecos-rslib SDist
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -130,13 +135,20 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
ignore-nothing-to-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/requirements*.txt
**/uv.lock
- name: Remove conflicting README.md
run: |
if [ -f crates/pecos-python/README.md ]; then
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
echo "Moved conflicting README.md to README.md.bak"
else
echo "No conflicting README.md found"
fi
- name: Build wheel
Expand All @@ -153,16 +165,14 @@ jobs:
run: |
if [ -f crates/pecos-python/README.md.bak ]; then
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
echo "Restored README.md from backup"
else
echo "No README.md backup found"
fi
- name: Test wheel
if: ${{ !(matrix.architecture == 'x86_64' && matrix.os == 'macos-latest') && matrix.architecture != 'aarch64' }}
run: |
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.whl
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
uv sync --project .
uv pip install --force-reinstall python/pecos-rslib/dist/*.whl
uv run python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
- name: Upload wheel
uses: actions/upload-artifact@v4
Expand All @@ -187,29 +197,38 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
ignore-nothing-to-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/requirements*.txt
**/uv.lock
- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ env.PYTHON_VERSION }}
path: ./pecos-rslib-wheel

- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl

- name: Install build dependencies
- name: Setup environment and install dependencies
run: |
python -m pip install --upgrade pip
pip install build
uv sync --project .
uv pip install ./pecos-rslib-wheel/*.whl
uv pip install build
- name: Build quantum-pecos SDist
run: |
cd python/quantum-pecos
uv pip install --system build
python -m build --sdist --outdir dist
- name: Test quantum-pecos SDist
run: |
pip install python/quantum-pecos/dist/*.tar.gz
python -c 'import pecos; print(pecos.__version__)'
uv pip install python/quantum-pecos/dist/*.tar.gz
uv run python -c 'import pecos; print(pecos.__version__)'
- name: Upload quantum-pecos SDist
uses: actions/upload-artifact@v4
Expand All @@ -233,24 +252,30 @@ jobs:
with:
ref: ${{ inputs.sha || github.sha }}

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
ignore-nothing-to-cache: true
cache-dependency-glob: |
**/pyproject.toml
**/requirements*.txt
**/uv.lock
- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ matrix.python-version }}
path: ./pecos-rslib-wheel

- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl

- name: Install build dependencies
- name: Setup environment and install dependencies
run: |
python -m pip install --upgrade pip
pip install build
uv pip install --system ./pecos-rslib-wheel/*.whl build
- name: Build quantum-pecos wheel
run: |
Expand All @@ -259,8 +284,9 @@ jobs:
- name: Test quantum-pecos wheel
run: |
pip install python/quantum-pecos/dist/*.whl
python -c 'import pecos; print(pecos.__version__)'
uv sync # This will use the workspace config correctly
uv pip install python/quantum-pecos/dist/*.whl
uv run python -c 'import pecos; print(pecos.__version__)'
- name: Upload quantum-pecos wheel
uses: actions/upload-artifact@v4
Expand Down
55 changes: 24 additions & 31 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Python test / linting

on:
push:
branches: [ "master", "development" ]
Expand All @@ -22,7 +21,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


env:
RUSTFLAGS: -C debuginfo=0
RUST_BACKTRACE: 1
Expand All @@ -34,7 +32,6 @@ defaults:

jobs:
python-test:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -50,25 +47,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Create and activate virtual environment
env:
BIN: ${{ matrix.os == 'windows-latest' && 'Scripts' || 'bin' }}
run: |
python -m venv .venv
source .venv/$BIN/activate
echo "$GITHUB_WORKSPACE/.venv/$BIN" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install maturin pre-commit
echo "Temporarily removing pecos-rslib from requirements... because we need to build it"
grep -v "pecos-rslib" python/quantum-pecos/requirements.txt > temp_requirements.txt
echo "Installing project requirements (excluding pecos-rslib)..."
pip install -r temp_requirements.txt
echo "Cleaning up temporary files..."
rm temp_requirements.txt
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Set up Rust
run: rustup show
Expand All @@ -78,23 +60,34 @@ jobs:
with:
workspaces: python/pecos-rslib

- name: Install pecos-rslib with maturin develop
- name: Generate lockfile and install dependencies
run: |
uv lock --project .
uv sync --project .
- name: Install pecos-rslib with maturin
run: |
cd python/pecos-rslib
maturin develop
uv run maturin develop --uv
- name: Install pure Python PECOS
run: pip install ./python/quantum-pecos/
- name: Install quantum-pecos
run: |
cd python/quantum-pecos
uv pip install -e .
- name: Run pre-commit checks
run: uv run pre-commit run --all-files --show-diff-on-failure

- name: Install test dependencies
run: |
pre-commit run --all-files --show-diff-on-failure
cd python/quantum-pecos
uv pip install -e .[all,test] # Install with both all and test extras
uv pip install pytest pytest-cov # Explicitly install test requirements
- name: Run standard tests
run: |
pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
uv run pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
- name: Run tests with optional dependencies
- name: Run optional dependency tests
run: |
pip install ./python/quantum-pecos/[all]
pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
uv run pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
39 changes: 7 additions & 32 deletions development.md → DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,14 @@ For developers who want to contribute or modify PECOS:
cd PECOS
```

3. Set up the development environment either using the `Makefile` (Note: for Windows to use the `Makefile` you may need to use a shell that has access to Linux commands such as utilizing [git bash](https://gitforwindows.org/)):
```sh
make venv
```
<details>
<summary>or manually set up a Python virtual environment for develop of this project's code.</summary>

On Linux/Mac:

```sh
python -m venv .venv
source .venv/bin/activate
pip install -U pip setuptools
pip install -r python/quantum-pecos/requirements.txt
make metadeps
pre-commit install
```

On Windows:
3. [Install `uv` for your system](https://docs.astral.sh/uv/getting-started/installation/).
And run the following at the root of the project to create a development environment, which will be stored in `.venv/`:

```sh
python -m venv .venv
.\venv\Scripts\activate
pip install -U pip setuptools
pip install -r python/quantum-pecos/requirements.txt
make metadeps
pre-commit install
uv sync
```
</details>


4. When developing in the development environment, be sure to activate the venv:
4. You may wish to explicitly activate the environment for development. To do so:

On Linux/Mac:
```sh
Expand All @@ -50,24 +26,21 @@ For developers who want to contribute or modify PECOS:

On Windows:
```sh
.\venv\Scripts\activate
.\.venv\Scripts\activate
```


5. Build the project in editable mode
```sh
make build
```
See other build options in the `Makefile`.


6. Run all Python and Rust tests:
```sh
make test
```
Note: Make sure you have run a build command before running tests.


7. Run linters using pre-commit (after [installing it](https://pre-commit.com/)) to make sure all everything is properly linted/formated
```sh
make lint
Expand All @@ -78,4 +51,6 @@ For developers who want to contribute or modify PECOS:
deactivate
```

Before pull requests are merged, they must pass linting and the test.

Note: For the Rust side of the project, you can use `cargo` to run tests, benchmarks, formatting, etc.
Loading

0 comments on commit 34bb330

Please sign in to comment.