Skip to content
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

Multi lora inference #12

Merged
merged 1 commit into from
Aug 23, 2024
Merged

Multi lora inference #12

merged 1 commit into from
Aug 23, 2024

Conversation

andreasjansson
Copy link
Member

@andreasjansson andreasjansson commented Aug 23, 2024

Supersedes #10


🚀 This description was created by Ellipsis for commit 3c22799

Summary:

This PR introduces multi-LoRA inference, refactors CI workflows, enhances weight management with caching, and adds unit tests, superseding PR #10.

Key points:

  • Supersedes PR Multiple loras #10
  • Introduces multi-LoRA inference in predict.py with load_single_lora and load_multiple_loras
  • Refactors CI workflows in .github/workflows/ci.yaml to separate linting and unit testing
  • Adds .github/workflows/push.yaml for safe push operations using cog-safe-push
  • Enhances weight management with caching in weights.py using WeightsDownloadCache
  • Implements make_download_url in weights.py for URL parsing and download
  • Adds unit tests in unit-tests/test_weights.py for weight management and URL parsing
  • Creates requirements-test.txt for test dependencies

Generated with ❤️ by ellipsis.dev

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 0ea52ad in 26 seconds

More details
  • Looked at 911 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. weights.py:87
  • Draft comment:
    Consider adding a more descriptive error message or handling for URLs that do not end with .tar or .safetensors to improve robustness.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights_url function in weights.py is responsible for downloading files based on their extensions. However, it does not handle URLs that end with neither .tar nor .safetensors, which could lead to unexpected errors if such URLs are passed. This should be addressed to ensure robustness.
2. predict.py:316
  • Draft comment:
    The download_weights function is defined but not used in this file. Consider removing it if it's redundant, as it seems to duplicate functionality from weights.py.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights function in predict.py is defined but not used within the file. It seems to be a duplicate of the function in weights.py. This redundancy should be addressed to avoid confusion and maintain code clarity.
3. predict.py:125
  • Draft comment:
    The lora_scale parameter allows negative values, which might not be intended. Consider restricting the range to non-negative values if negative scaling is not supported.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    In predict.py, the lora_scale parameter has a default value of 1.0, but the range allows for negative values. This might not be intended, as negative scaling could lead to unexpected behavior.
4. predict.py:263
  • Draft comment:
    The load_single_lora function uses model to access self.pipes, but it should use pipe directly as passed to the function. Consider updating the function to use pipe instead of self.pipes[model].
  • Reason this comment was not posted:
    Confidence changes required: 50%
    In predict.py, the load_single_lora function uses the model parameter to access self.pipes, but it should be using pipe directly as passed to the function. This is a logical inconsistency that should be corrected.

Workflow ID: wflow_lrvABZCTIzCU7qlF


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

predict.py Outdated
main_lora_path = self.weights_cache.ensure(main_lora_url)
pipe.load_lora_weights(main_lora_path, adapter_name="main")

extra_lora_path = self.weights_cache.ensure(main_lora_url)
Copy link

Choose a reason for hiding this comment

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

Suggested change
extra_lora_path = self.weights_cache.ensure(main_lora_url)
extra_lora_path = self.weights_cache.ensure(extra_lora_url)

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 0a7b049 in 37 seconds

More details
  • Looked at 910 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. weights.py:71
  • Draft comment:
    The download_weights function is defined twice, here and in predict.py. Consider removing the duplicate in predict.py to avoid redundancy.
  • Reason this comment was not posted:
    Marked as duplicate.
2. weights.py:76
  • Draft comment:
    The download_weights_url function is not used anywhere in the code. Consider removing it if it's not needed.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is incorrect because the download_weights_url function is used in the download_weights function. Removing it would break the functionality of the code. The comment should be removed as it suggests an incorrect action.
    I might be overlooking other potential uses of the function or misunderstand the flow of the code. However, the direct call within download_weights is clear and indicates usage.
    The direct call to download_weights_url within download_weights confirms its usage, so the comment is indeed incorrect.
    The comment should be removed because it incorrectly states that the download_weights_url function is unused, while it is actually used in the code.
