Skip to content

Fix path normalization on Windows#375

Open
Richienb wants to merge 2 commits intoallenai:mainfrom
Richienb:patch-1
Open

Fix path normalization on Windows#375
Richienb wants to merge 2 commits intoallenai:mainfrom
Richienb:patch-1

Conversation

@Richienb
Copy link
Copy Markdown

@Richienb Richienb commented Oct 5, 2023

os.path.abspath uses forward slashes on posix and back slashes on Windows.
This is a problem because the next line of code splits the string by (only) forward slashes.
Instead, we can use posixpath.normpath which always uses forward slashes.

@Richienb Richienb changed the title Fix normalization on Windows Fix path normalization on Windows Oct 5, 2023
Copy link
Copy Markdown
Contributor

@Lucaweihs Lucaweihs left a comment

Choose a reason for hiding this comment

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

Hi @Richienb, in principle I am happy to make a change like this, though I think we'd need to do something like:

rel_base_dir = posixpath.normpath(os.path.relpath(os.path.abspath(args.experiment_base), os.getcwd()))

to retain the same behavior of ensuring the path is relative the current working directory. Before making this change though: this change suggests that you're trying to get allenact working with Windows. Have you successfully done so? This isn't a use case we officially support (as most development is done on Mac/Linux) but I'd be interested in hearing otherwise.

@Richienb
Copy link
Copy Markdown
Author

I have not yet succeeding in running allenact on Windows, this pr contains a change I made which fixes an error that was thrown, though there are likely more.

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.

2 participants