The client.py
module#
Summary#
Provides for monitoring and tracking the state of the worker binary. |
|
|
Provides the Python client to the HPS data transfer APIs. |
|
Provides an async interface to the Python client to the HPS data transfer APIs. |
|
Provides the Python client to the HPS data transfer APIs. |
|
Check if a binary is in use. |
|
|
|
Description#
Provides the Python client to the HPS data transfer APIs.
Module detail#
- class client.MonitorState#
Provides for monitoring and tracking the state of the worker binary.
Overview#
Reset the monitor state to the initial values. |
|
Mark the worker as ready or not ready. |
|
Mark the worker as failed. |
|
Report the worker status. |
Sleep time based on the worker state. |
Import detail#
from ansys.hps.data_transfer.client.client import MonitorState
Property detail#
- property MonitorState.sleep_for#
Sleep time based on the worker state.
Method detail#
- MonitorState.reset()#
Reset the monitor state to the initial values.
- MonitorState.mark_ready(ready)#
Mark the worker as ready or not ready.
- MonitorState.mark_failed(exc=None, binary=None)#
Mark the worker as failed.
- MonitorState.report(binary)#
Report the worker status.
- class MonitorState.ClientBase(bin_config: ansys.hps.data_transfer.client.binary.BinaryConfig = None, download_dir: str = 'dt_download', clean=False, clean_dev=True, check_in_use=True, timeout=60.0, retries=10)#
Provides the Python client to the HPS data transfer APIs.
This class uses the provided credentials to create and store an authorized
requests.Session
object.- Parameters:
- bin_config: BinaryConfig, default: None
Binary configuration. If no configuration is provided, a default
BinaryConfig
object is created.- download_dir: str, default: “dt_download”
Path to the download directory.
- clean: bool, default: False
Whether to clean the path to the download directory.
- clean_dev: bool, default: True
Whether to clean the path to the download directory if the binary is from the development branch.
- check_in_use: bool, default: True
Whether to check if the binary is in use and skip downloading a new binary.
- timeout: float, default: 60.0
Timeout for the session. This is the maximum time to wait for a response from the server.
- retries: int, default: 1
Number of times to retry the operation.
- Examples:
- ——–
- Create a client object and connect to HPS data transfer with an access token.
- >>> from ansys.hps.data_transfer.client import Client
- >>> token = authenticate(username=username, password=password, verify=False, url=auth_url)
- >>> token = token.get(“access_token”, None)
- >>> client = Client(clean=True)
- >>> client.binary_config.update(
verbosity=3, debug=False, insecure=True, token=token, data_transfer_url=dt_url,
)
- >>> client.start()
Overview#
Number of retries. |
|
Binary configuration. |
|
API URL from the configuration. |
|
Session object. If one does not exist, a new one is created. |
|
Flag indicating if the binary is up and running. |
|
Timeout for the session. |
Import detail#
from ansys.hps.data_transfer.client.client import ClientBase
Property detail#
- property ClientBase.retries#
Number of retries.
- property ClientBase.binary_config#
Binary configuration.
- property ClientBase.base_api_url#
API URL from the configuration.
- property ClientBase.session#
Session object. If one does not exist, a new one is created.
- property ClientBase.is_started#
Flag indicating if the binary is up and running.
- property ClientBase.timeout#
Timeout for the session.
Attribute detail#
- ClientBase.binary = None#
Method detail#
- ClientBase.start()#
Start the client session using the binary configuration credentials.
- ClientBase.stop(wait=5.0)#
Stop the client session.
- class ClientBase.AsyncClient(*args, **kwargs)#
Provides an async interface to the Python client to the HPS data transfer APIs.
Overview#
Import detail#
from ansys.hps.data_transfer.client.client import AsyncClient
Method detail#
- async AsyncClient.start()#
Start the async binary worker.
- async AsyncClient.stop(wait=5.0)#
Stop the async binary worker.
- class AsyncClient.Client(*args, **kwargs)#
Provides the Python client to the HPS data transfer APIs.
This class uses the provided credentials to create and store an authorized
requests.Session
object.
Overview#
Import detail#
from ansys.hps.data_transfer.client.client import Client
Method detail#
- Client.start()#
Start the client session using the binary configuration credentials.
- Client.stop(wait=5.0)#
Stop the client session.
- Client.bin_in_use(bin_path)#
Check if a binary is in use.
- Client.logger#
- Client.log#