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

Use absolute paths in model manager #5900

Merged
merged 6 commits into from
Mar 8, 2024

Conversation

brandonrising
Copy link
Collaborator

@brandonrising brandonrising commented Mar 8, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Community Node Submission

Have you discussed this change with the InvokeAI team?

  • Yes
  • No, because:

Have you updated all relevant documentation?

  • Yes
  • No

Description

Removes relative paths for models within model manager. This should make it less likely that paths managed in the backend point to non-existant files/dirs. This also removes the logic that has to guess whether or not the path is relative or absolute.

Merge Plan

This PR can be merged when approved

Added/updated tests?

  • Yes
  • No : please replace this line with details on why tests
    have not been included

@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files services PRs that change app services python-tests PRs that change python tests labels Mar 8, 2024
@brandonrising brandonrising force-pushed the use-absolute-paths-in-model-manager branch from eb337a2 to 177677f Compare March 8, 2024 17:23
@brandonrising brandonrising force-pushed the use-absolute-paths-in-model-manager branch 2 times, most recently from 2af1fa2 to d498366 Compare March 8, 2024 18:13
@brandonrising brandonrising force-pushed the use-absolute-paths-in-model-manager branch from d498366 to 3ead2f8 Compare March 8, 2024 19:06
Copy link
Collaborator

@lstein lstein left a comment

Choose a reason for hiding this comment

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

This is fine. The original idea of using relative paths was to make it easier to move the root directory around, but in fact the .venv contained within the root can't be moved without breaking stuff, so it is moot.

@brandonrising brandonrising force-pushed the use-absolute-paths-in-model-manager branch from 3ead2f8 to ebaee02 Compare March 8, 2024 19:46
@brandonrising brandonrising merged commit 8ba4b2a into main Mar 8, 2024
14 checks passed
@brandonrising brandonrising deleted the use-absolute-paths-in-model-manager branch March 8, 2024 20:36
psychedelicious added a commit that referenced this pull request Mar 29, 2024
We switched all model paths to be absolute in #5900. In hindsight, this is a mistake, because it makes the `models_dir` non-portable.

This change reverts to the previous model pathing:
- Invoke-managed models (in the `models_dir`) are stored with relative paths
- Non-invoke-managed models (outside the `models_dir`, i.e. in-place installed models) still have absolute paths.

## Why absolute paths make things non-portable

Let's say my `models_dir` is `/media/rhino/invokeai/models/`. In the DB, all model paths will be absolute children of this path, like this:

- `/media/rhino/invokeai/models/sd-1/main/model1.ckpt`

I want to change my `models_dir` to `/home/bat/invokeai/models/`. I update my `invokeai.yaml` file and physically move the files to that directory.

On startup, the app checks for missing models. Because all of my model paths were absolute, they now point to a nonexistent path. All models are broken.

There are a couple options to recover from this situation, neither of which are reasonable:

1. The user must manually update every model's path. Unacceptable UX.
2. On startup, we check for missing models. For each missing model, we compare its path with the last-known models dir. If there is a match, we replace that portion of the path with the new models dir. Then we re-check to see if the path exists. If it does, we update the models DB entry. Brittle and requires a new DB entry for last-known models dir.

It's better to use relative paths for Invoke-managed models.
hipsterusername pushed a commit that referenced this pull request Mar 29, 2024
We switched all model paths to be absolute in #5900. In hindsight, this is a mistake, because it makes the `models_dir` non-portable.

This change reverts to the previous model pathing:
- Invoke-managed models (in the `models_dir`) are stored with relative paths
- Non-invoke-managed models (outside the `models_dir`, i.e. in-place installed models) still have absolute paths.

## Why absolute paths make things non-portable

Let's say my `models_dir` is `/media/rhino/invokeai/models/`. In the DB, all model paths will be absolute children of this path, like this:

- `/media/rhino/invokeai/models/sd-1/main/model1.ckpt`

I want to change my `models_dir` to `/home/bat/invokeai/models/`. I update my `invokeai.yaml` file and physically move the files to that directory.

On startup, the app checks for missing models. Because all of my model paths were absolute, they now point to a nonexistent path. All models are broken.

There are a couple options to recover from this situation, neither of which are reasonable:

1. The user must manually update every model's path. Unacceptable UX.
2. On startup, we check for missing models. For each missing model, we compare its path with the last-known models dir. If there is a match, we replace that portion of the path with the new models dir. Then we re-check to see if the path exists. If it does, we update the models DB entry. Brittle and requires a new DB entry for last-known models dir.

It's better to use relative paths for Invoke-managed models.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend PRs that change backend files python PRs that change python files python-tests PRs that change python tests services PRs that change app services
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants