Skip to content

Conversation

@mina-parham
Copy link
Contributor

No description provided.

Copy link
Member

@dadmobile dadmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruff errors seem legit.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
api/transformerlab/fastchat_openai_api.py 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

request_id = uuid.uuid4()
params["request_id"] = str(request_id)
output = await worker.generate(params)
release_worker_semaphore()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is not thread safe, there is no guarantee that release_worker_semaphore() will ever get called. I would highly recommend using a finally: clause.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just trying to understand if this also impacts other things. What do you mean by not being thread safe? is it because of the try catch or something else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's difficult to explain thoroughly without getting into the complexities of thread management, but basically if worker.generate throws an exception, then release_worker_semaphore() will never get called, which is problematic. The fix should be easy though, you should be able to do something like

finally:
    release_worker_semaphore()

to ensure that this line does get called.

It's really easy to write code that isn't thread-safe so definitely keep an eye out for stuff like this.

lang_code = params.get("lang_code", None)
stream = params.get("stream", False)

experiment_dir = get_experiments_dir()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion but I think this doesnt work because the lab context getting set when this file runs is not passed on to the uvicorn app that runs from this. I do set a lab context so the get_experiments_dir should've worked if it was running directly in this file. Do you think a better approach would be passing in experiments dir through the main() function by calling this function there? Or does that not work?
I'm just concerned if plugin_harness did not set the context correctly for this case and was wanting to get to the core of the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants