Commit 0c8ce134 authored by bellotti_r's avatar bellotti_r
Browse files

Made repo installable; added documentation; Simulation.run() returns the...

Made repo installable; added documentation; Simulation.run() returns the correct SLURM ID of the job
parent d3db9780
from .simulation import Simulation
from .opaldict import OpalDict
from PathNameGenerator import PathNameGenerator
from .PathNameGenerator import PathNameGenerator
from decimal import Decimal
from ast import literal_eval
import sys
......@@ -21,6 +21,7 @@ class OpalDict:
Parameters
==========
template: str
Path the .data file.
'''
self.dict = {}
self.rangevars = {}
......
......@@ -96,6 +96,9 @@ class Simulation:
Support for batch systems is available.
The directory containing the fieldmaps is given in the environment
variable FIELDMAPS.
Parameters
==========
N: int
......@@ -247,7 +250,8 @@ class Simulation:
queue = os.getenv("SGE_QUEUE", "prime_bd.q")
# Merlin6
if (hostname.startswith("merlin-l")):
if (hostname.startswith('merlin-l')
or hostname.startswith('merlin-c')):
batchsys = 'SLURM'
runfile = 'run.merlin6'
time = os.getenv("SLURM_TIME", "23:59:59")
......@@ -345,7 +349,12 @@ class Simulation:
elif batchsys == 'COBALT':
command = 'qsub'
qid = subprocess.call([command, runfile, '|', 'awk', "\'{print $3}\'"])
completed_process = subprocess.run([command, runfile],
stdout=subprocess.PIPE,
encoding='utf-8')
output = completed_process.stdout
# output format for SLURM: "Submitted batch job <ID>"
ID = output.split(' ')[-1].strip()
if not quiet:
print(f'Done with setup of the OPAL simulation and submitting the job with {CORES} cores \n\n\n')
......@@ -357,7 +366,7 @@ class Simulation:
print("Batch system", batchsys, "not known!")
os.chdir('..')
return qid
return ID
# Write for host
def WriteCori(self, opalexe, oinpFile, cores, time, ram, info, name):
......
from setuptools import setup
# file content adapted from:
# https://stackoverflow.com/a/39811884
setup(
name='runOPAL',
version='1.0',
description='Run OPAL simulations from within Python',
author='Andreas Adelmann et al.',
packages=['runOPAL'], # same as name
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment