Operations
Operations are functions that operate on either a list of the examples or a single example. If the function operates on a single example, Recon will take care of applying it to all examples in a dataset.
The following operations are built into Recon
Error
... full list of operations to come
Operation
¶
Operation class that takes care of calling and reporting the results of an operation on a Dataset
__call__(self, dataset, *args, **kwargs)
¶
Show source code in recon/operations.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 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 145 146 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 |
|
Runs op on a dataset and records the results
Parameters
Name | Type | Description | Default |
---|---|---|---|
dataset |
Any |
Dataset to operate on | required |
Exceptions
Type | Description |
---|---|
ValueError |
if track_example is called in the op with no data |
Returns
Type | Description |
---|---|
OperationResult |
OperationResult: Container holding new data and the state of the Operation |
__init__(self, name, pre, op)
¶
Show source code in recon/operations.py
88 89 90 91 92 93 94 95 96 97 98 |
|
Initialize an Operation instance
Parameters
Name | Type | Description | Default |
---|---|---|---|
name |
str |
Name of operation | required |
pre |
List[recon.preprocess.PreProcessor] |
List of preprocessors to run | required |
op |
Callable |
Decorated function | required |
operation
¶
__call__(self, *args, **kwargs)
¶
Show source code in recon/operations.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
Decorator for an operation. The first arg is the function being decorated. This function can either operate on a List[Example] and in that case self.batch should be True.
e.g. @operation("recon.v1.some_name", batch=True)
Or it should operate on a single example and recon will take care of applying it to a full Dataset
Parameters
Name | Type | Description | Default |
---|---|---|---|
*args |
Any |
First arg is function to decorate | () |
Returns
Type | Description |
---|---|
Callable |
Callable: Original function |
__init__(self, name, pre=[])
¶
Show source code in recon/operations.py
51 52 53 54 55 56 57 58 59 |
|
Decorate an operation that makes some changes to a dataset.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name |
str |
Operation name. | required |
pre |
List[recon.preprocess.PreProcessor] |
List of preprocessors to run | [] |
op_iter(data, pre)
¶
Show source code in recon/operations.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
Iterate over list of examples for an operation yielding tuples of (example hash, example)
Parameters
Name | Type | Description | Default |
---|---|---|---|
data |
List[recon.types.Example] |
List of examples to iterate | required |
pre |
List[recon.preprocess.PreProcessor] |
List of preprocessors to run | required |
Yields: Iterator[Tuple[int, Example]]: Tuples of (example hash, example)