![]() |
Coretex
|
Inherits NetworkObject, Generic, and DatasetType.
Public Member Functions | |
Dict[str, Any] | parameters (self) |
Path | taskPath (self) |
DatasetType | dataset (self) |
bool | updateStatus (self, Optional[TaskRunStatus] status=None, Optional[str] message=None, bool notifyServer=True) |
None | createMetrics (self, List[Metric] metrics) |
bool | submitMetrics (self, Dict[str, Tuple[float, float]] metricValues) |
None | submitOutput (self, str parameterName, Any value) |
None | submitOutputs (self, Dict[str, Any] outputs) |
bool | downloadTask (self) |
Optional[Artifact] | createArtifact (self, Union[Path, str] localFilePath, str remoteFilePath, Optional[str] mimeType=None) |
Self | run (cls, int taskId, Union[int, str] nodeId, Optional[str] name, Optional[str] description=None, Optional[List[Dict[str, Any]]] parameters=None) |
Self | runLocal (cls, int projectId, bool saveSnapshot, Optional[str] name, Optional[str] description=None, Optional[List[Dict[str, Any]]] parameters=None, Optional[str] entryPoint=None) |
str | generateEntityName (self) |
Represents TaskRun entity from Coretex.ai Properties ---------- datasetId : int id of dataset name : str name of TaskRun description : str description of TaskRun meta : Dict[str, Any] meta data of TaskRun status : TaskRunStatus status of TaskRun projectId : int id of Coretex Project projectName : str name of Coretex Project projectType : ProjectType appropriate project type taskId : int id of task taskName : str name of task createdById : str id of created TaskRun useCachedEnv : bool if True chached env will be used, otherwise new environment will be created
Definition at line 45 of file task_run.py.
Optional[Artifact] coretex.entities.task_run.task_run.TaskRun.createArtifact | ( | self, | |
Union[Path, str] | localFilePath, | ||
str | remoteFilePath, | ||
Optional[str] | mimeType = None |
||
) |
Creates Artifact for the current TaskRun on Coretex.ai Parameters ---------- localFilePath : Union[Path, str] local path of Artifact file remoteFilePath : str path of Artifact file on Coretex mimeType : Optional[str] mimeType (not required) if not passed guesMimeType() function is used Returns ------- Optional[Artifact] -> if response is True returns Artifact object, None otherwise
Definition at line 447 of file task_run.py.
None coretex.entities.task_run.task_run.TaskRun.createMetrics | ( | self, | |
List[Metric] | metrics | ||
) |
Creates specified metrics for the TaskRun Parameters ---------- values : List[Metric]] List of Metric meta objects in this format Metric("name", "x_label", "x_type", "y_label", "y_type", "x_range", "y_range") Returns ------- List[Metric] -> List of Metric objects Raises ------ NetworkRequestError -> if the request failed Example ------- >>> from coretex import ExecutingTaskRun, MetricType \b >>> metrics = ExecutingTaskRun.current().createMetrics([ Metric.create("loss", "epoch", MetricType.int, "value", MetricType.float, None, [0, 100]), Metric.create("accuracy", "epoch", MetricType.int, "value", MetricType.float, None, [0, 100]) ]) >>> if len(metrics) == 0: print("Failed to create metrics")
Definition at line 270 of file task_run.py.
DatasetType coretex.entities.task_run.task_run.TaskRun.dataset | ( | self | ) |
Value of the parameter with name "dataset" assigned to this TaskRun Returns ------- Dataset object if there was a parameter with name "dataset" entered when the TaskRun was started Raises ------ ValueError -> if there is not parameter with name "dataset"
Definition at line 121 of file task_run.py.
bool coretex.entities.task_run.task_run.TaskRun.downloadTask | ( | self | ) |
Downloads task snapshot linked to the TaskRun Returns ------- bool -> True if task downloaded successfully, False if task download has failed
Definition at line 419 of file task_run.py.
str coretex.entities.task_run.task_run.TaskRun.generateEntityName | ( | self | ) |
Combines the id and the name of the task run into a name for enitites like datasets or models. Returns ------- str -> the generated name
Definition at line 657 of file task_run.py.
Dict[str, Any] coretex.entities.task_run.task_run.TaskRun.parameters | ( | self | ) |
Returns ------- Dict[str, Any] -> Parameters for TaskRun
Definition at line 101 of file task_run.py.
Self coretex.entities.task_run.task_run.TaskRun.run | ( | cls, | |
int | taskId, | ||
Union[int, str] | nodeId, | ||
Optional[str] | name, | ||
Optional[str] | description = None , |
||
Optional[List[Dict[str, Any]]] | parameters = None |
||
) |
Schedules an TaskRun for execution on the specified Node on Coretex.ai Parameters ---------- taskId : int id of task that is being used for starting TaskRun nodeId : Union[int, str] id of node that is being used for starting TaskRun name : Optional[str] name of TaskRun (not required) description : Optional[str] TaskRun description (not required) parameters : Optional[List[Dict[str, Any]]] list of parameters (not required) Returns ------- Self -> TaskRun object Raises ------ NetworkRequestError -> if the request failed Example ------- >>> from coretex import TaskRun >>> from coretex.networking import NetworkRequestError \b >>> parameters = [ { "name": "dataset", "description": "Dataset id that is used for fetching dataset from coretex.", "value": null, "data_type": "dataset", "required": true } ] \b >>> try: taskRun = TaskRun.run( taskId = 1023, nodeId = 23, name = "Dummy Custom TaskRun description = "Dummy description", parameters = parameters ) print(f"Created TaskRun with name: {taskRun.name}") >>> except NetworkRequestError: print("Failed to create TaskRun")
Definition at line 505 of file task_run.py.
Self coretex.entities.task_run.task_run.TaskRun.runLocal | ( | cls, | |
int | projectId, | ||
bool | saveSnapshot, | ||
Optional[str] | name, | ||
Optional[str] | description = None , |
||
Optional[List[Dict[str, Any]]] | parameters = None , |
||
Optional[str] | entryPoint = None |
||
) |
Creates TaskRun on Coretex.ai with the provided parameters, which will be run on the same machine which created it immidiately after running the entry point file of the task Parameters ---------- projectId : int id of project that is being used for starting TaskRun saveSnapshot : bool true if snapshot of local files will be saved to Coretex name : Optional[str] name of TaskRun (not required) description : Optional[str] TaskRun description (not required) parameters : Optional[List[Dict[str, Any]]] list of parameters (not required) entryPoint : Optional[str] relative path to the script inside of the project Returns ------- Self -> TaskRun object Raises ------ NetworkRequestError -> if the request failed
Definition at line 590 of file task_run.py.
bool coretex.entities.task_run.task_run.TaskRun.submitMetrics | ( | self, | |
Dict[str, Tuple[float, float]] | metricValues | ||
) |
Appends metric values for the provided metrics Parameters ---------- metricValues : Dict[str, Tuple[float, float]] Values of metrics in this format {"name": x, y} Example ------- >>> from coretex import ExecutingTaskRun \b >>> result = ExecutingTaskRun.current().submitMetrics({ "loss": (epoch, logs["loss"]), "accuracy": (epoch, logs["accuracy"]), }) >>> print(result) True
Definition at line 311 of file task_run.py.
None coretex.entities.task_run.task_run.TaskRun.submitOutput | ( | self, | |
str | parameterName, | ||
Any | value | ||
) |
Submit an output of this task to act as a parameter in tasks downstream in the Workflow Parameters ---------- parameterName : str name of the parameter value : Any value that will be sent (id of the object will be sent in case Coretex objects like CustomDataset, Model etc. is submited) Raises ------ NetworkRequestError -> if the request failed Example ------- >>> from coretex import TaskRun \b >>> ExecutingTaskRun.current().submitOutputParameter( parameterName = "outputDataset" value = outputDataset )
Definition at line 347 of file task_run.py.
None coretex.entities.task_run.task_run.TaskRun.submitOutputs | ( | self, | |
Dict[str, Any] | outputs | ||
) |
Submit multiple outputs of this task to act as parameters in tasks downstream in the Workflow Parameters ---------- outputs : Dict[str, Any] dictionary with outputs, with key being the name of the parameter (id of the object will be sent in case Coretex objects like CustomDataset, Model etc. is submited) Raises ------ NetworkRequestError -> if the request failed Example ------- >>> from coretex import TaskRun \b >>> result = ExecutingTaskRun.current().submitOutputParameters({ "outputDataset": outputDataset, "numbers": 123 })
Definition at line 376 of file task_run.py.
Path coretex.entities.task_run.task_run.TaskRun.taskPath | ( | self | ) |
Returns ------- Path -> Path for TaskRun
Definition at line 111 of file task_run.py.
bool coretex.entities.task_run.task_run.TaskRun.updateStatus | ( | self, | |
Optional[TaskRunStatus] | status = None , |
||
Optional[str] | message = None , |
||
bool | notifyServer = True |
||
) |
Updates TaskRun status, if message parameter is None default message value will be used\n Some TaskRun statuses do not have default message Parameters ---------- status : Optional[TaskRunStatus] Status to which the TaskRun will be updated to message : Optional[str] Descriptive message for TaskRun status, it is diplayed when the status is hovered on the Coretex Web App notifyServer : bool if True update request will be sent to Coretex.ai Example ------- >>> from coretex import ExecutingTaskRun, TaskRunStatus \b >>> ExecutingTaskRun.current().updateStatus( TaskRunStatus.completedWithSuccess ) True
Definition at line 208 of file task_run.py.