3. weights.py:92
  • Draft comment:
    The download_safetensors_tarball function is not used anywhere in the code. Consider removing it if it's not needed.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment suggests that download_safetensors_tarball is not used, but upon reviewing the code, it is clear that this function is called within download_weights_url. Therefore, the comment is incorrect as the function is indeed used in the code.
    I might be missing some context about whether the function is used in a meaningful way or if the logic is correct, but the fact remains that the function is called in the code.
    The function is explicitly called in the code, which means it is used. The comment is incorrect in stating that it is not used.
    The comment is incorrect because download_safetensors_tarball is used in the code. Therefore, the comment should be removed.
4. weights.py:72
  • Draft comment:
    Ensure that the download_weights function in weights.py is used consistently across the codebase to avoid redundancy and potential inconsistencies.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is speculative and doesn't point out a specific issue in the code. It suggests a general practice rather than addressing a concrete problem in the diff. According to the rules, comments should only be made if there's a definite issue or code change required.
    I might be overlooking a potential inconsistency in the code that the comment is hinting at. However, without a specific example or evidence, the comment remains speculative.
    The comment does not provide specific evidence of inconsistency, making it speculative. It doesn't align with the rules for actionable comments.
    The comment should be removed as it is speculative and does not point out a specific issue or required code change.

Workflow ID: wflow_ksgnFUT0qdzBri14


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

predict.py Outdated
return ASPECT_RATIOS[aspect_ratio]


def download_weights(url, dest):
Copy link

Choose a reason for hiding this comment

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

The download_weights function is defined twice, here and in weights.py. Consider removing this duplicate and using the one from weights.py to avoid redundancy.

weights.py Show resolved Hide resolved
weights.py Show resolved Hide resolved
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on a2c2bb1 in 36 seconds

More details
  • Looked at 918 lines of code in 7 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. predict.py:316
  • Draft comment:
    The download_weights function is defined here and in weights.py. Consider removing this duplicate definition and importing it from weights.py to avoid redundancy.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment suggests a code quality improvement by removing redundancy, which is generally a good practice. However, without seeing the weights.py file in the diff, I cannot confirm if the function is indeed duplicated. The comment might be speculative if the duplication is not confirmed.
    I might be missing the context of weights.py since it's not shown in the diff. The comment could be speculative if the duplication is not confirmed, which would violate the rules against speculative comments.
    Even if the duplication is not confirmed, suggesting to remove redundancy is a valid code quality improvement. However, without confirmation, the comment might not be actionable.
    The comment is speculative because it assumes a duplication without confirmation from the diff. It should be removed unless the duplication is confirmed.
2. weights.py:71
  • Draft comment:
    The download_weights function is defined here and in predict.py. Consider removing this duplicate definition and importing it from predict.py to avoid redundancy.
  • Reason this comment was not posted:
    Marked as duplicate.
3. weights.py:97
  • Draft comment:
    Consider handling other potential exceptions that might occur during the subprocess execution in download_safetensors_tarball to make the function more robust.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_safetensors_tarball function uses subprocess.run without handling potential exceptions other than CalledProcessError. It's good practice to handle other exceptions that might occur during the subprocess execution.
4. weights.py:132
  • Draft comment:
    Consider handling other potential exceptions that might occur during the subprocess execution in download_safetensors to make the function more robust.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_safetensors function uses subprocess.run without handling potential exceptions other than CalledProcessError. It's good practice to handle other exceptions that might occur during the subprocess execution.

Workflow ID: wflow_gKXuZqxbZKH2Vgdi


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

predict.py Outdated
main_lora_path = self.weights_cache.ensure(main_lora_url)
pipe.load_lora_weights(main_lora_path, adapter_name="main")

extra_lora_path = self.weights_cache.ensure(main_lora_url)
Copy link

Choose a reason for hiding this comment

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

The extra_lora_path should be derived from extra_lora_url, not main_lora_url. This will ensure the correct LoRA weights are loaded.

Suggested change
extra_lora_path = self.weights_cache.ensure(main_lora_url)
extra_lora_path = self.weights_cache.ensure(extra_lora_url)

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 1eb6e49 in 22 seconds

