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

Switch ModelSearch from os.walk to os.scandir #5781

Merged
merged 5 commits into from
Feb 29, 2024

Conversation

brandonrising
Copy link
Collaborator

@brandonrising brandonrising commented Feb 23, 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

Drastically speeds up initial invokeai startup time and subsequent model scans

Related Tickets & Documents

  • Related Issue #
  • Closes #

QA Instructions, Screenshots, Recordings

Merge Plan

Added/updated tests?

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

[optional] Are there any post deployment tasks we need to perform?

@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files labels Feb 23, 2024
@brandonrising brandonrising marked this pull request as ready for review February 23, 2024 19:53
@github-actions github-actions bot added the api label Feb 23, 2024
@psychedelicious
Copy link
Collaborator

This needs cross platform testing. Scandir uses different system APIs for each platform than walk.

Also we should probably manually test the outputs from each method to ensure the behaviour isn't changed.

@blessedcoolant
Copy link
Collaborator

blessedcoolant commented Feb 23, 2024

This needs cross platform testing. Scandir uses different system APIs for each platform than walk.

Also we should probably manually test the outputs from each method to ensure the behaviour isn't changed.

The only change I think we need to make here is to pass the as_posix value to scandir rather than the Path object because that is where the cross platform issues might pop up. Afaik, scandir itself works well cross platform as long as the supplied path is a string that is absolute.

@brandonrising brandonrising merged commit cb8e0cb into next Feb 29, 2024
6 of 8 checks passed
@brandonrising brandonrising deleted the next-speed-up-modelsearch branch February 29, 2024 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api backend PRs that change backend files python PRs that change python files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants