aistore.sdk.obj.object_client

View as Markdown

Module Contents

Classes

NameDescription
ObjectClientObjectClient is a simple wrapper around a given RequestClient that makes requests to an individual object.

API

class aistore.sdk.obj.object_client.ObjectClient(
request_client: aistore.sdk.request_client.RequestClient,
path: str,
params: typing.Dict[str, str],
headers: typing.Optional[typing.Dict[str, str]] = None,
byte_range: typing.Optional[typing.Tuple[typing.Optional[int], typing.Optional[int]]] = (None, None),
uname: typing.Optional[str] = None
)

ObjectClient is a simple wrapper around a given RequestClient that makes requests to an individual object.

Parameters:

request_client
RequestClient

The RequestClient used to make HTTP requests

path
str

URL Path to the object

params
Dict[str, str]

Query parameters for the request

headers
Optional[Dict[str, str]]Defaults to None

HTTP request headers

byte_range
Optional[Tuple[Optional[int], Optional[int]]Defaults to (None, None)

Tuple representing the byte range

uname
Optional[str]Defaults to None

Unique (namespaced) name of the object (used for determining the target node)

path
str

Get the URL path for the object.

aistore.sdk.obj.object_client.ObjectClient._initialize_target_client(
force: bool = False
)

Initialize a new RequestClient pointing to the target node for the object.

aistore.sdk.obj.object_client.ObjectClient._make_get_request(
headers: typing.Dict[str, str],
stream: bool
) -> requests.Response

Make a GET request with retry on object not found.

Parameters:

headers
Dict[str, str]

Request headers including any Range header.

stream
bool

Whether to stream the response.

Returns: requests.Response

requests.Response: The response object.

Raises:

  • ErrObjNotFound: If the object is not found and cannot be retried.
aistore.sdk.obj.object_client.ObjectClient._retry_with_new_smap(
method: str,
kwargs = {}
) -> requests.Response

Retry the request with the latest smap if a 404 error is encountered.

Parameters:

method
str

HTTP method (e.g., GET, HEAD).

**kwargs
Defaults to {}

Additional arguments to pass to the request.

Returns: requests.Response

requests.Response: The response object from the retried request.

aistore.sdk.obj.object_client.ObjectClient.get(
stream: bool,
offset: typing.Optional[int] = None
) -> requests.Response

Fetch object content from AIS, applying an optional offset.

Parameters:

stream
bool

If True, stream the response content.

offset
intDefaults to None

Byte offset for reading the object. Defaults to None.

Returns: requests.Response

requests.Response: The response object containing the content.

Raises:

  • ErrObjNotFound: If the object is not found and cannot be retried.
  • requests.RequestException: For network-related errors.
aistore.sdk.obj.object_client.ObjectClient.get_chunk(
start: int,
end: int
) -> requests.Response

Fetch a specific byte range of the object as a streaming response.

Use response.iter_content() to read the data in small pieces.

Parameters:

start
int

Start byte offset (inclusive).

end
int

End byte offset (exclusive).

Returns: requests.Response

requests.Response: Streaming response. Caller should close it.

Raises:

  • ErrObjNotFound: If the object is not found and cannot be retried.
  • requests.RequestException: For network-related errors.
aistore.sdk.obj.object_client.ObjectClient.head() -> aistore.sdk.obj.object_attributes.ObjectAttributes

Make a head request to AIS to update and return only object attributes.

Returns: ObjectAttributes

ObjectAttributes containing metadata for this object.

aistore.sdk.obj.object_client.ObjectClient.head_v2(
props: str = ''
) -> aistore.sdk.obj.object_attributes.ObjectAttributesV2

Make a HEAD request with selective property retrieval (V2 API).

EXPERIMENTAL: This API is experimental and may change in future releases.

This method allows requesting specific object properties, reducing response size and processing overhead when only certain attributes are needed.

Parameters:

props
strDefaults to ''

Comma-separated list of properties to retrieve. Available values: name, size, version, checksum, atime, present, copies, ec, custom, location, chunked, last-modified, etag. See: https://github.com/NVIDIA/aistore/blob/main/api/apc/lsmsg.go If empty, returns default properties (name, size).

Returns: ObjectAttributesV2

ObjectAttributesV2 containing the requested metadata.