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

5 8
from importlib.util import find_spec
6

7 8
from . import _version
8

9 8
__all__ = ["get_information"]
10

11 8
versions = _version.get_versions()
12

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

15

16 8
def _isnotebook():
17
    """
18
    Checks if we are inside a jupyter notebook or not.
19
    """
20 8
    try:
21 8
        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 8
    except NameError:
29 8
        return False
30

31

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

34

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

38

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

47 8
    return __info[key]
48

49

50 8
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