Skip to content

Commit

Permalink
fix notifications config pydantic to orm data conversion for create_j…
Browse files Browse the repository at this point in the history
…ob_def
  • Loading branch information
andrii-i committed Nov 1, 2023
1 parent a38af7a commit 6d69a32
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion jupyter_scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,20 @@ def create_job_definition(self, model: CreateJobDefinition) -> str:
if not self.file_exists(model.input_uri):
raise InputUriError(model.input_uri)

job_definition = JobDefinition(**model.dict(exclude_none=True, exclude={"input_uri"}))
orm_notifications_config = None
if model.notifications_config:
orm_notifications_config = NotificationsConfigTable(
**model.notifications_config.dict()
)
session.add(orm_notifications_config)
session.flush()

job_definition_data = model.dict(
exclude={"input_uri", "notifications_config"}, exclude_none=True
)
job_definition = JobDefinition(
**job_definition_data, notifications_config=orm_notifications_config
)
session.add(job_definition)
session.commit()

Expand Down

0 comments on commit 6d69a32

Please sign in to comment.