<?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: Passing a Datagrid from Python Code file in Intelligent Decisioning in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/731355#M1154</link>
    <description>And what further irks me is that if the computed json strings are not returned in the outputs of the decision flow, they DONT get populated by the program either. I really dont like duplicated nonsense in my interfaces!</description>
    <pubDate>Mon, 05 Apr 2021 13:37:05 GMT</pubDate>
    <dc:creator>klay_martens</dc:creator>
    <dc:date>2021-04-05T13:37:05Z</dc:date>
    <item>
      <title>Passing a Datagrid from Python Code file in Intelligent Decisioning</title>
      <link>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/731328#M1151</link>
      <description>&lt;P&gt;Hi all.&lt;/P&gt;&lt;P&gt;I was wondering if anyone had a more elegant way of doing this: the solution I found was to convert the python object to a json string and then pass this back from the code file to the decision flow, then I use DS2 to convert the json to a datagrid. Works fine, but it seems pretty clumsy.&lt;/P&gt;&lt;P&gt;Just wondering if there was a better way to do this...&lt;/P&gt;&lt;P&gt;I created some utility methods to assist with creating the appropriate objects in Python...&lt;/P&gt;&lt;P&gt;BTW, does anyone else find the lack of proper datatypes for the datagrids in ID a little lame? The fact that we cant pass datetime fields or booleans is really quite silly!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 10:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/731328#M1151</guid>
      <dc:creator>klay_martens</dc:creator>
      <dc:date>2021-04-05T10:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a Datagrid from Python Code file in Intelligent Decisioning</title>
      <link>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/731335#M1152</link>
      <description>&lt;P&gt;For a Python code that is absolutely correct approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;BTW, does anyone else find the lack of proper datatypes for the datagrids in ID a little lame? The fact that we cant pass datetime fields or booleans is really quite silly!&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Data Grids in SAS Intelligent Decision currently supports Characters, Decimal, and Integer columns. There is no boolean data type in DS2, so you have to use integers 1 or 0. Also, you could store datetime in a decimal format.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 10:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/731335#M1152</guid>
      <dc:creator>alexal</dc:creator>
      <dc:date>2021-04-05T10:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a Datagrid from Python Code file in Intelligent Decisioning</title>
      <link>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/731345#M1153</link>
      <description>Lame. You should be able to work with the types natively. RTDM had this facility...its dumb that the latest and greatest does not.</description>
      <pubDate>Mon, 05 Apr 2021 13:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/731345#M1153</guid>
      <dc:creator>klay_martens</dc:creator>
      <dc:date>2021-04-05T13:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a Datagrid from Python Code file in Intelligent Decisioning</title>
      <link>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/731355#M1154</link>
      <description>And what further irks me is that if the computed json strings are not returned in the outputs of the decision flow, they DONT get populated by the program either. I really dont like duplicated nonsense in my interfaces!</description>
      <pubDate>Mon, 05 Apr 2021 13:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/731355#M1154</guid>
      <dc:creator>klay_martens</dc:creator>
      <dc:date>2021-04-05T13:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a Datagrid from Python Code file in Intelligent Decisioning</title>
      <link>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/732122#M1159</link>
      <description>I've created two feature requests for you. May I ask you to describe your problem with computed JSON strings in details? It will be better if you provide an example.</description>
      <pubDate>Thu, 08 Apr 2021 01:45:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/732122#M1159</guid>
      <dc:creator>alexal</dc:creator>
      <dc:date>2021-04-08T01:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a Datagrid from Python Code file in Intelligent Decisioning</title>
      <link>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/732151#M1160</link>
      <description>&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;Thanks for that - the enhancement will be usefull to most, I think. With regards to the JSON issue I mentioned....here is a sample. Start with a Python program which returns a data grid JSON object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;''' List all output parameters as comma-separated values in the "Output:" docString. Do not specify "None" if there is no output parameter. '''&lt;BR /&gt;def execute ():&lt;BR /&gt;'Output:PythonString,PythonNumeric'&lt;BR /&gt;PythonString='''&lt;BR /&gt;[&lt;BR /&gt;{&lt;BR /&gt;"metadata": [&lt;BR /&gt;{&lt;BR /&gt;"ProductAuthenticationQuestionID": "int"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"AnswerID": "int"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"Answer": "string"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"IsEnteredAnswerYN": "int"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"data": [&lt;BR /&gt;[&lt;BR /&gt;28038,&lt;BR /&gt;21388640,&lt;BR /&gt;"No",&lt;BR /&gt;1&lt;BR /&gt;],&lt;BR /&gt;[&lt;BR /&gt;28038,&lt;BR /&gt;21388639,&lt;BR /&gt;"Yes",&lt;BR /&gt;0&lt;BR /&gt;],&lt;BR /&gt;[&lt;BR /&gt;27003,&lt;BR /&gt;21388647,&lt;BR /&gt;"None of these",&lt;BR /&gt;1&lt;BR /&gt;],&lt;BR /&gt;[&lt;BR /&gt;27003,&lt;BR /&gt;21388646,&lt;BR /&gt;"011 DAINFERN",&lt;BR /&gt;0&lt;BR /&gt;]&lt;BR /&gt;]&lt;BR /&gt;} &lt;BR /&gt;]&lt;BR /&gt;'''&lt;BR /&gt;PythonNumeric=100&lt;BR /&gt;return PythonString,PythonNumeric&lt;BR /&gt;&lt;BR /&gt;
