-
Notifications
You must be signed in to change notification settings - Fork 2
/
metadata_widget.py
59 lines (46 loc) · 2.34 KB
/
metadata_widget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""Setup metadata for an AiiDA process."""
from __future__ import print_function
from __future__ import absolute_import
import ipywidgets as ipw
STYLE = {'description_width': '120px'}
LAYOUT = {'width': '70%'}
class MetadataWidget(ipw.VBox):
"""Setup metadata for an AiiDA process."""
def __init__(self):
""" Metadata widget to generate metadata"""
self.walltime_d = ipw.IntText(value=0,
description='d:',
style={'description_width': 'initial'},
layout={'width': 'initial'})
self.walltime_h = ipw.IntText(value=24,
description='h:',
style={'description_width': 'initial'},
layout={'width': 'initial'})
self.walltime_m = ipw.IntText(value=0,
description='m:',
style={'description_width': 'initial'},
layout={'width': 'initial'})
self.num_machines = ipw.IntText(value=1, description='# Nodes', style=STYLE, layout=LAYOUT)
self.num_mpiprocs_per_machine = ipw.IntText(value=12, description='# Tasks', style=STYLE, layout=LAYOUT)
self.num_cores_per_mpiproc = ipw.IntText(value=1, description='# Threads', style=STYLE, layout=LAYOUT)
children = [
self.num_machines, self.num_mpiprocs_per_machine, self.num_cores_per_mpiproc,
ipw.HBox([ipw.HTML("walltime:"), self.walltime_d, self.walltime_h, self.walltime_m])
]
super(MetadataWidget, self).__init__(children=children)
### ---------------------------------------------------------
@property
def dict(self):
return {
"options": {
"resources": {
"num_machines": self.num_machines.value,
"num_mpiprocs_per_machine": self.num_mpiprocs_per_machine.value,
"num_cores_per_mpiproc": self.num_cores_per_mpiproc.value,
},
"max_wallclock_seconds":
int(self.walltime_d.value * 3600 * 24 + self.walltime_h.value * 3600 + self.walltime_m.value * 60),
'withmpi':
True,
}
}