Skip to content

optimize_gguf.py: add alternative ollama model dir#1

Open
DronNick wants to merge 1 commit into
OJamals:mainfrom
DronNick:fix-optimize-gguf
Open

optimize_gguf.py: add alternative ollama model dir#1
DronNick wants to merge 1 commit into
OJamals:mainfrom
DronNick:fix-optimize-gguf

Conversation

@DronNick
Copy link
Copy Markdown

@DronNick DronNick commented Aug 2, 2025

On hosts with ollama running as service the model directory is not in users home, but in ollama service home.

Summary by Sourcery

Enhancements:

  • Add fallback to system-wide Ollama models directory (/usr/share/ollama/.ollama/models) when the user's home directory is missing or empty

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Aug 2, 2025

Reviewer's Guide

Enhanced GGUFOptimizer to detect and choose between user and system 'ollama' model directories at initialization

Class diagram for updated GGUFOptimizer initialization

classDiagram
    class GGUFOptimizer {
        +Path ollama_models_dir
        +Path blobs_dir
        +Path manifests_dir
        GGUFOptimizer()
    }
    GGUFOptimizer : ollama_models_dir is set to user or system model dir based on existence
    GGUFOptimizer : blobs_dir = ollama_models_dir / "blobs"
    GGUFOptimizer : manifests_dir = ollama_models_dir / "manifests"
Loading

File-Level Changes

Change Details Files
Improve ollama_models_dir initialization to support a fallback directory
  • Introduce home_models_dir as Path.home() / '.ollama' / 'models'
  • Check if home_models_dir exists and contains files
  • Assign ollama_models_dir to home_models_dir or fallback to system '/usr/share/ollama/.ollama/models'
optimize_gguf.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @DronNick - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `optimize_gguf.py:29` </location>
<code_context>
+        if home_models_dir.is_dir() and any(home_models_dir.iterdir()):
+            self.ollama_models_dir = home_models_dir
+        else:
+            self.ollama_models_dir = Path("/usr/share/ollama") / ".ollama" / "models"
         self.blobs_dir = self.ollama_models_dir / "blobs"
         self.manifests_dir = self.ollama_models_dir / "manifests"
</code_context>

<issue_to_address>
Hardcoding the fallback path may reduce portability.

Consider making the fallback path configurable or verifying its existence before assignment to improve portability across different systems.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread optimize_gguf.py
if home_models_dir.is_dir() and any(home_models_dir.iterdir()):
self.ollama_models_dir = home_models_dir
else:
self.ollama_models_dir = Path("/usr/share/ollama") / ".ollama" / "models"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Hardcoding the fallback path may reduce portability.

Consider making the fallback path configurable or verifying its existence before assignment to improve portability across different systems.

@DronNick DronNick changed the title optimize_gguf.py: add laternative ollama model dir optimize_gguf.py: add alternative ollama model dir Aug 17, 2025
@DronNick
Copy link
Copy Markdown
Author

Hi @OJamals , I just wanted to kindly check in on my pull request (cameroncooke/reloaderoo#1). Please let me know if any changes are needed. Thanks!

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