Acquire.Client._par module

class PAR(url=None, key=None, encrypt_key=None, created_datetime=None, expires_datetime=None, is_readable=False, is_writeable=False, is_executable=False, par_id=None, par_name=None, driver=None)[source]

Bases: object

This class holds the result of a pre-authenticated request (a PAR - also called a pre-signed request). This holds a pre-authenticated URL to access either;

  1. A individual object in an object store (read or write)
  2. An entire bucket in the object store (write only)
  3. A calculation to be performed on the compute service (start or stop)

The PAR is created encrypted, so can only be used by the person or service that has access to the decryption key

close()[source]

Close this PAR - this closes and deletes the PAR

driver()[source]

Return the underlying object store driver used for this PAR

execute(encrypt_key)[source]

Return an object that can be used to control execution of this PAR

fingerprint()[source]

Return a fingerprint for this PAR that can be used in authorisations

static from_data(data)[source]

Return a PAR constructed from the passed json-deserliased dictionary

is_bucket()[source]

Return whether or not this PAR is for an entire bucket

is_calculation()[source]

Return whether or not this PAR is for a calculation

is_executable()[source]

Return whether or not this is an executable job

is_null()[source]

Return whether or not this is null

is_object()[source]

Return whether or not this PAR is for a single object

is_readable()[source]

Return whether or not this PAR gives read access

is_writeable()[source]

Return whether or not this PAR gives write access

key()[source]

Return the key for the object this accesses - this is None if the PAR grants access to the entire bucket

par_id()[source]

Return the ID of the PAR, if this was supplied by the underlying driver. This could be useful for PAR management by the server

par_name()[source]

Return the user-supplied name of the PAR, if this was supplied by the user and supported by the underlying driver. This could be useful for PAR management by the server

read(encrypt_key)[source]

Return an object that can be used to read data from this PAR

seconds_remaining(buffer=30)[source]

Return the number of seconds remaining before this PAR expires. This will return 0 if the PAR has already expired. To be safe, you should renew PARs if the number of seconds remaining is less than 60. This will subtract ‘buffer’ seconds from the actual validity to provide a buffer against race conditions (function says this is valid when it is not)

to_data()[source]

Return a json-serialisable dictionary that contains all data for this object

uid()[source]

Return the UID of this PAR

url(encrypt_key)[source]

Return the URL at which the bucket/object can be accessed. This will raise a PARTimeoutError if the url has less than 30 seconds of validity left. Note that you must pass in the key used to decrypt the PAR

write(encrypt_key)[source]

Return an object that can be used to write data to this PAR

class BucketReader(par=None, encrypt_key=None)[source]

Bases: object

This class provides functions to enable reading data from a bucket via a PAR

get_all_object_names(prefix=None)[source]

Returns the names of all objects in the passed bucket

get_all_objects(prefix=None)[source]

Return all of the objects in the passed bucket

get_all_strings(prefix=None)[source]

Return all of the strings in the passed bucket

get_object(key)[source]

Return the binary data contained in the key ‘key’ in the passed bucket

get_object_as_file(key, filename)[source]

Get the object contained in the key ‘key’ in the passed ‘bucket’ and writing this to the file called ‘filename’

get_object_from_json(key)[source]

Return an object constructed from json stored at ‘key’ in the passed bucket. This raises an exception if there is no data or the PAR has expired

get_string_object(key)[source]

Return the string in ‘bucket’ associated with ‘key’

class BucketWriter(par=None, encrypt_key=None)[source]

Bases: object

This class provides functions to enable writing data to a bucket via a PAR

set_object(key, data)[source]

Set the value of ‘key’ in ‘bucket’ to binary ‘data’

set_object_from_file(key, filename)[source]

Set the value of ‘key’ in ‘bucket’ to equal the contents of the file located by ‘filename’

set_object_from_json(key, data)[source]

Set the value of ‘key’ in ‘bucket’ to equal to contents of ‘data’, which has been encoded to json

set_string_object(key, string_data)[source]

Set the value of ‘key’ in ‘bucket’ to the string ‘string_data’

class ObjectReader(par=None, encrypt_key=None)[source]

Bases: object

This class provides functions for reading an object via a PAR

get_object()[source]

Return the binary data contained in this object

get_object_as_file(filename)[source]

Get the object contained in this PAR and write this to the file called ‘filename’

get_object_from_json()[source]

Return an object constructed from json stored at behind this PAR. This raises an exception if there is no data or the PAR has expired

get_string_object()[source]

Return the object behind this PAR as a string (raises exception if it is not a string)’

class ObjectWriter(par=None, encrypt_key=None)[source]

Bases: Acquire.Client._par.ObjectReader

This is an extension of ObjectReader that also allows writing to the object via the PAR

set_object(data)[source]

Set the value of the object behind this PAR to the binary ‘data’

set_object_from_file(filename)[source]

Set the value of the object behind this PAR to equal the contents of the file located by ‘filename’

set_object_from_json(data)[source]

Set the value of the object behind this PAR to equal to contents of ‘data’, which has been encoded to json

set_string_object(string_data)[source]

Set the value of the object behind this PAR to the string ‘string_data’

class ComputeRunner(par=None, encrypt_key=None)[source]

Bases: object

This class provides functions for executing a calculation pre-authorised by the passed PAR