1414
1515
1616class ResourceAPI (ABC ):
17+ """
18+ Abstract base class for OpenML resource APIs.
19+
20+ This class defines the common interface for interacting with OpenML
21+ resources (e.g., datasets, flows, runs) across different API versions.
22+ Concrete subclasses must implement the resource-specific operations
23+ such as publishing, deleting, and tagging.
24+
25+ Parameters
26+ ----------
27+ http : HTTPClient
28+ Configured HTTP client used for communication with the OpenML API.
29+ minio : MinIOClient or None, optional
30+ Optional MinIO client used for object storage operations.
31+
32+ Attributes
33+ ----------
34+ api_version : APIVersion
35+ API version implemented by the resource.
36+ resource_type : ResourceType
37+ Type of OpenML resource handled by the implementation.
38+ _http : HTTPClient
39+ Internal HTTP client instance.
40+ _minio : MinIOClient or None
41+ Internal MinIO client instance, if provided.
42+ """
43+
1744 api_version : APIVersion
1845 resource_type : ResourceType
1946
@@ -22,18 +49,107 @@ def __init__(self, http: HTTPClient, minio: MinIOClient | None = None):
2249 self ._minio = minio
2350
2451 @abstractmethod
25- def delete (self , resource_id : int ) -> bool : ...
52+ def delete (self , resource_id : int ) -> bool :
53+ """
54+ Delete a resource by its identifier.
55+
56+ Parameters
57+ ----------
58+ resource_id : int
59+ Unique identifier of the resource to delete.
60+
61+ Returns
62+ -------
63+ bool
64+ ``True`` if the deletion was successful.
65+
66+ Notes
67+ -----
68+ Concrete subclasses must implement this method.
69+ """
2670
2771 @abstractmethod
28- def publish (self , path : str , files : Mapping [str , Any ] | None ) -> int : ...
72+ def publish (self , path : str , files : Mapping [str , Any ] | None ) -> int :
73+ """
74+ Publish a new resource to the OpenML server.
75+
76+ Parameters
77+ ----------
78+ path : str
79+ API endpoint path used for publishing the resource.
80+ files : Mapping of str to Any or None
81+ Files or payload data required for publishing. The structure
82+ depends on the resource type.
83+
84+ Returns
85+ -------
86+ int
87+ Identifier of the newly created resource.
88+
89+ Notes
90+ -----
91+ Concrete subclasses must implement this method.
92+ """
2993
3094 @abstractmethod
31- def tag (self , resource_id : int , tag : str ) -> list [str ]: ...
95+ def tag (self , resource_id : int , tag : str ) -> list [str ]:
96+ """
97+ Add a tag to a resource.
98+
99+ Parameters
100+ ----------
101+ resource_id : int
102+ Identifier of the resource to tag.
103+ tag : str
104+ Tag to associate with the resource.
105+
106+ Returns
107+ -------
108+ list of str
109+ Updated list of tags assigned to the resource.
110+
111+ Notes
112+ -----
113+ Concrete subclasses must implement this method.
114+ """
32115
33116 @abstractmethod
34- def untag (self , resource_id : int , tag : str ) -> list [str ]: ...
117+ def untag (self , resource_id : int , tag : str ) -> list [str ]:
118+ """
119+ Remove a tag from a resource.
120+
121+ Parameters
122+ ----------
123+ resource_id : int
124+ Identifier of the resource to untag.
125+ tag : str
126+ Tag to remove from the resource.
127+
128+ Returns
129+ -------
130+ list of str
131+ Updated list of tags assigned to the resource.
132+
133+ Notes
134+ -----
135+ Concrete subclasses must implement this method.
136+ """
35137
36138 def _not_supported (self , * , method : str ) -> NoReturn :
139+ """
140+ Raise an error indicating that a method is not supported.
141+
142+ Parameters
143+ ----------
144+ method : str
145+ Name of the unsupported method.
146+
147+ Raises
148+ ------
149+ OpenMLNotSupportedError
150+ If the current API version does not support the requested method
151+ for the given resource type.
152+ """
37153 version = getattr (self .api_version , "value" , "unknown" )
38154 resource = getattr (self .resource_type , "value" , "unknown" )
39155
0 commit comments