More details
  • Looked at 932 lines of code in 7 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    The use of '|' for type hinting is only supported in Python 3.10 and later. Ensure compatibility if using older Python versions.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of '|' for type hinting is only supported in Python 3.10 and later. Since the setup specifies Python 3.12, this is fine, but it's worth noting for compatibility.
2. predict.py:57
  • Draft comment:
    The function download_weights is defined in weights.py but not used here. Ensure that download_base_weights is the intended function to use.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights function is defined in weights.py but is not used in predict.py. Instead, download_base_weights is used. This might be intentional, but it's worth checking for consistency.
3. weights.py:71
  • Draft comment:
    The download_weights function is not used in the current code. Consider removing it if it's redundant.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights function in weights.py is not used anywhere in the current PR. It might be redundant if download_base_weights is intended to replace it.
4. weights.py:61
  • Draft comment:
    Remove the debug print statement for free disk space before merging.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The print statement for free disk space is marked as a TODO to remove. It should be removed before merging.

Workflow ID: wflow_QXiX2OkDQzpBQswx


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 43ef925 in 28 seconds

More details
  • Looked at 932 lines of code in 7 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Using '|' for type hinting is only supported in Python 3.10 and later. Ensure compatibility if earlier Python versions are needed.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of '|' for type hinting is only supported in Python 3.10 and later. Since the CI is set up for Python 3.12, this is fine, but it's worth noting for compatibility with earlier versions.
2. weights.py:72
  • Draft comment:
    Consider adding exception handling for make_download_url to handle cases where the URL parsing fails.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights function in weights.py is not handling exceptions for the make_download_url function. If make_download_url raises an exception, it will not be caught, and the program will crash.
3. weights.py:99
  • Draft comment:
    Consider adding exception handling for the subprocess call to pget to handle download failures gracefully.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights_url function in weights.py does not handle exceptions for the subprocess call to pget. If pget fails, it will raise an exception that is not caught.
4. weights.py:134
  • Draft comment:
    Consider adding exception handling for the subprocess call to pget to handle download failures gracefully.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights_url function in weights.py does not handle exceptions for the subprocess call to pget. If pget fails, it will raise an exception that is not caught.
5. predict.py:320
  • Draft comment:
    Consider adding exception handling for the subprocess call to pget to handle download failures gracefully.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights_url function in weights.py does not handle exceptions for the subprocess call to pget. If pget fails, it will raise an exception that is not caught.

Workflow ID: wflow_fLs6oJaRQjlJhzKP


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 822dd1d in 32 seconds

More details
  • Looked at 924 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. weights.py:89
  • Draft comment:
    The error message here is misleading for data: URLs. Consider updating it to reflect that data: URLs are valid.
raise ValueError("URL must end with either .tar, .safetensors, or be a valid data URL")
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The current implementation of the download_weights_url function in weights.py uses a series of conditional checks to determine the type of URL and the appropriate download method. However, the error message when the URL does not end with .tar or .safetensors is misleading because it doesn't account for data: URLs, which are handled separately. This could lead to confusion if a user provides a valid data: URL but receives an error indicating an invalid file extension.
2. weights.py:99
  • Draft comment:
    Using subprocess.run with URLs can be risky if the URL is not properly validated. Ensure that the URL is safe and expected before executing this command.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_safetensors_tarball function in weights.py uses subprocess.run to download files, which can be a security risk if the URL is not properly validated. Although the URL is generated by make_download_url, it's still good practice to ensure that the URL is safe and expected before executing a command with it.
3. weights.py:109
  • Draft comment:
    Consider logging the contents of the tarball if the number of .safetensors files is not exactly one. This can help with debugging if the tarball contents are unexpected.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_safetensors_tarball function in weights.py expects exactly one .safetensors file in the tarball. If there are multiple or none, it raises a ValueError. This is a good check, but it might be helpful to log the contents of the tarball for debugging purposes if the check fails.
