Skip to content

Conversation

@marcfranquesa
Copy link

@marcfranquesa marcfranquesa commented Oct 30, 2025

Solves the following error raised when writing an h5ad file if a parent directory does not exist:

FileNotFoundError: [Errno 2] Unable to synchronously create file (unable to open file: name = 'dir1/dir2/adata.h5ad', errno = 2, error message = 'No such file or directory', flags = 13, o_flags = 242)

It is specifically raised by the following line

with h5py.File(filepath, mode) as f:

I am not sure if this is the general desired behavior, if not, I would happily modify the implementation (e.g. adding a new function argument to write_h5ad).

I believe it makes more sense to create the directories by default. Let me know otherwise. I will happily add a test if this behavior is desired.

@ilan-gold
Copy link
Contributor

Hmm @marcfranquesa I generally hesitate to introduce more "magic" file behavior. What happens if the writing of the h5ad file fails? Then you have a magically created directory. I wonder if this somehow could break something else unexpectedly. I don't see any reason mdkir -p would not be threadsafe, but that was just a first glance. So that isn't an issue.

I believe it makes more sense to create the directories by default.

What's the use-case here? Just convenience?

@marcfranquesa
Copy link
Author

Hi Ilan, thank you for the reply and explanation.

What's the use-case here? Just convenience?

Yes.

The PR can be closed.

@ilan-gold
Copy link
Contributor

@flying-sheep any thoughts?

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