mirror of
https://github.com/pfloos/quack
synced 2025-01-03 01:56:09 +01:00
spinner simulation
This commit is contained in:
parent
9aebbe74f0
commit
76c797fa4a
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@ -3,4 +3,5 @@ FeatherBench.db
|
|||||||
FeatherBench.json
|
FeatherBench.json
|
||||||
|
|
||||||
*.xyz
|
*.xyz
|
||||||
|
work
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
import time
|
||||||
|
import threading
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -10,7 +12,7 @@ import argparse
|
|||||||
|
|
||||||
from molecule import get_molecules_from_db
|
from molecule import get_molecules_from_db
|
||||||
from molecule import generate_xyz
|
from molecule import generate_xyz
|
||||||
from utils import print_col
|
from utils import print_col, stdout_col
|
||||||
|
|
||||||
|
|
||||||
current_date = datetime.now()
|
current_date = datetime.now()
|
||||||
@ -98,34 +100,54 @@ class Quack_Job:
|
|||||||
print_col("File 'inp/{}' does not exist.".format(inp_file), "red")
|
print_col("File 'inp/{}' does not exist.".format(inp_file), "red")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def run(file_out, mol, bas, multip):
|
def run(self, work_path):
|
||||||
|
|
||||||
os.chdir('..')
|
def display_spinner():
|
||||||
print(f" :$ cd ..")
|
spinner = ['|', '/', '-', '\\']
|
||||||
|
idx = 0
|
||||||
|
while not done_event.is_set():
|
||||||
|
stdout_col(f'\r Testing {self.methd} ({self.basis}) {spinner[idx]}', "yellow")
|
||||||
|
sys.stdout.flush()
|
||||||
|
idx = (idx + 1) % len(spinner)
|
||||||
|
time.sleep(0.1)
|
||||||
|
stdout_col(f'\r Testing {self.methd} ({self.basis}) ', "yellow")
|
||||||
|
|
||||||
for file_in in ["methods", "options"]:
|
done_event = threading.Event()
|
||||||
command = ['cp', 'tests/{}.RHF'.format(file_in), 'input/{}'.format(file_in)]
|
spinner_thread = threading.Thread(target=display_spinner)
|
||||||
print(f" :$ {' '.join(command)}")
|
spinner_thread.start()
|
||||||
result = subprocess.run(command, capture_output=True, text=True)
|
|
||||||
if result.returncode != 0:
|
|
||||||
print("Error moving file: {}".format(result.stderr))
|
|
||||||
|
|
||||||
command = [
|
try:
|
||||||
'python{}'.format(PYTHON_VERSION), 'PyDuck.py',
|
|
||||||
'-x', '{}'.format(mol),
|
os.chdir('..')
|
||||||
'-b', '{}'.format(bas),
|
#print_col(f" Starting QuAck..", "magenta")
|
||||||
'-m', '{}'.format(multip)
|
#print_col(f" $ cd ..", "magenta")
|
||||||
]
|
|
||||||
print(f" :$ {' '.join(command)}")
|
command = [
|
||||||
with open(file_out, 'w') as fobj:
|
'python{}'.format(PYTHON_VERSION), 'PyDuck.py',
|
||||||
result = subprocess.run(command, stdout=fobj, stderr=subprocess.PIPE, text=True)
|
'-x', '{}'.format(self.mol),
|
||||||
if result.stderr:
|
'-b', '{}'.format(self.basis),
|
||||||
print("Error output:", result.stderr)
|
'-m', '{}'.format(self.multip)
|
||||||
|
]
|
||||||
|
#print_col(f" $ {' '.join(command)}", "magenta")
|
||||||
|
|
||||||
|
file_out = "{}/{}/{}_{}_{}.out".format(work_path, self.methd, self.mol, self.multip, self.basis)
|
||||||
|
with open(file_out, 'w') as fobj:
|
||||||
|
result = subprocess.run(command, stdout=fobj, stderr=subprocess.PIPE, text=True)
|
||||||
|
if result.stderr:
|
||||||
|
print("Error output:", result.stderr)
|
||||||
|
|
||||||
|
os.chdir('tests')
|
||||||
|
#print_col(f" $ cd tests", "magenta")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
|
||||||
os.chdir('tests')
|
print_col(f"An error occurred: {str(e)}", "red")
|
||||||
print(f" :$ cd tests")
|
|
||||||
|
|
||||||
|
finally:
|
||||||
|
|
||||||
|
done_event.set()
|
||||||
|
spinner_thread.join()
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
|
|
||||||
@ -147,21 +169,21 @@ def main():
|
|||||||
|
|
||||||
for mol_prop_name, mol_prop_data in mol_data.items():
|
for mol_prop_name, mol_prop_data in mol_data.items():
|
||||||
|
|
||||||
print_col(" Testing {}".format(mol_prop_name), "cyan")
|
#print_col(" Testing {}".format(mol_prop_name), "cyan")
|
||||||
|
|
||||||
methd = mol_prop_name[len('properties_'):]
|
methd = mol_prop_name[len('properties_'):]
|
||||||
|
|
||||||
if(len(mol_prop_data) == 0):
|
if(len(mol_prop_data) == 0):
|
||||||
print_col(" {} is empty. Skipping...".format(mol_prop_name), "cyan")
|
#print_col(" {} is empty. Skipping...".format(mol_prop_name), "cyan")
|
||||||
print()
|
#print()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for basis_name, basis_data in mol_prop_data.items():
|
for basis_name, basis_data in mol_prop_data.items():
|
||||||
print_col(" Basis set = {}".format(basis_name), "yellow")
|
#print_col(" Basis set: {}".format(basis_name), "yellow")
|
||||||
|
|
||||||
if(len(basis_data) == 0):
|
if(len(basis_data) == 0):
|
||||||
print_col(" {} is empty. Skipping...".format(basis_name), "yellow")
|
#print_col(" {} is empty. Skipping...".format(basis_name), "yellow")
|
||||||
print()
|
#print()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
work_methd = Path('{}/{}'.format(work_path, methd))
|
work_methd = Path('{}/{}'.format(work_path, methd))
|
||||||
@ -171,6 +193,7 @@ def main():
|
|||||||
|
|
||||||
New_Quack_Job = Quack_Job(mol_name, mol_mult, basis_name, mol_geom, methd)
|
New_Quack_Job = Quack_Job(mol_name, mol_mult, basis_name, mol_geom, methd)
|
||||||
New_Quack_Job.prep_inp()
|
New_Quack_Job.prep_inp()
|
||||||
|
New_Quack_Job.run(work_path)
|
||||||
|
|
||||||
# for name, val in basis_data.items():
|
# for name, val in basis_data.items():
|
||||||
# print(f" name = {name}")
|
# print(f" name = {name}")
|
||||||
@ -183,20 +206,6 @@ def main():
|
|||||||
quit()
|
quit()
|
||||||
|
|
||||||
|
|
||||||
# # create input files
|
|
||||||
# class_methd.gen_input()
|
|
||||||
#
|
|
||||||
# file_out = "{}/{}/{}_{}_{}.out".format(work_path, prop, mol_name, mol_mult, bas)
|
|
||||||
#
|
|
||||||
# print(" testing {} for {}@{} (2S+1 = {})".format(prop, mol_name, bas, mol_mult))
|
|
||||||
# print(" file_out: {}".format(file_out))
|
|
||||||
#
|
|
||||||
# class_methd.run_job(file_out, mol_name, bas, mol_mult)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
db_name = '{}.db'.format(bench)
|
db_name = '{}.db'.format(bench)
|
||||||
|
|
||||||
molecules = get_molecules_from_db(db_name)
|
molecules = get_molecules_from_db(db_name)
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def print_col(text, color):
|
def print_col(text, color):
|
||||||
|
|
||||||
if(color == "black"):
|
if(color == "black"):
|
||||||
@ -37,3 +42,47 @@ def print_col(text, color):
|
|||||||
|
|
||||||
print("{}".format(text))
|
print("{}".format(text))
|
||||||
|
|
||||||
|
|
||||||
|
# ---
|
||||||
|
|
||||||
|
def stdout_col(text, color):
|
||||||
|
|
||||||
|
if(color == "black"):
|
||||||
|
|
||||||
|
sys.stdout.write("\033[30m{}\033[0m".format(text))
|
||||||
|
|
||||||
|
elif(color == "red"):
|
||||||
|
|
||||||
|
sys.stdout.write("\033[31m{}\033[0m".format(text))
|
||||||
|
|
||||||
|
elif(color == "green"):
|
||||||
|
|
||||||
|
sys.stdout.write("\033[32m{}\033[0m".format(text))
|
||||||
|
|
||||||
|
elif(color == "yellow"):
|
||||||
|
|
||||||
|
sys.stdout.write("\033[33m{}\033[0m".format(text))
|
||||||
|
|
||||||
|
elif(color == "blue"):
|
||||||
|
|
||||||
|
sys.stdout.write("\033[34m{}\033[0m".format(text))
|
||||||
|
|
||||||
|
elif(color == "magenta"):
|
||||||
|
|
||||||
|
sys.stdout.write("\033[35m{}\033[0m".format(text))
|
||||||
|
|
||||||
|
elif(color == "cyan"):
|
||||||
|
|
||||||
|
sys.stdout.write("\033[36m{}\033[0m".format(text))
|
||||||
|
|
||||||
|
elif(color == "white"):
|
||||||
|
|
||||||
|
sys.stdout.write("\033[37m{}\033[0m".format(text))
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
sys.stdout.write("{}".format(text))
|
||||||
|
|
||||||
|
# ---
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user