How do i get the username under which a process is executing?

PBM
PBM New Altair Community Member
edited November 5 in Community Q&A
Hi, I am relatively new to RapidMiner and currently using it to load data to RedShift. 
I need to log the username under which a process is executing. I will later on log that username and datetime in a log table. 
I have trouble getting the username as a macro. I got some reference that I maybe able to use %{_ra_user}  but I get an error that _ra_user is unknown. Any guidance or working sample process would be appreciated.

Thank You
Tagged:

Best Answers

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Answer ✓
    Hi @PBM ,
    usually you just create a macro called _ra_user and populate it with a predefined name, e.g. your rm server user name. then you can run it.

    if another user runs this process on server, this macro gets overriden right when the process starts.

    Best,
    Martin
  • Edin_Klapic
    Edin_Klapic New Altair Community Member
    Answer ✓
    Hi @PBM
    If you add the Macro to the Process context you can assign a default value. It will automatically be overwritten when someone runs the process on Server.
    For debugging you could add the Operator "Print to Console" and enter the Macro there. This Operator actively writes to the Log in RapidMiner Studio / Server and the JobAgent processes.

    Happy Mining,
    Edin

Answers

  • Papad
    Papad New Altair Community Member
    Hi @PBM ,
    I recommend you to check this:
    https://docs.rapidminer.com/latest/studio/getting-started/macros.html
    It is about how to use macros. Generally you can find lot of things explained into DOCS.
    Hope it helps.

  • MartinLiebig
    MartinLiebig
    Altair Employee
    Hi,

    _ra_user is only available if you run processes on server.

    Best,
    Martin
  • PBM
    PBM New Altair Community Member
    Hi,

    If _ra_user is only available on server, I believe I will have to use error handling when I am in development mode and using RM Studio. I will try it.

    Thank You
  • MartinLiebig
    MartinLiebig
    Altair Employee
    Answer ✓
    Hi @PBM ,
    usually you just create a macro called _ra_user and populate it with a predefined name, e.g. your rm server user name. then you can run it.

    if another user runs this process on server, this macro gets overriden right when the process starts.

    Best,
    Martin
  • PBM
    PBM New Altair Community Member
    I used the handle exception operator and it works fine for now. Then I will test on server later. Will check also to give it default value, if that allows me to avoid error handling.

    Thanks
  • Edin_Klapic
    Edin_Klapic New Altair Community Member
    Answer ✓
    Hi @PBM
    If you add the Macro to the Process context you can assign a default value. It will automatically be overwritten when someone runs the process on Server.
    For debugging you could add the Operator "Print to Console" and enter the Macro there. This Operator actively writes to the Log in RapidMiner Studio / Server and the JobAgent processes.

    Happy Mining,
    Edin