<?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: User selection and parameter for SSE Plugin in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2298#M14105</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Virilio!&lt;/P&gt;&lt;P&gt;It's hard for me to say exactly why you receive a NaN without knowing how your data model looks like and what plugin you're using. If you could provide the .qvf file I could take a look. Did you use the FullScriptSupport example when you tried to run `&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;=Script.ScriptEval('list(numpy.asarray(args[0]) + 5)', [petal width])`?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We released a new SSE version yesterday (&lt;A href="https://github.com/qlik-oss/server-side-extension/releases/tag/v1.1.0"&gt;v1.1.0&lt;/A&gt;) where we also updated the python examples, one of the updates being to evaluate the script after all data is collected(and not per row as you noticed), in the script example. There is also a new python script example using &lt;EM&gt;pandas&lt;/EM&gt; and &lt;EM&gt;exec&lt;/EM&gt;, which is better suitable for more complex scripts. Read more about the pandas example &lt;A href="https://github.com/qlik-oss/server-side-extension/tree/master/examples/python/FullScriptSupport_Pandas"&gt;here&lt;/A&gt;. Note that the new features in the SSE protocol v1.1.0 are supported first in Sense February 2018. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Jan 2018 13:46:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-01-19T13:46:53Z</dc:date>
    <item>
      <title>User selection and parameter for SSE Plugin</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2294#M14101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have translated the Kmeans example to Python, using HelloWorld code as reference.&amp;nbsp; I have this expression working:&lt;/P&gt;&lt;P&gt;IrisPython.PredictIris([petal length], [petal width], [sepal length], [sepal width])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I'd like to pass the parameter n_cluster to the python SSE plugin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I do the next: IrisPython.PredictIris(3, [petal length], [petal width], [sepal length], [sepal width])&lt;BR /&gt;The value "3" is going to be replicated on each row.&amp;nbsp; It would be very inefficient using some parameters like that for a large dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I'd like to let the user to chose the n_cluster value.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps, it could be possible using a new data field:&lt;/P&gt;&lt;P&gt; LOAD * Inline &lt;BR /&gt; [NUM_CLUSTER&lt;BR /&gt; 1&lt;BR /&gt; 2&lt;BR /&gt; 3&lt;BR /&gt; 4&lt;BR /&gt; 5&lt;BR /&gt; 6&lt;BR /&gt; 7&lt;BR /&gt; ...&lt;BR /&gt; ];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could the SSE plugin know the user selection?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How could I pass parameters in addition to data to a python script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Virilo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2024 08:51:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2294#M14101</guid>
      <dc:creator>virilo_tejedor</dc:creator>
      <dc:date>2024-11-16T08:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: User selection and parameter for SSE Plugin</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2295#M14102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.qlik.com/qlik-users/229544"&gt;virilo.tejedor&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;We are aware of the limitation of not being able to send constants as parameters, without it being replicated on each row as you said, and it's in our backlog. As of today the data passed as parameters to the plugin must have the same cardinality. When you pass a field to the plugin, Qlik will send the selected values in that field, to the plugin. If no selection was made, all values will be sent. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can create a field for the number of clusters and let the user make selections, but then you need to handle the fact that the user might choose more than one value. I would recommend you to use a variable instead. If you're using a plugin defined function, like the PredictIris function, you have to pass the variable as a parameter. But if you are using a script function you can use string concatenation to include the variable directly in the script without having to pass it as a separate parameter. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jan 2018 09:59:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2295#M14102</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-18T09:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: User selection and parameter for SSE Plugin</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2296#M14103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Josefine described it well.&lt;/P&gt;&lt;P&gt;Just to give you an example of using a variable as constant when calling scripteval:&lt;/P&gt;&lt;P&gt;If myvar is my variable, then you can pass it in the script string as $(myvar), see below example:&lt;/P&gt;&lt;P&gt;Script.ScriptEval('list(numpy.asarray(args[0]) + $(myvar))', Numeric) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There also exists another way, still a bit hard for the one writing the expressions in Qlik but it is possible at least until the needed functionality is added in Qlik. You can expose your own Iris-methods on the python side so that they are accessible from scripteval calls. In that case you can call your iris-methods through a scripteval call like below example shows where I call my method helloworld:&lt;/P&gt;&lt;P&gt;Script.ScriptEvalStr('myfuncs.helloworld(str($(myvar)), args[0])', String) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However you need to change the python plugin to expose your methods. In my example I have modified the script example (ScriptEval_script.py) by first adding a new class that contains my own method like below:&lt;/P&gt;&lt;P&gt;class MyFunctions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @staticmethod&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def helloworld(conststring, mystrings):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return iter([str.join(conststring) for str in mystrings])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I add the following line in evaluate method:&lt;/P&gt;&lt;P&gt;funcs = MyFunctions()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and finally I pass that class in the eval call next to the other exposed classes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = eval(script, {'args': params, 'numpy': numpy, 'myfuncs': funcs})&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know, it is not nice, but could be worth trying.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jan 2018 11:34:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2296#M14103</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-18T11:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: User selection and parameter for SSE Plugin</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2297#M14104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Josefine, Tobias for your responses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this simple example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; =Script.ScriptEval('list(numpy.asarray(args[0]) + 5)', [petal width])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'm receiving a nan as arg[0].&amp;nbsp; I added some extra traces:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt; 2018-01-19 13:29:16,296 - INFO - Logging enabled&lt;BR /&gt; 2018-01-19 13:29:16,328 - INFO - *** Running server in insecure mode on port: 50600 ***&lt;BR /&gt; 2018-01-19 13:29:45,870 - INFO - EvaluateScript: list(numpy.asarray(args[0]) + 5) (ArgType.Numeric ReturnType.Numeric) FunctionType.Tensor&lt;BR /&gt; header.params !&lt;BR /&gt; Evaluate script row wise&lt;BR /&gt; call to evaluate&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ----------------&lt;BR /&gt; script:&amp;nbsp; list(numpy.asarray(args[0]) + 5)&lt;BR /&gt; params:&amp;nbsp; [nan]&lt;BR /&gt; ret_type:&amp;nbsp; ReturnType.Numeric&lt;BR /&gt; 2018-01-19 13:29:45,920 - ERROR - Exception iterating responses: 'numpy.float64' object is not iterable&lt;BR /&gt; Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp;&amp;nbsp; File "C:\Users\virilo.tejedor\AppData\Local\Continuum\Anaconda3\lib\site-packages\grpc\_server.py", line 393, in _take_response_from_response_iterator&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return next(response_iterator), True&lt;BR /&gt;&amp;nbsp;&amp;nbsp; File "C:\POC\src\SSE_Plugins-0.1\FullScriptSupport\ScriptEval_script.py", line 59, in EvaluateScript&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield self.evaluate(header.script, ret_type, params=params)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; File "C:\POC\src\SSE_Plugins-0.1\FullScriptSupport\ScriptEval_script.py", line 177, in evaluate&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = eval(script, {'args': params, 'numpy': numpy})&lt;BR /&gt;&amp;nbsp;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt; TypeError: 'numpy.float64' object is not iterable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why am I receiving a NaN?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, it seems like doing it in this way is going to perform an evaluate execution per row (Evaluate script row wise)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;It won't allow me some use cases, like retrain the model using the selected data or perform a moving average&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As workaround I'm exposing another funtion SetUserParam to send the user variables to python; and qsVariable for the selectors in the UI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This workaround have some issues:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt; - race conditions with other requests&lt;BR /&gt; - the selectors aren't refreshing the graphs due to Qlik doesn't know that Y hat is modified in SetUserParam call&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since it is a proof of concept for using Advanced Analytics in Qlik, I could wait for future versions without this limitation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jan 2018 13:00:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2297#M14104</guid>
      <dc:creator>virilo_tejedor</dc:creator>
      <dc:date>2018-01-19T13:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: User selection and parameter for SSE Plugin</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2298#M14105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Virilio!&lt;/P&gt;&lt;P&gt;It's hard for me to say exactly why you receive a NaN without knowing how your data model looks like and what plugin you're using. If you could provide the .qvf file I could take a look. Did you use the FullScriptSupport example when you tried to run `&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;=Script.ScriptEval('list(numpy.asarray(args[0]) + 5)', [petal width])`?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We released a new SSE version yesterday (&lt;A href="https://github.com/qlik-oss/server-side-extension/releases/tag/v1.1.0"&gt;v1.1.0&lt;/A&gt;) where we also updated the python examples, one of the updates being to evaluate the script after all data is collected(and not per row as you noticed), in the script example. There is also a new python script example using &lt;EM&gt;pandas&lt;/EM&gt; and &lt;EM&gt;exec&lt;/EM&gt;, which is better suitable for more complex scripts. Read more about the pandas example &lt;A href="https://github.com/qlik-oss/server-side-extension/tree/master/examples/python/FullScriptSupport_Pandas"&gt;here&lt;/A&gt;. Note that the new features in the SSE protocol v1.1.0 are supported first in Sense February 2018. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jan 2018 13:46:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2298#M14105</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-19T13:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: User selection and parameter for SSE Plugin</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2299#M14106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a quick update: &lt;/P&gt;&lt;P&gt;I tried using the latest version of FullScriptSupport and the Ctrl+00 script, and the following expression worked fine:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=Script.ScriptEval('list(numpy.asarray(args[0]) + 5)', AsciiNum)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using the provided examples, I would recommend you to update to the latest version and try again, to see if you still have the same issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know how it goes! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jan 2018 14:42:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/User-selection-and-parameter-for-SSE-Plugin/m-p/2299#M14106</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-19T14:42:21Z</dc:date>
    </item>
  </channel>
</rss>

