Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docs and test #171

Merged
merged 12 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
148 changes: 96 additions & 52 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,88 @@ orbs:
python: circleci/python@2.1.1
codecov: codecov/codecov@3.2.2

commands:
create_pypirc:
description: "Create .pypirc file"
steps:
- run:
name: init .pypirc
command: |
echo -e "[distutils]" >> ~/.pypirc
echo -e "index-servers = " >> ~/.pypirc
echo -e " pypi" >> ~/.pypirc
echo -e " gpjax-nightly" >> ~/.pypirc
echo -e "" >> ~/.pypirc
echo -e "[pypi]" >> ~/.pypirc
echo -e " username = thomaspinder" >> ~/.pypirc
echo -e " password = $PYPI_TOKEN" >> ~/.pypirc
echo -e "" >> ~/.pypirc
echo -e "[gpjax]" >> ~/.pypirc
echo -e " repository = https://upload.pypi.org/legacy/" >> ~/.pypirc
echo -e " username = __token__" >> ~/.pypirc
echo -e " password = $GPJAX_PYPI" >> ~/.pypirc
echo -e "" >> ~/.pypirc
echo -e "[gpjax-nightly]" >> ~/.pypirc
echo -e " repository = https://upload.pypi.org/legacy/" >> ~/.pypirc
echo -e " username = __token__" >> ~/.pypirc
echo -e " password = $GPJAX_NIGHTLY_PYPI" >> ~/.pypirc
publish_to_pypi:
description: "Publish a package to PyPI"
parameters:
pkgname:
description: Package name
type: string
default: gpjax
nightly:
description: Perform a nightly installation
type: string
default: None
steps:
- run:
name: Build package
command: |
pip install -U twine
python setup.py sdist bdist_wheel
environment:
BUILD_GPJAX_NIGHTLY: << parameters.nightly >>
- run:
name: Upload to PyPI
command: twine upload dist/* -r << parameters.pkgname >> --verbose

install_pandoc:
description: "Install pandoc"
parameters:
pandoc_url:
type: string
pandoc_dest:
type: string
steps:
- restore_cache:
keys:
- pandoc-download
- run:
name: Install pandoc
command: |
if [ ! -f "~/pandoc.tar.gz" ]; then
wget << parameters.pandoc_url >> -O ~/pandoc.tar.gz
fi
sudo tar xvzf ~/pandoc.tar.gz --strip-components 1 -C << parameters.pandoc_dest >>
- save_cache:
key: pandoc-download
paths:
- ~/pandoc.tar.gz

jobs:
build-and-test:
docker:
- image: cimg/python:3.8.0
parallelism: 4
resource_class: large
steps:
- checkout
- restore_cache:
keys:
- pip-cache
- run:
name: Update pip
command: pip install --upgrade pip
Expand All @@ -18,77 +94,45 @@ jobs:
path-args: .[dev]
- run:
name: Run tests
command: pytest --cov=./ --cov-report=xml
command: |
TEST_FILES=$(circleci tests glob "tests/test_*.py" | circleci tests split --split-by=timings)
pytest --cov=./ --cov-report=xml --verbose $TEST_FILES
- run:
name: Upload tests to Codecov
command: |
curl -Os https://uploader.codecov.io/v0.1.0_4653/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN}
- save_cache:
key: pip-cache
paths:
- ~/.cache/pip
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
- codecov/upload:
file: coverage.xml


publish:
docker:
- image: cimg/python:3.9.0
steps:
- checkout
- run:
name: init .pypirc
command: |
echo -e "[distutils]" >> ~/.pypirc
echo -e "index-servers = " >> ~/.pypirc
echo -e " pypi" >> ~/.pypirc
echo -e " gpjax" >> ~/.pypirc
echo -e "" >> ~/.pypirc
echo -e "[pypi]" >> ~/.pypirc
echo -e " username = thomaspinder" >> ~/.pypirc
echo -e " password = $PYPI_TOKEN" >> ~/.pypirc
echo -e "" >> ~/.pypirc
echo -e "[gpjax]" >> ~/.pypirc
echo -e " repository = https://upload.pypi.org/legacy/" >> ~/.pypirc
echo -e " username = __token__" >> ~/.pypirc
echo -e " password = $GPJAX_PYPI" >> ~/.pypirc
- run:
name: Build package
command: |
pip install -U twine
python setup.py sdist bdist_wheel
- run:
name: Upload to PyPI
command: twine upload dist/* -r gpjax --verbose
- create_pypirc
- publish_to_pypi:
pkgname: gpjax

publish-nightly:
docker:
- image: cimg/python:3.9.0
steps:
- checkout
- run:
name: init .pypirc
command: |
echo -e "[distutils]" >> ~/.pypirc
echo -e "index-servers = " >> ~/.pypirc
echo -e " pypi" >> ~/.pypirc
echo -e " gpjax-nightly" >> ~/.pypirc
echo -e "" >> ~/.pypirc
echo -e "[pypi]" >> ~/.pypirc
echo -e " username = thomaspinder" >> ~/.pypirc
echo -e " password = $PYPI_TOKEN" >> ~/.pypirc
echo -e "" >> ~/.pypirc
echo -e "[gpjax-nightly]" >> ~/.pypirc
echo -e " repository = https://upload.pypi.org/legacy/" >> ~/.pypirc
echo -e " username = __token__" >> ~/.pypirc
echo -e " password = $GPJAX_NIGHTLY_PYPI" >> ~/.pypirc
- run:
name: Build package
command: |
pip install -U twine
python setup.py sdist bdist_wheel
environment:
BUILD_GPJAX_NIGHTLY: 'nightly'
- run:
name: Upload to PyPI
command: twine upload dist/* -r gpjax-nightly --verbose
- create_pypirc
- publish_to_pypi:
pkgname: gpjax-nigthly
nightly: nightly

workflows:
main:
Expand All @@ -112,6 +156,6 @@ workflows:
filters:
branches:
only:
- main
- master
jobs:
- publish-nightly
40 changes: 40 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build the documentation

on:
pull_request:
branches: [master]

jobs:
build:
name: Build docs (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9"]
steps:
- name: Checkout the branch
uses: actions/checkout@v2.3.1
with:
persist-credentials: false

- name: create Conda environment
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}

# - name: Set up Python 3.9
# uses: actions/setup-python@v1
# with:
# python-version: 3.9

- name: Build the documentation with Sphinx
run: |
pip install -r docs/requirements.txt
conda install pandoc
cd docs
make html
3 changes: 2 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SPHINXOPTS = -j auto
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# NCORES ?= $(shell nproc)

# Put it first so that "make" without argument is like "make help".
help:
Expand All @@ -12,4 +13,4 @@ help:
.PHONY: help Makefile

%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
11 changes: 9 additions & 2 deletions docs/_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,17 @@ Configuration
.. automodule:: gpjax.config
.. currentmodule:: gpjax.config

.. autofunction:: add_parameter

.. autofunction:: get_defaults
.. autofunction:: get_global_config_if_exists

.. autofunction:: add_parameter
.. autofunction:: get_default_config

.. autofunction:: update_x64_sensitive_settings

.. autofunction:: get_global_config

.. autofunction:: reset_global_config


Quadrature
Expand Down
11 changes: 8 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

from importlib_metadata import version

import docs.conf_sphinx_patch


def read(*names, **kwargs):
"""Function to decode a read files. Credit GPyTorch."""
Expand Down Expand Up @@ -59,7 +57,14 @@ def find_version(*file_paths):
author = "Thomas Pinder"

# The full version, including alpha/beta/rc tags
version = find_version("gpjax", "__init__.py")
import sys
from os.path import join, pardir, dirname

sys.path.insert(0, join(dirname(__file__), pardir))

import gpjax

version = gpjax.__version__
release = version


Expand Down
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ matplotlib==3.3.3
seaborn
sphinx-copybutton
networkx>=2.0.0
pandoc
sphinxcontrib.bibtex
jupytext
ipython
Expand Down
2 changes: 1 addition & 1 deletion examples/barycentres.pct.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def wasserstein_barycentres(
cov_stack = jnp.stack(covariances)
stack_sqrt = jax.vmap(sqrtm)(cov_stack)

def step(covariance_candidate: jax.Array):
def step(covariance_candidate: jax.Array, idx: None):
inner_term = jax.vmap(sqrtm)(
jnp.matmul(jnp.matmul(stack_sqrt, covariance_candidate), stack_sqrt)
)
Expand Down
1 change: 1 addition & 0 deletions examples/classification.pct.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from jaxtyping import Array, Float
from jaxutils import Dataset
import jaxkern as jk
import jax

import gpjax as gpx

Expand Down
Loading