Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated rmg_runner.py and test_rmg_runner.py #86

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions t3/runners/rmg_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def write_submit_script(project_directory: str,
max_iterations (str, optional): Max RMG iterations, e.g., ``-m 100``.
t3_project_name (str, optional): THe T3 project name, used for setting a job name on the server for the RMG run.
"""
if memory is not None:
assert 8000<= memory <=32000, "Memory is in MB and must be between 8000 and 32000"
assert memory % 1000 == 0, "Memory is in MB and must be divisable by 1000"
global MEM
submit_scripts_content = submit_scripts['rmg'].format(name=f'{t3_project_name}_RMG' or 'T3_RMG',
cpus=cpus or CPUS,
Expand Down
39 changes: 36 additions & 3 deletions tests/test_rmg_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import os
from t3.common import DATA_BASE_PATH, EXAMPLES_BASE_PATH
from t3.runners.rmg_runner import write_submit_script

import pytest


class TestWriteSubmitScript(object):

#Need to think of multiple cases...


def test_minimial_write_submit_script(self):
"""Test the write_submit_script() function with minimal input.
Expand Down Expand Up @@ -52,6 +52,11 @@ def test_minimial_write_submit_script(self):
os.remove(os.path.join(project_directory_path,"job.sh"))

def test_minimal_project_name_included(self):
"""
This test has been constructed to ensure that when the user provides a t3 project name, it will be displayed in the submit name whilst also
not affecting the job file.
"""

project_directory_path = os.path.join(EXAMPLES_BASE_PATH, "minimal")
t3_proj_name = "T3_test_name"
actual = write_submit_script(project_directory_path,
Expand Down Expand Up @@ -110,6 +115,9 @@ def test_minimal_project_name_included(self):


def test_minimal_parameters_set(self):
"""
This test has been built to ensure that chosen parameters by the user are being correctly written into the job and submit file
"""
project_directory_path = os.path.join(EXAMPLES_BASE_PATH, "minimal")

####To be edited by user if required####
Expand Down Expand Up @@ -170,4 +178,29 @@ def test_minimal_parameters_set(self):
assert content_submit == expected_submit

os.remove(os.path.join(project_directory_path,"job.sh"))
os.remove(os.path.join(project_directory_path,"submit.sub"))
os.remove(os.path.join(project_directory_path,"submit.sub"))

def test_minimal_incorrect_mem(self):
"""
This test has been constructed to raise an assertion error due to the user specifiying the incorrent memory.
Memory selection for assertion error can either be less than 8000 or higher than 32000 (Subject to change) OR/AND
the selection of Memory may not be divisable by 1000 (Subject to change)
"""
project_directory_path = os.path.join(EXAMPLES_BASE_PATH, "minimal")

####To be edited by user if required####
t3_proj_name = "T3_test_name"
cpus = 8
max_iter = "-m 100"
mem = 16230 #in MB - This is to be incorrect
#########################################

with pytest.raises(AssertionError) as assertion_error:
actual = write_submit_script(project_directory_path,
Fixed Show fixed Hide fixed
cpus=cpus,
memory=mem, #in MB
verbose="-v 20",
max_iterations=max_iter,
t3_project_name= t3_proj_name)
Fixed Show fixed Hide fixed

assert 'Memory is in MB and must be between 8000 and 32000' or "Memory is in MB and must be divisable by 1000" in str(assertion_error.value)