Passing parameters to HxRun.exe

I’d like to use HxRun to setup some automated testing of a method. Normally, we show a custom dialog for a user to select a file, which is then processed etc.

I understand that we can start run control from the command line via HxRun.exe, but is there a way to pass parameters/arguments to the method, so I can select the file automatically and not show the dialog? I don’t need help with handling the logic once I get the parameter, I just need help with the passing of parameters into the method.

Thanks in advance.

2 Likes

I think you need to buy the scheduler software

You can have a dedicated location for the parameter file and then the method just reads the file at the beginning to get the info. The method could delete or move the file after it is read in. It would require another process to download or overwrite the parameter file in the designated folder.

Otherwise, scheduler software can pass parameters to a method from a workflow, but you’d still need to select the parameter file from the workflow.

1 Like

Are there any plans in VENUS 5 to allow the passage of parameters or will this l always be an additional cost to purchase scheduling software.

This would be suuuuuuuuuper amazing for automated testing of method versions. If I can pass parameters to a method I can automate the passage of those parameters and for every new version check if some combination of inputs creates unforseen bugs.

1 Like

For VENUS five, installers for Scheduler and TADM are included.

But you don’t need scheduler to pass parameters from external files (csv, xls, json, etc.) or a database. You can do that within standard VENUS using the default file commands or libraries.

1 Like

Thanks Eric.

Unfortunately that won’t be what I need, though. The file I am asking the user to select is a worklist- this is custom for each run… I need to be able to send test worklists to the method to use instead of showing a dialog to allow the user to choose, if that makes any sense…

This here is exactly what I’m trying to do :slight_smile:

1 Like

@gwp tried using the FileDirectoryLibrary to loop over a large set of example worklist but the library function GetFilesInDirectory didn’t work. I kept getting an invalid class string error even though I followed the docs on the input types.

You’ll need to run the installer which I uploaded here. But that is what I was alluding to - so long as you put the file in a designated location you can either give it the same name (overwriting as needed) or use commands such as the GetFilesInDirectory from the HSLFileDirectory library to get the file name, then you don’t need a user prompt in your method.

Unfortunately we can’t use logic like that, namely because we need unique worklists that are generated externally and are saved with unique names to a specific network location (and for regulated areas this folder has special perms), and we can’t iterate through all files in a directory because we need to keep all worklists in the same folder, even those already run. The way we have it is as we need it. Just I’d like to be able to send arguments into the method that can override that. I guess I could have “test mode” that looks at a special folder for testing, but as 1 run = 1 worklist, I’d need an external way to keep track of what worklists have been run for this test session. Calling it in a bash script for e.g. with an argument for which worklist to use would be much simpler and cleaner. I guess it’s just not an option without the scheduler software.

Sorry, I should also point out that the Directory.hsl library in the HSL Extensions also has commands to GetFileNames, GetNewestFileName, etc. which you could also use instead of overwriting or moving files.

1 Like


@EricSindelar_Hamilton found an error in the docs that holding me up me up. It needs to be “*.txt”* instead of “.txt” for the filter command.

While it isn’t possible to directly pass a parameter to a method by way of the Executor class, the parameter file Eric mentioned at the start achieves the same thing. The file could be as simple as a text file sitting in a designated location (i.e. “HAMILTON\Parameter Files”) that only has one line of information, that being the file path of the worklist for the run. When the method starts, it opens this file and reads in the one line to be stored in your worklist variable, then everything proceeds as normal.

The added functionality you need is something to change the name of the worklist in the parameter file. This could be as simple as a user opening and changing the worklist file path manually, or using a different software tool to change it automatically. Your automated setup would need a way to change the file path either way, however in this case it needs to handle writing to a file instead of passing the information as a method parameter.

We use this technique when working with third-party integration software to send/receive information between the integration software and VENUS during runtime.

3 Likes

Hi all,

Just to add to Dan’s response, yes, it would likely require some kind of a “Developer Mode” switch within your Method or at the very least a “GetSimulationMode” condition, to determine whether to use the user input or the “parameter file.” As for editing the value of the file, at least in a Windows environment it’s pretty straightforward writing a line to a text file, and the Method can delete the file if needed after reading it.

Just to clarify on Scheduler, a Scheduled Method can accept parameters, but only from a Workflow, which is an alternate “Method” file type that uses specific steps to call out and execute Methods in the scheduled environment. Having Scheduler would not allow you to call a Method directly from a command line or script with specific parameters and would still result in the same situation as previously encountered: At some point, that input needs to be retrieved somehow (user dialog, flat file, database, etc.).

As a side note, I would also recommend using HSLExtensions over any specific File/Directory libraries we had previously as long as the function needed exists in it, as HSLExtensions doesn’t require a DLL to be registered to function, while most of the others do.

~William

2 Likes

Im happy to show how to do this (or any other unique method request) in PyHamilton, passing parameters to a method can be accomplished fairly easily in a lot of forms. @Gareth if you want to send a message with some brief details of your method I can post an example that very simply elucidates how to implement this.

For me it sounds like @Gareth just needs the parameters for the command line to start a method with HxRun.exe immediately (without loading the file within HxRun and hit the start button).
This can already be done in Venus 4.5, e.g. with a desktop shortcut or command line using

“C:\Program Files (x86)\Hamilton\Bin\Hxrun.exe” " -

parameters can be
-t meaning that HxRun terminates after the run
there are more, but I dont have them in mind. Will look it up tomorrow. One is to run HxRun minimized, maybe you need a parameter to immediately start. Will let you know tomorrow.

Since you talked about testing: There is a Unit Test tool to test Hamilton submethods. It is called Vector Unittest Framework. Maybe it is just what you are currently setting up.

Oh, that’s super interesting that there’s a unit test tool. Do you have more information on the Vector Unit test Framework?

1 Like

Good lord this would be the dream right. But you cannot pass a parameter to a method from the cli. Man if you could though and if they updated the cli to allow parameter passing you could set up a git commit process so when people commit changes you could auto run and catch any stdout errors.

I guess this would mean though you’d need to beable to install VENUS in some sort of docker container thought and run in a headless mode. :thinking:

Just spit balling now

1 Like

I know about the /t /r arguments, this is more about passing custom arguments to the method rather than those few to the run control.

I too am interested in the unit test tool. Would you be able to upload it/have more info?

I was expecting you to suggest pyhamilton. However for lots of reasons we can’t use it (at least for the current projects). Stuff like this is easy in python in general, but we need to stick to venus.

1 Like