Skip to content

Fix Windows path compatibility for data loading#106

Open
fbattini wants to merge 1 commit intoopenclimatefix:mainfrom
fbattini:fix/windows-path-compatibility
Open

Fix Windows path compatibility for data loading#106
fbattini wants to merge 1 commit intoopenclimatefix:mainfrom
fbattini:fix/windows-path-compatibility

Conversation

@fbattini
Copy link

Problem

The metoffice load command failed on Windows with two issues:

  1. Incorrect path structure: The archive path was missing year/month/day subdirectories, causing 404 errors when downloading from HuggingFace.

    • Expected: data/2023/12/01/2023-12-01-00.zarr.zip
    • Actual: data/2023-12-01-00.zarr.zip
  2. Windows path separators: On Windows, Path objects use backslashes (\) which broke HuggingFace URLs when converted to strings.

    • Expected: data/2023/12/01/...
    • Actual: data\2023\12\01\...

Changes

  • main.py: Added year/month/day subdirectories to archive_path (line 115)
  • data_downloader.py: Convert backslashes to forward slashes in download_from_hf()

How Has This Been Tested?

  • Tested metoffice load command on Windows 11

  • Successfully downloads and loads Met Office UK data from HuggingFace

  • All 53 existing tests pass (pytest)

  • Yes

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

  ---                                                                                                                                                                                                                                      ## Problem

  The `metoffice load` command failed on Windows with two issues:

  1. Incorrect path structure: The archive path was missing year/month/day
     subdirectories, causing 404 errors when downloading from HuggingFace.
     - Expected: `data/2023/12/01/2023-12-01-00.zarr.zip`
     - Actual: `data/2023-12-01-00.zarr.zip`

  2. Windows path separators: On Windows, `Path` objects use backslashes (`\`)
     which broke HuggingFace URLs when converted to strings.
     - Expected: `data/2023/12/01/...`
     - Actual: `data\2023\12\01\...`

  ## Changes

  - `main.py`: Added year/month/day subdirectories to archive_path (line 115)
  - `data_downloader.py`: Convert backslashes to forward slashes in download_from_hf()

  ## Testing

  - Tested on Windows 11
  - Successfully downloads and loads Met Office UK data
  - All 53 existing tests pass

  ---
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.

1 participant