MCPcopy Create free account
hub / github.com/assemblerflow/flowcraft / set_channels

Method set_channels

flowcraft/generator/process.py:444–487  ·  view source on GitHub ↗

General purpose method that sets the main channels This method will take a variable number of keyword arguments to set the :py:attr:`Process._context` attribute with the information on the main channels for the process. This is done by appending the process ID (:py:

(self, **kwargs)

Source from the content-addressed store, hash-verified

442 return x
443
444 def set_channels(self, **kwargs):
445 """ General purpose method that sets the main channels
446
447 This method will take a variable number of keyword arguments to
448 set the :py:attr:`Process._context` attribute with the information
449 on the main channels for the process. This is done by appending
450 the process ID (:py:attr:`Process.pid`) attribute to the input,
451 output and status channel prefix strings. In the output channel,
452 the process ID is incremented by 1 to allow the connection with the
453 channel in the next process.
454
455 The ``**kwargs`` system for setting the :py:attr:`Process._context`
456 attribute also provides additional flexibility. In this way,
457 individual processes can provide additional information not covered
458 in this method, without changing it.
459
460 Parameters
461 ----------
462 kwargs : dict
463 Dictionary with the keyword arguments for setting up the template
464 context
465 """
466
467 if not self.pid:
468 self.pid = "{}_{}".format(self.lane, kwargs.get("pid"))
469
470 for i in self.status_channels:
471 if i.startswith("STATUS_"):
472 self.status_strs.append("{}_{}".format(i, self.pid))
473 else:
474 self.status_strs.append("STATUS_{}_{}".format(i, self.pid))
475
476 if self.main_forks:
477 logger.debug("Setting main fork channels: {}".format(
478 self.main_forks))
479 operator = "set" if len(self.main_forks) == 1 else "into"
480 self.forks = ["\n{}.{}{{ {} }}\n".format(
481 self.output_channel, operator, ";".join(self.main_forks))]
482
483 self._context = {**kwargs, **{"input_channel": self.input_channel,
484 "output_channel": self.output_channel,
485 "template": self.template,
486 "forks": "\n".join(self.forks),
487 "pid": self.pid}}
488
489 def update_main_input(self, input_str):
490

Calls

no outgoing calls