Hi... 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 ''' List all output parameters as comma-separated values in the "Output:" docString. Do not specify "None" if there is no output parameter. ''' def execute (): 'Output:PythonString,PythonNumeric' PythonString=''' [ { "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 ] ] } ] ''' PythonNumeric=100 return PythonString,PythonNumeric
And then create a DS2 program which converts the string to a datagrid package "${PACKAGE_NAME}" /inline; method execute(varchar(2048) PythonString, in_out package datagrid AGrid); Ds2String = PythonString; DATAGRID_CREATE(AGrid ,PythonString ); end; endpackage;
Now create a simple decision flow, adding first the Python code file, then the DS2 code file... Leave the Python variables selected as outputs, publish and submit a test score. You get the expected results 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') <Response [201]>
response= <Response [201]>
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 "
}
]
} Now. Switch off the PythonString variable from the reply, and republish: Run the same test again... <Response [201]>
response= <Response [201]>
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
}
] 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...
... View more