Skip to content

base

openml._api.resources.base.base #

ResourceAPI #

ResourceAPI(http: HTTPClient, minio: MinIOClient)

Bases: ABC

Abstract base class for OpenML resource APIs.

This class defines the common interface for interacting with OpenML resources (e.g., datasets, flows, runs) across different API versions. Concrete subclasses must implement the resource-specific operations such as publishing, deleting, and tagging.

PARAMETER DESCRIPTION
http

Configured HTTP client used for communication with the OpenML API.

TYPE: HTTPClient

minio

Configured MinIO client used for object storage operations.

TYPE: MinIOClient

ATTRIBUTE DESCRIPTION
api_version

API version implemented by the resource.

TYPE: APIVersion

resource_type

Type of OpenML resource handled by the implementation.

TYPE: ResourceType

_http

Internal HTTP client instance.

TYPE: HTTPClient

_minio

Internal MinIO client instance, if provided.

TYPE: MinIOClient or None

Source code in openml/_api/resources/base/base.py
def __init__(self, http: HTTPClient, minio: MinIOClient):
    self._http = http
    self._minio = minio

delete abstractmethod #

delete(resource_id: int) -> bool

Delete a resource by its identifier.

PARAMETER DESCRIPTION
resource_id

Unique identifier of the resource to delete.

TYPE: int

RETURNS DESCRIPTION
bool

True if the deletion was successful.

Notes

Concrete subclasses must implement this method.

Source code in openml/_api/resources/base/base.py
@abstractmethod
def delete(self, resource_id: int) -> bool:
    """
    Delete a resource by its identifier.

    Parameters
    ----------
    resource_id : int
        Unique identifier of the resource to delete.

    Returns
    -------
    bool
        ``True`` if the deletion was successful.

    Notes
    -----
    Concrete subclasses must implement this method.
    """

publish abstractmethod #

publish(path: str, files: Mapping[str, Any] | None) -> int

Publish a new resource to the OpenML server.

PARAMETER DESCRIPTION
path

API endpoint path used for publishing the resource.

TYPE: str

files

Files or payload data required for publishing. The structure depends on the resource type.

TYPE: Mapping of str to Any or None

RETURNS DESCRIPTION
int

Identifier of the newly created resource.

Notes

Concrete subclasses must implement this method.

Source code in openml/_api/resources/base/base.py
@abstractmethod
def publish(self, path: str, files: Mapping[str, Any] | None) -> int:
    """
    Publish a new resource to the OpenML server.

    Parameters
    ----------
    path : str
        API endpoint path used for publishing the resource.
    files : Mapping of str to Any or None
        Files or payload data required for publishing. The structure
        depends on the resource type.

    Returns
    -------
    int
        Identifier of the newly created resource.

    Notes
    -----
    Concrete subclasses must implement this method.
    """

tag abstractmethod #

tag(resource_id: int, tag: str) -> list[str]

Add a tag to a resource.

PARAMETER DESCRIPTION
resource_id

Identifier of the resource to tag.

TYPE: int

tag

Tag to associate with the resource.

TYPE: str

RETURNS DESCRIPTION
list of str

Updated list of tags assigned to the resource.

Notes

Concrete subclasses must implement this method.

Source code in openml/_api/resources/base/base.py
@abstractmethod
def tag(self, resource_id: int, tag: str) -> list[str]:
    """
    Add a tag to a resource.

    Parameters
    ----------
    resource_id : int
        Identifier of the resource to tag.
    tag : str
        Tag to associate with the resource.

    Returns
    -------
    list of str
        Updated list of tags assigned to the resource.

    Notes
    -----
    Concrete subclasses must implement this method.
    """

untag abstractmethod #

untag(resource_id: int, tag: str) -> list[str]

Remove a tag from a resource.

PARAMETER DESCRIPTION
resource_id

Identifier of the resource to untag.

TYPE: int

tag

Tag to remove from the resource.

TYPE: str

RETURNS DESCRIPTION
list of str

Updated list of tags assigned to the resource.

Notes

Concrete subclasses must implement this method.

Source code in openml/_api/resources/base/base.py
@abstractmethod
def untag(self, resource_id: int, tag: str) -> list[str]:
    """
    Remove a tag from a resource.

    Parameters
    ----------
    resource_id : int
        Identifier of the resource to untag.
    tag : str
        Tag to remove from the resource.

    Returns
    -------
    list of str
        Updated list of tags assigned to the resource.

    Notes
    -----
    Concrete subclasses must implement this method.
    """