Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelRobidas committed Mar 11, 2022
2 parents b33a5c3 + 043c5ce commit 509da7e
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 114 deletions.
4 changes: 2 additions & 2 deletions docker/slurm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:latest

RUN apt update && apt install slurmd slurmctld munge openssh-server -y
ENV DEBIAN_FRONTEND "noninteractive"
RUN apt update && apt install slurmd slurmctld munge openssh-server openmpi-bin -y
RUN mkdir -p /home/slurm/
RUN usermod --shell /bin/bash --home /home/slurm slurm
RUN chown slurm:slurm /home/slurm
Expand Down
2 changes: 2 additions & 0 deletions frontend/calcusliveserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def _test_wrapper(self):
else:
num += 1
print("Test failed, trying again (attempt {}/{})".format(num, MAX_ATTEMPTS))
self.cleanupCalculations()
self.lget("/home/")
time.sleep(3)
else:
break
Expand Down
2 changes: 1 addition & 1 deletion frontend/cluster_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def _process_command(self, lines):
calc.status = 3
calc.error_message = "Job cancelled"
calc.save()
return
return

access = calc.order.resource

Expand Down
5 changes: 0 additions & 5 deletions frontend/gen_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ def gen_param(params):
solvation_model = params['solvation_model']
if 'solvation_radii' in params.keys():
solvation_radii = params['solvation_radii']
else:
if solvation_model == "SMD":
solvation_radii = "Default"
if solvation_model in ["PCM", "CPCM"]:
solvation_radii = "UFF"

if 'basis_set' in params.keys():
basis_set = params['basis_set']
Expand Down
2 changes: 1 addition & 1 deletion frontend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ def delete(self, *args, **kwargs):
if self.new_status:
with transaction.atomic():
p = Profile.objects.select_for_update().get(id=self.author.id)
p.unseen_calculations -= 1
p.unseen_calculations = max(0, p.unseen_calculations-1)
p.save()
super(CalculationOrder, self).delete(*args, **kwargs)

Expand Down
71 changes: 42 additions & 29 deletions frontend/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,15 @@ def retry():
try:
response = conn[1].run("source ~/.bashrc; " + command, hide='both')
except invoke.exceptions.UnexpectedExit as e:
logger.info(f"Got exception {e} for command {command}")
lock.release()
if e.result.exited == 1 and e.result.stderr.find("Invalid job id specified") != -1:
return []

logger.info(f"Command {command} terminated with exception: {e}")
return []
except ConnectionResetError as e:
logger.debug("Connection reset")
return self.retry()

lock.release()

Expand Down Expand Up @@ -1498,9 +1504,6 @@ def xtb_stda(in_file, calc):#TO OPTIMIZE
return ErrorCodes.SUCCESS

def calc_to_ccinput(calc):
global PAL
global MEM

if calc.parameters.method != "":
_method = calc.parameters.method
elif calc.parameters.theory_level.lower() == "hf":
Expand All @@ -1515,8 +1518,11 @@ def calc_to_ccinput(calc):
if software in ['gaussian', 'orca']:
_specifications += ' ' + getattr(calc.order.author, "default_" + software)

PAL = int(os.environ.get("NUM_CPU", 1))
MEM = int(os.environ.get("OMP_STACKSIZE", "1G")[:-1])*1024*PAL

if is_test:
_nproc = PAL
_nproc = min(4, PAL)
_mem = 2000
else:
if calc.local:
Expand Down Expand Up @@ -2499,7 +2505,7 @@ def analyse_opt_Gaussian(calc):
s_ind += 1
xyz += "{}\n\n".format(num_atoms)
ind += 5
while lines[ind].find("---------") == -1:
while ind < len(lines) - 2 and lines[ind].find("---------") == -1:
try:
n, z, T, X, Y, Z = lines[ind].strip().split()
except ValueError:
Expand Down Expand Up @@ -2957,6 +2963,10 @@ def get_calc(calc_id):

return ret

@app.task
def del_order(order_id):
_del_order(order_id)

