functions
openml.flows.functions
#
assert_flows_equal
#
assert_flows_equal(flow1: OpenMLFlow, flow2: OpenMLFlow, ignore_parameter_values_on_older_children: str | None = None, ignore_parameter_values: bool = False, ignore_custom_name_if_none: bool = False, check_description: bool = True) -> None
Check equality of two flows.
Two flows are equal if their all keys which are not set by the server are equal, as well as all their parameters and components.
| PARAMETER | DESCRIPTION |
|---|---|
flow1
|
TYPE:
|
flow2
|
TYPE:
|
ignore_parameter_values_on_older_children
|
If set to
TYPE:
|
ignore_parameter_values
|
Whether to ignore parameter values when comparing flows.
TYPE:
|
ignore_custom_name_if_none
|
Whether to ignore the custom name field if either flow has
TYPE:
|
check_description
|
Whether to ignore matching of flow descriptions.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
When either argument is not an :class: |
ValueError
|
When a relevant mismatch is found between the two flows. |
Examples:
>>> import openml
>>> f1 = openml.flows.get_flow(5)
>>> f2 = openml.flows.get_flow(5)
>>> openml.flows.assert_flows_equal(f1, f2)
>>> # If flows differ, a ValueError is raised
Source code in openml/flows/functions.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
delete_flow
#
Delete flow with id flow_id from the OpenML server.
You can only delete flows which you uploaded and which which are not linked to runs.
| PARAMETER | DESCRIPTION |
|---|---|
flow_id
|
OpenML id of the flow
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the deletion was successful. False otherwise. |
| RAISES | DESCRIPTION |
|---|---|
OpenMLServerException
|
If the server-side deletion fails due to permissions or other errors. |
Side Effects
- Removes the flow from the OpenML server (if permitted).
Examples:
>>> import openml
>>> # Deletes flow 23 if you are the uploader and it's not linked to runs
>>> openml.flows.delete_flow(23)
Source code in openml/flows/functions.py
flow_exists
#
Check whether a flow (name + external_version) exists on the server.
The OpenML server defines uniqueness of flows by the pair
(name, external_version). This helper queries the server and
returns the corresponding flow id when present.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Flow name (e.g.,
TYPE:
|
external_version
|
Version information associated with flow.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int or bool
|
The flow id if the flow exists on the server, otherwise |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
OpenMLServerException
|
When the API request fails. |
Examples:
Source code in openml/flows/functions.py
get_flow
#
get_flow(flow_id: int, reinstantiate: bool = False, strict_version: bool = True) -> OpenMLFlow
Fetch an OpenMLFlow by its server-assigned ID.
Queries the OpenML REST API for the flow metadata and returns an
:class:OpenMLFlow instance. If the flow is already cached locally,
the cached copy is returned. Optionally the flow can be re-instantiated
into a concrete model instance using the registered extension.
| PARAMETER | DESCRIPTION |
|---|---|
flow_id
|
The OpenML flow id.
TYPE:
|
reinstantiate
|
If True, convert the flow description into a concrete model instance
using the flow's extension (e.g., sklearn). If conversion fails and
TYPE:
|
strict_version
|
When
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
OpenMLFlow
|
The flow object with metadata; |
| RAISES | DESCRIPTION |
|---|---|
OpenMLServerException
|
When the REST API call fails. |
Side Effects
- Caches the retrieved flow using the HTTP client's caching mechanism.
Preconditions
- Network access to the OpenML server is required unless the flow is cached.
- For private flows,
openml.config.apikeymust be set.
Notes
Results are cached to speed up subsequent calls. When reinstantiate is
True and version mismatches occur, a new flow may be returned to reflect
the converted model (only when strict_version is False).
Examples:
Source code in openml/flows/functions.py
get_flow_id
#
get_flow_id(model: Any | None = None, name: str | None = None, exact_version: bool = True) -> int | bool | list[int]
Retrieve flow id(s) for a model instance or a flow name.
Provide either a concrete model (which will be converted to a flow by
the appropriate extension) or a flow name. Behavior depends on
exact_version:
model+exact_version=True: convertmodelto a flow and call :func:flow_existsto get a single flow id (or False).model+exact_version=False: convertmodelto a flow and return all server flow ids with the same flow name.name: ignoreexact_versionand return all server flow ids that matchname.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
TYPE:
|
name
|
TYPE:
|
exact_version
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int or bool or list[int]
|
If |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If neither |
OpenMLServerException
|
If underlying API calls fail. |
Side Effects
- May call server APIs (
flow/exists,flow/list) and therefore depends on network access and API keys for private flows.
Examples:
>>> import openml
>>> # Lookup by flow name
>>> openml.flows.get_flow_id(name="weka.JRip")
>>> # Lookup by model instance (requires a registered extension)
>>> import sklearn
>>> import openml_sklearn
>>> clf = sklearn.tree.DecisionTreeClassifier()
>>> openml.flows.get_flow_id(model=clf)
Source code in openml/flows/functions.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
list_flows
#
list_flows(offset: int | None = None, size: int | None = None, tag: str | None = None, uploader: str | None = None) -> DataFrame
List flows available on the OpenML server.
This function supports paging and filtering and returns a pandas DataFrame with one row per flow and columns for id, name, version, external_version, full_name and uploader.
| PARAMETER | DESCRIPTION |
|---|---|
offset
|
Number of flows to skip, starting from the first (for paging).
TYPE:
|
size
|
Maximum number of flows to return.
TYPE:
|
tag
|
Only return flows having this tag.
TYPE:
|
uploader
|
Only return flows uploaded by this user.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
Rows correspond to flows. Columns include |
| RAISES | DESCRIPTION |
|---|---|
OpenMLServerException
|
When the API call fails. |
Side Effects
- None: results are fetched and returned; Read-only operation.
Preconditions
- Network access is required to list flows unless cached mechanisms are used by the underlying API helper.
Examples: