Skip to content

[ENH] Add the ability to check the validity of a PAG #670

[ENH] Add the ability to check the validity of a PAG

[ENH] Add the ability to check the validity of a PAG #670

Workflow file for this run

name: gh-ci-checks
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.type }}
cancel-in-progress: true
on:
pull_request:
paths:
- "**.py"
- "**.yml"
- "**.toml"
push:
branches: [main]
paths:
- "**.py"
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
style:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
architecture: "x64"
- name: Install packages for Ubuntu
run: |
sudo apt-get update
sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r style_requirements.txt
# check formatting of the code style
- name: Check code formatting
run: make pre-commit
build:
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# upgrade to macos-latest when 3.10 is removed
os: ["ubuntu-latest", "macos-13", "windows-latest"]
python-version: ["3.10", "3.11", "3.12"]
name: build ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Install and setup package
run: |
python -m pip install --progress-bar off .[build]
- name: Test package install
run: python -c "import pywhy_graphs; print(pywhy_graphs.__version__)"
- name: Remove package install
run: python -m pip uninstall -yq pywhy_graphs
- name: Build package
run: python -m build
- name: Upload package distribution files
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.11' }}
uses: actions/upload-artifact@v4
with:
name: package
path: dist
- name: Install sdist
run: pip install ./dist/*.tar.gz
- name: Test sdist install
run: python -c "import pywhy_graphs; print(pywhy_graphs.__version__)"
- name: Remove sdist install
run: python -m pip uninstall -yq pywhy_graphs
- name: Install wheel
run: pip install ./dist/*.whl
- name: Test wheel install
run: python -c "import pywhy_graphs; print(pywhy_graphs.__version__)"
- name: Remove wheel install
run: python -m pip uninstall -yq pywhy_graphs
test:
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
# oldest and newest supported versions
python-version: ["3.10", "3.11"] # TODO: update to 3.12 when statsmodels supports
networkx: [stable, main]
exclude:
- { python-version: "3.10", os: "macos-latest" }
include:
- { python-version: "3.10", os: "macos-13" }
name: Unit-test ${{ matrix.os }} - py${{ matrix.python-version }} - Networkx ${{ matrix.networkx }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Setup torch for pgmpy
if: "matrix.os == 'ubuntu'"
shell: bash
run: |
sudo apt-get update
sudo apt-get install nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc
- name: Install packages via pip
run: |
python -m pip install --upgrade pip
python -m pip install numpy scipy networkx statsmodels
python -m pip install .[test]
- name: Install DoDiscover (main)
run: |
git clone https://github.com/py-why/dodiscover.git
cd dodiscover
python -m pip install .
- name: Install Networkx (main)
if: "matrix.networkx == 'main'"
run: |
pip uninstall -yq networkx
git clone https://github.com/networkx/networkx.git
cd networkx
pip install .[default]
# pip install --progress-bar off git+https://github.com/networkx/networkx
- name: Run pytest # headless via Xvfb on linux
run: |
pytest --cov pywhy_graphs ./pywhy_graphs
- name: Upload coverage stats to codecov
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.11' && matrix.networkx == 'stable' }}
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
# release is ran when a release is made on Github
release:
name: Release
runs-on: ubuntu-latest
needs: [style, build, test]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.10"
architecture: "x64"
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install --progress-bar off build twine
- name: Prepare environment
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Download package distribution files
uses: actions/download-artifact@v4
with:
name: package
path: dist
# TODO: refactor scripts to generate release notes from `whats_new.rst` file instead
# - name: Generate release notes
# run: |
# python scripts/release_notes.py > ${{ github.workspace }}-RELEASE_NOTES.md
- name: Publish package to PyPI
run: |
twine upload -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} dist/*
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# body_path: ${{ github.workspace }}-RELEASE_NOTES.md
prerelease: ${{ contains(env.TAG, 'rc') }}
files: |
dist/*