def generateSPLOperator(self): _op = {} _op["name"] = self.name _op["kind"] = self.kind _op["partitioned"] = False if self._start_op: _op["startOp"] = True _outputs = [] _inputs = [] for output in self.outputPorts: _outputs.append(output.getSPLOutputPort()) for input in self.inputPorts: _inputs.append(input.getSPLInputPort()) _op["outputs"] = _outputs _op["inputs"] = _inputs _op["config"] = {} _op["config"]["streamViewability"] = self.viewable _op["config"]["viewConfigs"] = self.view_configs if self._placement: _op["config"]["placement"] = self._placement if 'resourceTags' in self._placement: # Convert the set to a list for JSON tags = _op['config']['placement']['resourceTags'] _op['config']['placement']['resourceTags'] = list(tags) # Add parameters as their string representation # unless they value has a spl_json() function, # then use that _params = {} # Fix up any pending streams for input style if 'pyStyle' in self.params and 'pending' == self.params['pyStyle']\ and self.kind.startswith('com.ibm.streamsx.topology.functional.python'): StreamSchema._fnop_style(self.inputPorts[0].schema, self, 'pyStyle') for name in self.params: param = self.params[name] try: _params[name] = param.spl_json() except: _value = {} _value["value"] = param _params[name] = _value _op["parameters"] = _params if self.sl is not None: _op['sourcelocation'] = self.sl.spl_json() if self._layout_hints: _op['layout'] = self._layout_hints # Callout to allow a ExtensionOperator # to augment the JSON if hasattr(self, '_ex_op'): self._ex_op._generate(_op) return _op
def generateSPLOperator(self): _op = dict(self._op_def) _op["name"] = self.name if self.category: _op["category"] = self.category _op["kind"] = self.kind if self.model: _op["model"] = self.model if self.language: _op["language"] = self.language _op["partitioned"] = False if self._start_op: _op["startOp"] = True _outputs = [] _inputs = [] for output in self.outputPorts: _outputs.append(output.getSPLOutputPort()) for input in self.inputPorts: _inputs.append(input.getSPLInputPort()) _op["outputs"] = _outputs _op["inputs"] = _inputs _op["config"] = self.config _op["config"]["streamViewability"] = self.viewable _op["config"]["viewConfigs"] = list(self.view_configs.values()) if self._placement: _op["config"]["placement"] = self._placement if 'resourceTags' in self._placement: # Convert the set to a list for JSON tags = _op['config']['placement']['resourceTags'] _op['config']['placement']['resourceTags'] = list(tags) # Fix up any pending streams for input style if 'pyStyle' in self.params and 'pending' == self.params['pyStyle']\ and self.kind.startswith('com.ibm.streamsx.topology.functional.python'): StreamSchema._fnop_style(self.inputPorts[0].schema, self, 'pyStyle') # Add parameters as their natural representation # unless they value has a spl_json() function, # then use that _params = {} for name in self.params: param = _as_spl_expr(self.params[name]) try: _params[name] = param.spl_json() except: _value = {} _value["value"] = param _params[name] = _value _op["parameters"] = _params if self.sl is not None: _op['sourcelocation'] = self.sl.spl_json() if self._layout_hints: _op['layout'] = self._layout_hints if self._consistent is not None: _op['consistent'] = {} consistent = _op['consistent'] consistent['trigger'] = self._consistent.trigger.name if self._consistent.trigger == streamsx.topology.state.ConsistentRegionConfig.Trigger.PERIODIC: if isinstance(self._consistent.period, datetime.timedelta): consistent_period = self._consistent.period.total_seconds() else: consistent_period = float(self._consistent.period) consistent['period'] = str(consistent_period) if isinstance(self._consistent.drain_timeout, datetime.timedelta): consistent_drain = self._consistent.drain_timeout.total_seconds(); else: consistent_drain = float(self._consistent.drain_timeout) consistent['drainTimeout'] = str(consistent_drain) if isinstance(self._consistent.reset_timeout, datetime.timedelta): consistent_reset = self._consistent.reset_timeout.total_seconds(); else: consistent_reset = float(self._consistent.reset_timeout) consistent['resetTimeout'] = str(consistent_reset) consistent['maxConsecutiveResetAttempts'] = int(self._consistent.max_consecutive_attempts) # Callout to allow a ExtensionOperator # to augment the JSON if hasattr(self, '_ex_op'): self._ex_op._generate(_op) return _op