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

Implement store/load methods for eprint resources on CanonicalStorage #19

Open
erickpeirson opened this issue Jun 27, 2019 · 0 comments
Labels
arxiv.canonical Work related to the arxiv.canonical package

Comments

@erickpeirson
Copy link
Contributor

The arxiv.canonical.services.store.CanonicalStorage class has two private methods for loading/storing the state of an e-print from/to S3.

def _store_eprint(self, eprint: EPrint) -> None:
"""
Store a :class:`.EPrint`.
If the :attr:`.EPrint.source_package` or :attr:`.EPrint.pdf` content
has changed, those should also be stored.
Should complain loudly if ``self.read_only`` is ``True``.
"""
raise NotImplementedError('Implement me!')
def _load_eprint(self, identifier: Identifier, version: int) \
-> EPrint:
"""
Load an :class:`.EPrint`.
The content of the :attr:`.EPrint.source_package` and
:attr:`.EPrint.pdf` should implement :class:`.Readable`. The ``read()``
method should be a closure that, when called, retrieves the content of
the corresponding resource from storage.
"""
raise NotImplementedError('Implement me!')

The schema for eprint metadata stored on S3 can be found here.

_load_eprint(self, identifier: Identifier, version: int) -> EPrint:

This should load metadata (a JSON document) from S3 using the path/key described here. That metadata should be used to instantiate an arxiv.canonical.domain.EPrint object.

When instantiating the Eprint object, the source_package and pdf members should be objects with a read() -> bytes: method. That method should lazily retrieve and read the contents of the corresponding resource on S3 (again, at the path/key described in the README.

_store_eprint(self, eprint: EPrint) -> None:

This should basically do everything in reverse. Note that source_package and pdf may be None. If they are not None, then their contents should also be stored to S3 at the correct paths.

@erickpeirson erickpeirson added the arxiv.canonical Work related to the arxiv.canonical package label Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arxiv.canonical Work related to the arxiv.canonical package
Projects
None yet
Development

No branches or pull requests

1 participant