8.3.1. Parsing of the Commands Output

Since some commands like submit, queryStatus, and queryQueues require some parsing of cluster-specific output, RSM has externalized this parsing so that any custom cluster output can be interpreted by a custom parsing script that can be written by anyone.

Parsing scripts are available for supported cluster types: LSF, PBS (Pro or TORQUE), UGE, and MSCC. They are named lsfParsing.py, pbsParsing.py, ugeParsing.py, and msccParsing.py respectively.

If you are not using the default implementation of a supported cluster, or you are trying to integrate with an unsupported cluster, then you may need to write your own parsing script(s).

8.3.1.1. Getting Output from Primary Commands in the Parsing Scripts

In order to parse the output of the primary command and return an answer to the RSM code, you need to use a few standardized variables. Every parsing command, parseSubmit, parseStatus and checkQueueExists, has access to these variables.

  • RSM_HPC_PRIMARY_STDOUT

  • RSM_HPC_PRIMARY_STDERR

These environment variables are set by RSM when running the parsing code. They contain all of the standard output and standard error, respectively, from the associated primary command submit, queryStatus, or queryQueues. The parsing code simply needs to make a call to the environment variables above to get the necessary output from the associated command.

8.3.1.2. Outputting Variables from the Parsing Scripts

The parsing code also needs to be able to define variables. Putting them in the environment is not enough for RSM. You must define them explicitly by writing a specific phrase to the standard output:

  • !RSM_DEFINE <VARIABLE_NAME> = <VARIABLE_VALUE>

As an example in Python, if you wanted to define a variable "RSM_HPC_OUTPUT_STATUS" as "FINISHED" you could simply code:

print("!RSM_DEFINE RSM_HPC_OUTPUT_STATUS = FINISHED")

8.3.1.3. Required Output from Parsing Commands

Each parsing command needs to output a specific variable after performing the parsing and determining what needs to be determined.

Parsing CommandRequired Output VariableDescription
parseSubmitRSM_HPC_OUTPUT_JOBIDThe job’s unique ID. A string that can be used as an input to the queryStatus command.
parseStatusRSM_HPC_OUTPUT_STATUSThe job’s status. An enumeration that must be exactly one of these values:
  • Unknown

  • Queued

  • Running

  • Finished

  • Failed

  • Cancelled

checkQueueExistsRSM_HPC_OUTPUT_QUEUE_DEFINEDMust be set to TRUE or FALSE based on whether or not the queue was found.

8.3.1.4. Commands Output in the RSM Job Log

The output for all cluster command scripts (submit, queryStatus, queryQueues and so on) should be sent directly to stdout or stderr, so that the output can be properly interpreted by the parsing code. The contents of stdout may be added to the RSM job log as standard messages. This content is also searched by the parsing commands in order to parse the information necessary as a result of the command execution.

The handling of the command output depends on the post commands parseSubmit, parseStatus and checkQueueExists discussed previously.

Error Handling

Error messages and warnings information are written to stdout as necessary. If they are properly labeled as indicated below, they will appear in the RSM log as orange for warnings and bold red for errors.

Output format:

  • RSM_HPC_ERROR=<errormessage>

  • RSM_HPC_WARN=<warning>

Example Python snippet:

print(‘RSM_HPC_WARN=This is what a warning displays like’)
Debugging

Debugging information, typically used for troubleshooting purposes, is shown in the RSM job log only if the Debug Messages option is selected from the job log context menu. (To access this option, right-click anywhere inside the job log pane of the RSM application main window.)

Output format:

  • RSM_HPC_DEBUG=<debugmessage>


Release 18.2 - © ANSYS, Inc. All rights reserved.