Skip to content

Commit

Permalink
Update circleCI and gh actions and package to python 3.9 (#137)
Browse files Browse the repository at this point in the history
* Update circleCI and gh actions and package to python 3.9

---------

Signed-off-by: Adam Li <[email protected]>
  • Loading branch information
adam2392 authored Jun 21, 2023
1 parent 7221295 commit dd7cbbb
Show file tree
Hide file tree
Showing 7 changed files with 677 additions and 1,438 deletions.
147 changes: 39 additions & 108 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
version: 2.1

orbs:
python: circleci/[email protected]

jobs:
build_doc:
executor: python/default
docker:
- image: cimg/python:3.9

steps:
- restore_cache:
name: Restore .git
keys:
- source-cache-graphs
- checkout

- run:
name: Complete checkout
command: |
Expand All @@ -34,61 +30,59 @@ jobs:
echo "Skip detected, exiting job ${CIRCLE_JOB} for PR ${CIRCLE_PULL_REQUEST}."
circleci-agent step halt;
fi
- run:
name: Merge with upstream
command: |
echo $(git log -1 --pretty=%B) | tee gitlog.txt
echo ${CI_PULL_REQUEST//*pull\//} | tee merge.txt
if [[ $(cat merge.txt) != "" ]]; then
echo "Merging $(cat merge.txt)";
git pull --ff-only upstream "refs/pull/$(cat merge.txt)/merge";
fi
- run:
name: Install the latest version of Poetry
command: |
curl -sSL https://install.python-poetry.org | python3 - --version 1.3.0
poetry --version
- restore_cache:
keys:
- poetry-v1-{{ checksum "poetry.lock" }}
- poetry-v1-

- run:
name: Set BASH_ENV
command: |
set -e
sudo apt update
sudo apt-get update
sudo apt install -qq graphviz optipng libxft2 graphviz-dev
echo "set -e" >> $BASH_ENV
echo "export OPENBLAS_NUM_THREADS=4" >> $BASH_ENV
echo "export XDG_RUNTIME_DIR=/tmp/runtime-circleci" >> $BASH_ENV
echo "export PATH=~/.local/bin/:$PATH" >> $BASH_ENV
echo "export DISPLAY=:99" >> $BASH_ENV
echo "BASH_ENV:"
echo 'set -e' >> $BASH_ENV
echo 'export OPENBLAS_NUM_THREADS=4' >> $BASH_ENV
echo 'export XDG_RUNTIME_DIR=/tmp/runtime-circleci' >> $BASH_ENV
echo 'export PATH=~/.local/bin/:$PATH' >> $BASH_ENV
echo 'export DISPLAY=:99' >> $BASH_ENV
echo 'BASH_ENV:'
cat $BASH_ENV
- run:
name: Install pysal dependencies
command: |
sudo apt install libspatialindex-dev xdg-utils
- python/install-packages:
pkg-manager: poetry
args: "-E graph_func -E viz --with docs"
cache-version: "v1" # change to clear cache
- run:
name: Check poetry package versions
command: |
poetry --version
poetry show
sudo apt install libspatialindex-dev xdg-utils shared-mime-info
- run:
name: Setup pandoc
command: sudo apt update && sudo apt install -y pandoc optipng

- run:
name: Install Poetry
command: |
curl -sSL https://install.python-poetry.org | python -
export PATH='$HOME/.poetry/bin:$PATH'
- run:
name: Install Dependencies
command: |
poetry install --no-interaction --no-ansi --with docs --extras viz --extras graph_func
- run:
name: Check installation
name: Show installed versions
command: |
poetry run python -c "import dodiscover;"
poetry run python -c "import numpy; numpy.show_config()"
LIBGL_DEBUG=verbose poetry run python -c "import matplotlib.pyplot as plt; plt.figure()"
poetry show
- save_cache:
paths:
- $HOME/.poetry
key: poetry-v1-{{ checksum "poetry.lock" }}

- run:
name: Build documentation
name: Build Documentation
command: |
cd doc
poetry run make html
poetry run poe build_docs
# Save the example test results
- store_test_results:
path: doc/_build/test-results
Expand All @@ -113,53 +107,6 @@ jobs:
- html
- html_stable

linkcheck:
parameters:
scheduled:
type: string
default: "false"
executor: python/default
steps:
- restore_cache:
keys:
- source-cache-graphs
- checkout
- run:
name: Check-skip
command: |
export COMMIT_MESSAGE=$(git log --format=oneline -n 1);
if [[ "$COMMIT_MESSAGE" != *"[circle linkcheck]"* ]] && [ "<< parameters.scheduled >>" != "true" ]; then
echo "Skip detected, exiting job ${CIRCLE_JOB}."
circleci-agent step halt;
fi
- run:
name: Set BASH_ENV
command: |
set -e
echo "set -e" >> $BASH_ENV
echo "export PATH=~/.local/bin/:$PATH" >> $BASH_ENV
- python/install-packages:
pkg-manager: poetry
cache-version: "v1" # change to clear cache
args: "--with docs"
- run:
name: Check poetry package versions
command: |
poetry --version
poetry show
- run:
name: make linkcheck
command: |
make -C doc linkcheck
- run:
name: make linkcheck-grep
when: always
command: |
make -C doc linkcheck-grep
- store_artifacts:
path: doc/_build/linkcheck
destination: linkcheck

deploy:
docker:
- image: cimg/node:lts
Expand Down Expand Up @@ -209,8 +156,6 @@ workflows:
jobs:
- build_doc:
name: build_doc
- linkcheck:
name: linkcheck
- deploy:
requires:
- build_doc
Expand All @@ -236,17 +181,3 @@ workflows:
branches:
only:
- main

weekly:
jobs:
- linkcheck:
name: linkcheck_weekly
scheduled: "true"
triggers:
- schedule:
# "At 00:00 on Sunday" should be often enough
cron: "0 0 * * 0"
filters:
branches:
only:
- main
30 changes: 20 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
poetry-version: [1.3.0]
poetry-version: [1.5.1]
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -58,8 +58,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: [3.8, 3.9, "3.10"]
poetry-version: [1.3.0]
python-version: [3.9, "3.10", "3.11"]
poetry-version: [1.5.1]
name: build ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
defaults:
Expand Down Expand Up @@ -121,8 +121,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: [3.8, "3.10"] # oldest and newest supported versions
poetry-version: [1.3.0]
python-version: [3.9, "3.11"] # oldest and newest supported versions
poetry-version: [1.5.1]
networkx: [stable, main]
name: Unit-test ${{ matrix.os }} - py${{ matrix.python-version }} - Networkx ${{ matrix.networkx }}
runs-on: ${{ matrix.os }}-latest
Expand Down Expand Up @@ -165,8 +165,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu]
python-version: ["3.10"] # oldest and newest supported versions
poetry-version: [1.3.0]
python-version: ["3.10"] # oldest and newest supported versions
poetry-version: [1.5.1]
networkx: [main]
name: Integration test ${{ matrix.os }} - py${{ matrix.python-version }} - Networkx ${{ matrix.networkx }}
runs-on: ${{ matrix.os }}-latest
Expand All @@ -180,17 +180,27 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
architecture: "x64"
- name: Install Poetry ${{ matrix.poetry-version }}
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Install packages for Ubuntu
run: |
sudo apt-get update
sudo apt-get install -y graphviz optipng libxft2 graphviz-dev
- name: Setup torch
run: |
sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
- name: Install Poetry Dynamic Versioning Plugin
run: pip install poetry-dynamic-versioning
- name: Install packages via poetry
run: |
poetry install --with test,docs --extras graph_func
- name: Run pytest # headless via Xvfb on linux
- name: Run pytest # headless via Xvfb on linux
run: poetry run poe integration_test

# release is ran when a release is made on Github
Expand Down Expand Up @@ -220,7 +230,7 @@ jobs:
- name: Build the release artifact
run: |
poetry-dynamic-versioning
poetry build
poetry build
- name: Download package distribution files
uses: actions/download-artifact@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ Installation is best done via `pip` or `conda`. For developers, they can also in

Minimally, dodiscover requires:

* Python (>=3.8)
* Python (>=3.9)
* numpy
* scipy
* networkx
* pandas

For explicit graph functionality for representing various causal graphs, such as ADMG, or CPDAGs, you will also need:
We have removed support for Python 3.8 as we depend explicitly on networkx, which has deprecated Python 3.8 support. For explicit graph functionality for representing various causal graphs, such as ADMG, or CPDAGs, you will also need:

* pywhy-graphs
* graphs # this is a development version for PRable MixedEdgeGraph to networkx
Expand Down
7 changes: 1 addition & 6 deletions dodiscover/_version.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
"""Version number."""

# TODO: Remove try/except once the minimum python requirement is bumped to 3.8
try:
from importlib.metadata import version # type: ignore
except ImportError:
from importlib_metadata import version # type: ignore
from importlib.metadata import version # type: ignore

__version__ = version(__package__)
Loading

0 comments on commit dd7cbbb

Please sign in to comment.