From 9f8c0017cdad555255dc7a3a99e392b44262f722 Mon Sep 17 00:00:00 2001 From: Adam Struck Date: Mon, 23 Oct 2023 21:22:38 -0700 Subject: [PATCH] fix: store the task type value rather than enum when creating a task (#1329) * fix: store the task type value not enum when creating a task * Update demo.py --- querybook/server/logic/demo.py | 2 +- querybook/server/logic/schedule.py | 2 +- querybook/server/models/schedule.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/querybook/server/logic/demo.py b/querybook/server/logic/demo.py index 04b836f3c..984761d97 100644 --- a/querybook/server/logic/demo.py +++ b/querybook/server/logic/demo.py @@ -72,7 +72,7 @@ def set_up_demo(uid: int, session=None): "task": "tasks.update_metastore.update_metastore", "cron": "0 0 * * *", "args": [metastore_id], - "task_type": ScheduleTaskType.PROD, + "task_type": ScheduleTaskType.PROD.value, "enabled": True, }, # commit=False, diff --git a/querybook/server/logic/schedule.py b/querybook/server/logic/schedule.py index 310b326dc..9fb09d931 100644 --- a/querybook/server/logic/schedule.py +++ b/querybook/server/logic/schedule.py @@ -65,7 +65,7 @@ def create_task_schedule( kwargs=kwargs or {}, options=options or {}, enabled=enabled, - task_type=get_schedule_task_type(name), + task_type=get_schedule_task_type(name).value, ) session.add(schedule) diff --git a/querybook/server/models/schedule.py b/querybook/server/models/schedule.py index 37bd84880..c097ada0e 100644 --- a/querybook/server/models/schedule.py +++ b/querybook/server/models/schedule.py @@ -67,7 +67,9 @@ class TaskSchedule(CRUDMixin, Base): no_changes = sql.Column(sql.Boolean, default=False) task_type = sql.Column( - sql.String(length=name_length), nullable=False, default=ScheduleTaskType.PROD + sql.String(length=name_length), + nullable=False, + default=ScheduleTaskType.PROD.value, ) def get_cron(self):