-
Notifications
You must be signed in to change notification settings - Fork 2
/
__init__.py
63 lines (42 loc) · 2.21 KB
/
__init__.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
60
61
62
63
import scm.plams
from typing import Dict
from .__version__ import __version__
def __autoimport(path, folders):
import os
from os.path import join as opj
is_module = lambda x: x.endswith(".py") and not x.startswith("__init__")
ret = []
for folder in folders:
for dirpath, dirnames, filenames in os.walk(opj(path, folder)):
modules = [os.path.splitext(f)[0] for f in filter(is_module, filenames)]
relpath = os.path.relpath(dirpath, path).split(os.sep)
for module in modules:
imp = ".".join(relpath + [module])
tmp = __import__(imp, globals=globals(), fromlist=["*"], level=1)
if hasattr(tmp, "__all__"):
ret += tmp.__all__
for name in tmp.__all__:
globals()[name] = vars(tmp)[name]
return ret
__all__ = __autoimport(__path__[0], ["core"])
def init(path=None, folder=None, config_settings: Dict = None):
"""Initializes pyZacros and PLAMS environment. It internally calls the scm.plams.init() method."""
scm.plams.init(path=path, folder=folder, config_settings=config_settings)
def finish(otherJM=None):
"""Wait for all threads to finish and clean the environment. It internally calls the scm.plams.finish() method."""
scm.plams.finish(otherJM=otherJM)
def load(filename):
"""Load previously saved job from ``.dill`` file. It internally calls the scm.plams.load() method."""
return scm.plams.load(filename)
def load_all(path, jobmanager=None):
"""Load all jobs from *path*. It internally calls the scm.plams.load_all() method."""
return scm.plams.load_all(path=path, jobmanager=jobmanager)
def delete_job(job):
"""Remove *job* from its corresponding |JobManager| and delete the job folder from the disk. Mark *job* as 'deleted'. It internally calls the scm.plams.delete_job() method."""
scm.plams.load_all(job=job)
def log(message, level=0):
"""Log *message* with verbosity *level*. It internally calls the scm.plams.log() method."""
scm.plams.load_all(message=message, level=level)
def workdir():
"""Equivalent to scm.plams.config.default_jobmanager.workdir."""
return scm.plams.config.default_jobmanager.workdir