7.1 Running the network from the command line

Problem

Although a network can be created and executed through the HARK-Designer’s GUI, it is inconvenient to run the GUI everytime in order to execute the network. I want to execute the network file by using the command line, as well as to change the network parameters using command line arguments.

Solution

The target parameters and command line arguments should be set in the nodes within the network file in order to pass and process an argument from the command line.

Open HARK-Desiner and edit the network file as shown below:

  1. Open the node’s property that includes the variable that will be passed as an argument in the MAIN subnetwork.

  2. Set Type to subnet_param and Value to “ARG?” in the parameters of the variable that will substitute the command line argument. The ? is the index of the argument. The data type of the argument should also be specified if it is in int or float (i.e. “int:ARG1” or “float:ARG2”).

Note that only the nodes in the MAIN subnetwork can pass a command line argument. To set the parameter of the nodes from other subnetwork, the parameter should first be set to subnet_param so that it can be seen in the MAIN subnetwork. The values can then be set through the MAIN subnetwork.

batchflow reads and executes the contents of the network file. Just type “batchflow“ before the file name to execute the network.

$ batchflow foo.n 0.5 0.9

In this example, the input to ARG1 is 0.5, and ARG2 is 0.9 in foo.n, then it is executed by batchflow. This method is similar to both Windows and Ubuntu.

Discussion

HARK-Designer is the GUI for editing the network file, while the actual execution is done by batchflow.

All command line arguments are being handled as string . To pass an argument that is in int or float data type, Value should be set as “int :ARG1“, “float :ARG1“.

Passing command line arguments by this method that are Object type such as Vector<int> are not allowed in the current version of HARK  .

See also

None.