https://github.com/GPflow/GPflow
Raw File
Tip revision: 457ddf89341f5ac22641eda524747fa2ad628a2f authored by Jesper Nielsen on 08 March 2022, 13:31:32 UTC
Support Optional values for check_shapes. (#1797)
Tip revision: 457ddf8
config.yml
version: 2.1

parameters:
  min_py_ver:
    type: string
    default: "3.7"
  max_py_ver:
    type: string
    default: "3.10"
  min_tf_ver:
    type: string
    default: "2.4"
  max_tf_ver:
    type: string
    default: "2.8"
  min_tfp_ver:
    type: string
    default: "0.12"
  max_tfp_ver:
    type: string
    default: "0.16"

commands:
  setup_venv:
    parameters:
      py_ver:
        type: string
    steps:
      - checkout
      - run:
          name: Setup virtual environment
          command: |
            # Run in a fresh virtual environment, to avoid conflicts with preinstalled packages.
            virtualenv -p python<<parameters.py_ver>> .venv
            source .venv/bin/activate
            pip install --progress-bar=off -U pip
  install_gpflow:
    parameters:
      py_ver:
        type: string
      tf_ver:
        type: string
      tfp_ver:
        type: string
    steps:
      - setup_venv:
          py_ver: <<parameters.py_ver>>
      - run:
          name: Install GPflow
          command: "
            source .venv/bin/activate \n
            git clone --branch develop https://github.com/GPflow/GPflow.git \n
            # Everything is installed in one pip command, to allow for better dependency version
            # resolution. Explicit tensorflow and tensorflow-probability version, to ensure
            # consistency between them. \n
            pip install --progress-bar=off
              -e .
              -r tests_requirements.txt
              tensorflow==<<parameters.tf_ver>>
              tensorflow-probability==<<parameters.tfp_ver>> \n
          "
  run_tests:
    parameters:
      py_ver:
        type: string
      tf_ver:
        type: string
      tfp_ver:
        type: string
      pytest_filter:
        type: string
    steps:
      - install_gpflow:
          py_ver: <<parameters.py_ver>>
          tf_ver: <<parameters.tf_ver>>
          tfp_ver: <<parameters.tfp_ver>>
      - run:
          name: Run tests
          command: |
            source .venv/bin/activate
            pytest -v -W ignore::UserWarning --durations=10 -m "<<parameters.pytest_filter>>" --cov=./gpflow ./tests
      - run:
          name: Upload coverage report
          command: |
            source .venv/bin/activate
            bash <(curl -s https://codecov.io/bash) -t "${CODECOV_TOKEN}"

jobs:
  verify-install:
    parameters:
      py_ver:
        type: string
      tf_ver:
        type: string
      tfp_ver:
        type: string
    docker:
      - image: cimg/python:<<parameters.py_ver>>
    steps:
      - install_gpflow:
          py_ver: <<parameters.py_ver>>
          tf_ver: <<parameters.tf_ver>>
          tfp_ver: <<parameters.tfp_ver>>
      - run:
          name: Check installed dependencies are compatible
          command: |
            source .venv/bin/activate
            pip check -vvv
            python -c "import gpflow"

  type-check:
    parameters:
      py_ver:
        type: string
      tf_ver:
        type: string
      tfp_ver:
        type: string
    docker:
      - image: cimg/python:<<parameters.py_ver>>
    steps:
      - install_gpflow:
          py_ver: <<parameters.py_ver>>
          tf_ver: <<parameters.tf_ver>>
          tfp_ver: <<parameters.tfp_ver>>
      - run:
          name: Run type check
          command: |
            source .venv/bin/activate
            mypy gpflow tests

  format-check:
    parameters:
      py_ver:
        type: string
      tf_ver:
        type: string
      tfp_ver:
        type: string
    docker:
      - image: cimg/python:<<parameters.py_ver>>
    steps:
      - install_gpflow:
          py_ver: <<parameters.py_ver>>
          tf_ver: <<parameters.tf_ver>>
          tfp_ver: <<parameters.tfp_ver>>
      - run:
          name: Run format check
          command: |
            source .venv/bin/activate
            make format-check

  unit-test:
    parameters:
      py_ver:
        type: string
      tf_ver:
        type: string
      tfp_ver:
        type: string
    docker:
      - image: cimg/python:<<parameters.py_ver>>
    steps:
      - run_tests:
          py_ver: <<parameters.py_ver>>
          tf_ver: <<parameters.tf_ver>>
          tfp_ver: <<parameters.tfp_ver>>
          pytest_filter: not notebooks

  notebook-test:
    parameters:
      py_ver:
        type: string
      tf_ver:
        type: string
      tfp_ver:
        type: string
    docker:
      - image: cimg/python:<<parameters.py_ver>>
    steps:
      - run_tests:
          py_ver: <<parameters.py_ver>>
          tf_ver: <<parameters.tf_ver>>
          tfp_ver: <<parameters.tfp_ver>>
          pytest_filter: notebooks

  trigger-docs-generation:
    docker:
      - image: cimg/python:<<pipeline.parameters.min_py_ver>>
        environment:
            ORGANIZATION: GPflow
            PROJECT: docs
            BRANCH: << pipeline.git.branch >>
    steps:
      - run:
          name: Trigger the Build Job in Docs repo
          # Compiled documentation for readthedocs are built and stored in the https://github.com/GPflow/docs/ repository
          # For configuration of the doc build, see https://github.com/GPflow/docs/blob/develop/.circleci/config.yml
          command: |
            curl \
              -u ${DOCS_TOKEN}: \
              -d 'build_parameters[CIRCLE_JOB]=build' \
              https://circleci.com/api/v1.1/project/github/GPflow/docs/tree/<< pipeline.git.branch >>

  deploy:
    docker:
      - image: cimg/python:<<pipeline.parameters.min_py_ver>>
    steps:
      - checkout
      - run:
          name: Verify git tag vs. VERSION
          command: |
            VERSION="v$(cat VERSION | tr -d '\t\r\n ')"
            if [ "$VERSION" != "$CIRCLE_TAG" ]; then
              echo "The package version ($VERSION) and the latest tag version ($CIRCLE_TAG) are different"
              exit 1
            fi
      - run:
          name: Install twine
          command: |
            # Run in a fresh virtual environment, to avoid conflicts with preinstalled packages.
            virtualenv -p python<<pipeline.parameters.min_py_ver>> .venv
            source .venv/bin/activate
            pip install --progress-bar=off -U pip
            pip install --progress-bar=off twine
      - run:
          name: Init .pypirc
          command: |
            echo -e "[pypi]" >> ~/.pypirc
            echo -e "username = artemav" >> ~/.pypirc
            echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
      - run:
          name: Create pip package
          command: |
            source .venv/bin/activate
            python setup.py bdist_wheel sdist
      - run:
          name: Upload to PyPI
          command: |
            source .venv/bin/activate
            twine upload dist/*


workflows:
  version: 2.1
  build_test_and_deploy:
    jobs:
      - verify-install:
          name: verify-install-min
          py_ver: <<pipeline.parameters.min_py_ver>>
          tf_ver: <<pipeline.parameters.min_tf_ver>>
          tfp_ver: <<pipeline.parameters.min_tfp_ver>>
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - verify-install:
          name: verify-install-max
          py_ver: <<pipeline.parameters.max_py_ver>>
          tf_ver: <<pipeline.parameters.max_tf_ver>>
          tfp_ver: <<pipeline.parameters.max_tfp_ver>>
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - type-check:
          name: type-check-min
          py_ver: <<pipeline.parameters.min_py_ver>>
          tf_ver: <<pipeline.parameters.min_tf_ver>>
          tfp_ver: <<pipeline.parameters.min_tfp_ver>>
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - type-check:
          name: type-check-max
          py_ver: <<pipeline.parameters.max_py_ver>>
          tf_ver: <<pipeline.parameters.max_tf_ver>>
          tfp_ver: <<pipeline.parameters.max_tfp_ver>>
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - format-check:
          name: format-check-min
          py_ver: <<pipeline.parameters.min_py_ver>>
          tf_ver: <<pipeline.parameters.min_tf_ver>>
          tfp_ver: <<pipeline.parameters.min_tfp_ver>>
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - format-check:
          name: format-check-max
          py_ver: <<pipeline.parameters.max_py_ver>>
          tf_ver: <<pipeline.parameters.max_tf_ver>>
          tfp_ver: <<pipeline.parameters.max_tfp_ver>>
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - unit-test:
          name: unit-test-min
          py_ver: <<pipeline.parameters.min_py_ver>>
          tf_ver: <<pipeline.parameters.min_tf_ver>>
          tfp_ver: <<pipeline.parameters.min_tfp_ver>>
          requires:
            - verify-install-min
            - verify-install-max
            - type-check-min
            - type-check-max
            - format-check-min
            - format-check-max
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - unit-test:
          name: unit-test-max
          py_ver: <<pipeline.parameters.max_py_ver>>
          tf_ver: <<pipeline.parameters.max_tf_ver>>
          tfp_ver: <<pipeline.parameters.max_tfp_ver>>
          requires:
            - verify-install-min
            - verify-install-max
            - type-check-min
            - type-check-max
            - format-check-min
            - format-check-max
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - notebook-test:
          name: notebook-test-min
          py_ver: <<pipeline.parameters.min_py_ver>>
          tf_ver: <<pipeline.parameters.min_tf_ver>>
          tfp_ver: <<pipeline.parameters.min_tfp_ver>>
          requires:
            - verify-install-min
            - verify-install-max
            - type-check-min
            - type-check-max
            - format-check-min
            - format-check-max
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - notebook-test:
          name: notebook-test-max
          py_ver: <<pipeline.parameters.max_py_ver>>
          tf_ver: <<pipeline.parameters.max_tf_ver>>
          tfp_ver: <<pipeline.parameters.max_tfp_ver>>
          requires:
            - verify-install-min
            - verify-install-max
            - type-check-min
            - type-check-max
            - format-check-min
            - format-check-max
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
      - trigger-docs-generation:
          requires:
            - verify-install-min
            - verify-install-max
            - type-check-min
            - type-check-max
            - format-check-min
            - format-check-max
            - unit-test-min
            - unit-test-max
            - notebook-test-min
            - notebook-test-max
          filters:
            branches:
              only:
                - master
                - develop
      - deploy:
          requires:
            - verify-install-min
            - verify-install-max
            - type-check-min
            - type-check-max
            - format-check-min
            - format-check-max
            - unit-test-min
            - unit-test-max
            - notebook-test-min
            - notebook-test-max
          filters:
            tags:
              only: /^v[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
            branches:
              ignore: /.*/
back to top