&lt;/PRE&gt;&lt;P&gt;And then create a DS2 program which converts the string to a datagrid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;package "${PACKAGE_NAME}" /inline;&lt;BR /&gt;method execute(varchar(2048) PythonString, in_out package datagrid AGrid);&lt;BR /&gt;Ds2String = PythonString; &lt;BR /&gt;DATAGRID_CREATE(AGrid ,PythonString );&lt;BR /&gt;end;&lt;BR /&gt;endpackage;&lt;BR /&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now create a simple decision flow, adding first the Python code file, then the DS2 code file...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 625px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57106i3A0A6D68F431E9D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Leave the Python variables selected as outputs, publish and submit a test score. You get the expected results&lt;/P&gt;&lt;PRE&gt;requestBody='''{
    "inputs":[
        
    ]
}'''
moduleID = "testdecision1_0"
# Define the request URL.
masModuleUrl = "/microanalyticScore/modules/" + moduleID
requestUrl = baseUrl1 + masModuleUrl + "/steps/execute"

# Execute the decision.
masExecutionResponse = post(requestUrl, contentType, 
                       acceptType, accessToken1, requestBody) 
print(masExecutionResponse)
# Display the response.
print ("response=", masExecutionResponse, end='\n\n')
print ("response content=", "\n", json.dumps(json.loads(masExecutionResponse.content), indent=4), end='\n\n') &lt;/PRE&gt;&lt;PRE&gt;&amp;lt;Response [201]&amp;gt;
response= &amp;lt;Response [201]&amp;gt;

response content= 
 {
    "links": [],
    "version": 2,
    "moduleId": "testdecision1_0",
    "stepId": "execute",
    "executionState": "completed",
    "outputs": [
        {
            "name": "AGrid",
            "value": [
                {
                    "metadata": [
                        {
                            "PRODUCTAUTHENTICATIONQUESTIONID": "int"
                        },
                        {
                            "ANSWERID": "int"
                        },
                        {
                            "ANSWER": "string"
                        },
                        {
                            "ISENTEREDANSWERYN": "int"
                        }
                    ]
                },
                {
                    "data": [
                        [
                            28038,
                            21388640,
                            "No",
                            1
                        ],
                        [
                            28038,
                            21388639,
                            "Yes",
                            0
                        ],
                        [
                            27003,
                            21388647,
                            "None of these",
                            1
                        ],
                        [
                            27003,
                            21388646,
                            "011 DAINFERN",
                            0
                        ]
                    ]
                }
            ]
        },
        {
            "name": "PythonNumeric",
            "value": 100.0
        },
        {
            "name": "PythonString",
            "value": "\n  [\n{\n\"metadata\": [\n{\n\"ProductAuthenticationQuestionID\": \"int\"\n},\n{\n\"AnswerID\": \"int\"\n},\n{\n\"Answer\": \"string\"\n},\n{\n\"IsEnteredAnswerYN\": \"int\"\n}\n]\n},\n{\n\"data\": [\n[\n28038,\n21388640,\n\"No\",\n1\n],\n[\n28038,\n21388639,\n\"Yes\",\n0\n],\n[\n27003,\n21388647,\n\"None of these\",\n1\n],\n[\n27003,\n21388646,\n\"011 DAINFERN\",\n0\n]\n]\n}\n]\n   "
        }
    ]
}&lt;/PRE&gt;&lt;P&gt;Now. Switch off the PythonString variable from the reply, and republish:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57108i714E35F1726C4893/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Run the same test again...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;Response [201]&amp;gt;
response= &amp;lt;Response [201]&amp;gt;

response content= 
 {
    "links": [],
    "version": 2,
    "moduleId": "testdecision1_0",
    "stepId": "execute",
    "executionState": "completed",
    "outputs": [
        {
            "name": "AGrid",
            "value": [
                {
                    "metadata": [
                        {
                            "PRODUCTAUTHENTICATIONQUESTIONID": "int"
                        },
                        {
                            "ANSWERID": "int"
                        }
                    ]
                }
            ]
        },
        {
            "name": "PythonNumeric",
            "value": 100.0
        }
    ]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;As you can see, most of the structure and all of the data for the grid is now not populated. I suppose the Python string variable might be getting truncated somewhere down the line or something. But this is definitely a problem...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 06:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/732151#M1160</guid>
      <dc:creator>klay_martens</dc:creator>
      <dc:date>2021-04-08T06:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a Datagrid from Python Code file in Intelligent Decisioning</title>
      <link>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/787202#M1349</link>
      <description>&lt;P&gt;This is a response to the feature request for supporting more data types in datagrid.&lt;/P&gt;&lt;P&gt;I am evaluating the feature request.&lt;/P&gt;&lt;P&gt;Could you please include customer use cases for each of the types that you requested (date-time, boolean)?&lt;/P&gt;&lt;P&gt;Please include the type of processing you plan to do with the data of those types in a decision flow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 07:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-a-Datagrid-from-Python-Code-file-in-Intelligent/m-p/787202#M1349</guid>
      <dc:creator>Prasenjit_Sen</dc:creator>
      <dc:date>2021-12-23T07:09:28Z</dc:date>
    </item>
  </channel>
</rss>

