romero61
romero61
SSolara
Created by romero61 on 10/21/2023 in #general
Use_thread
@maartenbreddels I wanted to thank you for your response to this, I ended up getting fulltime employment on top of the internship I am building this for so I got quite busy. It still has this bug but to clarify its on huggingface and runs perfectly fine locally. I can't seem to figure what the issue is there so I may just to have to live with it. I'll be sharing it shortly on the showcase channel.
7 replies
SSolara
Created by romero61 on 10/21/2023 in #general
Use_thread
@solara.component def CombinedThread(running, timer_value,t1, elapsed_time, status_message, available_dates, selected_coordinates, selected_country, model_status): def thread_function(): while True: thread_running.wait() # Wait until signaled to start. if available_dates.value and running.value: status_message.value = "Model is running..." timer_value.value +=1 final_df = CNN(model_status, t1, elapsed_time, dates_list=available_dates.value, coordinates=selected_coordinates.value, country=selected_country.value ) if model_status.value == "Model run complete!": status_message.value = "Model run complete!" timer_value.value -=1 available_dates.value = None thread_running.clear()# Signal the thread to stop. running.value = False elif not available_dates.value and status_message.value != 'Model run complete!': status_message.value = 'Requires Date Selection' running.value = False timer_value.value = 0 thread_running.clear() result = solara.use_thread(thread_function, dependencies=[running.value]) @solara.component def Page(): ModelControl(running, status_message, start_time) CombinedThread(running, timer_value, elapsed_time, status_message, model_status)
7 replies
SSolara
Created by romero61 on 10/21/2023 in #general
Use_thread
Sorry what I mean by crash is I get a server disconnected that looks like the solar.dev server disconnected notification. running = solara.reactive(False) status_message = solara.reactive("Ready to start.") timer_value = solara.reactive(0) start_time = solara.reactive(None) elapsed_time = solara.reactive(None) model_status = solara.reactive('Waiting') thread_running = threading.Event() @solara.component def ModelControl(running, status_message, start_time): def start_model(): running.value = True start_time.value = datetime.datetime.now() thread_running.set() def stop_model(): thread_running.clear() running.value = False status_message.value = "Model stopped by user." if running.value: return solara.Button(label="Stop Execution", on_click=stop_model) else: return solara.Button(label="Start Model", on_click=start_model)
7 replies