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

Fix Windows-specific bugs #341

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

JostMigenda
Copy link
Member

This should eventually fix #340.

`os.path.join` uses an OS-dependent separator (i.e. backslash on Windows, which leads to invalid URLs); let’s hardcode a forward slash here.
Later, ModelRegistry.get_file() turns this string into a Path in https://github.com/SNEWS2/snewpy/blob/50ba643f3e5779b11de06d6904748a9a2557e2ce/python/snewpy/_model_downloader.py#L194 so the OS-specific separator is then used for the local file.
@JostMigenda
Copy link
Member Author

The first commit (50ba643) adds test for Windows[*] without any fixes to the code; to confirm that the tests fail in CI and reproduce the issue observed by our project student.

The second commit (22b66ce) adds a fix for the Warren_2020 model download, as described in #340. This fixes the Warren_2020 test failures, as expected.

Now the only remaining test failure is in test_flux_container.py:115 (test_save_and_load), which has a hard-coded file path that doesn’t appear to work under Windows:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/flux.npz'
I’ll check if there’s an easy fix for this.

[*] and MacOS, for good measure; though that is a UNIX and shouldn’t have as many peculiarities

@JostMigenda JostMigenda marked this pull request as ready for review June 4, 2024 16:52
@JostMigenda
Copy link
Member Author

… and commit 4bb76d5 replaces the hardcoded path by using the tempfile module; so it now works on Windows. This is now ready for review.

@JostMigenda
Copy link
Member Author

Hm … one remaining issue in the integration tests: The command jupyter execute ccsn/*.ipynb fails on Windows (see lines 136–156 of the log) (and same for presn), but the return code is still successful.

I see a few options:

  1. Figure out how to implement that wildcard correctly in a Windows shell
  2. Skip that step on Windows
  3. Ignore; the other Jupyter notebooks in the step are running successfully, so this is still a useful test

Option 1 would be the right thing to do; but since I don’t have access to a Windows machine, that doesn’t sound like a rabbit hole I particularly want to go down … 🫣

PowerShell is not expanding wildcard characters, but requires separate command for that
via https://stackoverflow.com/questions/43897242/powershell-wildcards-in-passing-filenames-as-arguments
@JostMigenda JostMigenda force-pushed the JostMigenda/fixWarrenPathsOnWindows branch from 2871549 to c713c78 Compare June 6, 2024 17:13
@JostMigenda
Copy link
Member Author

After some experimentation, it turns out that PowerShell apparently does not expand wildcard characters (which is not obvious from the documentation 🤬). Commit c713c78 adds the additional code required for this. With that, afaict the test on Windows are equivalent to those on Linux/MacOS and this PR is ready for review.

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.

Warren_2020 downloads fail on Windows
1 participant