seguro.common.store¶
Classes
|
Helper class for S3 object store interaction with the SEGuRo platform |
|
|
|
Helper class for asynchronous watching of of S3 objects |
- class seguro.common.store.Client(host='localhost', port=9000, tls_cacert='keys/ca.crt', tls_cert='keys/clients/admin.crt', tls_key='keys/clients/admin.key', region='minio', bucket='seguro')[source]¶
Bases:
object
Helper class for S3 object store interaction with the SEGuRo platform
This class provides an abstraction layer for interactions between the S3 data store and the SEGuRo platform.
Connect to an S3 object store using the given credentials and store the returned client handle.
- Parameters:
host (str) – Hostname or IP address of the storage server
port (int) – Network port of the storage server
tls_cert (str) – File containing the TLS client certificate for mutual TLS authentication.
tls_key (str) – File containing the TLS client key for mutual TLS authentication.
tls_cacert (str) – File containing the TLS certificate authority to validate the servers certificate against.
secure – Establish secure connection via TLS
region (str) – The S3 region
bucket (str) – The S3 bucket
- get_file(filename, file)[source]¶
Download file from the S3 object store and store it locally.
- Parameters:
filename (str) – Local filename that is used
file (str) – Name of requested file in storage
filename – str:
file – str:
- Returns:
Object Information
- get_file_contents(filename)[source]¶
Write to file stored it in the S3Storage.
- Parameters:
filename (str) – Name of file in storage
content – Content that is written to file
filename – str:
- Return type:
BaseHTTPResponse
Returns:
- get_file_url(filename, expires=datetime.timedelta(days=7), public=True)[source]¶
- Parameters:
filename (str)
public (bool)
- Return type:
str
- get_frame(filename)[source]¶
Download a Pandas Dataframe as a Parquet file to the store
- Parameters:
filename (str) – The filename from which it should be retrieved
- Return type:
DataFrame
Returns:
- put_file(filename, file)[source]¶
Upload local file and store it in the S3Storage.
- Parameters:
filename (str) – Name of uploaded file in storage
file (str) – Local file that is used
filename – str:
file – str:
Returns:
- put_file_contents(filename, content)[source]¶
Write to file stored it in the S3Storage.
- Parameters:
filename (str) – Name of file in storage
content (bytes) – Content that is written to file
filename – str:
content – bytes:
Returns:
- put_frame(filename, df)[source]¶
Upload a Pandas Dataframe as a Parquet file to the store
- Parameters:
filename (str) – The filename at which it should be stored
df (DataFrame) – The Pandas DataFrame
Returns:
- remove_file(filename)[source]¶
Remove a local file from the S3Storage.
- Parameters:
filename (str) – Name of removed file in storage
filename – str:
Returns:
- watch(prefix, events=<Event.CREATED|REMOVED: 6>, initial=False)[source]¶
- Parameters:
prefix (str) – str:
events (Event) – Event: (Default value = Event.CREATED | Event.REMOVED)
initial (bool) – bool: (Default value = False)
Returns:
- class seguro.common.store.Event(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Flag
- CREATED = 2¶
- REMOVED = 4¶
- UNKNOWN = 1¶
- class seguro.common.store.Watcher(client, prefix, cb, events=<Event.CREATED|REMOVED: 6>, initial=False)[source]¶
Bases:
Thread
Helper class for asynchronous watching of of S3 objects
- Parameters:
- run()[source]¶
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.