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

Python Scripting Extension version 9.5.0 is live!

tkeneztkenez Employee-RapidMiner, RapidMiner Certified Expert, Member Posts: 22 RM Product Management
edited December 2019 in Knowledge Base
Good news everyone!

We have just released a new version of the Python Scripting Extension. It contains a bunch of great improvements so I encourage you all to update/download and give it a go. You can get it here.

Here are the highlights:

  • Data handover between RapidMiner and Python has been reworked, fixing several bugs reported by users (such as handling multiline text, special characters in attribute names, timezone in date types and empty values correctly). We also made it faster! (Note: new compatibility level introduced to ensure we don’t break existing behavior)
  • It is now possible to expose processes containing Execute Python operators as webservices on Server!
  • Macros are now handled consistently in inline scripts and files
  • Execution robustness has been improved on Linux and Mac
We have also published a new version of our python-rapidminer Python library on GitHub, which allows you to access the RapidMiner repository and execute processes right from your Python code.

Enjoy! And as always, we welcome any and all feedback :)




Comments

  • Pradyumna_26Pradyumna_26 Member Posts: 7 Learner II
    Hi, can you direct me to where I can get more documentation on using macros with the execute python operator? Thanks in advance!
  • tkeneztkenez Employee-RapidMiner, RapidMiner Certified Expert, Member Posts: 22 RM Product Management

    Please check the information tooltip for "use macros" on the Parameters panel of the Execute Python operator. If you enable it, you will need to pass an additional input parameter named macros to your rm_main method. Our wrapper code will then make all macros available to you via a dictionary where the keys are the names of the macros.

    Hope this helps,
    Tamas
  • Pradyumna_26Pradyumna_26 Member Posts: 7 Learner II

    Hi Tamas,


    I’m trying to read a csv file from my system into a pandas dataframe and display it through the execute python operator. I need to pass the name (FullCustomerData) of the file to be read as a user input which I defined through a macro filNam.

    I checked the ‘use macros’ box in the parameters tab for the execute python operator to be able to use the macro in the script, but I’m getting an error. I’m attaching the pics of the script and the error message. I would greatly appreciate any help in resolving this! Thank you!


    Regards,

    Pradyumna.



  • tkeneztkenez Employee-RapidMiner, RapidMiner Certified Expert, Member Posts: 22 RM Product Management

    I think I see what the problem is. So you have two options to use macros, I did not elaborate on the one you tried in your above example.

    So here are your options.

    1) The "use macros" way. This is more Pythonic, and does not require you to produce a script that will give you syntax errors when executing outside of the RM operator.
    To do this, here are your steps in detail:
    • check the "use macros" box on your Execute Python operator
    • change your rm_main() definition to rm_main(macros):
    • now you can access the value of the filNam macro inside your method like this: macros['filNam']
    2) The old-fashioned macro string replacement way. Here, think of your macro as a drop-in replacement for your macro value. In the example above, you end up with trying to concatenate the value of a variable named FullCustomerData. What you want instead is a simple string concatenation. Either of these should work in your code above (in this case you don't need "use macros"):
    • Cust_Dat_Path = 'C:/Users/path/to/my/' + '%{filNam}' + '.csv'
    • Cust_Dat_Path = 'C:/Users/path/to/my/%{filNam}.csv'
    So this comes down to personal taste and the way you use your code. If you want your code snippet to be easily transferable to and from the RM world, I'd suggest the first way. Otherwise, it's up to your preference.

    Let me know how it goes,
    Tamas

  • Pradyumna_26Pradyumna_26 Member Posts: 7 Learner II
    Hi Tamas,

    I think I understand where the conflict is now. And both methods worked! Thanks a ton!

    Regards,
    Pradyumna.
Sign In or Register to comment.