Coretex
coretex.coretex.experiment.artifact.Artifact Class Reference
Inheritance diagram for coretex.coretex.experiment.artifact.Artifact:
coretex.codable.codable.Codable

Public Member Functions

Path localFilePath (self)
 
bool isDirectory (self)
 
bool isFile (self)
 
bool download (self)
 
List[ArtifactfetchAll (cls, int experimentId, Optional[str] path=None, bool recursive=False)
 
- Public Member Functions inherited from coretex.codable.codable.Codable
Dict[str, Any] encode (self)
 
None onDecode (self)
 
Self decode (cls, Dict[str, Any] encodedObject)
 

Detailed Description

    Artifact class represents a single result of an experiment\n
    Result can be file of any kind

    Properties
    ----------
    artifactType : ArtifactType
        type of Artifact
    remoteFilePath : str
        path of Artifact on Coretex
    size : Optional[int]
        size of Artifact in bytes (not required)
    mimeType : str
        mimeType of Artifact
    timestamp : int
        current timestamp
    experimentId : int
        id of experiment

Definition at line 61 of file artifact.py.

Member Function Documentation

◆ download()

bool coretex.coretex.experiment.artifact.Artifact.download (   self)
    Downloads Artifact from Coretex.ai

    Returns
    -------
    bool -> False if response has failed, True otherwise

Definition at line 160 of file artifact.py.

160  def download(self) -> bool:
161  """
162  Downloads Artifact from Coretex.ai
163 
164  Returns
165  -------
166  bool -> False if response has failed, True otherwise
167  """
168 
169  artifactsFolder = FolderManager.instance().getArtifactsFolder(self.experimentId)
170  if not artifactsFolder.exists():
171  artifactsFolder.mkdir(parents = True, exist_ok = True)
172 
173  return not networkManager.genericDownload(
174  f"artifact/download-file?path={self.remoteFilePath}&model_queue_id={self.experimentId}",
175  str(self.localFilePath)
176  ).hasFailed()
177 

◆ fetchAll()

List[Artifact] coretex.coretex.experiment.artifact.Artifact.fetchAll (   cls,
int  experimentId,
Optional[str]   path = None,
bool   recursive = False 
)
    Fetch all Artifacts from Coretex.ai for the specified experiment

    Parameters
    ----------
    experimentId : int
id of experiment
    path : Optional[str]
local path where u want to store fetched Artifacts
    recursive : bool
True if you want list to be sorted recursively, False otherwise

Definition at line 179 of file artifact.py.

179  def fetchAll(cls, experimentId: int, path: Optional[str] = None, recursive: bool = False) -> List[Artifact]:
180  """
181  Fetch all Artifacts from Coretex.ai for the specified experiment
182 
183  Parameters
184  ----------
185  experimentId : int
186  id of experiment
187  path : Optional[str]
188  local path where u want to store fetched Artifacts
189  recursive : bool
190  True if you want list to be sorted recursively, False otherwise
191  """
192 
193  queryParameters = [
194  f"model_queue_id={experimentId}"
195  ]
196 
197  if path is not None:
198  queryParameters.append(f"path={path}")
199 
200  parameters = "&".join(queryParameters)
201  response = networkManager.genericJSONRequest(
202  f"artifact/list-contents?{parameters}",
203  RequestType.get
204  )
205 
206  if response.hasFailed():
207  return []
208 
209  artifacts = [Artifact.decode(element) for element in response.json]
210 
211  for artifact in artifacts:
212  artifact.experimentId = experimentId
213 
214  if recursive and artifact.isDirectory:
215  artifacts.extend(
216  cls.fetchAll(experimentId, artifact.remoteFilePath)
217  )
218 
219  return artifacts

◆ isDirectory()

bool coretex.coretex.experiment.artifact.Artifact.isDirectory (   self)
    Returns
    -------
    bool -> True if Artifact type is directory

Definition at line 103 of file artifact.py.

103  def isDirectory(self) -> bool:
104  """
105  Returns
106  -------
107  bool -> True if Artifact type is directory
108  """
109 
110  return self.artifactType == ArtifactType.directory
111 

◆ isFile()

bool coretex.coretex.experiment.artifact.Artifact.isFile (   self)
    Returns
    -------
    bool -> True if Artifact type is file

Definition at line 113 of file artifact.py.

113  def isFile(self) -> bool:
114  """
115  Returns
116  -------
117  bool -> True if Artifact type is file
118  """
119 
120  return self.artifactType == ArtifactType.file
121 

◆ localFilePath()

Path coretex.coretex.experiment.artifact.Artifact.localFilePath (   self)
    Represents the local path of the Artifact

    Returns
    -------
    Path -> local path to Artifact

Definition at line 91 of file artifact.py.

91  def localFilePath(self) -> Path:
92  """
93  Represents the local path of the Artifact
94 
95  Returns
96  -------
97  Path -> local path to Artifact
98  """
99 
100  return FolderManager.instance().getArtifactsFolder(self.experimentId) / self.remoteFilePath
101 

The documentation for this class was generated from the following file: