Abstraction over operator node. Operator holds its inputs (all arguments passed to operator) and outputs (resulting tables). Inputs and outputs retain their original order.
| 82 | |
| 83 | |
| 84 | class Operator(ABC): |
| 85 | """Abstraction over operator node. |
| 86 | |
| 87 | Operator holds its inputs (all arguments passed to operator) and outputs (resulting tables). |
| 88 | Inputs and outputs retain their original order. |
| 89 | """ |
| 90 | |
| 91 | _inputs: dict[str, InputHandle] |
| 92 | _outputs: dict[str, OutputHandle] |
| 93 | trace: Trace |
| 94 | graph: SetOnceProperty[ParseGraph] = SetOnceProperty() |
| 95 | id: int |
| 96 | error_log: tables.Table | None |
| 97 | |
| 98 | def __init__(self, id: int) -> None: |
| 99 | self.id = id |
| 100 | self._inputs = {} |
| 101 | self._outputs = {} |
| 102 | self.trace = Trace.from_traceback() |
| 103 | |
| 104 | @property |
| 105 | def output_tables(self) -> Iterable[tables.Table]: |
| 106 | return (output.value for output in self.outputs) |
| 107 | |
| 108 | @cached_property |
| 109 | def intermediate_and_output_tables(self) -> Iterable[tables.Table]: |
| 110 | return list( |
| 111 | chain( |
| 112 | *( |
| 113 | table._id_column.context.intermediate_tables() |
| 114 | for table in self.output_tables |
| 115 | ), |
| 116 | self.output_tables, |
| 117 | ) |
| 118 | ) |
| 119 | |
| 120 | @property |
| 121 | def input_tables(self) -> StableSet[tables.Table]: |
| 122 | return StableSet.union( |
| 123 | *(i.value._operator_dependencies() for i in self._inputs.values()) |
| 124 | ) |
| 125 | |
| 126 | @property |
| 127 | def inputs(self) -> list[InputHandle]: |
| 128 | return list(self._inputs.values()) |
| 129 | |
| 130 | @property |
| 131 | def outputs(self) -> list[OutputHandle]: |
| 132 | return list(self._outputs.values()) |
| 133 | |
| 134 | def get_input(self, name: str) -> InputHandle: |
| 135 | return self._inputs[name] |
| 136 | |
| 137 | def get_output(self, name: str) -> OutputHandle: |
| 138 | return self._outputs[name] |
| 139 | |
| 140 | def get_table(self, name: str) -> tables.Table: |
| 141 | return self._outputs[name].value |
nothing calls this directly
no test coverage detected