4. weights.py:126
  • Draft comment:
    Consider logging the contents of the extracted data if the number of .safetensors files is not exactly one. This can help with debugging if the data contents are unexpected.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_data_url function in weights.py also expects exactly one .safetensors file in the extracted data. Similar to the download_safetensors_tarball function, it would be beneficial to log the contents of the extracted data for debugging if the check fails.
5. weights.py:134
  • Draft comment:
    Using subprocess.run with URLs can be risky if the URL is not properly validated. Ensure that the URL is safe and expected before executing this command.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_safetensors function in weights.py uses subprocess.run to download files, which can be a security risk if the URL is not properly validated. Although the URL is generated by make_download_url, it's still good practice to ensure that the URL is safe and expected before executing a command with it.
6. weights.py:140
  • Draft comment:
    Ensure that the regex patterns used here are comprehensive and account for all expected URL formats. Consider adding comments to explain each regex pattern for maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The make_download_url function in weights.py uses regular expressions to parse URLs. While this is generally fine, it's important to ensure that the regex patterns are comprehensive and account for all expected URL formats. Additionally, consider adding comments to explain each regex pattern for maintainability.

Workflow ID: wflow_Xd7fKaySsh0wTZ6O


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 0ce45b3 in 31 seconds

More details
  • Looked at 929 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 8 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Consider using Optional[str] from typing for compatibility with Python versions earlier than 3.10.
    main: Optional[str]
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is only supported in Python 3.10 and later. Since the CI is set up for Python 3.12, this is fine, but it's worth noting for compatibility with earlier versions.
2. predict.py:43
  • Draft comment:
    Consider using Optional[str] from typing for compatibility with Python versions earlier than 3.10.
    extra: Optional[str]
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is only supported in Python 3.10 and later. Since the CI is set up for Python 3.12, this is fine, but it's worth noting for compatibility with earlier versions.
3. predict.py:57
  • Draft comment:
    Define download_base_weights before using it in the setup method for better readability and to avoid potential issues.

  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_base_weights function is defined at the end of the file, but it's used here. It's better to define functions before they are used to improve code readability and avoid potential issues.

4. predict.py:65
  • Draft comment:
    Define download_base_weights before using it in the setup method for better readability and to avoid potential issues.

  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_base_weights function is defined at the end of the file, but it's used here. It's better to define functions before they are used to improve code readability and avoid potential issues.

5. predict.py:73
  • Draft comment:
    Define download_base_weights before using it in the setup method for better readability and to avoid potential issues.

  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_base_weights function is defined at the end of the file, but it's used here. It's better to define functions before they are used to improve code readability and avoid potential issues.

6. predict.py:316
  • Draft comment:
    Consider moving this function definition above its first usage in the setup method for better readability and to avoid potential issues.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_base_weights function is defined at the end of the file, but it's used here. It's better to define functions before they are used to improve code readability and avoid potential issues.
7. weights.py:45
  • Draft comment:
    Define download_weights before using it in the WeightsDownloadCache class for better readability and to avoid potential issues.

  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_weights function is used in the WeightsDownloadCache class but is defined later. It's better to define functions before they are used to improve code readability and avoid potential issues.

8. weights.py:112
  • Draft comment:
    Consider moving this function definition above its first usage in the WeightsDownloadCache class for better readability and to avoid potential issues.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_weights function is used in the WeightsDownloadCache class but is defined later. It's better to define functions before they are used to improve code readability and avoid potential issues.

Workflow ID: wflow_3aEGcNt543nftolA


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 58adcfd in 29 seconds

More details
  • Looked at 938 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. weights.py:72
  • Draft comment:
    Ensure consistency by using subprocess.run with check=True instead of subprocess.check_call in other parts of the codebase.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights function in weights.py uses subprocess.run with check=True, which is a better practice than subprocess.check_call. This should be consistent across the codebase.
2. weights.py:62
  • Draft comment:
    Remove or replace the debug print statement with proper logging.
        # print(f"{free=}")  # Debugging line, consider removing or using logging
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The print statement for debugging purposes should be removed or replaced with proper logging before merging to the main branch.
3. weights.py:55
  • Draft comment:
    Remove or replace the debug print statement with proper logging.
        # print("removing oldest", oldest)  # Debugging line, consider removing or using logging
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The print statement for debugging purposes should be removed or replaced with proper logging before merging to the main branch.

