MCPcopy Index your code
hub / github.com/pathwaycom/pathway / add_iterate

Method add_iterate

python/pathway/internals/parse_graph.py:156–180  ·  view source on GitHub ↗

Adds iterate operator. New scope is added to stack before calling iteration result. This scope is then preserved in IterateOperator node and removed from the stack. Args: body: specification of an iterated body function call_operator: iterate opereat

(
        self,
        body: FunctionSpec,
        call_operator: Callable[[operator.IterateOperator], T],
        iteration_limit: int | None = None,
    )

Source from the content-addressed store, hash-verified

154 return result
155
156 def add_iterate(
157 self,
158 body: FunctionSpec,
159 call_operator: Callable[[operator.IterateOperator], T],
160 iteration_limit: int | None = None,
161 ) -> T:
162 """Adds iterate operator.
163
164 New scope is added to stack before calling iteration result. This scope is then preserved
165 in IterateOperator node and removed from the stack.
166
167 Args:
168 body: specification of an iterated body function
169 call_operator: iterate opereator callback
170 """
171
172 def create_node(id: int) -> operator.IterateOperator:
173 return operator.IterateOperator(body, id, iterate_scope, iteration_limit)
174
175 def call_operator_in_scope(o: operator.IterateOperator) -> T:
176 with iterate_scope:
177 return call_operator(o)
178
179 iterate_scope = self.new_scope()
180 return self.add_operator(create_node, call_operator_in_scope)
181
182 def add_error_log(self, global_log: bool = False) -> Table[ErrorLogSchema]:
183 datasource = ErrorLogDataSource(schema=ErrorLogSchema)

Callers 1

iterateFunction · 0.80

Calls 2

new_scopeMethod · 0.95
add_operatorMethod · 0.95

Tested by

no test coverage detected