Skip to content

wrap_kvs inconsistencies (due to incorrect signature-based conditioning) #9

Description

@thorwhalen

And example of the problem with wrap_kvs(...obj_of_data).

from dol import Files, wrap_kvs

s = wrap_kvs(
     Files(rootdir), 
     obj_of_data=lambda x: bytes.decode(x)
)

s.head()  # works fine (as long as the first item's bytes can be decoded (as text)

But, though bytes.decode is "equivalent" to lambda x: bytes.decode(x), the following doesn't work:

from dol import Files, wrap_kvs

s = wrap_kvs(
     Files(rootdir), 
     obj_of_data=bytes.decode,
)

s.head() 

Instead we get:

TypeError: descriptor 'decode' for 'bytes' objects doesn't apply to a 'Store' object

The reason is that there's some dark (and apparently bad) magic happening behind the scenes.
Probably something that checks the signature of obj_of_data and does something (not so) "smart" about how it applies the function.

┆Issue is synchronized with this Asana task by Unito

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeFix likely changes public behavior/API; needs dependents test-gatebugSomething isn't workingpriority: highTackle first — high leverage/impactwrap_kvsThe wrap_kvs / store_decorator / Store.wrap core machinery

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions