Skip to content

Commit

Permalink
#2152 on submission change called twice with same status (#2353)
Browse files Browse the repository at this point in the history
#2305 normalize components height
resolves #2152 #2305
  • Loading branch information
Fred Lefévère-Laoide authored and Fred Lefévère-Laoide committed Dec 18, 2024
1 parent 11ff277 commit a044069
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 52 deletions.
4 changes: 4 additions & 0 deletions frontend/taipy-gui/public/stylekit/controls/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
MODIFIER CLASSES
**************************************************/

.taipy-button {
margin: 4px 0;
}

/* fullwidth : */
.taipy-button.fullwidth {
display: flex;
Expand Down
3 changes: 3 additions & 0 deletions frontend/taipy-gui/public/stylekit/controls/file_download.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
/*************************************************
MODIFIER CLASSES
**************************************************/
.taipy-file-download>button {
margin: 4px 0;
}

/* fullwidth : */
.taipy-file-download.fullwidth button {
Expand Down
3 changes: 3 additions & 0 deletions frontend/taipy-gui/public/stylekit/controls/file_selector.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
/*************************************************
MODIFIER CLASSES
**************************************************/
.taipy-file-selector .MuiButtonBase-root {
margin: 4px 0;
}

/* fullwidth : */
.taipy-file-selector.fullwidth [role='button'] {
Expand Down
2 changes: 1 addition & 1 deletion frontend/taipy-gui/public/stylekit/controls/selector.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
**************************************************/

.taipy-selector {
margin: 0;
margin: 4px 0;
}


Expand Down
1 change: 1 addition & 0 deletions frontend/taipy-gui/public/stylekit/controls/slider.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
max-width: 100%;
min-height: 48px;
align-items: center;
margin: 4px 0;
}
1 change: 1 addition & 0 deletions frontend/taipy-gui/public/stylekit/controls/status.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
display: inline-flex;
min-height: 48px;
padding-top: 0.5em;
margin: 4px 0;
}
3 changes: 3 additions & 0 deletions frontend/taipy-gui/public/stylekit/controls/toggle.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
/*************************************************
MODIFIER CLASSES
**************************************************/
.taipy-toggle {
margin: 4px 0;
}

/* relative : Reset the theme toggle position to fit page flow */
.taipy-toggle.relative {
Expand Down
99 changes: 48 additions & 51 deletions taipy/gui_core/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,67 +166,64 @@ def submission_status_callback(self, submission_id: t.Optional[str] = None, even
if not submission_id:
return
submission = None
new_status = None
new_status: t.Optional[SubmissionStatus] = None
payload: t.Optional[t.Dict[str, t.Any]] = None
client_id: t.Optional[str] = None
submission_name: t.Optional[str] = None
try:
last_client_status = self.client_submission.get(submission_id)
if not last_client_status:
submission = t.cast(Submission, core_get(submission_id))
if not submission or not submission.entity_id:
return
new_status = submission.submission_status

client_id = last_client_status.client_id

with self.gui._get_authorization(client_id):
if not is_readable(t.cast(SubmissionId, submission_id)):
return
submission = t.cast(Submission, core_get(submission_id))
if not submission or not submission.entity_id:
with self.submissions_lock:
last_client_status = self.client_submission.get(submission_id)
if not last_client_status:
return

payload = {}
new_status = t.cast(SubmissionStatus, submission.submission_status)

if client_id:
running_tasks = {}
# with self.gui._get_authorization(client_id):
for job in submission.jobs:
job = job if isinstance(job, Job) else t.cast(Job, core_get(job))
running_tasks[job.task.id] = (
SubmissionStatus.RUNNING.value
if job.is_running()
else SubmissionStatus.PENDING.value
if job.is_pending()
else None
)
payload.update(tasks=running_tasks)

if last_client_status.submission_status is not new_status:
# callback
submission_name = submission.properties.get("on_submission")
if submission_name:
self.gui.invoke_callback(
client_id,
submission_name,
[
core_get(submission.id),
{
"submission_status": new_status.name,
"submittable_entity": core_get(submission.entity_id),
**(event.metadata if event else {}),
},
],
submission.properties.get("module_context"),
if last_client_status.submission_status is not new_status:
# callback
submission_name = submission.properties.get("on_submission")

if new_status in (
SubmissionStatus.COMPLETED,
SubmissionStatus.FAILED,
SubmissionStatus.CANCELED,
):
self.client_submission.pop(submission_id, None)
else:
last_client_status.submission_status = new_status

if client_id:= submission.properties.get("client_id"):
with self.gui._get_authorization(client_id):
if payload is not None:
running_tasks = {}
for job in submission.jobs:
job = job if isinstance(job, Job) else t.cast(Job, core_get(job))
running_tasks[job.task.id] = (
SubmissionStatus.RUNNING.value
if job.is_running()
else SubmissionStatus.PENDING.value
if job.is_pending()
else None
)
payload.update(tasks=running_tasks)

if new_status in (
SubmissionStatus.COMPLETED,
SubmissionStatus.FAILED,
SubmissionStatus.CANCELED,
):
with self.submissions_lock:
self.client_submission.pop(submission_id, None)
else:
last_client_status.submission_status = new_status
if submission_name:
self.gui.invoke_callback(
client_id,
submission_name,
[
core_get(submission.id),
{
"submission_status": new_status.name if new_status else "None",
"submittable_entity": core_get(submission.entity_id),
**(event.metadata if event else {}),
},
],
submission.properties.get("module_context"),
)

except Exception as e:
_warn(f"Submission ({submission_id}) is not available", e)
Expand Down

0 comments on commit a044069

Please sign in to comment.