Skip to content

Fix case sensitive check to be case insensitive - #192

Merged
lstein merged 2 commits into
invoke-ai:mainfrom
david-ford:working-branch
Aug 29, 2022
Merged

lstein merged 2 commits into
invoke-ai:mainfrom
david-ford:working-branch

Conversation

@david-ford

Copy link
Copy Markdown
Contributor

Case sensitivity between os.getcwd and os.realpath can fail due to different drive letter casing. C:\ vs c:. This change addresses that by normalizing the strings before comparing. Otherwise this will throw a 404 for files like index.js

Includes a .gitattributes file to auto normalize text files (ignores images and such) so that line endings get normalized on commit but local line endings for devs remain unchanged. Git will handle the translation to and from on commit.

Some minor changes to the HTML for the web version to include tags expected by browsers and some accessibility.

Case sensitivity between os.getcwd and os.realpath can fail due to different drive letter casing. C:\ vs c:\. This change addresses that by normalizing the strings before comparing.

@lstein lstein left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks fine. I didn't spot any issues.

@lstein
lstein requested review from TesseractCat and bakkot August 29, 2022 18:35
@lstein

lstein commented Aug 29, 2022

Copy link
Copy Markdown
Collaborator

Includes a .gitattributes file to auto normalize text files (ignores images and such) so that line endings get normalized on commit but local line endings for devs remain unchanged. Git will handle the translation to and from on commit.

Will this automagically fix pull requests that use CRLF rather than Unix LF? That would be amazing!

Comment thread ldm/dream/server.py Outdated
Comment on lines +20 to +21
cwd = os.getcwd().lower()
is_in_cwd = os.path.commonprefix((os.path.realpath(path).lower(), cwd)) == cwd

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@david-ford Can you check if the following works instead?

Suggested change
cwd = os.getcwd().lower()
is_in_cwd = os.path.commonprefix((os.path.realpath(path).lower(), cwd)) == cwd
cwd = os.path.realpath(os.getcwd())
is_in_cwd = os.path.commonprefix((os.path.realpath(path), cwd)) == cwd

If that works, it would be better, since then the check is still correct on case-sensitive filesystems.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, this looks better because on Linux we could have ./static and ./Static side-by-side and they shouldn't both pass the test. Is there a specific test case for case-sensitive filesystems that I can check?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I couldn't repro the issue personally, but a user tested my suggestion in #196 (comment) and reports that it worked, so it should be ok. Do you want to just add that in while merging this PR? Alternatively I could open a new one with just that change.

@david-ford david-ford Aug 29, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this looks better because on Linux we could have ./static and ./Static side-by-side and they shouldn't both pass the test. Is there a specific test case for case-sensitive filesystems that I can check?

I'm using Windows 10, with my environment setup following the instructions in the readme using Anaconda. When I do os.getcwd() I get c:\path\to\project and when I do os.realpath I get C:\path\to\project.

I believe the suggestion here will work, but my PC is currently training so it will be another hour~ before I can get this updated. Strangely, the original dataset has no idea what a scythe is.

As mentioned below, I'll pull the unrelated changes from this PR, and then commit them in separate PRs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I couldn't repro the issue personally, but a user tested my suggestion in #196 (comment) and reports that it worked, so it should be ok. Do you want to just add that in while merging this PR? Alternatively I could open a new one with just that change.

I made those changes and got the PR updated for ya. I can confirm your suggestion worked, and it's so much cleaner than the way I was trying to do it.

@TesseractCat TesseractCat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change to placeholder values should probably be in a different PR. Also I don't think we should be lowercasing the path, maybe calling realpath will fix issues.

@david-ford

Copy link
Copy Markdown
Contributor Author

Includes a .gitattributes file to auto normalize text files (ignores images and such) so that line endings get normalized on commit but local line endings for devs remain unchanged. Git will handle the translation to and from on commit.

Will this automagically fix pull requests that use CRLF rather than Unix LF? That would be amazing!

That would indeed be the intention. It won't fix old items, but I went ahead and already ran the command to update them based on the config in this pr. There weren't any because you've been diligent.

What it will do is if your local machine uses CRLF and the repo uses LF, it will convert line endings automagically on commit to LF, and when doing a pull, it will convert them back to CRLF for the local user.

As for the other changes, I will break this into three branch/commits. One for the CRLF <> LF, one for the suggested fix for the case insensitive match, and one for the HTML changes -- minus the placeholder for now.

Removed the changes to the index.html and .gitattributes for this PR. Will add them in separate PRs.

Applied recommended change for resolving the case issue.
@lstein
lstein merged commit 81ad239 into invoke-ai:main Aug 29, 2022
@david-ford
david-ford deleted the working-branch branch August 29, 2022 21:59
austinbrown34 pushed a commit to cognidesign/InvokeAI that referenced this pull request Dec 30, 2022
Fix case sensitive check to be case insensitive
JPPhoto pushed a commit to JPPhoto/InvokeAI that referenced this pull request Aug 31, 2026
…locator-credit

fix(model cache): credit the allocator's reclaimable reserve in the VRAM budget
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.

4 participants