Skip to content

Commit

Permalink
Merge branch 'deploy/hammer' into hammer/generic-alerts
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth committed May 23, 2024
2 parents d2a7d58 + 38d5869 commit 907f739
Show file tree
Hide file tree
Showing 31 changed files with 995 additions and 439 deletions.
261 changes: 174 additions & 87 deletions packages/api-client/lib/openapi/api.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/api-client/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { version as rmfModelVer } from 'rmf-models';

export const version = {
rmfModels: rmfModelVer,
rmfServer: 'fd45675f94b75df6845303db4f45276d0998f3e6',
rmfServer: '98741b14ceca74208ca98e4bb0c3ca9e41ca1e3c',
openapiGenerator: '6.2.1',
};
98 changes: 66 additions & 32 deletions packages/api-client/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,36 @@ export default {
},
},
},
'/tasks/{task_id}/booking_label': {
get: {
tags: ['Tasks'],
summary: 'Get Task Booking Label',
operationId: 'get_task_booking_label_tasks__task_id__booking_label_get',
parameters: [
{
description: 'task_id',
required: true,
schema: { title: 'Task Id', type: 'string', description: 'task_id' },
name: 'task_id',
in: 'path',
},
],
responses: {
'200': {
description: 'Successful Response',
content: {
'application/json': { schema: { $ref: '#/components/schemas/TaskBookingLabel' } },
},
},
'422': {
description: 'Validation Error',
content: {
'application/json': { schema: { $ref: '#/components/schemas/HTTPValidationError' } },
},
},
},
},
},
'/tasks/{task_id}/log': {
get: {
tags: ['Tasks'],
Expand Down Expand Up @@ -1556,7 +1586,7 @@ export default {
schema: {
title: 'Response Get Favorites Tasks Favorite Tasks Get',
type: 'array',
items: { $ref: '#/components/schemas/TaskFavoritePydantic' },
items: { $ref: '#/components/schemas/TaskFavorite' },
},
},
},
Expand All @@ -1569,20 +1599,14 @@ export default {
operationId: 'post_favorite_task_favorite_tasks_post',
requestBody: {
content: {
'application/json': { schema: { $ref: '#/components/schemas/TaskFavoritePydantic' } },
'application/json': { schema: { $ref: '#/components/schemas/TaskFavorite' } },
},
required: true,
},
responses: {
'200': {
description: 'Successful Response',
content: {
'application/json': {
schema: {
$ref: '#/components/schemas/api_server.models.tortoise_models.tasks.TaskFavorite.leaf',
},
},
},
content: { 'application/json': { schema: {} } },
},
'422': {
description: 'Validation Error',
Expand Down Expand Up @@ -3647,6 +3671,28 @@ export default {
},
},
},
TaskBookingLabel: {
title: 'TaskBookingLabel',
required: ['description'],
type: 'object',
properties: { description: { $ref: '#/components/schemas/TaskBookingLabelDescription' } },
description:
'This label is to be populated by any frontend during a task dispatch, by\nbeing added to TaskRequest.labels, which in turn populates\nTaskState.booking.labels, and can be used to display relevant information\nneeded for any frontends.',
},
TaskBookingLabelDescription: {
title: 'TaskBookingLabelDescription',
required: ['task_definition_id'],
type: 'object',
properties: {
task_definition_id: { title: 'Task Definition Id', type: 'string' },
unix_millis_warn_time: { title: 'Unix Millis Warn Time', type: 'integer' },
pickup: { title: 'Pickup', type: 'string' },
destination: { title: 'Destination', type: 'string' },
cart_id: { title: 'Cart Id', type: 'string' },
},
description:
'This description holds several fields that could be useful for frontend\ndashboards when dispatching a task, to then be identified or rendered\naccordingly back on the same frontend.',
},
TaskCancelResponse: {
title: 'TaskCancelResponse',
allOf: [{ $ref: '#/components/schemas/SimpleResponse' }],
Expand Down Expand Up @@ -3730,9 +3776,16 @@ export default {
},
additionalProperties: false,
},
TaskFavoritePydantic: {
title: 'TaskFavoritePydantic',
required: ['id', 'name', 'unix_millis_earliest_start_time', 'category', 'user'],
TaskFavorite: {
title: 'TaskFavorite',
required: [
'id',
'name',
'unix_millis_earliest_start_time',
'category',
'user',
'task_definition_id',
],
type: 'object',
properties: {
id: { title: 'Id', type: 'string' },
Expand All @@ -3745,6 +3798,7 @@ export default {
category: { title: 'Category', type: 'string' },
description: { title: 'Description', type: 'object' },
user: { title: 'User', type: 'string' },
task_definition_id: { title: 'Task Definition Id', type: 'string' },
},
},
TaskInterruptionRequest: {
Expand Down Expand Up @@ -4259,26 +4313,6 @@ export default {
$ref: '#/components/schemas/api_server.models.tortoise_models.scheduled_task.ScheduledTask',
},
},
'api_server.models.tortoise_models.tasks.TaskFavorite.leaf': {
title: 'TaskFavorite',
required: ['id', 'name', 'category', 'user'],
type: 'object',
properties: {
id: { title: 'Id', maxLength: 255, type: 'string' },
name: { title: 'Name', maxLength: 255, type: 'string' },
unix_millis_earliest_start_time: {
title: 'Unix Millis Earliest Start Time',
type: 'string',
format: 'date-time',
nullable: true,
},
priority: { title: 'Priority' },
category: { title: 'Category', maxLength: 255, type: 'string' },
description: { title: 'Description' },
user: { title: 'User', maxLength: 255, type: 'string' },
},
additionalProperties: false,
},
api_server__models__delivery_alerts__DeliveryAlert__Category: {
title: 'Category',
enum: ['missing', 'wrong', 'obstructed', 'cancelled'],
Expand Down
2 changes: 1 addition & 1 deletion packages/api-server/api_server/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def verify_token(self, token: Optional[str]) -> User:
user = await self._get_user(claims)

return user
except jwt.DecodeError as e:
except jwt.InvalidTokenError as e:
raise AuthenticationError(str(e)) from e

def fastapi_dep(self) -> Callable[..., Union[Coroutine[Any, Any, User], User]]:
Expand Down
2 changes: 2 additions & 0 deletions packages/api-server/api_server/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@
from .rmf_api.task_state_update import TaskStateUpdate
from .rmf_api.undo_skip_phase_request import UndoPhaseSkipRequest
from .rmf_api.undo_skip_phase_response import UndoPhaseSkipResponse
from .task_booking_label import *
from .task_favorite import *
from .user import *
46 changes: 46 additions & 0 deletions packages/api-server/api_server/models/task_booking_label.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from typing import Optional

import pydantic
from pydantic import BaseModel

# NOTE: This label model needs to exactly match the fields that are defined and
# populated by the dashboard. Any changes to either side will require syncing.


class TaskBookingLabelDescription(BaseModel):
"""
This description holds several fields that could be useful for frontend
dashboards when dispatching a task, to then be identified or rendered
accordingly back on the same frontend.
"""

task_definition_id: str
unix_millis_warn_time: Optional[int]
pickup: Optional[str]
destination: Optional[str]
cart_id: Optional[str]

@staticmethod
def from_json_string(json_str: str) -> Optional["TaskBookingLabelDescription"]:
try:
return TaskBookingLabelDescription.parse_raw(json_str)
except pydantic.error_wrappers.ValidationError:
return None


class TaskBookingLabel(BaseModel):
"""
This label is to be populated by any frontend during a task dispatch, by
being added to TaskRequest.labels, which in turn populates
TaskState.booking.labels, and can be used to display relevant information
needed for any frontends.
"""

description: TaskBookingLabelDescription

@staticmethod
def from_json_string(json_str: str) -> Optional["TaskBookingLabel"]:
try:
return TaskBookingLabel.parse_raw(json_str)
except pydantic.error_wrappers.ValidationError:
return None
14 changes: 14 additions & 0 deletions packages/api-server/api_server/models/task_favorite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from typing import Dict

from pydantic import BaseModel


class TaskFavorite(BaseModel):
id: str
name: str
unix_millis_earliest_start_time: int
priority: Dict | None
category: str
description: Dict | None
user: str
task_definition_id: str
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
TaskEventLogPhasesEventsLog,
TaskEventLogPhasesLog,
TaskFavorite,
TaskFavoritePydantic,
TaskLabel,
TaskRequest,
TaskState,
)
Expand Down
25 changes: 11 additions & 14 deletions packages/api-server/api_server/models/tortoise_models/tasks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields import (
BigIntField,
CharField,
DatetimeField,
FloatField,
ForeignKeyField,
ForeignKeyRelation,
JSONField,
Expand Down Expand Up @@ -31,6 +31,15 @@ class TaskState(Model):
unix_millis_warn_time = DatetimeField(null=True, index=True)
pickup = CharField(255, null=True, index=True)
destination = CharField(255, null=True, index=True)
labels = ReverseRelation["TaskLabel"]


class TaskLabel(Model):
state = ForeignKeyField("models.TaskState", null=True, related_name="labels")
label_name = CharField(255, null=False, index=True)
label_value_str = CharField(255, null=True, index=True)
label_value_num = BigIntField(null=True, index=True)
label_value_float = FloatField(null=True, index=True)


class TaskEventLog(Model):
Expand Down Expand Up @@ -81,16 +90,4 @@ class TaskFavorite(Model):
category = CharField(255, null=False, index=True)
description = JSONField()
user = CharField(255, null=False, index=True)


TaskFavoritePydantic = pydantic_model_creator(TaskFavorite)


# class TaskPath(Model):
# task_id = CharField(255, null=False, index=True)


# class TaskLocationCheckIn(Model):
# task_id = CharField(255, null=False, index=True)
# unix_millis_check_in_time = BigIntField(null=False, index=True)
# location = CharField(255, null=False, index=True)
task_definition_id = CharField(255, null=True, index=True)
Loading

0 comments on commit 907f739

Please sign in to comment.