Skip to content

Commit

Permalink
Add Hatch (#468)
Browse files Browse the repository at this point in the history
* Add Hatch

* Update workflows

* Update workflows

* Update workflows

* Add networkx

* Update tests

* Add formatters

* Drop Poetry refs

* Respond to PR comments
  • Loading branch information
thomaspinder authored Aug 21, 2024
1 parent c962092 commit 4fb76f1
Show file tree
Hide file tree
Showing 40 changed files with 486 additions and 4,832 deletions.
10 changes: 1 addition & 9 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
## Type of changes

- [ ] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [ ] Other

## Checklist

- [ ] I've formatted the new code by running `poetry run pre-commit run --all-files --show-diff-on-failure` before committing.
- [ ] I've formatted the new code by running `hatch run dev:format` before committing.
- [ ] I've added tests for new code.
- [ ] I've added docstrings for the new code.

Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,15 @@ jobs:
- name: Install KaTeX
run: |
npm install katex
# Install Poetry and build the documentation
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: false
virtualenvs-in-project: false
installer-parallel: true
# Install Hatch
- name: Install Hatch
uses: pypa/hatch@install

- name: Build the documentation with MKDocs
run: |
poetry install --all-extras --with docs
conda install pandoc
poetry run python docs/scripts/gen_examples.py --execute && poetry run mkdocs build
hatch run docs:build
- name: Deploy Page 🚀
uses: JamesIves/[email protected]
Expand Down
20 changes: 4 additions & 16 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# Install Poetry
- name: Install Poetry
uses: snok/[email protected]
with:
version: 1.5.1

# Configure Poetry to use the virtual environment in the project
- name: Setup Poetry
run: |
poetry config virtualenvs.in-project true
# Install the dependencies
- name: Install Package
run: |
poetry install --with docs
# Install Hatch
- name: Install Hatch
uses: pypa/hatch@install

# Run the unit tests and build the coverage report
- name: Run Integration Tests
run: poetry run python tests/integration_tests.py
run: hatch run docs:integration
14 changes: 4 additions & 10 deletions .github/workflows/test_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,11 @@ jobs:
auto-update-conda: true
python-version: ${{ matrix.python-version }}

# Install Poetry and build the documentation
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: false
virtualenvs-in-project: false
installer-parallel: true
# Install Hatch
- name: Install Hatch
uses: pypa/hatch@install

- name: Build the documentation with MKDocs
run: |
poetry install --all-extras --with docs
conda install pandoc
poetry run python docs/scripts/gen_examples.py --execute && poetry run mkdocs build
hatch run docs:build
24 changes: 5 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,18 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# Install Poetry
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: false
virtualenvs-in-project: false
installer-parallel: true

# Configure Poetry to use the virtual environment in the project
- name: Setup Poetry
run: |
poetry config virtualenvs.in-project true
# Install Hatch
- name: Install Hatch
uses: pypa/hatch@install

# Install the dependencies
- name: Install Package
run: |
poetry install --with dev
- name: Check docstrings
run: |
poetry run xdoctest ./gpjax
hatch run dev:docstrings
# Run the unit tests and build the coverage report
- name: Run Tests
run: poetry run pytest -v --cov=./gpjax --cov-report=xml:./coverage.xml
run: hatch run dev:coverage

- name: Upload code coverage
uses: codecov/codecov-action@v3
Expand Down
59 changes: 0 additions & 59 deletions .pre-commit-config.yaml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,14 @@ configuration in development mode.
```bash
git clone https://github.com/JaxGaussianProcesses/GPJax.git
cd GPJax
poetry install
hatch env create
hatch shell
```
> We recommend you check your installation passes the supplied unit tests:
>
> ```python
> poetry run pytest
> hatch run dev:test
> ```
# Citing GPJax
Expand Down
29 changes: 6 additions & 23 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,36 +72,19 @@ you through every detail!
Always use a `feature` branch. It's good practice to avoid
work on the ``main`` branch of any repository.

4. We use [Poetry](https://python-poetry.org/) for packaging and dependency management, and project requirements are in ``pyproject.toml``. We suggest using a [virtual environment](https://docs.python-guide.org/dev/virtualenvs/) for
development. For those using Apple Silicon chips, we advise using [Conda miniforge](https://github.com/conda-forge/miniforge). Once the virtual environment is activated, run:
4. We use [Hatch](https://hatch.pypa.io/latest/) for packaging and dependency management. Project requirements are in ``pyproject.toml``. To install GPJax into a Hatch virtual environment, run:

```bash
$ poetry install
$ hatch env create
```

At this point we recommend you check your installation passes the supplied unit tests:

```bash
$ poetry run pytest
$ hatch run dev:all-tests
```

5. Install the pre-commit hooks.

```bash
$ pre-commit install
```

Please ensure you have done this before committing any files. If
successful, this will print the following output `pre-commit installed at
.git/hooks/pre-commit`.

6. At this point you can manually run the pre-commit hooks with the following command:

```bash
poetry run pre-commit run --all-files
```

7. Add changed files using `git add` and then `git commit` files to record your
5. Add changed files using `git add` and then `git commit` files to record your
changes locally:

```bash
Expand All @@ -122,7 +105,7 @@ development. For those using Apple Silicon chips, we advise using [Conda minifor
$ git push -u origin my-feature
```

8. Go to the GitHub web page of your fork of the GPJax repo. Click the 'Pull
6. Go to the GitHub web page of your fork of the GPJax repo. Click the 'Pull
request' button to send your changes to the project's maintainers for
review.

Expand Down Expand Up @@ -159,7 +142,7 @@ request, we recommend you check the following:
accepted. Test coverage can be checked with:

```bash
$ poetry run pytest tests --cov=./ --cov-report=html
$ hatch run dev:coverage
```

Navigate to the newly created folder `htmlcov` and open `index.html` to view
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ hardware acceleration support as detailed in the
```bash
git clone https://github.com/thomaspinder/GPJax.git
cd GPJax
poetry install
hatch shell create
```

!!! tip
Expand All @@ -45,5 +45,5 @@ hardware acceleration support as detailed in the
and recommend you check your installation passes the supplied unit tests:

```bash
poetry run pytest tests/
hatch run dev:all-tests
```
Loading

0 comments on commit 4fb76f1

Please sign in to comment.