compiler.services.store package¶
Content store for compiled representation of paper.
Uses S3 as the underlying storage facility.
The intended use pattern is that a client (e.g. API controller) can check for
a compilation using the source ID (e.g. file manager source_id), the format,
and the checksum of the source package (as reported by the FM service) before
taking any IO-intensive actions. See Store.get_status()
.
Similarly, if a client needs to verify that a compilation product is available
for a specific source checksum, they would use Store.get_status()
before calling Store.retrieve()
. For that reason,
Store.retrieve()
is agnostic about checksums. This cuts down on
an extra GET request to S3 every time we want to get a compiled resource.
-
exception
compiler.services.store.
DoesNotExist
[source]¶ Bases:
RuntimeError
The requested content does not exist.
-
class
compiler.services.store.
Store
(buckets, verify=False, region_name=None, endpoint_url=None, aws_access_key_id=None, aws_secret_access_key=None)[source]¶ Bases:
object
Represents an object store session.
-
KEY
= '{src_id}/{chk}/{out_fmt}/{src_id}.{ext}'¶
-
LOG_KEY
= '{src_id}/{chk}/{out_fmt}/{src_id}.{ext}.log'¶
-
STATUS_KEY
= '{src_id}/{chk}/{out_fmt}/status.json'¶
-
classmethod
current_session
()[source]¶ Get the current store session for this application.
- Return type
-
get_status
(src_id, chk, out_fmt, bucket='arxiv')[source]¶ Get the status of a compilation.
- Parameters
- Returns
- Return type
Task
- Raises
DoesNotExist – Raised if no status exists for the provided parameters.
- Return type
-
classmethod
init_app
(app)[source]¶ Set defaults for required configuration parameters.
- Return type
None
-
set_status
(task, bucket='arxiv')[source]¶ Update the status of a compilation.
- Parameters
task (
Task
) –bucket (str) –
- Return type
None
-
-
compiler.services.store.
hash_content
(body)[source]¶ Generate an encoded MD5 hash of a bytes.
- Return type