et_engine.clients¶
Classes
|
Base client for interacting with the ET Engine API |
|
Client for handling parallelized multipart downloads to ET Engine. |
|
Client for handling parallelized multipart uploads to ET Engine. |
|
Decorate an iterable object, returning an iterator which acts exactly like the original iterable, but prints a dynamically updating progressbar every time a value is requested. |
- class APIClient(url: str = 'https://api.exploretech.ai/v1')¶
Bases:
object
Base client for interacting with the ET Engine API
- authorized_request(method: str, path: str, headers: dict = {}, params: dict = {}, data: dict = {}) dict ¶
Similar to the request method, but adds an API key authorization header.
- Parameters:
method (str) – HTTP method to make request to. Supported options are [“GET”, “POST”, “DELETE”].
path (str) – Resource path appended to the base URL.
headers (dict, optional) – Key-value pairs of headers to send with the request. Defaults to {}.
params (dict, optional) – Key-value pairs of query string params to send with the request. Defaults to {}.
data (dict, optional) – Key-value paris of request body to data to send with the request. Formatted as a JSON-like dictionary. Defaults to {}.
- Returns:
The response data formatted as a JSON-like dictionary.
- Return type:
dict
- delete(path: str = '') dict ¶
Performs a DELETE request with authorization at the specified resource path.
- Parameters:
path (str, optional) – Resource path appended to the base URL. Defaults to “”.
- Returns:
The response data formatted as a JSON-like dictionary.
- Return type:
dict
- get(path: str = '', params: dict = {}) dict ¶
Performs a GET request with authorization at the specified resource path.
- Parameters:
path (str, optional) – Resource path appended to the base URL. Defaults to “”.
params (dict, optional) – Query string params to send with the request. Defaults to {}.
- Returns:
The response data formatted as a JSON-like dictionary.
- Return type:
dict
- post(path: str = '', data: dict = {}) dict ¶
Performs a POST request with authorization at the specified resource path.
- Parameters:
path (str, optional) – Resource path appended to the base URL. Defaults to “”.
data (dict, optional) – Request body data to send with the request, in a JSON-like dictionary. Defaults to {}.
- Returns:
The response data formatted as a JSON-like dictionary.
- Return type:
dict
- request(method: str, path: str, headers: dict = {}, params: dict = {}, data: dict = {}) dict ¶
Base method for making a request to the base endpoint.
- Parameters:
method (str) – HTTP method to make request to. Supported options are [“GET”, “POST”, “DELETE”].
path (str) – Resource path appended to the base URL.
headers (dict, optional) – Key-value pairs of headers to send with the request. Defaults to {}.
params (dict, optional) – Key-value pairs of query string params to send with the request. Defaults to {}.
data (dict, optional) – Key-value paris of request body to data to send with the request. Formatted as a JSON-like dictionary. Defaults to {}.
- Returns:
The response data formatted as a JSON-like dictionary.
- Return type:
dict
- class MultipartDownload(local_file: str, url: str, chunk_size: int = 8388608, timeout: int = 7200)¶
Bases:
object
Client for handling parallelized multipart downloads to ET Engine.
NOTE: This needs to be combined with Multipart Upload because of duplicate code.
- complete_download() None ¶
Complete the download by renaming the temporary file
- download() None ¶
Launch the paralellized download.
- async download_part(starting_byte: int, session: ClientSession) int ¶
Downloads one part in the multipart download.
- Parameters:
starting_byte (int) – Index of the first byte in the part.
session (aiohttp.ClientSession) – The base asynchronous client session.
- Raises:
Exception – Something went wrong with the upload.
Exception – Max retries exceeded.
- Returns:
HTTP status code of the response.
- Return type:
int
- async download_parts_in_parallel() list[int] ¶
Creates the parallelized download tasks and defines how they run, but does not execute them.
- Returns:
A list of HTTP status codes.
- Return type:
list[int]
- initialize_file() None ¶
Creates a local file to be filled in parts during the download.
- Raises:
Exception – The download has not been initialized.
- request_download() None ¶
Initialize the download with a GET request.
- class MultipartUpload(local_file: str, url: str, chunk_size: int = 8388608, timeout: int = 7200)¶
Bases:
object
Client for handling parallelized multipart uploads to ET Engine.
NOTE: This needs to be combined with Multipart Download because of duplicate code.
- complete_upload() None ¶
Confirm the upload is complete with a POST request.
- Raises:
Exception – The upload has not been initialized yet.
- request_upload() None ¶
Initialize the upload with a POST request.
- upload() None ¶
Launch the parallelized upload.
- async upload_part(starting_byte: int, session: ClientSession) int ¶
Uploads one part in a multipart upload.
- Parameters:
starting_byte (int) – Index of the first byte in the part.
session (aiohttp.ClientSession) – The base asynchronous client session.
- Raises:
Exception – The upload has not yet been initialized.
Exception – Something went wrong with the upload.
Exception – Max retries exceeded.
- Returns:
HTTP status code of the response.
- Return type:
int
- async upload_parts_in_parallel() list[int] ¶
Creates the parallelized upload tasks and defines how they run, but does not execute them.
- Returns:
A list of HTTP status codes.
- Return type:
list[int]