diff --git a/README.md b/README.md index cac31d82..6895c1d0 100644 --- a/README.md +++ b/README.md @@ -31,17 +31,25 @@ $ pip install coretex **Step 3:** Migrate your project to coretex: ```python +<<<<<<< HEAD from coretex import CustomDataset, ExecutingTaskRun from coretex.project import initializeProject def main(TaskRun: ExecutingTaskRun[CustomDataset]): # Remove "pass" and start project execution from here +======= +from coretex import CustomDataset, ExecutingExperiment + + +def main(experiment: ExecutingExperiment[CustomDataset]): + # Remove "pass" and start task execution from here +>>>>>>> develop pass if __name__ == "__main__": - initializeProject(main) + main() ``` Read the documentation and learn how you can migrate your project to the Coretex platform -> [Migrate your project to Coretex](https://app.gitbook.com/o/6QxmEiF5ygi67vFH3kV1/s/YoN0XCeop3vrJ0hyRKxx/getting-started/demo-experiments/migrate-your-project-to-coretex) @@ -50,7 +58,7 @@ Read the documentation and learn how you can migrate your project to the Coretex Coretex.ai offers a range of features to support users in their AI experimentation, including: -* **Project Templates:** Battle-tested templates that make training ML models and processing data simple, +* **Task Templates:** Battle-tested templates that make training ML models and processing data simple, * **Machine Learning Model Creation:** Quick and easy creation of machine learning models, with less friction and more stability, diff --git a/coretex/__init__.py b/coretex/__init__.py index 9f4e8d4c..8f7613af 100644 --- a/coretex/__init__.py +++ b/coretex/__init__.py @@ -27,4 +27,4 @@ # Use this only from .coretex import * -from ._project import currentTaskRun, initializeRProject +from ._task import currentTaskRun, initializeRTask diff --git a/coretex/_project/__init__.py b/coretex/_task/__init__.py similarity index 92% rename from coretex/_project/__init__.py rename to coretex/_task/__init__.py index e06ab3a6..5c77557a 100644 --- a/coretex/_project/__init__.py +++ b/coretex/_task/__init__.py @@ -18,4 +18,4 @@ from ._local import _processLocal from ._remote import _processRemote from ._current_task_run import currentTaskRun -from ._initialization import _prepareForExecution, initializeRProject +from ._initialization import _prepareForExecution, initializeRTask diff --git a/coretex/_project/_base_callback.py b/coretex/_task/_base_callback.py similarity index 99% rename from coretex/_project/_base_callback.py rename to coretex/_task/_base_callback.py index 95afc44e..853e413e 100644 --- a/coretex/_project/_base_callback.py +++ b/coretex/_task/_base_callback.py @@ -33,7 +33,7 @@ from ..utils import DATE_FORMAT -class ProjectCallback: +class TaskCallback: def __init__(self, taskRun: TaskRun, refreshToken: str) -> None: self._taskRun: Final = taskRun diff --git a/coretex/_project/_current_task_run.py b/coretex/_task/_current_task_run.py similarity index 100% rename from coretex/_project/_current_task_run.py rename to coretex/_task/_current_task_run.py diff --git a/coretex/_project/_initialization.py b/coretex/_task/_initialization.py similarity index 91% rename from coretex/_project/_initialization.py rename to coretex/_task/_initialization.py index 818899e0..3d8fb5a7 100644 --- a/coretex/_project/_initialization.py +++ b/coretex/_task/_initialization.py @@ -30,15 +30,15 @@ def _prepareForExecution(taskRunId: int) -> TaskRun: taskRun.updateStatus( status = TaskRunStatus.inProgress, - message = "Executing project." + message = "Executing task." ) return taskRun -def initializeRProject(mainFunction: Callable[[TaskRun], None], args: List[str]) -> None: +def initializeRTask(mainFunction: Callable[[TaskRun], None], args: List[str]) -> None: """ - Initializes and starts the R project as Coretex run + Initializes and starts the R task as Coretex TaskRun Parameters ---------- diff --git a/coretex/_project/_local.py b/coretex/_task/_local.py similarity index 96% rename from coretex/_project/_local.py rename to coretex/_task/_local.py index 020aec1d..3857439b 100644 --- a/coretex/_project/_local.py +++ b/coretex/_task/_local.py @@ -27,13 +27,13 @@ import psutil -from ._base_callback import ProjectCallback +from ._base_callback import TaskCallback from .. import folder_manager from ..coretex import TaskRun, TaskRunStatus, BaseParameter, validateParameters, parameter_factory from ..networking import networkManager -class LocalProjectCallback(ProjectCallback): +class LocalTaskCallback(TaskCallback): def onStart(self) -> None: super().onStart() @@ -111,7 +111,7 @@ def _readTaskRunConfig() -> List[BaseParameter]: return parameters -def _processLocal(args: Optional[List[str]] = None) -> Tuple[int, ProjectCallback]: +def _processLocal(args: Optional[List[str]] = None) -> Tuple[int, TaskCallback]: parser, unknown = LocalArgumentParser().parse_known_args(args) if parser.username is not None and parser.password is not None: @@ -144,4 +144,4 @@ def _processLocal(args: Optional[List[str]] = None) -> Tuple[int, ProjectCallbac logging.getLogger("coretexpylib").info(f">> [Coretex] Created local run with ID \"{taskRun.id}\"") taskRun.updateStatus(TaskRunStatus.preparingToStart) - return taskRun.id, LocalProjectCallback(taskRun, response.json["refresh_token"]) + return taskRun.id, LocalTaskCallback(taskRun, response.json["refresh_token"]) diff --git a/coretex/_project/_remote.py b/coretex/_task/_remote.py similarity index 87% rename from coretex/_project/_remote.py rename to coretex/_task/_remote.py index d93eee59..826cd0e2 100644 --- a/coretex/_project/_remote.py +++ b/coretex/_task/_remote.py @@ -18,7 +18,7 @@ from typing import Tuple, Optional, List from tap import Tap -from ._base_callback import ProjectCallback +from ._base_callback import TaskCallback from ..networking import networkManager @@ -32,11 +32,11 @@ def configure(self) -> None: self.add_argument("--taskRunId", type = int) -def _processRemote(args: Optional[List[str]] = None) -> Tuple[int, ProjectCallback]: +def _processRemote(args: Optional[List[str]] = None) -> Tuple[int, TaskCallback]: remoteArgumentParser, unknown = RemoteArgumentParser().parse_known_args(args) response = networkManager.authenticateWithRefreshToken(remoteArgumentParser.refreshToken) if response.hasFailed(): raise RuntimeError(">> [Coretex] Failed to authenticate") - return remoteArgumentParser.taskRunId, ProjectCallback.create(remoteArgumentParser.taskRunId, remoteArgumentParser.refreshToken) + return remoteArgumentParser.taskRunId, TaskCallback.create(remoteArgumentParser.taskRunId, remoteArgumentParser.refreshToken) diff --git a/coretex/_project/_task_run_worker.py b/coretex/_task/_task_run_worker.py similarity index 100% rename from coretex/_project/_task_run_worker.py rename to coretex/_task/_task_run_worker.py diff --git a/coretex/coretex/conversion/base_converter.py b/coretex/coretex/conversion/base_converter.py index 0d015085..7f496271 100644 --- a/coretex/coretex/conversion/base_converter.py +++ b/coretex/coretex/conversion/base_converter.py @@ -42,7 +42,7 @@ class ConverterProcessorType(Enum): labelMe = 4 pascalSeg = 5 - # TODO: Migrate to Human Segmentation project template repo, or try to make it generic + # TODO: Migrate to Human Segmentation task template repo, or try to make it generic humanSegmentation = 6 cityScape = 7 diff --git a/coretex/coretex/model/model.py b/coretex/coretex/model/model.py index 64e8a2c4..247a673d 100644 --- a/coretex/coretex/model/model.py +++ b/coretex/coretex/model/model.py @@ -47,8 +47,8 @@ class Model(NetworkObject): dataset id that is used for training the model spaceId : int space id that is used for training the model - projectId : int - project id that is used for training the model + taskId : int + task id that is used for training the model isTrained : bool True if model is trained, False otherwise isDeleted : bool @@ -66,7 +66,7 @@ class Model(NetworkObject): createdOn: datetime datasetId: int spaceId: int - projectId: int + taskId: int isTrained: bool isDeleted: bool accuracy: float diff --git a/coretex/coretex/space/__init__.py b/coretex/coretex/space/__init__.py index 9f23d197..ef58aa12 100644 --- a/coretex/coretex/space/__init__.py +++ b/coretex/coretex/space/__init__.py @@ -17,4 +17,4 @@ from .space import Space from .space_task import SpaceTask -from .project import Project +from .task import Task diff --git a/coretex/coretex/space/base.py b/coretex/coretex/space/base.py index 20e8d75c..94a48675 100644 --- a/coretex/coretex/space/base.py +++ b/coretex/coretex/space/base.py @@ -26,7 +26,7 @@ class BaseObject(NetworkObject): """ - Represents the base class for Space/Project objects from Coretex.ai + Represents the base class for Space/Task objects from Coretex.ai Properties ---------- @@ -61,7 +61,7 @@ def _keyDescriptors(cls) -> Dict[str, KeyDescriptor]: def rename(self, name: str) -> bool: """ - Renames the Space/Project + Renames the Space/Task Parameters ---------- @@ -70,7 +70,7 @@ def rename(self, name: str) -> bool: Returns ------- - bool -> True if Space/Project was renamed, False if Space/Project was not renamed + bool -> True if Space/Task was renamed, False if Space/Task was not renamed """ if self.name == name: @@ -89,7 +89,7 @@ def rename(self, name: str) -> bool: def updateDescription(self, description: str) -> bool: """ - Updates the Space/Project's description + Updates the Space/Task's description Parameters ---------- @@ -97,8 +97,8 @@ def updateDescription(self, description: str) -> bool: new description Returns - bool -> True if Space/Project's description was updated, - False if Space/Project's description was not updated + bool -> True if Space/Task's description was updated, + False if Space/Task's description was not updated """ if self.description == description: diff --git a/coretex/coretex/space/space.py b/coretex/coretex/space/space.py index d7f47152..4db3123e 100644 --- a/coretex/coretex/space/space.py +++ b/coretex/coretex/space/space.py @@ -19,7 +19,7 @@ from typing_extensions import Self from .base import BaseObject -from .project import Project +from .task import Task from .space_task import SpaceTask @@ -30,7 +30,7 @@ class Space(BaseObject): Contains properties that describe the space """ - projects: List[Project] + tasks: List[Task] @classmethod def createSpace(cls, name: str, spaceTask: SpaceTask, description: Optional[str] = None) -> Optional[Self]: @@ -70,31 +70,31 @@ def createSpace(cls, name: str, spaceTask: SpaceTask, description: Optional[str] @classmethod def decode(cls, encodedObject: Dict[str, Any]) -> Self: obj = super().decode(encodedObject) - obj.projects = Project.fetchAll(queryParameters=[ + obj.tasks = Task.fetchAll(queryParameters=[ f"parentId={obj.id}" ]) return obj - def addProject(self, name: str, description: Optional[str]) -> bool: + def addTask(self, name: str, description: Optional[str]) -> bool: """ - Adds new project to the space + Adds new task to the space Parameters ---------- name : str - project name + task name description : Optional[str] - project description + task description Returns ------- - bool -> True if the project was added. False if the project was not added + bool -> True if the task was added. False if the task was not added """ - project = Project.createProject(name, self.id, description) - if project is None: + task = Task.createTask(name, self.id, description) + if task is None: return False - self.projects.append(project) + self.tasks.append(task) return True diff --git a/coretex/coretex/space/project.py b/coretex/coretex/space/task.py similarity index 63% rename from coretex/coretex/space/project.py rename to coretex/coretex/space/task.py index 86d172e6..8c7e2432 100644 --- a/coretex/coretex/space/project.py +++ b/coretex/coretex/space/task.py @@ -22,53 +22,53 @@ from ...codable import KeyDescriptor -class Project(BaseObject): +class Task(BaseObject): """ - Represents the project entity from Coretex.ai\n - Contains properties that describe the project + Represents the task entity from Coretex.ai\n + Contains properties that describe the task """ isDefault: bool - projectId: int + taskId: int @classmethod def _keyDescriptors(cls) -> Dict[str, KeyDescriptor]: descriptors = super()._keyDescriptors() - descriptors["projectId"] = KeyDescriptor("parentId") + descriptors["taskId"] = KeyDescriptor("parentId") return descriptors @classmethod - def createProject(cls, name: str, spaceId: int, description: Optional[str]=None) -> Optional[Self]: + def createTask(cls, name: str, spaceId: int, description: Optional[str]=None) -> Optional[Self]: """ - Creates a new project with the provided name and description - Project is added to the space with provided space id + Creates a new task with the provided name and description + Task is added to the space with provided space id Parameters ---------- name : str - project name + task name spaceId : int - space id the project belongs to + space id the task belongs to description : Optional[str] - project description + task description Returns ------- - Optional[Self] -> The created project object + Optional[Self] -> The created task object Example ------- - >>> from coretex import Project + >>> from coretex import Task \b - >>> dummyProject = Project.createProject( - name = "dummyProject", + >>> dummyTask = Task.createTask( + name = "dummyTask", spaceId = 23, - description = "This is dummy project" + description = "This is dummy task" ) - >>> if dummyProject is None: - print("Failed to create project") + >>> if dummyTask is None: + print("Failed to create task") """ return cls.create(parameters={ diff --git a/coretex/coretex/task_run/task_run.py b/coretex/coretex/task_run/task_run.py index 7eafac1c..295d790e 100644 --- a/coretex/coretex/task_run/task_run.py +++ b/coretex/coretex/task_run/task_run.py @@ -63,10 +63,10 @@ class TaskRun(NetworkObject, Generic[DatasetType]): name of Coretex Space spaceTask : SpaceTask appropriate space task - projectId : int - id of project - projectName : str - name of project + taskId : int + id of task + taskName : str + name of task createdById : str id of created TaskRun useCachedEnv : bool @@ -80,8 +80,8 @@ class TaskRun(NetworkObject, Generic[DatasetType]): spaceId: int spaceName: str spaceTask: SpaceTask - projectId: int - projectName: str + taskId: int + taskName: str createdById: str useCachedEnv: bool metrics: List[Metric] @@ -103,7 +103,7 @@ def parameters(self) -> Dict[str, Any]: return self.__parameters @property - def projectPath(self) -> Path: + def taskPath(self) -> Path: """ Returns ------- @@ -149,8 +149,8 @@ def _keyDescriptors(cls) -> Dict[str, KeyDescriptor]: descriptors["spaceId"] = KeyDescriptor("project_id") descriptors["spaceName"] = KeyDescriptor("project_name") descriptors["spaceTask"] = KeyDescriptor("project_task", SpaceTask) - descriptors["projectId"] = KeyDescriptor("sub_project_id") - descriptors["projectName"] = KeyDescriptor("sub_project_name") + descriptors["taskId"] = KeyDescriptor("sub_project_id") + descriptors["taskName"] = KeyDescriptor("sub_project_name") # private properties of the object should not be encoded descriptors["__parameters"] = KeyDescriptor(isEncodable = False) @@ -326,16 +326,16 @@ def submitMetrics(self, metricValues: Dict[str, Tuple[float, float]]) -> bool: return not response.hasFailed() - def downloadProject(self) -> bool: + def downloadTask(self) -> bool: """ - Downloads project snapshot linked to the TaskRun + Downloads task snapshot linked to the TaskRun Returns ------- - bool -> True if project downloaded successfully, False if project download has failed + bool -> True if task downloaded successfully, False if task download has failed """ - zipFilePath = f"{self.projectPath}.zip" + zipFilePath = f"{self.taskPath}.zip" response = networkManager.genericDownload( endpoint=f"workspace/download?model_queue_id={self.id}", @@ -343,13 +343,13 @@ def downloadProject(self) -> bool: ) with ZipFile(zipFilePath) as zipFile: - zipFile.extractall(self.projectPath) + zipFile.extractall(self.taskPath) # remove zip file after extract os.unlink(zipFilePath) if response.hasFailed(): - logging.getLogger("coretexpylib").info(">> [Coretex] Project download has failed") + logging.getLogger("coretexpylib").info(">> [Coretex] Task download has failed") return not response.hasFailed() @@ -413,7 +413,7 @@ def createQiimeArtifact(self, rootArtifactFolderName: str, qiimeArtifactPath: Pa @classmethod def run( cls, - projectId: int, + taskId: int, nodeId: Union[int, str], name: Optional[str], description: Optional[str] = None, @@ -426,8 +426,8 @@ def run( Parameters ---------- - projectId : int - id of project that is being used for starting TaskRun + 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] @@ -462,7 +462,7 @@ def run( \b >>> try: taskRun = TaskRun.run( - projectId = 1023, + taskId = 1023, nodeId = 23, name = "Dummy Custom TaskRun description = "Dummy description", @@ -481,7 +481,7 @@ def run( parameters = [] response = networkManager.genericJSONRequest("run", RequestType.post, { - "sub_project_id": projectId, + "sub_project_id": taskId, "service_id": nodeId, "name": name, "description": description, @@ -506,7 +506,7 @@ def runLocal( """ 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 Job + after running the entry point file of the task Parameters ----------