Operator
DeclarativeOperator
Bases: Operator
DeclarativeOperator is a specialized Operator that declaratively specifies the execution of the operator as a set of plans.
Declarative plans are specified as part of the operator attributes plans which are added to the main plan as part of the planning / refine phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
properties
|
Dict[str, Any]
|
Properties dictionary containing plan definitions and other operator properties. Defaults to None. |
None
|
Source code in blue/operators/operator.py
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | |
Operator
Bases: Tool
Base class for all operators in the Blue framework.
Data in operator scope refers to JSON array of records (list of dictionaries) in Blue. Operator is a specialized Tool to perform data operations in Blue. Input data for operators: always expects multiple Data as [data_1, data_2, ...] (list of lists of dictionaries) Output data for operators: same as input data, always returns a list of JSON array of records. If there is only one data returned, it will return a list with one element (data).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the operator. |
required |
function
|
Callable
|
The operator function to execute. Defaults to default_operator_function. |
None
|
description
|
str
|
Description of the operator. Defaults to None. |
None
|
properties
|
Dict[str, Any]
|
Properties dictionary for the operator. Defaults to None. |
None
|
validator
|
Callable
|
Validation function for operator attributes. Defaults to default_operator_validator. |
None
|
explainer
|
Callable
|
Explanation function for operator output. Defaults to default_operator_explainer. |
None
|
refiner
|
Callable
|
Refinement function for operator planning. Defaults to default_operator_refiner. |
None
|
Source code in blue/operators/operator.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 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 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 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 | |
__init__(name, function=None, description=None, properties=None, validator=None, explainer=None, refiner=None)
Initialize the Operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the operator. |
required |
function
|
Callable
|
The operator function to execute. Defaults to default_operator_function. |
None
|
description
|
str
|
Description of the operator. Defaults to None. |
None
|
properties
|
Dict[str, Any]
|
Properties dictionary for the operator. Defaults to None. |
None
|
validator
|
Callable
|
Validation function for operator attributes. Defaults to default_operator_validator. |
None
|
explainer
|
Callable
|
Explanation function for operator output. Defaults to default_operator_explainer. |
None
|
refiner
|
callable
|
Refinement function for operator planning. Defaults to default_operator_refiner. |
None
|
Source code in blue/operators/operator.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
get_attribute(attribute)
Get a specific operator attribute definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Name of the attribute to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
(dict, None)
|
Dictionary containing the attribute definition, or None if not found. |
Source code in blue/operators/operator.py
261 262 263 264 265 266 267 268 269 270 271 272 273 | |
get_attribute_description(attribute)
Get the description of a specific operator attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Name of the attribute. |
required |
Returns:
| Type | Description |
|---|---|
(str, None)
|
String containing the attribute description, or None if not found. |
Source code in blue/operators/operator.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
get_attribute_type(attribute)
Get the type of a specific operator attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Name of the attribute. |
required |
Returns:
| Type | Description |
|---|---|
(str, None)
|
String containing the attribute type, or None if not found. |
Source code in blue/operators/operator.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
get_attributes()
Get all operator attributes.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing all operator attributes and their definitions. |
Source code in blue/operators/operator.py
237 238 239 240 241 242 243 | |
get_hyperparameters()
Get all operator hyperparameters.
Returns:
| Type | Description |
|---|---|
|
Dictionary containing all operator hyperparameters. |
Source code in blue/operators/operator.py
377 378 379 380 381 382 383 | |
get_tool_type(function_or_operator)
classmethod
Get the type of a function/operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_or_operator
|
The object to check. |
required |
Returns:
| Type | Description |
|---|---|
str
|
String indicating the type: "operator" or "function". |
Source code in blue/operators/operator.py
412 413 414 415 416 417 418 419 420 421 422 423 424 | |
is_attribute_hidden(attribute)
Check if a specific operator attribute is hidden.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Name of the attribute. |
required |
Returns:
| Type | Description |
|---|---|
|
Boolean indicating if the attribute is hidden, or None if not found. |
Source code in blue/operators/operator.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
is_attribute_required(attribute)
Check if a specific operator attribute is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Name of the attribute. |
required |
Returns:
| Type | Description |
|---|---|
|
Boolean indicating if the attribute is required, or None if not found. |
Source code in blue/operators/operator.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
is_operator(function_or_operator)
classmethod
Check if a tool/operator is actually an operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_or_operator
|
The object to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the object is an operator, False otherwise. |
Source code in blue/operators/operator.py
398 399 400 401 402 403 404 405 406 407 408 409 410 | |
set_attribute_description(attribute, description)
Set the description of a specific operator attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Name of the attribute. |
required | |
description
|
str
|
New description for the attribute. |
required |
Source code in blue/operators/operator.py
305 306 307 308 309 310 311 312 313 314 315 316 317 | |
set_attribute_hidden(attribute, hidden)
Set whether a specific operator attribute is hidden.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Name of the attribute. |
required | |
hidden
|
Boolean indicating if the attribute is hidden. |
required |
Source code in blue/operators/operator.py
333 334 335 336 337 338 339 340 341 342 343 344 345 | |
set_attribute_required(attribute, required)
Set whether a specific operator attribute is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
Name of the attribute. |
required | |
required
|
bool
|
Boolean indicating if the attribute is required. |
required |
Source code in blue/operators/operator.py
319 320 321 322 323 324 325 326 327 328 329 330 331 | |
update_attributes(attributes=None)
Update operator attributes with new definitions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
(dict, None)
|
attributes: Dictionary of attribute definitions to update. Defaults to None. |
required |
Source code in blue/operators/operator.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
update_hyperparameters(hyperparameters=None)
Update operator hyperparameters with new values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hyperparameters
|
Dictionary of hyperparameter values to update. Defaults to None. |
None
|
Source code in blue/operators/operator.py
385 386 387 388 389 390 391 392 393 394 395 | |
declarative_operator_explainer(output, input_data, attributes)
Generate explanation for declarative operator execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
Any
|
The output result from the operator execution. |
required |
input_data
|
List[List[Dict[str, Any]]]
|
The input data that was processed. |
required |
attributes
|
Dict[str, Any]
|
The attributes used for the operation. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary containing explanation of the declarative operation. |
Source code in blue/operators/operator.py
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | |
declarative_operator_function(input_data, attributes, properties=None)
Default function for declarative operator, simply passes execution to sub plans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
List[List[Dict[str, Any]]]
|
List of JSON arrays (List[List[Dict[str, Any]]]) containing records to process. |
required |
attributes
|
Dict[str, Any]
|
Dictionary containing operator-specific parameters. |
required |
properties
|
Dict[str, Any]
|
Optional properties dictionary containing plan definitions. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
List[List[Dict[str, Any]]]
|
List containing empty results as default implementation. |
Source code in blue/operators/operator.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 | |
declarative_operator_refiner(input_data, attributes, properties=None)
Default refiner for declarative operator, returning plans declaratively specified as operator properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
List[List[Dict[str, Any]]]
|
List of JSON arrays (List[List[Dict[str, Any]]]) containing records to process. |
required |
attributes
|
Dict[str, Any]
|
Dictionary containing operator-specific parameters. |
required |
properties
|
Dict[str, Any]
|
Optional properties dictionary containing plan definitions. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List containing pipeline definitions based on declarative plans. |
Source code in blue/operators/operator.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | |
declarative_operator_validator(input_data, attributes, properties=None)
Validate declarative operator attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
List[List[Dict[str, Any]]]
|
List of JSON arrays (List[List[Dict[str, Any]]]) to validate. |
required |
attributes
|
Dict[str, Any]
|
Dictionary containing operator attributes to validate. |
required |
properties
|
Dict[str, Any]
|
Optional properties dictionary. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if attributes are valid, False otherwise. |
Source code in blue/operators/operator.py
645 646 647 648 649 650 651 652 653 654 655 656 | |
default_attributes_validator(attributes, properties=None)
Validate actual attributes (attributes) using the attribute definitions in properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attributes
|
Dict[str, Any]
|
Dictionary containing actual attribute values to validate. |
required |
properties
|
Dict[str, Any]
|
Optional properties dictionary containing attribute definitions. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if attributes are valid, False otherwise. |
Source code in blue/operators/operator.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
default_operator_explainer(output, input_data, attributes)
Default explainer for operator output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
Any
|
The output result from the operator execution. |
required |
input_data
|
List[List[Dict[str, Any]]]
|
List of JSON arrays (List[List[Dict[str, Any]]]) that was processed. |
required |
attributes
|
Dict[str, Any]
|
The attributes used for the operation. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary containing explanation of the operation with statistics. |
Source code in blue/operators/operator.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
default_operator_function(input_data, attributes, properties=None)
Default function for operator. It should be overridden by each operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
List[List[Dict[str, Any]]]
|
List of JSON arrays (List[List[Dict[str, Any]]]) containing records to process. |
required |
attributes
|
Dict[str, Any]
|
Dictionary containing operator-specific parameters. |
required |
properties
|
Dict[str, Any]
|
Optional properties dictionary. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
List[List[Dict[str, Any]]]
|
Empty list as default implementation. |
Source code in blue/operators/operator.py
22 23 24 25 26 27 28 29 30 31 32 33 | |
default_operator_refiner(input_data, attributes, properties=None)
Default refiner for operator. It should be overridden by each operator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
List[List[Dict[str, Any]]]
|
List of JSON arrays (List[List[Dict[str, Any]]]) containing records to process. |
required |
attributes
|
Dict[str, Any]
|
Dictionary containing operator-specific parameters. |
required |
properties
|
Dict[str, Any]
|
Optional properties dictionary. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
Empty list as default implementation. |
Source code in blue/operators/operator.py
36 37 38 39 40 41 42 43 44 45 46 47 | |
default_operator_validator(input_data, attributes, properties=None)
Default validator for operator attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
List[List[Dict[str, Any]]]
|
List of JSON arrays (List[List[Dict[str, Any]]]) to validate. |
required |
attributes
|
Dict[str, Any]
|
Dictionary containing operator attributes to validate. |
required |
properties
|
Dict[str, Any]
|
Optional properties dictionary. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if attributes are valid, False otherwise. |
Source code in blue/operators/operator.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |