Skip to content

Commit

Permalink
Merge pull request #504 from ReactionMechanismGenerator/job
Browse files Browse the repository at this point in the history
Job adapters
  • Loading branch information
kfir4444 authored May 19, 2022
2 parents 3e06531 + 0a30345 commit e8f468e
Show file tree
Hide file tree
Showing 109 changed files with 192,749 additions and 4,494 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/cont_int.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@ jobs:
- name: Install dependencies
run: |
export PYTHONPATH=$PYTHONPATH:$(pwd)
echo 'export PYTHONPATH=$PYTHONPATH:'"$(pwd)" >> ~/.bashrc
conda activate arc_env
cd ..
git clone https://github.com/ReactionMechanismGenerator/RMG-Py
cd RMG-Py
export PYTHONPATH=$PYTHONPATH:$(pwd)
echo 'export PYTHONPATH=$PYTHONPATH:'"$(pwd)" >> ~/.bashrc
make
cd ..
git clone https://github.com/ReactionMechanismGenerator/RMG-database
cd ARC
conda deactivate
make gcn-cpu
cd ..
echo $(pwd)
source ~/.bashrc
make install-all
source ~/.bashrc
conda activate arc_env
echo $PYTHONPATH
conda list
- name: Lint with flake8
Expand All @@ -68,11 +70,8 @@ jobs:
- name: Test with python unittest
run: |
cd ..
cd RMG-Py
export PYTHONPATH=$PYTHONPATH:$(pwd)
cd ..
cd ARC
source ~/.bashrc
conda activate arc_env
echo $PYTHONPATH
make test
codecov --token=f259713a-7f1d-4e9c-b140-bb3bb371d3ef
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@
test test-unittests:
python3 -m unittest discover -p *Test.py -v

gcn:
install-all:
bash devtools/install_all.sh

install-autotst:
bash devtools/install_autotst.sh

install-gcn:
bash devtools/install_gcn.sh

gcn-cpu:
install-gcn-cpu:
bash devtools/install_gcn_cpu.sh

install-kinbot:
bash devtools/install_kinbot.sh

clean:
find -type d -name __pycache__ -exec rm -rf {} +
rm -rf testing
Expand Down
1 change: 1 addition & 0 deletions arc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import arc.exceptions
import arc.main
from arc.main import ARC
import arc.checks
import arc.common
import arc.imports
import arc.level
Expand Down
2 changes: 2 additions & 0 deletions arc/checks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import arc.checks.ts
import arc.checks.common
43 changes: 43 additions & 0 deletions arc/checks/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
A module with common functionalities used for checking the quality of calculations,
contains helper functions for Scheduler.
"""

import datetime

from typing import List, Optional


def sum_time_delta(timedelta_list: List[datetime.timedelta]) -> datetime.timedelta:
"""
A helper function for summing datetime.timedelta objects.
Args:
timedelta_list (list): Time delta's to sum.
Returns:
datetime.timedelta: The timedelta sum.
"""
result = datetime.timedelta(0)
for timedelta in timedelta_list:
if type(timedelta) == type(result):
result += timedelta
return result


def get_i_from_job_name(job_name: str) -> Optional[int]:
"""
Get the conformer or tsg index from the job name.
Args:
job_name (str): The job name, e.g., 'conformer12' or 'tsg5'.
Returns:
Optional[int]: The corresponding conformer or tsg index.
"""
i = None
if 'conformer' in job_name:
i = int(job_name[9:])
elif 'tsg' in job_name:
i = int(job_name[3:])
return i
46 changes: 46 additions & 0 deletions arc/checks/commonTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
# encoding: utf-8

"""
This module contains unit tests for the arc.checks.common module
"""

import datetime
import unittest

import arc.checks.common as common


class TestChecks(unittest.TestCase):
"""
Contains unit tests for the check module.
"""
def test_sum_time_delta(self):
"""Test the sum_time_delta() function"""
dt1 = datetime.timedelta(days=0, minutes=0, seconds=0)
dt2 = datetime.timedelta(days=0, minutes=0, seconds=0)
dt3 = datetime.timedelta(days=0, minutes=1, seconds=15)
dt4 = datetime.timedelta(days=10, minutes=1, seconds=15, microseconds=300)
fake_dt5 = None
fake_dt6 = 'fake'
fake_dt7 = 18.52
self.assertEqual(common.sum_time_delta([]), datetime.timedelta(days=0, minutes=0, seconds=0))
self.assertEqual(common.sum_time_delta([dt1]), datetime.timedelta(days=0, minutes=0, seconds=0))
self.assertEqual(common.sum_time_delta([dt1, dt2]), datetime.timedelta(days=0, minutes=0, seconds=0))
self.assertEqual(common.sum_time_delta([dt1, dt3]), datetime.timedelta(days=0, minutes=1, seconds=15))
self.assertEqual(common.sum_time_delta([dt3, dt4]), datetime.timedelta(days=10, minutes=2, seconds=30, microseconds=300))
self.assertEqual(common.sum_time_delta([dt3, fake_dt5, fake_dt6, fake_dt7]),
datetime.timedelta(days=0, minutes=1, seconds=15))

def test_get_i_from_job_name(self):
"""Test the get_i_from_job_name() function"""
self.assertIsNone(common.get_i_from_job_name(''))
self.assertIsNone(common.get_i_from_job_name('some_job_name'))
self.assertEqual(common.get_i_from_job_name('conformer3'), 3)
self.assertEqual(common.get_i_from_job_name('conformer33'), 33)
self.assertEqual(common.get_i_from_job_name('conformer3355'), 3355)
self.assertEqual(common.get_i_from_job_name('tsg2'), 2)


if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
Loading

0 comments on commit e8f468e

Please sign in to comment.