1
"""
2
Misc information and runtime information.
3
"""
4

5 4
from importlib.util import find_spec
6

7 4
from . import _version
8

9 4
__all__ = ["get_information"]
10

11 4
versions = _version.get_versions()
12

13 4
__info = {"version": versions["version"], "git_revision": versions["full-revisionid"]}
14

15

16 4
def _isnotebook():
17
    """
18
    Checks if we are inside a jupyter notebook or not.
19
    """
20 4
    try:
21 4
        shell = get_ipython().__class__.__name__
22 0
        if shell in ["ZMQInteractiveShell", "google.colab._shell"]:
23 0
            return True
24 0
        elif shell == "TerminalInteractiveShell":
25 0
            return False
26
        else:
27 0
            return False
28 4
    except NameError:
29 4
        return False
30

31

32 4
__info["isnotebook"] = _isnotebook()
33

34

35 4
def find_module(name):
36 4
    return find_spec(name)
37

38

39 4
def get_information(key):
40
    """
41
    Obtains a variety of runtime information about QCFractal.
42
    """
43 4
    key = key.lower()
44 4
    if key not in __info:
45 0
        raise KeyError("Information key '{}' not understood.".format(key))
46

47 4
    return __info[key]
48

49

50 4
def provenance_stamp(routine):
51
    """Return dictionary satisfying QCSchema,
52
    generating routine's name is passed in through `routine`.
53

54
    """
55 0
    return {"creator": "QCFractal", "version": get_information("version"), "routine": routine}

Read our documentation on viewing source code .

Loading