Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions alembic/versions/c12374978a12_rename_task_id_to_uuid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Rename task_id to uuid

Revision ID: c12374978a12
Revises: 6d5f957d035c
Create Date: 2024-10-11 11:44:29.159937

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'c12374978a12'
down_revision: Union[str, None] = '6d5f957d035c'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('tasks', 'task_id', new_column_name='uuid')
# ### end Alembic commands ###


def downgrade() -> None:
pass
2 changes: 1 addition & 1 deletion aqueductcore/backend/models/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Task(Base):
"""Task details"""

__tablename__ = "task"
task_id = mapped_column(String, primary_key=True)
uuid = mapped_column(String, primary_key=True)
extension_name: Mapped[str]
action_name: Mapped[str]
parameters: Mapped[Optional[str]]
Expand Down
2 changes: 1 addition & 1 deletion aqueductcore/backend/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class TaskParamList(AQDModel):
class TaskBase(AQDModel):
"""Base model for a task."""

task_id: str
uuid: str
experiment_uuid: UUID
extension_name: str
action_name: str
Expand Down
4 changes: 2 additions & 2 deletions aqueductcore/backend/routers/graphql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class KeyValuePair:
class TaskData:
"""Full information about the scheduled task."""

task_id: UUID = strawberry.field(description="Unique identifier of the task.")
uuid: UUID = strawberry.field(description="Unique identifier of the task.")
experiment: ExperimentData = strawberry.field(
description="Experiment the task is associated with.", resolver=resolve_experiment
)
Expand Down Expand Up @@ -272,7 +272,7 @@ def task_model_to_node(value: TaskRead) -> TaskData:
]

