🎉 🎉 RAPIDMINER 9.10 IS OUT!!! 🎉🎉

Download the latest version helping analytics teams accelerate time-to-value for streaming and IIOT use cases.

CLICK HERE TO DOWNLOAD

"Passing calculated macro values into report"

ozzyozzy Member Posts: 15 Contributor I
edited June 2019 in Help
Hi,
maybe I am missing something but I can't figure this one out....

Lets say you have a process with some defined macros. In a report you link them through realm variables and you can display these values in text field by referencing them as %{variable_name} .

Problem is you see these values at the beginning of the process, not the end, so if any of these values get recalculated, you don't see these results.

Simple problem, I want to display the  time report was executed. In the process I generate macro "now" which runs function date_now().
In the report I always get empty space which is what macro "now" is at the beginning of the process execution...

Is there anything that can be done to reference macro values at the end of the process execution?

Thanks
Ozzy
Tagged:

Answers

  • Marco_BoeckMarco_Boeck Team Lead Software Engineering Administrator, Moderator, Employee, Member, University Professor Posts: 1,963   RM Engineering
    Hi,

    yes. Since RapidMiner Server 2.4, you can set an option in the general settings of each app. When you active the "Allow processes to set app variables via context macros" option, the value of a predefined process macro will be written back to the app variable at the end of the process. That way, you can read in a variable from the app, change its value in the process and have the change reflected back to the app after the process has finished.

    Regards,
    Marco
  • ozzyozzy Member Posts: 15 Contributor I
    HI, I must be still missing something... Maybe I can explain what I am doing and you can see if this makes sense.
    The process (and associated service) creates a table. I use Extract macro type "number_of_examples" to define a macro called example_count. Now I have number of rows which I would like to display in the report.

    In service definition I delete parameter binding section for example_count. (since we are not passing this macro back to service)

    I go to Manage Domain and in my realm I define number domain called example_count with all default settings (0.0 is default value).

    In the app (report) I create variable "example_count" and point it at domain "example_count".

    I create visualization component pointed at globally defined service from above.

    I create text component with text:  "Counter: %{example_count}"

    Preview shows text "Counter: 0.0" , followed by the table  in visualization section but  "Counter: 0.0" does not change after the process is completed. The macro value is not being written back to the variable.

    I checked, and if I run process in studio the "example_count" macro  gets changed to a number of rows, so macro is getting set.

    In app general settings the "Allow processes to set app variables via context macros" is set.

    Am I doing something wrong here?

    Thanks,
    Ozzy
  • Marco_BoeckMarco_Boeck Team Lead Software Engineering Administrator, Moderator, Employee, Member, University Professor Posts: 1,963   RM Engineering
    Hi,

    you are correct, it won't work with global services for technical reasons. You either have to use the app initialization process or add a "Run process" effect for the process in question to any of your components.

    Regards,
    Marco
  • ozzyozzy Member Posts: 15 Contributor I
    Hi Marko,
    sorry I am not following you..

    First option - do you mean I have to run app initialization process to calculate the macro which then gets defined and read by the report at the beginning of the process...?

    Second option - "add a "Run process" effect for the process in question to any of your components".  I am afraid I don't understand this one at all... could you please give me some more detail? What is "Run process" effect and where am I adding it to?

    Thanks
    Ozzy

  • Marco_BoeckMarco_Boeck Team Lead Software Engineering Administrator, Moderator, Employee, Member, University Professor Posts: 1,963   RM Engineering
    Hi,

    when your initialization process defines macros in its context, the values of them are written back to the app at the end of the process - if there is a variable with the same name.

    Apart from that you can also write macro values back whenever the user interacts with your app.
    Note that when your data source type is a globally defined service (1 in the picture), macro values at the end of the process behind that service are NOT transferred back to the app due to technical reasons. Same for when you use a process as a data source for your visualization component (2 in the picture).

    To write macro values back, you need to add Interaction effects (3 in the picture). You can then chose from various effects, e.g. a "Run process" effect. Processes which are executed via that can write their macros back. These interactions occur when the user clicks on a component which supports these effects, e.g. buttons or charts.
    image

    Regards,
    Marco
  • ozzyozzy Member Posts: 15 Contributor I
    Hi,
    I now set  "process as a data source" and  managed to get macro values to transfer only if I Use Run Process effect .
    Problem is that first time I run the process nothing gets updated, so I have either empty space or worse, the variable value from the previous run.....

    I was also unable to get initialization process to set these values either. The funny thing is if I "run the initialization process now"  in the setup screen, the macro values get pulled through, so I see these values at the next run but they do not update any more when I run the app.
    So this kind of looks like a bug to me...
    Your thoughts?

    Kind regards
    Ozzy
  • Marco_BoeckMarco_Boeck Team Lead Software Engineering Administrator, Moderator, Employee, Member, University Professor Posts: 1,963   RM Engineering
    Hi,

    sorry for that, I was mistaken about 2). I have adapted my previous answer. The writing back of values only works for Initialization processes and "Run process" effects.
    I cannot reproduce your problem regarding the initialization processes though. The process is executed when someone opens the app for the first time. If he then views a different app without explicitly closing the first one, the init process will not run again as the state is preserved unless the user closes the app.

    Regards,
    Marco
  • JEdwardJEdward RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 574   Unicorn
    One way to achieve the result you want might be to use the Publish to App and Recall from App operators in your various processes to write an 'Example Set' of variables that is stored during the server runtime and you can then use this in your various processes that need it. 
    Unlike Macros, publishing to an app creates a piece of data unique to the server login.  A macro creates a piece of data unique to the process run, so when you could have two different variables setting the same macro with no conflict.  In your example you want to set the data in one place for all other processes to read it. 
    Here's a really simple example.

    Step 1: Set the counter.
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.4.000">
      <context>
        <input/>
        <output/>
        <macros>
          <macro>
            <key>counter</key>
            <value>1</value>
          </macro>
        </macros>
      </context>
      <operator activated="true" class="process" compatibility="6.4.000" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="generate_data_user_specification" compatibility="6.4.000" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="246" y="300">
            <list key="attribute_values">
              <parameter key="counter" value="%{counter}"/>
            </list>
            <list key="set_additional_roles"/>
          </operator>
          <operator activated="true" class="publish_to_app" compatibility="6.4.000" expanded="true" height="60" name="Publish to App" width="90" x="447" y="165">
            <parameter key="name" value="report_variables"/>
          </operator>
          <connect from_op="Generate Data by User Specification" from_port="output" to_op="Publish to App" to_port="store"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
        </process>
      </operator>
    </process>
    Step 2: Read the counter.
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.4.000">
      <context>
        <input/>
        <output/>
        <macros>
          <macro>
            <key>counter</key>
            <value>1</value>
          </macro>
        </macros>
      </context>
      <operator activated="true" class="process" compatibility="6.4.000" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="recall_from_app" compatibility="6.4.000" expanded="true" height="76" name="Recall from App" width="90" x="179" y="120">
            <parameter key="name" value="report_variables"/>
          </operator>
          <operator activated="true" class="text:create_document" compatibility="6.4.001" expanded="true" height="60" name="Create Document" width="90" x="380" y="300">
            <parameter key="text" value="Counter : %{counter}"/>
          </operator>
          <operator activated="true" class="extract_macro" compatibility="6.4.000" expanded="true" height="60" name="Extract Macro" width="90" x="313" y="165">
            <parameter key="macro" value="counter"/>
            <parameter key="macro_type" value="data_value"/>
            <parameter key="attribute_name" value="counter"/>
            <parameter key="example_index" value="1"/>
            <list key="additional_macros"/>
          </operator>
          <connect from_op="Recall from App" from_port="result" to_op="Extract Macro" to_port="example set"/>
          <connect from_op="Create Document" from_port="output" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    There's more things you can do with this, for example you could set your entire counter HTML and store it as the Publish to app with the Retried
Sign In or Register to comment.