-
Notifications
You must be signed in to change notification settings - Fork 33
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
fix(llm): enable tasks concurrency configs in Gradio #188
base: main
Are you sure you want to change the base?
Conversation
…o Graph Index generation
…adio and added logging decorator for RAG processing
…o Graph Index generation
…s/incubator-hugegraph-ai into gradioconcurrency
we could merge after #187 done (And some tips for the individual PRs)
![]() |
@imbajin thanks for the tips, I was having trouble getting used to that initially |
Also note check/fix the (CI) lint error to keep our code better refer https://github.com/apache/incubator-hugegraph-ai#contributing ![]() |
# queue=True, # Enable queueing for this event | ||
# concurrency_limit=5, # Maximum of 5 concurrent executions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe the two lines 211~212 modification is enough for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I'll modify it to incorporate the buttons for now.
….Button() concurrency.
# A decorator to wrap functions with a task id generation and logging | ||
def with_task_id(func): | ||
def wrapper(*args, **kwargs): | ||
import uuid | ||
task_id = str(uuid.uuid4()) | ||
log.info(f"New task created with id: {task_id}") | ||
# Optionally, you could also pass the task_id to the function if needed: | ||
# kwargs['task_id'] = task_id | ||
return func(*args, **kwargs) | ||
return wrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this decorator still useful now or in the future? Is the main purpose of logging newly created tasks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this one is useful, it's for generating concurrency ids, while the other is a more static general id useful for logging references (the one in the button) and can be modified or removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this one is useful, it's for generating concurrency ids, while the other is a more static general id useful for logging references (the one in the button) and can be modified or removed.
We can keep it, but I still don't understand the purpose of recording this taskID separately in the click function? It seems that there is no significant difference even if I don't use this decorator and record it?
BTW, our logs are already too numerous and need to be streamlined as much as possible 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, I'll try to streamline the logs next.
And you're right, there isnt any significant usage of the click function's taskID, it is merely for identifying the ongoing process so that it is clearer to the dev, which process' ID was being generated, but we can reduce this too if it is unneccesary. As for the decorator, the task_id = str(uuid.uuid4()) is being used to identify any concurrent processes being run, so that we can differentiate ongoing processes per task_id for further debugging as per #176 . I hope this is useful for further development and scaling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, I'll try to streamline the logs next.
And you're right, there isnt any significant usage of the click function's taskID, it is merely for identifying the ongoing process so that it is clearer to the dev, which process' ID was being generated, but we can reduce this too if it is unneccesary. As for the decorator, the task_id = str(uuid.uuid4()) is being used to identify any concurrent processes being run, so that we can differentiate ongoing processes per task_id for further debugging as per #176 . I hope this is useful for further development and scaling
I haven't found out how it works in my local tests. Can you give me an example of how to use it?
@@ -200,6 +208,9 @@ def toggle_slider(enable): | |||
example_num, | |||
], | |||
outputs=[raw_out, vector_only_out, graph_only_out, graph_vector_out], | |||
queue=True, # Enable queueing for this event | |||
concurrency_limit=5, # Maximum of 5 concurrent executions | |||
concurrency_id="rag_answer_task" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so as here
def wrapper(*args: Any, **kwargs: Any) -> Any: | ||
import uuid | ||
task_id = str(uuid.uuid4()) | ||
log.info("New task created with id: %s", task_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it locally and didn't see when this log will be output? There was no occurrence during concurrent use
fix #176
Cause of the Problem:
Blocking and Queuing Behavior: Gradio, by default, has a concurrency limit of 1. This causes blocking when multiple users or windows are accessing the application simultaneously.
No Asynchronous Execution: The current implementation does not specify concurrency_limit, leading to sequential execution.
Queue Configuration: If queue() is not configured properly, tasks are processed one at a time.
Changed:
to
in order to handle frequent unicode encoding errors during attempts to read logs.
Also added task ID generation for RAG functions, and enabled concurrency using Gradio Blocks in rag_block.py in rag_demo by creating a task ID generation decorator and used Gradio Blocks for concurrency control. Added logs for clear understanding. Issue: #176 #176
Closed previous PRs due to merge conflicts. please check this @imbajin