fsspec / fsspec/filesystem_spec

Support stateful transactions by allowing to pass keyword arguments

Open
#1,517 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.4k
Forks
490
Avg merge
2d 3h
Merged PRs (30d)
38

Description

A file system's corresponding transaction class has been a class attribute since https://github.com/fsspec/filesystem_spec/pull/1424.

However, the fsspec.transaction.Transaction interface is currently stateless. For someone trying to roll a transaction class that takes some state in the constructor, this results in incompatibilities that can break some of fsspec's most important features, e.g. like so:

from fsspec import filesystem
from fsspec.utils import get_protocol

class MyFS:
    protocol = "myfs"
    ...

    def transaction(foo: str = "hello") -> MyTransaction:
        return MyTransaction(foo)

def transact(uri, **kwargs):
    protocol = get_protocol(uri)
    fs = filesystem(protocol, **kwargs)
    with fs.transaction as tx:  # <- bang! if protocol == "myfs", tx will be MyFS's `transaction` class API.
        ...

Question is, would you support moving from the current "transactions as properties" approach to a more functional approach allowing for state passing to the respective transaction class?

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 by reading fsspec.transaction.Transaction and tracing the filesystem(protocol, **kwargs) and get_protocol entry points shown in the example. Done would require an agreed interface for passing transaction state while preserving existing transaction behavior, with coverage for both stateful and current property-style use.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.