Workflow ID: wflow_pmNZr3IP1luOpX8S


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

start = time.time()
print("downloading url: ", url)
print("downloading to: ", dest)
subprocess.check_call(["pget", "-xf", url, dest], close_fds=False)
Copy link

Choose a reason for hiding this comment

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

Consider using subprocess.run with check=True instead of subprocess.check_call for better error handling and security.

Suggested change
subprocess.check_call(["pget", "-xf", url, dest], close_fds=False)
subprocess.run(["pget", "-xf", url, dest], check=True)

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 19e777d in 31 seconds

More details
  • Looked at 938 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. weights.py:55
  • Draft comment:
    Consider using the logging module instead of print for better control over logging levels and outputs.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of print for logging is not ideal for production code. It would be better to use a logging library for better control over log levels and outputs.
2. weights.py:62
  • Draft comment:
    Consider using the logging module instead of print for better control over logging levels and outputs.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of print for logging is not ideal for production code. It would be better to use a logging library for better control over log levels and outputs.
3. weights.py:80
  • Draft comment:
    Consider using the logging module instead of print for better control over logging levels and outputs.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of print for logging is not ideal for production code. It would be better to use a logging library for better control over log levels and outputs.
4. weights.py:92
  • Draft comment:
    Consider using the logging module instead of print for better control over logging levels and outputs.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of print for logging is not ideal for production code. It would be better to use a logging library for better control over log levels and outputs.
5. predict.py:201
  • Draft comment:
    Consider using the logging module instead of print for better control over logging levels and outputs.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of print for logging is not ideal for production code. It would be better to use a logging library for better control over log levels and outputs.
6. predict.py:204
  • Draft comment:
    Consider using the logging module instead of print for better control over logging levels and outputs.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of print for logging is not ideal for production code. It would be better to use a logging library for better control over log levels and outputs.

Workflow ID: wflow_rETcXfXjLVlo5pks


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 96c4dba in 31 seconds

More details
  • Looked at 941 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Using '|' for type hinting requires Python 3.10+. Ensure compatibility if using older Python versions.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is not compatible with Python versions below 3.10. Since the setup specifies Python 3.12, this is not an issue, but it's worth noting for compatibility.
2. predict.py:57
  • Draft comment:
    Consider using download_weights from weights.py for consistency, unless download_base_weights is intentionally different.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_weights function is defined in weights.py but is not used in predict.py. Instead, download_base_weights is used. This might be intentional, but it's worth noting.
3. weights.py:72
  • Draft comment:
    The download_weights function is defined but not used. Consider removing it if it's not needed.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_weights function in weights.py is not used in the current code. It might be intended for future use or was replaced by download_base_weights.
4. weights.py:62
  • Draft comment:
    Remove debug print statement to clean up the code.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The debug print statement should be removed to clean up the code.
5. unit-tests/test_weights.py:112
  • Draft comment:
    The download_weights function is patched but not used in the tests. Consider removing the patch if it's not needed.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_weights function is defined but not used in the tests. It might be intended for future use or was replaced by another function.

Workflow ID: wflow_F53r4r0La1hqpG8z


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 0e1b3f4 in 24 seconds

More details
  • Looked at 939 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. weights.py:62
  • Draft comment:
    Remove the debug print statement or replace it with proper logging.
        # print(f"{free=}")  # Debugging line, consider removing or using logging
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The current implementation of the download_weights_url function in weights.py uses a print statement for debugging purposes. This should be removed or replaced with proper logging to maintain clean code and avoid unnecessary console output in production.
2. weights.py:90
  • Draft comment:
    Consider handling URLs that start with data: as they are valid in this context.
        raise ValueError("URL must end with either .tar, .safetensors, or start with data:")
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights_url function in weights.py raises a ValueError if the URL does not end with .tar or .safetensors. However, it should also handle URLs that start with data: as they are valid in this context.
3. predict.py:287
  • Draft comment:
    Clarify or remove the comment questioning if both LoRAs always need to be loaded.
        # Ensure both LoRAs are loaded
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The load_multiple_loras function in predict.py has a comment questioning if both LoRAs always need to be loaded. This should be clarified or removed if not necessary.
4. weights.py:73
  • Draft comment:
    Consider directly calling download_weights_url with the correct URL format to reduce unnecessary function calls.
    download_weights_url(make_download_url(url), path)
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights function in weights.py calls make_download_url and then download_weights_url. It would be more efficient to directly call download_weights_url with the correct URL format, reducing unnecessary function calls.

