Skip to content

base

openml._api.resources.base #

DatasetAPI #

DatasetAPI(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Abstract API interface for dataset resources.

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.
    """

EstimationProcedureAPI #

EstimationProcedureAPI(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Abstract API interface for estimation procedure resources.

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.
    """

EvaluationAPI #

EvaluationAPI(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Abstract API interface for evaluation resources.

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.
    """

EvaluationMeasureAPI #

EvaluationMeasureAPI(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Abstract API interface for evaluation measure resources.

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.
    """

FallbackProxy #

FallbackProxy(*api_versions: Any)

Proxy object that provides transparent fallback across multiple API versions.

This class delegates attribute access to a sequence of API implementations. When a callable attribute is invoked and raises OpenMLNotSupportedError, the proxy automatically attempts the same method on subsequent API instances until one succeeds.

PARAMETER DESCRIPTION
*api_versions

One or more API implementation instances ordered by priority. The first API is treated as the primary implementation, and subsequent APIs are used as fallbacks.

TYPE: Any DEFAULT: ()

RAISES DESCRIPTION
ValueError

If no API implementations are provided.

Notes

Attribute lookup is performed dynamically via __getattr__. Only methods that raise OpenMLNotSupportedError trigger fallback behavior. Other exceptions are propagated immediately.

Source code in openml/_api/resources/base/fallback.py
def __init__(self, *api_versions: Any):
    if not api_versions:
        raise ValueError("At least one API version must be provided")
    self._apis = api_versions

__getattr__ #

__getattr__(name: str) -> Any

Dynamically resolve attribute access across API implementations.

PARAMETER DESCRIPTION
name

Name of the attribute being accessed.

TYPE: str

RETURNS DESCRIPTION
Any

The resolved attribute. If it is callable, a wrapped function providing fallback behavior is returned.

RAISES DESCRIPTION
AttributeError

If none of the API implementations define the attribute.

Source code in openml/_api/resources/base/fallback.py
def __getattr__(self, name: str) -> Any:
    """
    Dynamically resolve attribute access across API implementations.

    Parameters
    ----------
    name : str
        Name of the attribute being accessed.

    Returns
    -------
    Any
        The resolved attribute. If it is callable, a wrapped function
        providing fallback behavior is returned.

    Raises
    ------
    AttributeError
        If none of the API implementations define the attribute.
    """
    api, attr = self._find_attr(name)
    if callable(attr):
        return self._wrap_callable(name, api, attr)
    return attr

FlowAPI #

FlowAPI(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Abstract API interface for flow resources.

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.
    """

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.
    """

ResourceV1API #

ResourceV1API(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Version 1 implementation of the OpenML resource API.

This class provides XML-based implementations for publishing, deleting, tagging, and untagging resources using the V1 API endpoints. Responses are parsed using xmltodict.

Notes

V1 endpoints expect and return XML. Error handling follows the legacy OpenML server behavior and maps specific error codes to more descriptive exceptions where appropriate.

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

delete #

delete(resource_id: int) -> bool

Delete a resource using the V1 API.

PARAMETER DESCRIPTION
resource_id

Identifier of the resource to delete.

TYPE: int

RETURNS DESCRIPTION
bool

True if the server confirms successful deletion.

RAISES DESCRIPTION
ValueError

If the resource type is not supported for deletion.

OpenMLNotAuthorizedError

If the user is not permitted to delete the resource.

OpenMLServerError

If deletion fails for an unknown reason.

OpenMLServerException

For other server-side errors.

Source code in openml/_api/resources/base/versions.py
def delete(self, resource_id: int) -> bool:
    """
    Delete a resource using the V1 API.

    Parameters
    ----------
    resource_id : int
        Identifier of the resource to delete.

    Returns
    -------
    bool
        ``True`` if the server confirms successful deletion.

    Raises
    ------
    ValueError
        If the resource type is not supported for deletion.
    OpenMLNotAuthorizedError
        If the user is not permitted to delete the resource.
    OpenMLServerError
        If deletion fails for an unknown reason.
    OpenMLServerException
        For other server-side errors.
    """
    if self.resource_type not in _LEGAL_RESOURCES_DELETE:
        raise ValueError(f"Can't delete a {self.resource_type.value}")

    endpoint_name = self._get_endpoint_name()
    path = f"{endpoint_name}/{resource_id}"
    try:
        response = self._http.delete(path)
        result = xmltodict.parse(response.content)
        return f"oml:{endpoint_name}_delete" in result
    except OpenMLServerException as e:
        self._handle_delete_exception(endpoint_name, e)
        raise

publish #

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

Publish a new resource using the V1 API.

PARAMETER DESCRIPTION
path

API endpoint path for the upload.

TYPE: str

files

Files to upload as part of the request payload.

TYPE: Mapping of str to Any or None

RETURNS DESCRIPTION
int

Identifier of the newly created resource.

RAISES DESCRIPTION
ValueError

If the server response does not contain a valid resource ID.

OpenMLServerException

If the server returns an error during upload.

Source code in openml/_api/resources/base/versions.py
def publish(self, path: str, files: Mapping[str, Any] | None) -> int:
    """
    Publish a new resource using the V1 API.

    Parameters
    ----------
    path : str
        API endpoint path for the upload.
    files : Mapping of str to Any or None
        Files to upload as part of the request payload.

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

    Raises
    ------
    ValueError
        If the server response does not contain a valid resource ID.
    OpenMLServerException
        If the server returns an error during upload.
    """
    response = self._http.post(path, files=files)
    parsed_response = xmltodict.parse(response.content)
    return self._extract_id_from_upload(parsed_response)

tag #

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

Add a tag to a resource using the V1 API.

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.

RAISES DESCRIPTION
ValueError

If the resource type does not support tagging.

OpenMLServerException

If the server returns an error.

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

    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.

    Raises
    ------
    ValueError
        If the resource type does not support tagging.
    OpenMLServerException
        If the server returns an error.
    """
    if self.resource_type not in _LEGAL_RESOURCES_TAG:
        raise ValueError(f"Can't tag a {self.resource_type.value}")

    endpoint_name = self._get_endpoint_name()
    path = f"{endpoint_name}/tag"
    data = {f"{endpoint_name}_id": resource_id, "tag": tag}
    response = self._http.post(path, data=data)

    parsed_response = xmltodict.parse(response.content, force_list={"oml:tag"})
    result = parsed_response[f"oml:{endpoint_name}_tag"]
    tags: list[str] = result.get("oml:tag", [])

    return tags

untag #

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

Remove a tag from a resource using the V1 API.

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.

RAISES DESCRIPTION
ValueError

If the resource type does not support tagging.

OpenMLServerException

If the server returns an error.

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

    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.

    Raises
    ------
    ValueError
        If the resource type does not support tagging.
    OpenMLServerException
        If the server returns an error.
    """
    if self.resource_type not in _LEGAL_RESOURCES_TAG:
        raise ValueError(f"Can't untag a {self.resource_type.value}")

    endpoint_name = self._get_endpoint_name()
    path = f"{endpoint_name}/untag"
    data = {f"{endpoint_name}_id": resource_id, "tag": tag}
    response = self._http.post(path, data=data)

    parsed_response = xmltodict.parse(response.content, force_list={"oml:tag"})
    result = parsed_response[f"oml:{endpoint_name}_untag"]
    tags: list[str] = result.get("oml:tag", [])

    return tags

ResourceV2API #

ResourceV2API(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Version 2 implementation of the OpenML resource API.

This class represents the V2 API for resources. Operations such as publishing, deleting, tagging, and untagging are currently not supported and will raise OpenMLNotSupportedError.

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

RunAPI #

RunAPI(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Abstract API interface for run resources.

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.
    """

SetupAPI #

SetupAPI(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Abstract API interface for setup resources.

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.
    """

StudyAPI #

StudyAPI(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Abstract API interface for study resources.

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.
    """

TaskAPI #

TaskAPI(http: HTTPClient, minio: MinIOClient)

Bases: ResourceAPI

Abstract API interface for task resources.

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.
    """