-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Add local model worker parameters #2974
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
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| '-w', worker, | ||
| '--max-requests', '10240', | ||
| '--max-requests-jitter', '2048', | ||
| '--access-logformat', log_format, |
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.
The provided Gunicorn command line is mostly correct, but there are a few minor improvements and clarifications that could be made:
-
Worker Configuration: The
workersetting should be more robust. Instead of hardcoding it to 1, you can use a variable that checks if the configuration has been set; otherwise, default it to 1. This ensures that the application works even if the configuration file does not specify this option. -
Security Considerations: Ensure that paths in the environment variables like
LOCAL_MODEL_HOST,LOCAL_MODEL_PORT, etc., are properly sanitized to avoid security vulnerabilities such as injection attacks if they come from user input. -
Logging Format: Double-check the format string for logging (
--access-logformat) to ensure it correctly reflects what information needs to be logged by your application. You might want to adjust it based on your specific requirements.
Here’s an improved version of the command with these considerations:
@@ -24,12 +24,14 @@ def cmd(self):
os.environ.setdefault('SERVER_NAME', 'local_model')
log_format = '%(h)s %(t)s %(L)ss "%(r)s" %(s)s %(b)s '
bind = f'{CONFIG.get("LOCAL_MODEL_HOST")}:{CONFIG.get("LOCAL_MODEL_PORT")}'
+ # Set worker using dynamic value or default
+ worker_setting = CONFIG.get("LOCAL_MODEL_HOST_WORKER")
+ if worker_setting is None:
+ worker_setting = 1
cmd = [
'gunicorn', 'smartdoc.wsgi:application',
'-b', bind,
'-k', 'gthread',
'--threads', '200',
- '-w', "1",
+ '-w', str(worker_setting),
'--max-requests', '10240',
'--max-requests-jitter', '2048',
'--access-logformat', log_format,Make sure to replace 'smartdoc.wsgi' with the actual path to your WSGI module if different, depending on how your Flask app is structured.
| 'LOCAL_MODEL_HOST_WORKER': 1 | ||
|
|
||
| } | ||
|
|
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.
The provided code snippet appears to be a section of a configuration dictionary class defined in Python. Here is a brief review for any potential issues:
-
Typo Correction: There is a typo in
'LOCAL_MODEL_HOST_WORKER'. The value should likely be an integer representing the number of worker processes, but it is currently missing its closing quotes. -
Code Formatting: While not strictly necessary, indentation can improve readability for those unfamiliar with Python's syntax.
Suggested corrections:
@@ -93,7 +93,8 @@
'SANDBOX': False,
'LOCAL_MODEL_HOST': '127.0.0.1',
'LOCAL_MODEL_PORT': '11636',
- 'LOCAL_MODEL_PROTOCOL': "http"
+ 'LOCAL_MODEL_PROTOCOL': "http",
+ 'LOCAL_MODEL_HOST_WORKER': 4 # Assuming you want four workersThese changes address the identified issue and make the code more readable and correct. If there are further optimizations needed, additional context about what these configurations represent (e.g., database settings, API endpoints) would be helpful.
| num_predict = forms.SliderField( | ||
| TooltipLabel(_('Output the maximum Tokens'), | ||
| _('Specify the maximum number of tokens that the model can generate')), | ||
| required=True, default_value=1024, |
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.
The code snippet you provided has a small typo in max_tokens that should be corrected to num_predict. Here's the updated line:
Updated Code Snippet:
num_predict = forms.SliderField(No other significant issues or optimizations are present in this particular part of the code.
fix: Ollama maximum output token field
feat: Add local model worker parameters