Welcome to the developer's guide for the interactive sessions repository. While this repository offers one method for creating interactive workflows in Parallel Works, please note that it's not the sole approach available. Ensure you review the information provided in these links on interactive workflows and developing workflows before proceeding with this guide.
This repository enables you to establish interactive session workflows for running various services, such as Jupyter or remote desktops, across different types of executors. The supported executors encompass your Parallel Works user workspace as well as remote on-premises or cloud clusters. When running on a cluster, we offer support for execution on the controller node, a SLURM partition, or a PBS queue. The session.sh script is launched on the selected executor to initiate the service..
The following files are executed in the specified order when a job is launched:
main.sh: Executes in the user workspace and contains the top-level logic for loading and preparing inputs, as well as the service.json file. This script also calls the<exec_mode>/session_wrapper.shscript.<exec_mode>/session_wrapper.sh: Executes in the user workspace, generating thesession.shby wrapping the<service_name>/start_template.shscript. Subsequently, it launches thesession.shscript on the designated executor. Thesession.shscript encapsulates the service code and oversees SSH tunnel management.
When a job is canceled, the following files are executed in this order:
kill.sh: Executes in the user workspace and is generated by the<exec_mode>/session_wrapper.shscript to terminate the session if the job is canceled.<service_name>/kill-template.sh: Executes in the selected executor and is used created by the by the<exec_mode>/session_wrapper.shscript to create thekill.sh. This scripts contains the commands that are specific to terminate the service.
The repository is structured as follows:
The Execution mode directories contain the wrapper script to execute the service in different types of executors:
local: User workspacecontroller: Controller node of the clusterpartition: SLURM partition or PBS queue
The workflow directory contains workflow-specific information and is further categorized into the following subdirectories:
readmes: Every file contains the description of a given workflow. The files are organized by service and each service has its own subdirectory.xmls: Contains the workflow XML files for each workflow. Remember this file is used by Parallel Works to render the input form and execute the workflow. The files are organized by service and each service has its own subdirectory. See workflow XML section for more information.thumbnails: Contains the thumbnail icon for each workflow. Typically, all workflows that run the same service use the same thumbnail.
The rest of the directories are service directories and contain the specific code to start the service.
The workflow XML encompasses both input parameters and execution details for each workflow. For a comprehensive understanding of workflow XML files, please consult the user guide. In this instance, it adheres to the subsequent structure:
- Command and cancellation items define the execution and cancellation process for the workflow.
- The
service_nameparameter is set as a fixed value corresponding to the service directory's name. - The resource section adheres to the resource wrapper tool's format. For further details, refer to this link.
- Additional parameters and sections are also included.
Follow this steps to add a new service using the interactive sessions repository.
You can either create a new service directory from scratch or duplicate an existing one that closely matches your requirements. Within the service directory, you'll be working with several scripts. These scripts have access to environment variables with the input parameters defined in the input form as well as any variables introduced by the workflow. Here are the key scripts:
-
start-template.sh: Use this script to write the necessary code to start the service.
-
url.sh: This script is responsible for writing the SLUG parameter within the file
service.json. Visit this link for more information about the service JSON file. In most cases, this script sets the SLUG parameter to """. -
kill-template.sh: This script serves the purpose of terminating the service initiated by start-template.sh when the workflow is canceled. For instance, if you employ
docker run -dwithin start-template.sh, this script becomes essential for stopping the Docker container. It is automatically executed when a job is canceled within the PW platform.
These components serve as the front end of the workflow, encompassing the description and XML files for each workflow that initiates this service. It's important to note that a single service can have various workflows tailored to strike the right balance between customization and generality. For instance, some workflows might require the exposure or hardcoding of specific SLURM directives, such as the account or the number of tasks per node for a particular cluster. Another common scenario involves desktop sessions that launch different software applications like MATLAB or RSTUDIO. This approach alleviates the need for users to complete extensive forms when submitting jobs to a designated cluster.
When crafting the XML file, we recommend starting with an existing one and making necessary adjustments to the service section to align with your requirements. It's crucial to ensure that the service_name parameter in the XML matches the name of the service directory.
Place a 120x120 PNG image into the thumbnails directory to serve as the workflow's thumbnail.