From 5b3ff06c8ef23710b98ab36203cd15bc9b657542 Mon Sep 17 00:00:00 2001 From: Vuk Manojlovic Date: Fri, 15 Sep 2023 11:52:54 +0200 Subject: [PATCH 1/3] CTX-4629: Renamed project to task --- README.md | 7 ++-- coretex/__init__.py | 2 +- coretex/_project/__init__.py | 2 +- coretex/_project/_base_callback.py | 2 +- coretex/_project/_initialization.py | 6 +-- coretex/_project/_local.py | 8 ++-- coretex/_project/_remote.py | 6 +-- coretex/coretex/conversion/base_converter.py | 2 +- coretex/coretex/experiment/experiment.py | 40 +++++++++---------- coretex/coretex/model/model.py | 6 +-- coretex/coretex/space/__init__.py | 2 +- coretex/coretex/space/base.py | 12 +++--- coretex/coretex/space/space.py | 22 +++++----- coretex/coretex/space/{project.py => task.py} | 36 ++++++++--------- 14 files changed, 76 insertions(+), 77 deletions(-) rename coretex/coretex/space/{project.py => task.py} (63%) diff --git a/README.md b/README.md index 7ae37600..7481df3e 100644 --- a/README.md +++ b/README.md @@ -32,16 +32,15 @@ $ pip install coretex ```python from coretex import CustomDataset, ExecutingExperiment -from coretex.project import initializeProject def main(experiment: ExecutingExperiment[CustomDataset]): - # Remove "pass" and start project execution from here + # Remove "pass" and start task execution from here 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 +49,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 1d9d2a7b..384f8527 100644 --- a/coretex/__init__.py +++ b/coretex/__init__.py @@ -27,4 +27,4 @@ # Use this only from .coretex import * -from ._project import currentExperiment, initializeRProject +from ._task import currentExperiment, initializeRTask diff --git a/coretex/_project/__init__.py b/coretex/_project/__init__.py index 3b8fc515..b9a5f567 100644 --- a/coretex/_project/__init__.py +++ b/coretex/_project/__init__.py @@ -18,4 +18,4 @@ from ._local import _processLocal from ._remote import _processRemote from ._current_experiment import currentExperiment -from ._initialization import _prepareForExecution, initializeRProject +from ._initialization import _prepareForExecution, initializeRTask diff --git a/coretex/_project/_base_callback.py b/coretex/_project/_base_callback.py index 5fc31daa..57411300 100644 --- a/coretex/_project/_base_callback.py +++ b/coretex/_project/_base_callback.py @@ -33,7 +33,7 @@ from ..utils import DATE_FORMAT -class ProjectCallback: +class TaskCallback: def __init__(self, experiment: Experiment, refreshToken: str) -> None: self._experiment: Final = experiment diff --git a/coretex/_project/_initialization.py b/coretex/_project/_initialization.py index f2d8ecd4..d60e3a81 100644 --- a/coretex/_project/_initialization.py +++ b/coretex/_project/_initialization.py @@ -30,15 +30,15 @@ def _prepareForExecution(experimentId: int) -> Experiment: experiment.updateStatus( status = ExperimentStatus.inProgress, - message = "Executing project." + message = "Executing task." ) return experiment -def initializeRProject(mainFunction: Callable[[Experiment], None], args: List[str]) -> None: +def initializeRTask(mainFunction: Callable[[Experiment], None], args: List[str]) -> None: """ - Initializes and starts the R project as Coretex experiment + Initializes and starts the R task as Coretex experiment Parameters ---------- diff --git a/coretex/_project/_local.py b/coretex/_project/_local.py index d119d49c..daa51015 100644 --- a/coretex/_project/_local.py +++ b/coretex/_project/_local.py @@ -26,13 +26,13 @@ import psutil -from ._base_callback import ProjectCallback +from ._base_callback import TaskCallback from .. import folder_manager from ..coretex import Experiment, ExperimentStatus, ExperimentParameter from ..networking import networkManager -class LocalProjectCallback(ProjectCallback): +class LocalTaskCallback(TaskCallback): def onStart(self) -> None: super().onStart() @@ -105,7 +105,7 @@ def _readExperimentConfig() -> List['ExperimentParameter']: 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: @@ -138,4 +138,4 @@ def _processLocal(args: Optional[List[str]] = None) -> Tuple[int, ProjectCallbac logging.getLogger("coretexpylib").info(f">> [Coretex] Created local experiment with ID \"{experiment.id}\"") experiment.updateStatus(ExperimentStatus.preparingToStart) - return experiment.id, LocalProjectCallback(experiment, response.json["refresh_token"]) + return experiment.id, LocalTaskCallback(experiment, response.json["refresh_token"]) diff --git a/coretex/_project/_remote.py b/coretex/_project/_remote.py index be00d831..87c0e339 100644 --- a/coretex/_project/_remote.py +++ b/coretex/_project/_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("--experimentId", 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.experimentId, ProjectCallback.create(remoteArgumentParser.experimentId, remoteArgumentParser.refreshToken) + return remoteArgumentParser.experimentId, TaskCallback.create(remoteArgumentParser.experimentId, remoteArgumentParser.refreshToken) 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/experiment/experiment.py b/coretex/coretex/experiment/experiment.py index c85e7bf2..fbd4779c 100644 --- a/coretex/coretex/experiment/experiment.py +++ b/coretex/coretex/experiment/experiment.py @@ -63,10 +63,10 @@ class Experiment(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 experiment useCachedEnv : bool @@ -80,8 +80,8 @@ class Experiment(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) @@ -321,16 +321,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 experiment + Downloads task snapshot linked to the experiment 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}", @@ -338,13 +338,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() @@ -408,7 +408,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, @@ -421,8 +421,8 @@ def run( Parameters ---------- - projectId : int - id of project that is being used for starting Experiment + taskId : int + id of task that is being used for starting Experiment nodeId : Union[int, str] id of node that is being used for starting Experiment name : Optional[str] @@ -457,7 +457,7 @@ def run( \b >>> try: experiment = Experiment.run( - projectId = 1023, + taskId = 1023, nodeId = 23, name = "Dummy Custom Experiment description = "Dummy description", @@ -476,7 +476,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, diff --git a/coretex/coretex/model/model.py b/coretex/coretex/model/model.py index b9a3b392..95b6584b 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={ From 06ce1ffbede2b8f97f87d5e87edabbc77433b881 Mon Sep 17 00:00:00 2001 From: Vuk Manojlovic Date: Fri, 15 Sep 2023 14:04:53 +0200 Subject: [PATCH 2/3] CTX-4629: Renamed /_project/ to /_task/ --- coretex/{_project => _task}/__init__.py | 0 coretex/{_project => _task}/_base_callback.py | 0 coretex/{_project => _task}/_current_experiment.py | 0 coretex/{_project => _task}/_experiment_worker.py | 0 coretex/{_project => _task}/_initialization.py | 0 coretex/{_project => _task}/_local.py | 0 coretex/{_project => _task}/_remote.py | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename coretex/{_project => _task}/__init__.py (100%) rename coretex/{_project => _task}/_base_callback.py (100%) rename coretex/{_project => _task}/_current_experiment.py (100%) rename coretex/{_project => _task}/_experiment_worker.py (100%) rename coretex/{_project => _task}/_initialization.py (100%) rename coretex/{_project => _task}/_local.py (100%) rename coretex/{_project => _task}/_remote.py (100%) diff --git a/coretex/_project/__init__.py b/coretex/_task/__init__.py similarity index 100% rename from coretex/_project/__init__.py rename to coretex/_task/__init__.py diff --git a/coretex/_project/_base_callback.py b/coretex/_task/_base_callback.py similarity index 100% rename from coretex/_project/_base_callback.py rename to coretex/_task/_base_callback.py diff --git a/coretex/_project/_current_experiment.py b/coretex/_task/_current_experiment.py similarity index 100% rename from coretex/_project/_current_experiment.py rename to coretex/_task/_current_experiment.py diff --git a/coretex/_project/_experiment_worker.py b/coretex/_task/_experiment_worker.py similarity index 100% rename from coretex/_project/_experiment_worker.py rename to coretex/_task/_experiment_worker.py diff --git a/coretex/_project/_initialization.py b/coretex/_task/_initialization.py similarity index 100% rename from coretex/_project/_initialization.py rename to coretex/_task/_initialization.py diff --git a/coretex/_project/_local.py b/coretex/_task/_local.py similarity index 100% rename from coretex/_project/_local.py rename to coretex/_task/_local.py diff --git a/coretex/_project/_remote.py b/coretex/_task/_remote.py similarity index 100% rename from coretex/_project/_remote.py rename to coretex/_task/_remote.py From fb2b51fd217f3e1c90d82ca20645820e7e0f13f0 Mon Sep 17 00:00:00 2001 From: Vuk Manojlovic Date: Mon, 18 Sep 2023 10:23:32 +0200 Subject: [PATCH 3/3] CTX-4629: Renamed instance of "job" into "task" --- coretex/coretex/experiment/experiment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coretex/coretex/experiment/experiment.py b/coretex/coretex/experiment/experiment.py index abafb6b0..61750aa0 100644 --- a/coretex/coretex/experiment/experiment.py +++ b/coretex/coretex/experiment/experiment.py @@ -506,7 +506,7 @@ def runLocal( """ Creates Experiment 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 ----------