aistore.sdk.utils
Module Contents
Classes
Functions
Data
API
Bases: BaseModel
Represents an error returned by the API.
Converts a time value (e.g., ‘5s’, ‘10m’, ‘2h’, ‘3d’, or 10) to seconds. If no unit is provided (e.g., ‘10’ or 10), seconds are assumed.
Parameters:
The time value to convert.
Returns: int
The equivalent time in seconds.
Raises:
ValueError: If the format or unit is invalid.
Parse response content from the cluster into a Python class, decoding with msgpack depending on content type in header
Parameters:
Resulting type to which the response should be deserialized
Response from the AIS cluster
Given a string template, apply bash-style brace expansion to return a list of strings Args: template: Valid brace expansion input, e.g. prefix-{0..10..2}-gap-{11..15}-suffix
Returns: Iterator[str]
Iterator of brace expansion output
Extract provider, bucket, and whether an object is present from raw string.
Parameters:
Any string that may contain an AIS FQN.
Returns: Optional[Tuple[str, str, bool]]
Optional[Tuple[str, str, bool]]: (prov, bck, has_obj) if a FQN is found, otherwise None.
Get the xxhash digest of a given string.
Get the size of a file and return it in human-readable format Args: file: File to read
Returns: str
Size of file as human-readable string
Create or retrieve a logger with the specified configuration.
Parameters:
The name of the logger.
Logging format.
Returns:
logging.Logger: Configured logger instance.
Given either a Request or PreparedRequest, return an AIS bucket provider.
The request property of a requests.RequestException can be either of these types,
so this can be used to find the bucket provider involved in the initial request.
Parameters:
Any request or prepared request.
Returns: Provider
Parsed AIS bucket Provider Enum.
Check if a given ConnectionError was caused by an underlying ReadTimeoutError Args: exc: Any requests.ConnectionError.
Returns: If ReadTimeoutError cause the exception.
Parse AIS URLs for bucket and object names.
Parameters:
Complete URL of the object (e.g., “ais://bucket1/file.txt”)
Returns: Tuple[str, str, str]
Tuple[str, str, str]: Provider, bucket name, and object name
Given a timeout, return an interval to wait between retries
Parameters:
Duration of timeout
Returns: float
Frequency to probe
Given a filepath, read the content as bytes Args: filepath: Existing local filepath
Returns: Raw bytes
Validate that a directory exists and is a directory Args: path (str or Path): Path to validate Raises: ValueError: If path does not exist or is not a directory
Validate that a file exists and is a file Args: path (str or Path): Path to validate Raises: ValueError: If path does not exist or is not a file
Xoshiro256-inspired hash function with 64-bit overflow behavior.