Skip to content

Commit

Permalink
Merge branch 'develop' into CTX-4155
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	coretex/__init__.py
#	coretex/_project/_experiment_worker.py
#	coretex/_task/__init__.py
#	coretex/_task/_current_experiment.py
#	coretex/_task/_current_task_run.py
#	coretex/_task/_experiment_worker.py
#	coretex/_task/_initialization.py
#	coretex/_task/_local.py
#	coretex/_task/_remote.py
#	coretex/_task/_task_run_worker.py
#	coretex/coretex/task_run/task_run.py
  • Loading branch information
Vuk Manojlovic committed Sep 18, 2023
2 parents b0c6f9d + f72afdd commit dcb3ddb
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 76 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,

Expand Down
2 changes: 1 addition & 1 deletion coretex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@

# Use this only
from .coretex import *
from ._project import currentTaskRun, initializeRProject
from ._task import currentTaskRun, initializeRTask
2 changes: 1 addition & 1 deletion coretex/_project/__init__.py → coretex/_task/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
8 changes: 4 additions & 4 deletions coretex/_project/_local.py → coretex/_task/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"])
6 changes: 3 additions & 3 deletions coretex/_project/_remote.py → coretex/_task/_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)
File renamed without changes.
2 changes: 1 addition & 1 deletion coretex/coretex/conversion/base_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions coretex/coretex/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -66,7 +66,7 @@ class Model(NetworkObject):
createdOn: datetime
datasetId: int
spaceId: int
projectId: int
taskId: int
isTrained: bool
isDeleted: bool
accuracy: float
Expand Down
2 changes: 1 addition & 1 deletion coretex/coretex/space/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

from .space import Space
from .space_task import SpaceTask
from .project import Project
from .task import Task
12 changes: 6 additions & 6 deletions coretex/coretex/space/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down Expand Up @@ -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
----------
Expand All @@ -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:
Expand All @@ -89,16 +89,16 @@ 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
----------
description : str
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:
Expand Down
22 changes: 11 additions & 11 deletions coretex/coretex/space/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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]:
Expand Down Expand Up @@ -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
36 changes: 18 additions & 18 deletions coretex/coretex/space/project.py → coretex/coretex/space/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down
Loading

0 comments on commit dcb3ddb

Please sign in to comment.