Make more operations in AsyncLocalFileSystem actually async

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

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by reading AsyncLocalFileSystem and the async file methods named in the issue: _write_text, _write_bytes, _read_text, _read_bytes, _put_file, and _pipe_file; compare them with AsyncFileSystem.open_async and the synchronous defaults in AbstractFileSystem. The issue leaves the design open: decide whether these should use open_async directly or be added as base defaults. Done means the applicable operations use async file I/O and have tests covering their behavior.

Written by the indexing model from the issue text.

Description

Thanks for providing this library. I use fsspec in a few projects (mostly via universal-pathlib) which are async and it's great to have an async option for local usage in order to have a consistent API.

Something I noticed in the AsyncLocalFileSystem implementation is that most operations, even those related to file io (rather than file-system io) aren't using aiofile when it appears that they could. I'm thinking of things like _write_text[^1], which doesn't use the open_async due to the methods they wrap calling AbstractFileSystem.open (which is synchronous).

Perhaps I'm missing something, however this feels like a missed opportunity to make the most of aiofile offering a complete async file interface.

I noticed that the base AsyncFileSystem doesn't implement those methods in terms of open_async as AbstractFileSystem does for open, so perhaps there's something I'm missing which makes that undesirable? And/or is this something which would be better fixed by implementing them there as defaults, rather than requiring every async implementation to build them from scratch?

Would you be open to a PR which added this support?

[^1]: _write_text, _write_bytes, _read_text, _read_bytes, _put_file, _pipe_file.

Dominant language
Python
Stars
18
Forks
3
PR merge metrics
No merged PRs in 30d

Getting set up

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 iterative/morefs

All issues in iterative/morefs

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.