-
Notifications
You must be signed in to change notification settings - Fork 32
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
Feat/callback state #130
base: dev
Are you sure you want to change the base?
Feat/callback state #130
Conversation
@fohrloop |
The current modification has been running well in my scene for quite a long time, for example: @du.callback(
output=[
PREVIEW_IMAGE_ID.get_output("children"),
UPLOAD_IMAGE_LOADING_ID.get_output("children"),
LOGIN_MODAL_ID.get_output("is_open"),
],
state=[
SESSION_STORE_ID.get_state("data"),
TOKEN_STORE_ID.get_state("data"),
],
id=UPLOAD_IMAGE_ID.get_identifier(),
)
def callback_on_completion(status: du.UploadStatus, session_id, token):
if session_id != status.upload_id:
return no_update, status_alert("Session mismatch.", color="danger"), no_update
if (not token) or (not is_valid_token(token)):
return no_update, status_alert("Login required.", color="danger"), True
session = Session.load(session_id)
if not session:
return no_update, status_alert("Session not found.", color="danger"), no_update
if status.is_completed:
return (
render_images(session),
status_alert(
f"Successfully uploaded {status.n_uploaded}/{status.n_total}.",
color="green",
),
no_update,
)
return (
render_images(session),
status_alert(f"Uploading {status.n_uploaded}...", color="green"),
no_update,
) |
Hi @mapix , Glad to see this one getting a fix. Tests would be nice though; what could be done to make testing easier on your local machine? I don't think I have too much time to contribute on this project, but could we get some user to comment this change? Or someone from your team? @salvocamiolo / @salvo-camiolo ? Niko |
The reason for the difficulty with tests is that I always have a critical Case failure on my Mac, but I cannot determine for a while whether it is due to differences in the logic of handling unlink files between Windows and Mac. This error is not related to the current changes. I wonder if other contributors have encountered this issue as well. Regarding more contributors, @Sisyphus235 from my team will collaborate more on this project.
|
state
parameter todu.callback
support more state supplies such as token or current sessionRef: #104