Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use task request labels to encode information required by dashboard #912

Merged
merged 46 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9daeb5d
Custom task type support, refactor tasks to be singular, cleaned up
aaronchongth Feb 18, 2024
81f0bd3
lint
aaronchongth Feb 18, 2024
a159492
Make custom task always available
aaronchongth Mar 1, 2024
0880120
Merge branch 'deploy/hammer' into hammer/debug-custom-description
aaronchongth Mar 1, 2024
b3bdf92
Check exception for TypeError
aaronchongth Mar 4, 2024
279b2b1
Unifying handleTaskDescriptionChange, added FIXME for allowing favori…
aaronchongth Mar 4, 2024
fab9d5d
Renaming custom to custom_compose, since the task category will alway…
aaronchongth Mar 4, 2024
03aa973
Catch possible exception with JSON.stringify, add fixmes for task des…
aaronchongth Mar 6, 2024
8c7739f
Merge branch 'deploy/hammer' into hammer/debug-custom-description
aaronchongth Mar 11, 2024
3573531
Pickup and destination in task state labels
aaronchongth Mar 12, 2024
be58006
Clean up past workaround where pickup and destination is saved when a…
aaronchongth Mar 12, 2024
194ed21
Migration script
aaronchongth Mar 13, 2024
83f44bb
Merge branch 'deploy/hammer' into hammer/use-labels
aaronchongth Mar 13, 2024
c9d4833
Remove stale testing label, push label instead of setting
aaronchongth Mar 13, 2024
0008c10
Lint
aaronchongth Mar 13, 2024
c4e7fc6
Hammer/use labels schedules (#921)
aaronchongth Mar 20, 2024
7a185d1
Merge branch 'deploy/hammer' into hammer/use-labels
aaronchongth Apr 7, 2024
0dbe2fd
Using a new generated file to handle parsing between json and object
aaronchongth Apr 17, 2024
d4c7f52
Merge branch 'deploy/hammer' into hammer/use-labels
aaronchongth Apr 25, 2024
440dc2c
Made fields all optional, nested in a description object, regenerated…
aaronchongth Apr 29, 2024
0ec29e0
Using Ajv properly, with basic json stringify and parse
aaronchongth Apr 29, 2024
e78c868
Renaming to task booking label, with the endpoint getting the label f…
aaronchongth Apr 29, 2024
136f7e2
Generated API client after rename
aaronchongth Apr 29, 2024
5ea73fa
Changes to dashboard and react components after rename
aaronchongth Apr 29, 2024
9fe336d
Refactoring and moving ajx instance to react-components
aaronchongth Apr 29, 2024
2327f5b
Updated migration scipt to use TaskBookingLabel and task_name
aaronchongth Apr 29, 2024
71f5de9
Handles editing scheduled task
aaronchongth Apr 29, 2024
bf45cf1
clean up task favorite models
aaronchongth Apr 30, 2024
37edc10
Adding label to favorite task before saving, setting booking label st…
aaronchongth Apr 30, 2024
f872e22
Lint
aaronchongth Apr 30, 2024
0d6f019
Merge pull request #943 from open-rmf/hammer/fix-favorite-with-labels
aaronchongth Apr 30, 2024
6e3c930
Added notes about TaskFavorite in migration script
aaronchongth May 6, 2024
3f9a874
Merge branch 'deploy/hammer' into hammer/use-labels
aaronchongth May 6, 2024
24ddad5
Description of TaskBookingLabel
aaronchongth May 6, 2024
6c8dcf2
Fix migration script
aaronchongth May 7, 2024
38e70a4
Merge branch 'deploy/hammer' into hammer/use-labels
aaronchongth May 8, 2024
963092f
task_definition_id for TaskFavorite
aaronchongth May 9, 2024
22dada0
Use mandatory task_definition_id instead of task_name
aaronchongth May 9, 2024
98741b1
Generate label only before dispatching
aaronchongth May 10, 2024
5f4393a
Merge branch 'deploy/hammer' into hammer/use-labels
aaronchongth May 10, 2024
305791b
Clean up of emergency lots usage in config
aaronchongth May 10, 2024
fe49360
Removed unused map
aaronchongth May 10, 2024
2c2d5d2
Lint
aaronchongth May 10, 2024
82422f4
New generic TaskLabel tortoise model, to handle more custom label fie…
aaronchongth May 17, 2024
bb95202
Fix migration script
aaronchongth May 17, 2024
7c2d8ef
Added float field, and more comments on the steps of label creation a…
aaronchongth May 20, 2024
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
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: 2 additions & 0 deletions packages/api-server/api_server/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,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,6 @@
TaskEventLogPhasesEventsLog,
TaskEventLogPhasesLog,
TaskFavorite,
TaskFavoritePydantic,
TaskRequest,
TaskState,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from tortoise.contrib.pydantic.creator import pydantic_model_creator
from tortoise.fields import (
CharField,
DatetimeField,
Expand Down Expand Up @@ -80,6 +79,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)
task_definition_id = CharField(255, null=True, index=True)
Loading
Loading