/ mlflow / entities / source_type.py
source_type.py
 1  class SourceType:
 2      """Enum for originating source of a :py:class:`mlflow.entities.Run`."""
 3  
 4      NOTEBOOK, JOB, PROJECT, LOCAL, UNKNOWN = range(1, 6)
 5  
 6      _STRING_TO_SOURCETYPE = {
 7          "NOTEBOOK": NOTEBOOK,
 8          "JOB": JOB,
 9          "PROJECT": PROJECT,
10          "LOCAL": LOCAL,
11          "UNKNOWN": UNKNOWN,
12      }
13      SOURCETYPE_TO_STRING = {value: key for key, value in _STRING_TO_SOURCETYPE.items()}
14  
15      @staticmethod
16      def from_string(status_str):
17          if status_str not in SourceType._STRING_TO_SOURCETYPE:
18              raise Exception(
19                  f"Could not get run status corresponding to string {status_str}. Valid run "
20                  f"status strings: {list(SourceType._STRING_TO_SOURCETYPE.keys())}"
21              )
22          return SourceType._STRING_TO_SOURCETYPE[status_str]
23  
24      @staticmethod
25      def to_string(status):
26          if status not in SourceType.SOURCETYPE_TO_STRING:
27              raise Exception(
28                  f"Could not get string corresponding to run status {status}. Valid run "
29                  f"statuses: {list(SourceType.SOURCETYPE_TO_STRING.keys())}"
30              )
31          return SourceType.SOURCETYPE_TO_STRING[status]