Skip to content

Rethink API - ephemeral/temporary/permanent #4

@effigies

Description

@effigies

Right now, we have three methods:

  • readable() - Guarantees the resource is readable
  • as_path() - Context manager that guarantees the resource is an existing Path
  • cached() - Guarantees the resource is an existing Path throughout the program life

This reflects that we're really just wrapping the importlib.resources API along with an interpreter-lifetime cache, but if part of the reason to use this is to file the edges off of IR, maybe we should think a little more abstractly. We could instead write these as:

  • ephemeral() - The data is accessible with a limited interface
  • temporary() - The data is temporarily accessible with a full interface
  • permanent() - The data is permanently accessible with a full interface

Perhaps this would be clearer to somebody who isn't already in the weeds of IR and just wants to understand the semantics of our loader?

Also, do we think it's worth keeping the __call__() behavior as the safe-but-potentially-wasteful cached()/permanent(), or remove it and always be explicit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions