The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

How to access a "Configurable" Parameter

janvanrijnjanvanrijn Member Posts: 15 Contributor II
The document "How to Extend RapidMiner 5" describes how to create Configurables, for example to store Connections to certain servers (Chapter 8 ). I try to do so for a RapidMiner Studio, and as it turns out, many of the code is applicable for this version. However, I ran into some difficulties.

I have for my Operator overridden the getParameterTypes function:
public List<ParameterType> getParameterTypes() {
List<ParameterType> types = super.getParameterTypes();
types.add(new ParameterTypeConfigurable(PARAMETER_CONFIG, "Choose a Connection", "Config"));
types.add(new ParameterTypeInt(PARAMETER_TASKID, "The Task that needs to be executed", 1, Integer.MAX_VALUE, false));
return types;
}
Hence, I can see both the integer and configurable parameter fields.

Now, if I want to access the integer parameter, I can easily access it in the doWork function:
getParameterAsInt(PARAMETER_TASKID);
I would assume there is a similar way to obtain the Configurable? Yet, I can't find it, and it is not documented in the manual. Many thanks for helping out.

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    I have some example code from our own Amazon S3 configurable for you which should be helpful.

    The parameter type defintion:

    @Override
    public List<ParameterType> getParameterTypes() {
          ParameterType type = new ParameterTypeConfigurable(PARAMETER_CONNECTION, "The Amazon S3 connection.",
    AmazonS3ConnectionConfigurator.TYPE_ID);
    type.setOptional(false);
    parameterTypes.add(type);
          //...
    }

    The doWork() method of the operator:

    @Override
    public void doWork() throws OperatorException {
    AmazonS3Connection connection = null;

    try {
    connection = (AmazonS3Connection) ConfigurationManager.getInstance().lookup(
    AmazonS3ConnectionConfigurator.TYPE_ID, getParameterAsString(PARAMETER_CONNECTION),
    getProcess().getRepositoryAccessor());
    } catch (ConfigurationException e) {
    throw new UserError(this, e, "amazon.configuration_read");
    }

          // access configurable settings
          String bucketName = connection.getBucketName(filePath);
          String fileName = connection.getFileName(filePath);


          AmazonS3 client = connection.createConnection();
          // do stuff with S3

    }
    Regards,
    Marco
  • janvanrijnjanvanrijn Member Posts: 15 Contributor II
    Dear Marco,

    You just made my day! Thanks.

    One more question regarding the GUI description, as described on page 73. I copied these values, of course changing ofcourse "crmconfig" into my own I18NBaseKey. However, these didn't change anything. Did something change between version 5 and RM Studio? Or am I changing the wrong config file? I work in src/main/resources/com/rapidminer/resources/i18n/GUITemplate.properties, since I found a reference to this file in some META-INF from a shadow Jar. Coudn't find any other references...
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    Seems to be out of date. Amazon S3 example again:

    gui.configurable.{baseKey}.name = Amazon S3 Connection
    gui.configurable.{baseKey}.description = Specifies the details to establish a connection to Amazon S3.
    gui.configurable.{baseKey}.icon = data_cloud.png
    Regards,
    Marco
  • janvanrijnjanvanrijn Member Posts: 15 Contributor II
    Seems to work, great.

    Just not the icon. I tried some different ones, but the button is still empty.

    Are you sure it's this one? In the manual it hints at
    gui.action.configuration.crmconfig.icon = data_cloud.png
    but replacing crmconfig with {baseKey} doesn't work
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    1. Where is your icon located? Should be "resources/icons/16/my_icon.png"
    2. What version of RapidMiner Studio are we talking about? I looked at the 6.4 sources.

    Ultimately, it should work if you can successfully get the icon in your code via

    this.getClass().getClassLoader().getResource("icons/16/my_icon.png");
    Regards,
    Marco
  • janvanrijnjanvanrijn Member Posts: 15 Contributor II
    Yeah, I'm using version 6.4 as well. It could be that the icon is not in the right directory, the code you showed me returns null.

    I tried using resources from the RapidMiner resources, like I do for the operators. Apparently that is not possible. In which subfolder of my plugin should I locate resources/icons/16/? I tried some different options, but apparently not the right one.
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    sorry, the code should have been:

    this.getClass().getClassLoader().getResource("com/rapidminer/resources/icons/16/my_icon.png");
    Regards,
    Marco
  • janvanrijnjanvanrijn Member Posts: 15 Contributor II
    So the following code:
    System.err.println("res: " + this.getClass().getClassLoader().getResource("com/rapidminer/resources/icons/16/my_icon.png") ); // my own icon, in resources folder
    System.err.println("res: " + this.getClass().getClassLoader().getResource("com/rapidminer/resources/icons/24/import.png") ); // icon borrowed from rapidminer icons
    Now returns the following output:
    res: jar:file:/vol/home/rijnjnvan/apps/rapidminer-studio/lib/plugins/OpenmlConnector-1.0.0-all.jar!/com/rapidminer/resources/icons/16/my_icon.png
    res: jar:file:/vol/home/rijnjnvan/apps/rapidminer-studio/lib/rapidminer-studio-core-6.4.0.jar!/com/rapidminer/resources/icons/24/import.png
    This is what the GUITemplate.properties reads:
    gui.configurable.{baseKey}.name = OpenML Connection
    gui.configurable.{baseKey}.description = An entry decribing an OpenML Connector
    gui.configurable.{baseKey}.icon = my_icon.png
    # also this doesn't work: com/rapidminer/resources/icons/16/my_icon.png

    When I open my operator, I can see in the parameter list "OpenML Connection" and when I hoover over the info button it also says "An entry decribing an OpenML Connector". However, the button still shows no icon which makes it both small and hard to understand for end users.

    Is there somewhere documentation on this GUI properties file, apart from the Extension manual?
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    the i18n files themselves are not documented, usually (at least for newer classes) the i18n key format is part of the JavaDoc for the classes.

    Your code looks good, it should work - I don't know why it does not. Does it work if you change the icon in the i18n file to "import.png", i.e. an icon from Studio itself?

    Regards,
    Marco
  • janvanrijnjanvanrijn Member Posts: 15 Contributor II
    No that does still not work.

    Just to be sure we're talking about the same thing, I have attached a screenshot about where I would expect an icon.

    (any icon would be fine by me.)

    [img=http://s1.postimg.org/wqydhjyxn/screen.jpg]
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    when you add a configurable instance to the operator (so it is selected) and the click the button again, is the correct configurable preselected in the dialog? Is the icon in the dialog correct?

    Regards,
    Marco
  • janvanrijnjanvanrijn Member Posts: 15 Contributor II
    Marco Boeck wrote:

    when you add a configurable instance to the operator (so it is selected) and the click the button again, is the correct configurable preselected in the dialog?
    Yes.
    Is the icon in the dialog correct?
    As I did not attempt to change the default icon of the dialog, there is a gear/plug icon displayed top left.
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    this icon:

    image

    Regards,
    Marco
  • janvanrijnjanvanrijn Member Posts: 15 Contributor II
    No Icon at all ...
Sign In or Register to comment.