@app.task
def del_project(proj_id):
_del_project(proj_id)
Expand All @@ -2969,6 +2979,16 @@ def del_molecule(mol_id):
def del_ensemble(ensemble_id):
_del_ensemble(ensemble_id)

def _del_order(id):
o = CalculationOrder.objects.get(pk=id)
for c in o.calculation_set.all():
_del_calculation(c)

if o.result_ensemble:
_del_ensemble(o.result_ensemble.id)

# The order is automatically deleted with the last calculation

def _del_project(id):
proj = Project.objects.get(pk=id)
proj.author = None
Expand All @@ -2983,6 +3003,20 @@ def _del_molecule(id):
_del_ensemble(e.id)
mol.delete()

def _del_calculation(calc):
if calc.status == 1 or calc.status == 2:
kill_calc(calc)

calc.delete()
try:
rmtree(os.path.join(CALCUS_SCR_HOME, str(calc.id)))
except OSError:
pass
try:
rmtree(os.path.join(CALCUS_RESULTS_HOME, str(calc.id)))
except OSError:
pass

def _del_ensemble(id):
try:
e = Ensemble.objects.get(pk=id)
Expand All @@ -2993,35 +3027,14 @@ def _del_ensemble(id):
_del_structure(s)

for c in e.calculation_set.all():
if c.status == 1 or c.status == 2:
kill_calc(c)
_del_calculation(c)

c.delete()
try:
rmtree(os.path.join(CALCUS_SCR_HOME, str(c.id)))
except OSError:
pass
try:
rmtree(os.path.join(CALCUS_RESULTS_HOME, str(c.id)))
except OSError:
pass
e.delete()

def _del_structure(s):
calcs = s.calculation_set.all()
for c in calcs:
if c.status == 1 or c.status == 2:
kill_calc(c)

c.delete()
try:
rmtree(os.path.join(CALCUS_SCR_HOME, str(c.id)))
except OSError:
pass
try:
rmtree(os.path.join(CALCUS_RESULTS_HOME, str(c.id)))
except OSError:
pass
_del_calculation(c)

s.delete()

Expand Down
2 changes: 1 addition & 1 deletion frontend/templates/frontend/calculation.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@
</script>
{% endif %}
<script>
frame_num = document.getElementById("opt_scroll").value;

