Deltares / Deltares/imod-python

No file lock on imod.idf.open

Open
#308 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
41
Forks
12
Avg merge
21h 8m
Merged PRs (30d)
1

Description

In GitLab by @Huite on Jan 18, 2023, 15:53

This goes rather wrong:

for _ in range(3):
    da = imod.idf.open(path)
    new = da.isel(y=slice(1,-1))
    imod.idf.save(path, new)

I.e. the save path is the same as the open path. It will also give weird errors: the dask graph expects to find a certain file at path, but finds one with a reduced number of rows.

Ideally, we could throw a PermissionError in this case when trying to save there, but not when it has been .computed or .loaded. I'm not sure how difficult that is to implement.

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start at the imod.idf.open and imod.idf.save entry points and trace how the dask graph retains the input path. Reproduce the loop shown in the issue, then compare saving before and after the data is computed or loaded. Done means saving to the same path raises PermissionError only while the opened data still depends on that file.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.