Workflow ID: wflow_5eXchGtBsnhRfKCb


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on bbb70ef in 21 seconds

More details
  • Looked at 939 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Consider using Optional[str] from the typing module instead of str | None for compatibility with Python versions below 3.10.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is not compatible with Python versions below 3.10. Since the CI is set up for Python 3.12, this is not an immediate issue, but it's worth noting for compatibility with older versions.
2. weights.py:45
  • Draft comment:
    Ensure that the download_weights function is defined or imported in this file, as it is used in the WeightsDownloadCache class.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is unnecessary because the download_weights function is already defined in the file. The comment does not point out a code change requirement, as the function is present and correctly used. The comment violates the rule against asking the author to confirm or ensure something that is already evident in the code.
    I might be overlooking the possibility that the comment is suggesting a different kind of issue, but the context strongly indicates it's about the presence of the function, which is already addressed.
    The function is clearly defined in the file, so the comment is redundant. There is no indication of any other issue related to download_weights.
    The comment should be removed because it incorrectly suggests a missing function definition that is already present in the file.
3. weights.py:62
  • Draft comment:
    Remove or replace the debug print statement with a proper logging mechanism.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The print statement for debugging should be removed or replaced with a proper logging mechanism before merging the code.

Workflow ID: wflow_2U2r1cM62K2UpH8k


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on a890040 in 31 seconds

More details
  • Looked at 978 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Using '|' for type hinting is only supported in Python 3.10 and later. Ensure compatibility if earlier Python versions are needed.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of '|' for type hinting is only supported in Python 3.10 and later. Since the CI is set up for Python 3.12, this is fine, but it's worth noting for compatibility with earlier versions.
2. predict.py:57
  • Draft comment:
    download_base_weights is used but not defined or imported. Ensure it's correctly imported or defined.
  • Reason this comment was not posted:
    Marked as duplicate.
3. predict.py:65
  • Draft comment:
    download_base_weights is used but not defined or imported before this line. Ensure it's correctly imported or defined earlier.
  • Reason this comment was not posted:
    Marked as duplicate.
4. predict.py:73
  • Draft comment:
    download_base_weights is used but not defined or imported before this line. Ensure it's correctly imported or defined earlier.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_6foEYhNhjwZ3K3Ya


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

predict.py Show resolved Hide resolved
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 4726442 in 24 seconds

More details
  • Looked at 997 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. predict.py:320
  • Draft comment:
    Using close_fds=False in subprocess.check_call is not recommended. Consider removing it to prevent potential file descriptor leaks.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of subprocess.check_call with close_fds=False is not recommended as it can lead to file descriptor leaks. It's better to use the default behavior which is close_fds=True.
2. weights.py:116
  • Draft comment:
    Consider using subprocess.run with check=True instead of subprocess.check_call for consistency and better error handling.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights function in weights.py uses subprocess.run with check=True, which is a better practice than subprocess.check_call. The download_base_weights function in predict.py should be updated to use subprocess.run for consistency and better error handling.
3. weights.py:78
  • Draft comment:
    The conversion of path to Path is redundant since path is already a Path object. Consider removing this line.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights_url function in weights.py has a redundant conversion of path to Path object since it's already a Path object. This conversion can be removed.
4. weights.py:62
  • Draft comment:
    Remove or replace the debug print statement with proper logging before merging.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The print statement for debugging purposes should be removed or replaced with proper logging before merging the code.

Workflow ID: wflow_7KSyEzPYJSpOYrzM


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 26467de in 30 seconds

