<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python SDK - Distinguish left and right input in the def ii_push_record Method in Dev Space</title>
    <link>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/184425#M503</link>
    <description>&lt;P&gt;Thanks for your clarification ! It worked ! Much appreciated for your help !&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jul 2018 04:24:58 GMT</pubDate>
    <dc:creator>Chriszou</dc:creator>
    <dc:date>2018-07-18T04:24:58Z</dc:date>
    <item>
      <title>Python SDK - Distinguish left and right input in the def ii_push_record Method</title>
      <link>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/182727#M485</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a Python plugin that has two input steams (left and right). When Alteryx is calling the "def ii_push_record", is there a way we could tell if a given in_record is associated to the left or right input stream ? Below is the snippet of the Python push_record method. Thanks for your help&amp;nbsp; !&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;def ii_push_record(self, in_record: object) -&amp;gt; bool:&lt;BR /&gt;"""&lt;BR /&gt;Preserving the state of the incoming record data, since the reference to a record dies beyond this point.&lt;BR /&gt;Called when an input record is being sent to the plugin.&lt;BR /&gt;:param in_record: The data for the incoming record.&lt;BR /&gt;:return: False if method calling limit (record_cnt) is hit.&lt;BR /&gt;"""&lt;/P&gt;&lt;P&gt;self.record_list.append(self.record_info_in.construct_record_creator())&lt;BR /&gt;self.record_copier.copy(self.record_list[-1], in_record)&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 19:40:10 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/182727#M485</guid>
      <dc:creator>Chriszou</dc:creator>
      <dc:date>2018-07-12T19:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK - Distinguish left and right input in the def ii_push_record Method</title>
      <link>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/182918#M486</link>
      <description>&lt;P&gt;The association happens when Alteryx calls pi_add_incoming_connection on your plugin class.&amp;nbsp; One of the parameters of pi_add_incoming_connection is the name of the incoming connection.&amp;nbsp; This function needs to return an object that implements the incoming interface.&amp;nbsp; I would recommend using a separate class to implement the incoming interface; it keeps things a bit more separated and cleaner.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One option is to process the records directly in the incoming interface class.&amp;nbsp; An example might look something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;class MyPlugin:
    def pi_add_incoming_connection(self, str_type, str_name):
        return Input(str_name)&lt;BR /&gt;&lt;BR /&gt;    # The rest of the pi_ methods are defined in this class

class Input:
    def __init__(self, input_str_name: str):
        self.input_str_name = input_str_name

    def ii_push_records(self, in_record):
        if self.input_str_name == 'Left':
            doSomething(in_record)
        elif self.input_str_name == 'Right':
            doSomethingElse(in_record)&lt;BR /&gt;&lt;BR /&gt;    # the rest of the ii_ methods are defined in this class&lt;/PRE&gt;&lt;P&gt;In this example the incoming connection name is passed to the Input class, which then executes ii_push_records differently based on the value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If, for some reason, you need to handle the logic in the plugin class, you could pass a reference&amp;nbsp;of the plugin class to your incoming interface class and then call the necessary methods on the plugin.&amp;nbsp; An example might look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;class MyPlugin:
    def pi_add_incoming_connection(self, str_type, str_name):
        return Input(self,str_name)

    def processRecord(self,input_str_name: str, in_record):
        if input_str_name == 'Left':
            doSomething(in_record)
        elif input_str_name == 'Right':
            doSomethingElse(in_record)
&lt;BR /&gt;    # The rest of the pi_ methods are defined in this class&lt;BR /&gt;
class Input:
    def __init__(self, parent: MyPlugin, input_str_name: str):
        self.parent = parent
        self.input_str_name = input_str_name

    def ii_push_records(self, in_record):
        self.parent.processRecord(self.input_str_name,in_record)&lt;BR /&gt;&lt;BR /&gt;    # the rest of the ii_ methods are defined in this class&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 03:17:22 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/182918#M486</guid>
      <dc:creator>tlarsen7572</dc:creator>
      <dc:date>2018-07-13T03:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK - Distinguish left and right input in the def ii_push_record Method</title>
      <link>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/183092#M487</link>
      <description>&lt;P&gt;Thanks for your quick response !&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think below codes should work but have a few questions and hope you can clarify. (I am still learning the Python SDK, please forgive all my dump questions):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1, for the return statement (return Input(str_name)) in the MyPlugin class. Can you explain where the Input() function come from ? I noticed sample code returns a IncomingInterface object here so want to confirm what this line of code is doing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2, for the Input class: I noticed you wrote the init method as follow "def __init__(self, input_str_name: str):". The sample code was written as follow "&amp;nbsp;__init__(self, parent: object)". Is this going to work since Alteryx might not recognize the "&lt;SPAN&gt;input_str_name: str" argument.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;class MyPlugin:
    def pi_add_incoming_connection(self, str_type, str_name):
        return Input(str_name)&lt;BR /&gt;&lt;BR /&gt;    # The rest of the pi_ methods are defined in this class

class Input:
    def __init__(self, input_str_name: str):
        self.input_str_name = input_str_name

    def ii_push_records(self, in_record):
        if self.input_str_name == 'Left':
            doSomething(in_record)
        elif self.input_str_name == 'Right':
            doSomethingElse(in_record)&lt;BR /&gt;&lt;BR /&gt;    # the rest of the ii_ methods are defined in this class&amp;nbsp;I&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 14:47:10 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/183092#M487</guid>
      <dc:creator>Chriszou</dc:creator>
      <dc:date>2018-07-13T14:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK - Distinguish left and right input in the def ii_push_record Method</title>
      <link>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/183102#M488</link>
      <description>&lt;P&gt;The Input() statement is the constructor for the Input class.&amp;nbsp; When you create a class in Python, you instantiate an instance of that class using its name.&amp;nbsp; Python links it all together behind the scenes.&amp;nbsp; The __init__ method in the Input class is what ends up getting called when you run Input().&amp;nbsp; As long as the Input class implements all of the IncomingInterface methods, then returning Input() will return an IncomingInterface object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For 2, I think it would still work, but it might be nice if the Input class holds a reference to the plugin class, so you can, e.g., call methods on the Alteryx engine object which is usually stored in the plugin class.&amp;nbsp; You should be able to do something like this and everything will play nicely with Alteryx:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;class MyPlugin:
    def pi_add_incoming_connection(self, str_type, str_name):
        return Input(self, str_name)

    # The rest of the pi_ methods are defined in this class

class Input:
    def __init__(self, parent: MyPlugin, input_str_name: str):
        self.parent = parent
        self.input_str_name = input_str_name

    def ii_push_records(self, in_record):
        if self.input_str_name == 'Left':
            doSomething(in_record)
        elif self.input_str_name == 'Right':
            doSomethingElse(in_record)

    # the rest of the ii_ methods are defined in this class&lt;/PRE&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 15:29:13 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/183102#M488</guid>
      <dc:creator>tlarsen7572</dc:creator>
      <dc:date>2018-07-13T15:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK - Distinguish left and right input in the def ii_push_record Method</title>
      <link>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/184425#M503</link>
      <description>&lt;P&gt;Thanks for your clarification ! It worked ! Much appreciated for your help !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 04:24:58 GMT</pubDate>
      <guid>https://community.alteryx.com/t5/Dev-Space/Python-SDK-Distinguish-left-and-right-input-in-the-def-ii-push/m-p/184425#M503</guid>
      <dc:creator>Chriszou</dc:creator>
      <dc:date>2018-07-18T04:24:58Z</dc:date>
    </item>
  </channel>
</rss>

