Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

MeteoGridCopy dump fails when initialized with pathlib.Path

Open Beginner friendly
#1,922 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
data

Research direction

Start with MeteoGridCopy initialization through MetaSwapModel.from_file(), then follow dump() to the dataset.to_netcdf() call. Reproduce the failure with a pathlib.Path and verify that dumping succeeds with the path serialized as a string.

Written by the indexing model from the issue text.

Description

bug

MeteoGridCopy is initialsed with pathlib.Path object when using MetaSwapModel.from_file(). During dump(), the package is serialized using dataset.to_netcdf(). Xarray cannot serialize pathlib.Path objects and raises the exception 'ValueError: unable to infer dtype on variable 'path'; xarray cannot serialize arbitrary Python objects'.

Proposed fix:

force to string via self.dataset["path"] = str(path)

This worked for me

Dominant language
Python
Stars
41
Forks
11
Avg merge
1d 15h
Merged PRs (30d)
5

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Deltares/imod-python

All issues in Deltares/imod-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.