More details
  • Looked at 966 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Using '|' for type hinting is only supported in Python 3.10 and above. Ensure compatibility if using older Python versions.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is not compatible with Python versions below 3.10. Since the setup specifies Python 3.12, this is not an issue for this project, but it's worth noting for compatibility with older versions.
2. weights.py:45
  • Draft comment:
    download_weights is not defined. Did you mean download_base_weights?
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is incorrect because download_weights is indeed defined in the code. The suggestion to use download_base_weights is not applicable as there is no such function in the code. The comment should be removed as it does not point out a real issue.
    I might be missing some context about the intended functionality of the code, but based on the provided diff, the comment is clearly incorrect.
    The code clearly defines download_weights, so the comment is not valid in this context.
    The comment is incorrect and should be removed because download_weights is defined in the code.
3. weights.py:62
  • Draft comment:
    Remove debug print statement or replace with proper logging.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The debug print statement should be removed or replaced with proper logging before merging into the main branch.
4. unit-tests/test_weights.py:149
  • Draft comment:
    download_weights is not defined. Did you mean download_base_weights?
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_Ic8AitP0FK3VSzCR


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 1e40d30 in 24 seconds

More details
  • Looked at 966 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Using '|' for type hinting requires Python 3.10 or later. Ensure compatibility if using older Python versions.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is not compatible with Python versions below 3.10. Since the setup specifies Python 3.12, this is not an issue, but it's good to be aware of compatibility.
2. weights.py:62
  • Draft comment:
    Remove or replace the debug print statement for free disk space with proper logging if needed.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The print statement for free disk space is marked as a TODO, indicating it might be left unintentionally. It should be removed or replaced with proper logging if needed.
3. weights.py:94
  • Draft comment:
    Ensure all expected URL formats are handled in download_weights_url to prevent unexpected errors.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The function download_weights_url has a check for URL endings but does not handle all possible cases, which might lead to unexpected errors if a new URL format is introduced.

Workflow ID: wflow_iKMnnIjBJZAzxPiW


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on cf142a4 in 34 seconds

More details
  • Looked at 966 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 7 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Consider using Optional[str] from typing for compatibility with Python versions earlier than 3.10.
    main: Optional[str]
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is only supported in Python 3.10 and later. Since the CI is set up for Python 3.12, this is fine, but it's worth noting for compatibility with earlier versions.
2. predict.py:43
  • Draft comment:
    Consider using Optional[str] from typing for compatibility with Python versions earlier than 3.10.
    extra: Optional[str]
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is only supported in Python 3.10 and later. Since the CI is set up for Python 3.12, this is fine, but it's worth noting for compatibility with earlier versions.
3. predict.py:57
  • Draft comment:
    Consider moving the download_base_weights function definition above its first usage for better readability.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_base_weights function is defined at the end of the file, but it's used here. It's better to define functions before they are used to improve code readability.
4. predict.py:65
  • Draft comment:
    Consider moving the download_base_weights function definition above its first usage for better readability.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_base_weights function is defined at the end of the file, but it's used here. It's better to define functions before they are used to improve code readability.
5. predict.py:73
  • Draft comment:
    Consider moving the download_base_weights function definition above its first usage for better readability.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_base_weights function is defined at the end of the file, but it's used here. It's better to define functions before they are used to improve code readability.
6. predict.py:316
  • Draft comment:
    Consider moving this function definition above its first usage for better readability.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_base_weights function is defined at the end of the file, but it's used here. It's better to define functions before they are used to improve code readability.
7. weights.py:73
  • Draft comment:
    The make_download_url function is well-tested in test_weights.py, ensuring robustness in URL parsing and handling.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The download_weights function in weights.py uses make_download_url to determine the download URL. This function is well-tested in test_weights.py, ensuring robustness.

Workflow ID: wflow_TpsiuR4r9uCPDf0a


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 9f073e6 in 27 seconds

More details
  • Looked at 966 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Using '|' for type hinting requires Python 3.10 or newer. Ensure compatibility if using older Python versions.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is not compatible with Python versions below 3.10. Since the setup specifies Python 3.12, this is not an issue for this project, but it's worth noting for compatibility with older versions.
