/ mlflow / utils / async_logging / run_artifact.py
run_artifact.py
 1  import threading
 2  from typing import TYPE_CHECKING, Union
 3  
 4  if TYPE_CHECKING:
 5      import PIL
 6  
 7  
 8  class RunArtifact:
 9      def __init__(
10          self,
11          filename: str,
12          artifact_path: str,
13          artifact: Union["PIL.Image.Image"],
14          completion_event: threading.Event,
15      ) -> None:
16          """Initializes an instance of `RunArtifacts`.
17  
18          Args:
19              filename: Filename of the artifact to be logged
20              artifact_path: Directory within the run's artifact directory in which to log the
21                  artifact.
22              artifact: The artifact to be logged.
23              completion_event: A threading.Event object.
24          """
25          self.filename = filename
26          self.artifact_path = artifact_path
27          self.artifact = artifact
28          self.completion_event = completion_event
29          self._exception = None
30  
31      @property
32      def exception(self):
33          """Exception raised during logging the batch."""
34          return self._exception
35  
36      @exception.setter
37      def exception(self, exception):
38          self._exception = exception