task = TaskData(
task_id=UUID(value.task_id),
uuid=UUID(value.uuid),
extension_name=value.extension_name,
action_name=value.action_name,
task_status=TaskStatus(value.status),
Expand Down
5 changes: 3 additions & 2 deletions aqueductcore/backend/services/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async def execute(
)

db_task = orm.Task(
task_id=str(task.task_id),
uuid=str(task.task_id),
action_name=self.name,
extension_name=extension.name,
parameters=params_json,
Expand All @@ -176,7 +176,8 @@ async def execute(
db_experiment.tasks.append(db_task)
await db_session.commit()
return await task_orm_to_model(
value=db_task, task_info=task,
value=db_task,
task_info=task,
experiment_uuid=db_task.experiment.uuid,
username=user_info.username,
)
Expand Down
8 changes: 4 additions & 4 deletions aqueductcore/backend/services/task_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async def revoke_task(
select(orm.Task)
.options(joinedload(orm.Task.created_by_user))
.options(joinedload(orm.Task.experiment))
.filter(orm.Task.task_id == task_id)
.filter(orm.Task.uuid == task_id)
)
result = await db_session.execute(statement)

Expand Down Expand Up @@ -219,7 +219,7 @@ async def get_task_by_uuid(
select(orm.Task)
.options(joinedload(orm.Task.experiment))
.options(joinedload(orm.Task.created_by_user))
.where(orm.Task.task_id == str(task_id))
.where(orm.Task.uuid == str(task_id))
)

result = await db_session.execute(statement)
Expand All @@ -240,7 +240,7 @@ async def get_task_by_uuid(
if db_task.experiment.created_by != user_info.uuid:
raise AQDPermission("User has no permission to see this task.")

task_info = await _update_task_info(task_id=db_task.task_id, wait=False)
task_info = await _update_task_info(task_id=db_task.uuid, wait=False)

return await task_orm_to_model(
value=db_task, task_info=task_info, experiment_uuid=db_task.experiment.uuid
Expand Down Expand Up @@ -308,7 +308,7 @@ async def get_all_tasks( # pylint: disable=too-many-arguments
if username is not None and item.created_by_user.username != username:
continue

task_info = await _update_task_info(task_id=item.task_id, wait=False)
task_info = await _update_task_info(task_id=item.uuid, wait=False)
tasks_list.append(
await task_orm_to_model(
value=item,
Expand Down
23 changes: 12 additions & 11 deletions aqueductcore/backend/services/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def task_orm_to_model(
username = value.created_by_user.username

task = TaskRead(
task_id=value.task_id,
uuid=value.uuid,
experiment_uuid=experiment_uuid,
extension_name=value.extension_name,
action_name=value.action_name,
Expand All @@ -56,7 +56,7 @@ def task_model_to_orm(
) -> orm.Task:
"""Convert ORM Experiment to Pydantic Model"""
return orm.Task(
task_id=value.task_id,
uuid=value.uuid,
action_name=value.action_name,
extension_name=value.extension_name,
parameters=(value.parameters.model_dump_json() if value.parameters else None),
Expand Down Expand Up @@ -128,15 +128,16 @@ def is_tag_valid(tag: str) -> bool:


def format_list_human_readable(arr: List[Union[str, int]]) -> str:
"""Convert list of strings to a single string separated by commas"""
arr = [str(value) for value in arr]
if len(arr) == 1:
return arr[0]
"""Convert a list of strings or integers to a human-readable string."""
str_arr = [str(value) for value in arr]

if not str_arr:
return ""

if len(arr) == 2:
return arr[-2] + " and " + arr[-1]
if len(str_arr) == 1:
return str_arr[0]

if len(arr) > 2:
return ", ".join(arr[:-2]) + ", " + arr[-2] + " and " + arr[-1]
if len(str_arr) == 2:
return " and ".join(str_arr)

return ""
return f"{', '.join(str_arr[:-1])} and {str_arr[-1]}"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const CANCEL_TASK = gql`
$taskId: UUID!
) {
cancelTask(cancelTaskInput: {taskId: $taskId}) {
taskId
uuid
resultCode
taskStatus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const GET_ALL_TASKS = gql`
resultCode
stdOut
stdErr
taskId
uuid
createdBy
experiment {
uuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const GET_TASK = gql`
resultCode
stdOut
stdErr
taskId
uuid
createdBy
experiment {
uuid
Expand Down
10 changes: 5 additions & 5 deletions aqueductcore/frontend/src/__mocks__/TasksDataMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const TasksDataMock: TaskType[] = [
"resultCode": 1,
"stdOut": "Some text 2",
"stdErr": null,
"taskId": "caab6b1e-d275-4bb3-9803-967d03eb843d",
"uuid": "caab6b1e-d275-4bb3-9803-967d03eb843d",
"experiment": {
uuid: ExperimentsDataMock[0].uuid,
title: ExperimentsDataMock[0].title,
Expand All @@ -28,7 +28,7 @@ export const TasksDataMock: TaskType[] = [
"resultCode": null,
"stdOut": null,
"stdErr": "Error!",
"taskId": "2640eb24-5d99-493c-8a44-5ade9df8769a",
"uuid": "2640eb24-5d99-493c-8a44-5ade9df8769a",
"experiment": {
uuid: ExperimentsDataMock[0].uuid,
title: ExperimentsDataMock[0].title,
Expand All @@ -44,7 +44,7 @@ export const TasksDataMock: TaskType[] = [
"resultCode": null,
"stdOut": null,
"stdErr": null,
"taskId": "9aec85cc-032a-4daf-b0f2-67d04d25455c",
"uuid": "9aec85cc-032a-4daf-b0f2-67d04d25455c",
"experiment": {
uuid: ExperimentsDataMock[0].uuid,
title: ExperimentsDataMock[0].title,
Expand Down Expand Up @@ -150,5 +150,5 @@ export const TaskParams = [
"__typename": "KeyValuePair"
}
]
export const SampleTaskId = TasksDataMock[0].taskId;
export const PendingTaskId = TasksDataMock[1].taskId;
export const SampleTaskId = TasksDataMock[0].uuid;
export const PendingTaskId = TasksDataMock[1].uuid;
4 changes: 2 additions & 2 deletions aqueductcore/frontend/src/__mocks__/queries/tasks/getTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getTask_mock = {
result: {
data: {
task: {
...TasksDataMock.find(task => task.taskId === SampleTaskId),
...TasksDataMock.find(task => task.uuid === SampleTaskId),
parameters: TaskParams
}
},
Expand All @@ -35,7 +35,7 @@ export const getTask_mock = {
result: {
data: {
task: {
...TasksDataMock.find(task => task.taskId === PendingTaskId),
...TasksDataMock.find(task => task.uuid === PendingTaskId),
parameters: TaskParams
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { TaskType } from "types/globalTypes";
interface TaskDetailsModalProps {
isOpen: boolean
handleClose: () => void
taskId: TaskType['taskId']
taskId: TaskType['uuid']
}

export type settingItemType = {
Expand Down Expand Up @@ -215,7 +215,7 @@ function TaskDetailsModal({ isOpen, handleClose, taskId }: TaskDetailsModalProps
},
{
label: "taskId",
value: task.taskId
value: task.uuid
},
{
label: "taskStatus",
Expand Down
2 changes: 1 addition & 1 deletion aqueductcore/frontend/src/helper/formatters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function experimentTableDataFormatter(experimentList: ExperimentDataType[

export function taskHistoryTableFormatter(tasks: TaskType[]): TaskDataType[] {
const formattedTasks = tasks.map(task => ({
taskId: task.taskId,
taskId: task.uuid,
experiment: {
title: task.experiment.title,
eid: task.experiment.eid
Expand Down
8 changes: 4 additions & 4 deletions aqueductcore/frontend/src/types/globalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ export type EXECUTE_EXTENSION_TYPE = {
resultCode: TaskData['resultCode']
stdErr: TaskData['stdErr']
stdOut: TaskData['stdOut']
taskId: TaskData['taskId']
taskId: TaskData['uuid']
taskStatus: TaskData['taskStatus']
}

export type CANCEL_TASK_TYPE = {
taskId: TaskData['taskId']
taskId: TaskData['uuid']
resultCode: TaskData['resultCode']
taskStatus: TaskData['taskStatus']
}
Expand Down Expand Up @@ -199,7 +199,7 @@ export type TaskDataType = {
name: ExtensionInfo['name']
action: ExtensionActionInfo['name']
};
taskId: TaskType['taskId']
taskId: TaskType['uuid'];
taskStatus: TaskType['taskStatus'];
receivedAt: TaskData['receivedAt'];
createdBy: TaskData['createdBy'];
Expand Down Expand Up @@ -263,7 +263,7 @@ export interface TaskType {
resultCode: TaskData['resultCode']
stdOut: TaskData['stdOut']
stdErr: TaskData['stdErr']
taskId: TaskData['taskId']
uuid: TaskData['uuid']
createdBy: TaskData['createdBy']
experiment: {
uuid: ExperimentData['uuid']
Expand Down
Loading
Loading