DataObject is a file-like object in OSS Connector for AI/ML that provides I/O access to OSS objects.
Note DataObject supports only read-only or write-only mode—not both simultaneously. Read-only mode supports sequential read and random read. Write-only mode supports sequential write only.
Mode overview
Methods are mode-specific. The following table shows availability by mode:
| Method | Read-only | Write-only |
|---|
tell | Yes | — |
seek | Yes | — |
read | Yes | — |
readinto | Yes | — |
write | — | Yes |
close | Yes | Yes |
Class definition
class DataObject:
key: str
size: int
label: str
def __enter__(self) -> DataObject: ...
def __exit__(self, exc_type, exc_val, exc_tb): ...
def tell(self) -> int: ...
def seek(self, offset: int, whence: int) -> int: ...
def read(self, count: int) -> bytes: ...
def readinto(self, buf) -> int: ...
def write(self, data) -> int: ...
def close(self) -> int: ...
def copy(self) -> DataObject: ...
Properties
| Property | Type | Description |
|---|
key | str | The unique identifier of the object. |
size | int | The actual size of the object, in bytes. |
label | str | The tags associated with the object, used for classification or labeling. |
Methods
Context manager methods
| Method | Return type | Description |
|---|
__enter__ | DataObject | Enters the context manager and initializes the DataObject instance. |
__exit__ | None | Exits the context manager and releases resources. |
Read-only methods
| Method | Return type | Description |
|---|
tell | int | Returns the current file pointer position in read-only mode, in bytes. |
seek(offset, whence) | int | Specifies the file pointer position in read-only mode, in bytes. |
read(count) | bytes | Reads the specified number of bytes from the current file pointer position in read-only mode. |
readinto(buf) | int | Reads bytes from the current file pointer position into a buffer in read-only mode. Returns the number of bytes read. |
Write-only methods
| Method | Return type | Description |
|---|
write(data) | int | Writes data to the current file pointer position in write-only mode. Returns the number of bytes written. |
Common methods
| Method | Return type | Description |
|---|
close | int | Closes the object and releases related resources. |
copy | DataObject | Creates a new DataObject instance with all attributes of the current instance. |