2. weights.py:45
  • Draft comment:
    download_weights is not defined. Use download_base_weights or the correct function name.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is incorrect because download_weights is defined in the code. The suggestion to use download_base_weights or another function name is not supported by the code, as there is no such function defined or needed. The comment does not point out a real issue in the code.
    I might be missing some context outside of the provided code, such as a larger codebase where download_weights might have been renamed. However, based on the provided diff, the comment is incorrect.
    The diff provided is self-contained, and the function download_weights is clearly defined. Therefore, the comment is not applicable to this diff.
    The comment is incorrect because download_weights is defined in the code. It should be removed as it does not point out a real issue.
3. weights.py:62
  • Draft comment:
    Remove debug print statement or replace with logging.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The debug print statement should be removed or replaced with proper logging before production deployment.
4. unit-tests/test_weights.py:133
  • Draft comment:
    download_weights is not defined. Use download_base_weights or the correct function name.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_Xh8yrANluYjnmpWZ


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on f358b44 in 23 seconds

More details
  • Looked at 966 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Consider using Optional[str] from the typing module instead of str | None for compatibility with Python versions below 3.10.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is not compatible with Python versions below 3.10. Since the CI is set up for Python 3.12, this is not an immediate issue, but it's worth noting for compatibility with older versions.
2. predict.py:57
  • Draft comment:
    The function download_base_weights is used here but defined later in the file. Consider moving the function definition above its first usage for better readability.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_base_weights function is defined at the end of the file but is used earlier in the setup method. This can lead to confusion if the function is not found immediately when reading the code.
3. weights.py:62
  • Draft comment:
    Remove or replace the debug print statement with proper logging before deploying to production.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The print statement for debugging disk space should be removed or replaced with proper logging before production deployment.
4. weights.py:94
  • Draft comment:
    Ensure that the URL validation in download_weights_url covers all expected cases to prevent unexpected errors.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The download_weights_url function has a check for URL endings but does not handle all possible cases, which might lead to unexpected errors.

Workflow ID: wflow_WPK5xlABHyXVdt7x


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 3c22799 in 35 seconds

More details
  • Looked at 974 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. predict.py:42
  • Draft comment:
    Consider using Optional[str] from typing for type hinting instead of str | None for compatibility with Python versions below 3.10.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The use of '|' for type hinting is not compatible with Python versions below 3.10. Since the setup specifies Python 3.12, this is not an issue for this project, but it's worth noting for compatibility with older versions.
2. weights.py:72
  • Draft comment:
    Consider adding exception handling to download_weights to manage potential download failures gracefully.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_weights function in weights.py is not handling exceptions that might occur during the download process. This could lead to unhandled exceptions if the download fails.
3. weights.py:62
  • Draft comment:
    Remove the debug print statement or replace it with proper logging.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The download_weights_url function in weights.py has a debug print statement that should be removed or replaced with proper logging.
4. weights.py:94
  • Draft comment:
    Consider providing a more descriptive error message when raising ValueError for unsupported URL formats.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The download_weights_url function in weights.py raises a ValueError if the URL does not end with .tar or .safetensors. This is a good check, but the error message could be more descriptive.
5. weights.py:127
  • Draft comment:
    Consider using os.rename instead of shutil.move if the source and destination are on the same filesystem for better performance.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The download_safetensors_tarball function in weights.py uses shutil.move to move the safetensors file. This is fine, but it might be better to use os.rename if the source and destination are on the same filesystem for better performance.
6. weights.py:148
  • Draft comment:
    Consider adding exception handling to download_safetensors to manage potential download failures gracefully.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The download_safetensors function in weights.py does not handle exceptions that might occur during the download process. This could lead to unhandled exceptions if the download fails.

Workflow ID: wflow_PfRj7IdPwrI4M7TJ


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

6 days left in your free trial, upgrade for $20/seat/month or contact us.

@andreasjansson andreasjansson merged commit 4da7238 into main Aug 23, 2024
2 checks passed
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.

1 participant