Skip to content

Commit

Permalink
PR: Finish xtb-YARP for pytest/Github workflow + add back organometal…
Browse files Browse the repository at this point in the history
…lics pytest

Finish xtb-YARP for pytest/Github workflow + add back organometallics pytest
  • Loading branch information
Zhaoli2042 authored Nov 7, 2024
2 parents 8b6cceb + 128358c commit 4a9e55b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 67 deletions.
56 changes: 22 additions & 34 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,26 @@ jobs:

- name: Install dependencies
run: |
#python -m pip install --upgrade pip
#conda create --name ENV python=3.9
#conda init
#conda activate ENV
#cd /opt/hostedtoolcache/Python/3.9.20/x64/bin/; ls
if [ -f pytest_requirements.txt ]; then
pip install -r pytest_requirements.txt;
fi
#pip install pytest-executable
#pip install pipdeptree
#pip install dask
export CONDA_ALWAYS_YES="true"
pip install 'numpy==1.24.0'
pip install rdkit
pip install scipy
pip install 'rdkit==2024.3.5'
pip install 'scipy==1.11.1'
pip install xtb
pip install joblib
pip install PyYAML
pip install 'joblib==1.3.1'
pip install 'PyYAML==6.0.1'
pip install openbabel-wheel
pip install pandas
pip install ase
#pip install xtb
pip install 'pandas==2.0.3'
pip install 'ase==3.22.1'
conda install -y conda-forge::xtb
pip install xgboost
pip install h5py
pip install 'xgboost==1.7.6'
pip install 'h5py==3.9.0'
pip install pysisyphus
conda install -y conda-forge::crest
unset CONDA_ALWAYS_YES
pip install --force-reinstall 'scikit-learn==1.3.0'
pip install --force-reinstall 'numpy==1.24.4'
pip install .
# CHECK
Expand All @@ -53,32 +45,28 @@ jobs:
cp .pysisyphusrc /home/runner/.pysisyphusrc
cond=asd
sed -i "s|CONDA_ENV|${CONDA}|g" /home/runner/.pysisyphusrc
#which crest
#if [ -f env.yaml ]; then
# #conda install --file env.yaml
# conda env create -f env.yaml
#fi
- name: Run pytest
run: |
#conda activate yarp
#cd examples/; pytest -s # Assuming your tests are in the 'tests' directory
home=$(pwd)
cd /opt/hostedtoolcache/Python/3.9.20/x64/bin/
ls
echo $CONDA
cd $CONDA/bin
ls
which pip; echo "GOOD1"
echo $(pwd)
$CONDA/bin/xtb --version
$CONDA/bin/crest --version
pysis --version
#ls
#echo $(pwd)
#$CONDA/bin/xtb --version
#$CONDA/bin/crest --version
#pysis --version
# test Organometallics
#obabel --version
cd $home/pyTEST_Example/;
#
# run Organometallic YARP Example #
cd $home/examples/
pytest -s
cd $home/pyTEST_Example/
# xtb and crest are in conda bin, others in pip bin
sed -i "s|CONDA_PATH|${CONDA}|g" test_rxn.py
pytest -s
shell: bash
59 changes: 26 additions & 33 deletions pyTEST_Example/test_rxn.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,10 @@
import pytest, os, re, yaml
import shutil
import subprocess
import pandas as pd
import numpy as np
#import yarp as yp
#from calculator import add
'''
import yarp as yp
import numpy as np
import threading
import pickle
import multiprocessing as mp
from multiprocessing import Queue
from logging.handlers import QueueHandler
from joblib import Parallel, delayed
from yarp.find_lewis import all_zeros
from yarp.find_lewis import bmat_unique
import os, sys, yaml, fnmatch
import logging
from openbabel import pybel
from utils import *
from wrappers.reaction import *
from job_mapping import *
from wrappers.crest import CREST
from qc_jobs import *
from conf import *
from analyze_functions import *
from wrappers.pysis import PYSIS
from wrappers.gsm import GSM
'''
def truthy(value):
return bool(value)
def falsy(value):
Expand Down Expand Up @@ -73,26 +51,41 @@ def rxn_setYAML(current_path, model_path, gsm_path, conda_path):
with open('parameters.yaml', 'w') as file: file.write(filedata)

def rxn_xtb():
#subprocess.call("crest ", shell=True)
#subprocess.call("pysis ", shell=True)
#subprocess.call("xtb " , shell=True)

subprocess.call("python main_xtb.py parameters.yaml", shell=True)
#exec(open("main_xtb.py").read())
subprocess.call("cat RESULT/IRC-record.txt", shell=True)

df = pd.read_csv('RESULT/IRC-record.txt', delim_whitespace=True)
# Check for 'intended' entry in 'type' column and if the barrier equals 6.747
intended_row = df[df['type'] == 'intended']
# Print result if intended row exists and barrier check
barrier = 1000
if not intended_row.empty:
barrier = float(intended_row['barrier'].values[0])
return barrier

def test_file():
current_directory = os.getcwd() + '/'
CONDA="CONDA_PATH"
#subprocess.call(f"cd {current_directory}/pyTEST_Example/", shell=True)

CONDA="CONDA_PATH" # will be replaced by a real path when running the github workflow #
if CONDA=="CONDA_" + "PATH":
# use "which crest" to find the path #
STR = os.popen('which crest').read().rstrip()
CONDA = STR.split("/bin/crest")[0]

rxn_setYAML(current_path = current_directory,
model_path = f"{current_directory}/bin",
gsm_path = f"{current_directory}/bin/inpfileq",
conda_path = f"{CONDA}/bin")

rxn_xtb()
with open('parameters.yaml', 'rb') as f: conf = yaml.safe_load(f.read())
#RUN(conf)
# run YARP-xtb for DA example #
barrier = rxn_xtb()
assert(np.abs(barrier - 6.747132) < 0.01)
print(f"YARP-xtb CHECK FINISHED\n")

'''
# run Organometallics YARP for Fe(CO)5 #
subprocess.call(f"cd {current_directory}/examples/", shell=True)
assert os.path.exists('FeCO5.xyz')
assert check_metal("FeCO5.xyz")
print("Organometallics CHECK FINISHED\n")
Expand Down

0 comments on commit 4a9e55b

Please sign in to comment.