From 655c0ae94d6f0f03e2a135eac0fcd4e5ab168b36 Mon Sep 17 00:00:00 2001 From: kylebystrom Date: Wed, 24 Apr 2024 14:05:31 -0400 Subject: [PATCH] start drafting github actions tests --- .github/workflows/run_tests.sh | 7 +++++ .github/workflows/tests.yml | 52 +++++++++++++++++++++++++++++++++ scripts/download_functionals.py | 43 +++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 .github/workflows/run_tests.sh create mode 100644 .github/workflows/tests.yml create mode 100644 scripts/download_functionals.py diff --git a/.github/workflows/run_tests.sh b/.github/workflows/run_tests.sh new file mode 100644 index 0000000..b8a051b --- /dev/null +++ b/.github/workflows/run_tests.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +export OMP_NUM_THREADS=2 +export PYTHONPATH=$(pwd):$PYTHONPATH +ulimit -s 20000 + +version=$(python -c 'import sys; print("{0}.{1}".format(*sys.version_info[:2]))') +PYTHONHASHSEED=0 pytest ciderpress/ -s -c pytest.ini ciderpress diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..853161a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,52 @@ +name: Run PySCF Tests + +on: + push: + branches: + - dev + + pull_request: + branches: + - dev + +jobs: + build: + + runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: ['3.10'] + defaults: + run: + shell: bash -el {0} + steps: + - uses: actions/checkout@v3 + - name: Setup conda environment + uses: mamba-org/setup-micromamba@v1 + with: + micromamba-version: '1.5.6-0' # any version from https://github.com/mamba-org/micromamba-releases + environment-file: nocomp_env.yml + environment-name: run_tests + init-shell: >- + bash + powershell + cache-environment: true + post-cleanup: 'all' + create-args: >- + python=3.10 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install dependencies and build + run: | + sudo apt-get -qq install gcc libblas-dev cmake + - name: Build things + run: | + source .github/workflows/load_conda.sh + python setup.py build_ext --inplace + python scripts/download_functionals.py + - name: Test with unittest + run: | + # See https://github.com/pytest-dev/pytest/issues/1075 + source .github/workflows/load_conda.sh + sh .github/workflows/run_tests.sh + # PYTHONHASHSEED=0 OMP_NUM_THREADS=2 python -m unittest discover ciderpress/dft/tests/ diff --git a/scripts/download_functionals.py b/scripts/download_functionals.py new file mode 100644 index 0000000..604e607 --- /dev/null +++ b/scripts/download_functionals.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +# CiderPress: Machine-learning based density functional theory calculations +# Copyright (C) 2024 The President and Fellows of Harvard College +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# +# Author: Kyle Bystrom +# + +import os +import subprocess + +basedir = __file__ +savedir = os.path.basename(os.path.join(basedir, "../functionals")) + +os.makedirs(savedir, exist_ok=True) + +links = { + "NL_GGA": "1UNxxvYpxc8RkywxIynbenkLEMGviIce1", + "NL_MGGA_DTR": "1-233LBivti-UDfbSuOMdPZuyC_Gibto0", + "NL_MGGA_PBE": "15x8s_Pf3_iYoAHl_sWChB2q1HFif1jFA", + "NL_MGGA": "1wwYFSJsZX_jhBSlsXVeggQutODXC2KP0", + "SL_GGA": "1qD_IpXQNYUbT8Y7nLt4e4pA1E1dNntu7", + "SL_MGGA": "18OFNglYpcPXHzXwFcRXeJn9VCLFtC7Zd", +} + +os.chdir(savedir) +cmd = "wget --no-check-certificate 'https://docs.google.com/uc?export=download&id={}' -O {}" +for name, linkid in links.items(): + fname = "CIDER23_{}.yaml".format(name) + mycmd = cmd.format(linkid, fname) + subprocess.call(mycmd, shell=True)