8.3.1. Parsing of the Commands Output

Commands such as submit and queryStatus 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 and implemented as a post command. For a list of commands that require output, see Required Output from Commands.

Parsing scripts are already implemented for supported cluster types (LSF, PBS, and so on). They are named lsfParsing.py, pbsParsing.py, and so on.

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

8.3.1.1. Getting Output from Primary Commands in the Parsing Scripts

If maintaining an entire wrapper script suite for the custom cluster is not possible, or those wrappers exist but cannot be changed in order to output the required RSM output, then using a post command to parse the output of the command is needed.

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 post command has access to these variables.

  • RSM_HPC_PRIMARY_STDOUT

  • RSM_HPC_PRIMARY_STDERR

These environment variables are set by RSM when running the post commands (parsing) code. They contain all of the standard output and standard error, respectively, from the associated primary command. The post command (parsing) script simply needs to make a call to the environment variables above to get the necessary output from the associated command. Then, after obtaining the standard output of the primary command, it can be parsed using any method desired in order to create the required RSM output.

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 Commands

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

Base CommandParsing CommandRequired Output DefinitionDescription
submitparseSubmitRSM_HPC_OUTPUT_JOBIDThe job’s unique ID. A string that can be used as an input to the queryStatus command.
queryStatusparseStatusRSM_HPC_OUTPUT_STATUSThe job’s status. An enumeration that must be exactly one of these values:
  • Unknown

  • Queued

  • Running

  • Finished

  • Failed

  • Cancelled

getAllStatusparseAllStatusRSM_HPC_OUTPUT_GENERICThe job statuses that are on the cluster in a Python dictionary format like {JobId1:Status1, JobId2:Status2, ….. }, where the jobID is the string from the cluster and the Status is one of the statuses from the list provided for parseStatus.
queryQueuescheckQueueExistsRSM_HPC_OUTPUT_QUEUE_DEFINEDMust be set to TRUE or FALSE based on whether or not the queue was found.
getAllQueuesparseQueueListRSM_HPC_OUTPUT_GENERICThe queues that are available to the user for job submission, in a Python list format such as [queue1, queue2, queue3, …..].
listStorageContentsparseListingRSM_HPC_OUTPUT_GENERIC

The files that are contained in RSM_HPC_FILE_REMOTE_DIR in a Python dictionary format such as {FileName:[Size, ModifiedDate], FileName2:[Size2, ModifiedDate2], …….}, where:

The filename is relative to the provided directory.

The size is in bytes.

The modified Date can be in many formats, but the common format of “MMM d HH:mm” or less accurately “MMM d yyyy” are allowed.

8.3.1.4. Commands Output in the RSM Job Log

The output for all cluster primary 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>