$('#launch_frame_form').submit(function(){
frame_num = document.getElementById("opt_scroll").value;
$('<input />').attr('type', 'hidden')
.attr('name', "frame_num")
.attr('value', frame_num)
Expand Down
68 changes: 30 additions & 38 deletions frontend/templates/frontend/calculationorder.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,47 @@
{% block extrahead %}
<link rel="stylesheet" href="{% static 'frontend/uis/jquery-ui-1.11.4.css' %}" type="text/css">
<script src="{% static 'frontend/jquery.min.js' %}"></script>

<script>
function cancel(id) {
$("#cancel_button_" + id).addClass("is-loading");
$.ajax({
method: "POST",
url: "/cancel_calc/",
headers: {
"X-CSRFToken": '{{ csrf_token }}',
},
data: {'id': id},
success: function() {
$("#cancel_button_" + id).removeClass("is-loading");
$("#cancel_button_" + id).addClass("has-background-success");
}
});

<style>
#delete_order_button {
margin: 50 auto;
margin-bottom: 10px;
display: block;
}
function relaunch(id) {
$("#relaunch_button_" + id).addClass("is-loading");
</style>
<script>
function calc_action(id, action) {
$("#" + action + "_button_" + id).addClass("is-loading");
$.ajax({
method: "POST",
url: "/relaunch_calc/",
url: "/" + action + "_calc/",
headers: {
"X-CSRFToken": '{{ csrf_token }}',
},
data: {'id': id},
success: function() {
$("#relaunch_button_" + id).removeClass("is-loading");
$("#relaunch_button_" + id).addClass("has-background-success");
$("#" + action + "_button_" + id).removeClass("is-loading");
$("#" + action + "_button_" + id).addClass("has-background-success");
}
});

}

function refetch(id) {
$("#refetch_button_" + id).addClass("is-loading");
$.ajax({
method: "POST",
url: "/refetch_calc/",
headers: {
"X-CSRFToken": '{{ csrf_token }}',
},
data: {'id': id},
success: function() {
$("#refetch_button_" + id).removeClass("is-loading");
$("#refetch_button_" + id).addClass("has-background-success");
}
});

function delete_order(id) {
var res = confirm('Delete this calculation order and all its calculations (including resulting structures and ensembles)"?');
if (res) {
$("#delete_order_button_").addClass("is-loading");
$.ajax({
method: "POST",
url: "/delete_order/",
headers: {
"X-CSRFToken": '{{ csrf_token }}',
},
data: {'id': {{ order.pk }}},
success: function() {
window.location.replace("/calculations/");
}
});
}
}

</script>
Expand Down Expand Up @@ -91,14 +82,15 @@ <h3 class="title is-h3">Calculation Order {{ order.id }} - {{ order.structure.pa
<th><a class="button is-warning" href="/calculation/{{ calc.id}}">{{ calc.id }}</a></th>
<th>{{ calc.text_status }}{% if calc.status == 3%} - {{ calc.error_message }}{% endif %}</th>
<th>{{ calc.execution_time }}</th>
<th>{% if request.user.profile == order.author %}<a class="button is-danger" id="cancel_button_{{ calc.id }}" onclick="cancel({{ calc.id }});">Kill</a> {% if not calc.local %} <a class="button" id="relaunch_button_{{ calc.id }}" onclick="relaunch({{ calc.id }});">Relaunch</a><a class="button" id="refetch_button_{{ calc.id }}" onclick="refetch({{ calc.id }});">Refetch</a> {% endif %}{% endif %}</th>
<th>{% if request.user.profile == order.author %}<a class="button is-danger" id="cancel_button_{{ calc.id }}" onclick="calc_action({{ calc.id }}, 'cancel');">Kill</a> {% if not calc.local %} <a class="button" id="relaunch_button_{{ calc.id }}" onclick="calc_action({{ calc.id }}, 'relaunch');">Relaunch</a><a class="button" id="refetch_button_{{ calc.id }}" onclick="calc_action({{ calc.id }}, 'refetch');">Refetch</a> {% endif %}{% endif %}</th>
</tr>
{% endfor %}
</tbody>
</table>
<a class="button is-primary" href="/download_all_logs/{{ order.id }}">Download all logs</a>
</center>
</div>
<button class="button is-danger" id="delete_order_button" onclick="delete_order()">Delete this calculation order</button>
</div>
<br />
{% endblock %}
Expand Down
11 changes: 3 additions & 8 deletions frontend/test_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,16 @@ def test_DFT_default_pop(self):
self.assertIn("Mulliken:", prop.charges)
self.assertIn("Loewdin:", prop.charges)

'''
# Not valid with ccinput v1.3.2
def test_DFT_hirshfeld_pop(self):
self.assertTrue(self.run_test(type="Geometrical Optimisation", theory_level="DFT",
method="M062X", specifications="--phirshfeld",
callback=partial(self.cb_has_n_conformers, 1)))
prop = Property.objects.latest('id')
self.assertIn("Hirshfeld:", prop.charges)
'''

class GaussianCalculationTests(CalculationUnitTest):
@classmethod
Expand Down Expand Up @@ -470,14 +473,6 @@ def test_DFT_pop_HLY(self):
prop = Property.objects.latest('id')
self.assertIn("HLY:", prop.charges)

def test_DFT_max_step(self):
self.assertTrue(self.run_test(type="Geometrical Optimisation", theory_level="DFT",
method="M062X", specifications="opt(maxstep=5)",
callback=partial(self.cb_has_n_conformers, 1)))

calc = Calculation.objects.latest('id')
self.assertEqual(calc.parameters.specifications.strip(), 'opt(maxstep=5)')

def test_scan_pop(self):
self.assertTrue(self.run_test(theory_level="HF", type="Constrained Optimisation",
constraints="Scan_3.5_5.0_10/1_2;", specifications="pop(nbo)",
Expand Down

0 comments on commit 509da7e

Please sign in to comment.