-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcapture_tags.py
More file actions
35 lines (32 loc) · 1.26 KB
/
capture_tags.py
File metadata and controls
35 lines (32 loc) · 1.26 KB
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
import archspec.cpu
from shutil import which
def capture_tags(instance, executor_type, env=None, tag_schema=None):
# append system architecture data gathered by archspec to tags
arch_info = archspec.cpu.host()
properties = {
"architecture": arch_info.name,
"micro-architecture": [],
"custom": [],
}
for i in arch_info.ancestors:
properties["micro-architecture"].append(i.name)
# if executor is batch, gather some more system info for tags
if executor_type == "batch":
if which("bsub"):
properties["scheduler"] = "lsf"
elif which("salloc"):
properties["scheduler"] = "slurm"
elif which("cqsub"):
properties["scheduler"] = "cobalt"
if env:
if tag_schema:
for e in env:
# "tag schema" is to be applied here
if e in tag_schema["properties"]["os"]["enum"]:
properties["os"] = e
elif e in tag_schema["properties"]["architecture"]["enum"]:
properties["architecture"] = e
else:
# if we don't recognize the tag, prepend name
properties["custom"].append(tag_schema["custom-name"] + "_" + e)
return properties