Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] A cleaner and clearer files model and interface #37

Open
alexdutton opened this issue Aug 11, 2020 · 0 comments
Open

[Proposal] A cleaner and clearer files model and interface #37

alexdutton opened this issue Aug 11, 2020 · 0 comments
Assignees
Labels
Proposal: Accepted Accepted proposal for new RFC

Comments

@alexdutton
Copy link
Member

alexdutton commented Aug 11, 2020

Motivation

The current implementation of invenio-files-rest is in places confusing to follow and doesn't provide an easy-to-use Python API or allow for easy extensibility to support multiple storage backends in one system.

See also related discussion on inveniosoftware/invenio-files-rest#255.

Summary

Proposed changes

  • Storage backends are registered using entry points, and a(n overridable) name→class mapping added to config
  • FileInstance.storage_class is migrated from String(1) to a larger string, and used to point to the storage backend entry point name used for the file. It is currently unused.
  • A new storage factory is created that uses FileInstance.storage_class to mediate access to stored files based on .storage_class
  • The new storage factory is the default for new cookiecutters, but the old pyfs storage factory remains with the old behaviour and a DeprecationWarning, to provide a migration path
  • The new storage factory can be overridden to use another way to determine storage class for both existing files and new files. I expect to make this a class-based factory, with obviously overrideable methods.
  • An alembic migration that ALTERs FileInstance.storage_class to extend its length and populates it with according to some (yet to be determined) heuristic
  • FileInstance.storage(**kwargs) has its **kwargs deprecated. Possibly deprecate in favour of a (cached) file property, for a cleaner interface. New interface is e.g. with file_instance.file.open() as f:
  • Update documentation to reflect changes
  • Updates to invenio-s3 to use the new storage framework implementation

Resources

Cottage Labs is offering 2 days a week of developer effort that could be spent on this. I haven't yet estimated the amount of effort required.

@alexdutton alexdutton added the Proposal: Pending Proposal for new RFC, pending triage label Aug 11, 2020
@lnielsen lnielsen added Proposal: Accepted Accepted proposal for new RFC and removed Proposal: Pending Proposal for new RFC, pending triage labels Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal: Accepted Accepted proposal for new RFC
Projects
None yet
Development

No branches or pull requests

5 participants