-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use task request labels to encode information required by dashboard (#…
…912) * Custom task type support, refactor tasks to be singular, cleaned up Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * lint Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Make custom task always available Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Check exception for TypeError Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Unifying handleTaskDescriptionChange, added FIXME for allowing favoriting custom tasks Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Renaming custom to custom_compose, since the task category will always be compose, display description for short description Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Catch possible exception with JSON.stringify, add fixmes for task description assumptions Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Pickup and destination in task state labels Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Clean up past workaround where pickup and destination is saved when a request is saved Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Migration script Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Remove stale testing label, push label instead of setting Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Lint Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Hammer/use labels schedules (#921) * Getting ScheduledTask as well Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Handle schedules as well Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * lint Signed-off-by: Aaron Chong <aaronchongth@gmail.com> --------- Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Using a new generated file to handle parsing between json and object Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Made fields all optional, nested in a description object, regenerated api-client Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Using Ajv properly, with basic json stringify and parse Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Renaming to task booking label, with the endpoint getting the label from the state, instead of the request Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Generated API client after rename Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Changes to dashboard and react components after rename Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Refactoring and moving ajx instance to react-components Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Updated migration scipt to use TaskBookingLabel and task_name Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Handles editing scheduled task Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * clean up task favorite models Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Adding label to favorite task before saving, setting booking label state when fav task is clicked Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Lint Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Added notes about TaskFavorite in migration script Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Description of TaskBookingLabel Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Fix migration script Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * task_definition_id for TaskFavorite Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Use mandatory task_definition_id instead of task_name Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Generate label only before dispatching Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Clean up of emergency lots usage in config Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Removed unused map Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Lint Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * New generic TaskLabel tortoise model, to handle more custom label fields for sorting and filtering Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Fix migration script Signed-off-by: Aaron Chong <aaronchongth@gmail.com> * Added float field, and more comments on the steps of label creation and saving Signed-off-by: Aaron Chong <aaronchongth@gmail.com> --------- Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
- Loading branch information
1 parent
9136efd
commit 38d5869
Showing
30 changed files
with
995 additions
and
428 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/api-server/api_server/models/task_booking_label.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.