### Clone and Setup OOD Shell App Source: https://github.com/osc/ondemand/blob/master/apps/shell/README.md Clones the OOD Shell repository and sets up the development environment by creating a symlink and running the setup script. This is the initial step for developing the application. ```bash mkdir -p ~/ondemand/dev git clone https://github.com/OSC/ondemand.git ~/ondemand/src cd ~/ondemand/dev ln -s ../src/apps/shell cd ~/ondemand/dev/shell bin/setup ``` -------------------------------- ### Setup Dashboard for Preset Apps Source: https://github.com/osc/ondemand/wiki/Testing-the-Preset-App-Functionality Commands to prepare your development dashboard for testing Preset Apps. This involves navigating to the dashboard directory, checking out a specific branch, cleaning and resetting files, setting up, and restarting the PUN. ```bash cd into your dev dashboard git checkout backportPresetAppInto2.0 rm -Rf public git checkout . bin/setup restart your PUN ``` -------------------------------- ### Bundle and Setup Dashboard Dependencies Source: https://github.com/osc/ondemand/blob/master/DEVELOPMENT.md This code configures Bundler to use a local vendor directory for gems and then runs the setup script to fetch all necessary dependencies and compile assets for the dashboard application. This is a crucial step after cloning the repository. ```bash # advanced users may not need to configure bundle. Container users must do this. bin/bundle config path --local vendor/bundle bin/setup ``` -------------------------------- ### Clone Repository and Setup Development Environment (Shell) Source: https://github.com/osc/ondemand/blob/master/apps/myjobs/README.md This snippet demonstrates how to clone the Open OnDemand repository, create a symbolic link for the Job Composer app, and set up the development environment by fetching dependencies and compiling. ```shell mkdir -p ~/ondemand/dev git clone https://github.com/OSC/ondemand.git ~/ondemand/src cd ~/ondemand/dev ln -s ../src/apps/myjobs bin/setup ``` -------------------------------- ### Ruby Hash Initialization Example (Pass) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Illustrates the preferred literal syntax for initializing a hash in Ruby. ```ruby hsh = {} ``` -------------------------------- ### Ruby Array Initialization Example (Pass) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Illustrates the preferred literal syntax for initializing an array in Ruby. ```ruby arr = [] ``` -------------------------------- ### Ruby Hash Initialization Example (Fail) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Shows the less preferred way to initialize a hash in Ruby using `Hash.new()`. ```ruby hsh = Hash.new() ``` -------------------------------- ### Ruby Array Initialization Example (Fail) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Shows the less preferred way to initialize an array in Ruby using `Array.new()`. ```ruby arr = Array.new() ``` -------------------------------- ### Ruby Method Definition Example Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Shows the convention of placing an empty line between method definitions in Ruby. ```ruby def method1(arg1) ... end def method2(arg1) ... end ``` -------------------------------- ### Start Jupyter Server Source: https://context7.com/osc/ondemand/llms.txt Command to launch a Jupyter notebook server with a specified configuration file. This is typically used for interactive data science sessions. ```bash jupyter notebook --config="${JUPYTER_CONFIG_DIR}/jupyter_notebook_config.py" ``` -------------------------------- ### Ruby String Array Literal Example (Pass) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Illustrates the preferred literal syntax for creating an array of strings in Ruby. ```ruby arr_1 = ["one", "two", "three"] ``` -------------------------------- ### Ruby Method Chaining Example Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Demonstrates the preferred alignment for successive method chains in Ruby, with the method call on a new line. ```ruby obj .compact .map { |elmt| ... } ``` -------------------------------- ### Ruby %w Array Literal Example (Fail) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Shows the less preferred way to create an array of strings in Ruby using the `%w` literal. ```ruby arr_1 = %w(one two three) ``` -------------------------------- ### Ruby Class with Attributes Example Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Demonstrates the recommended spacing around `attr_reader` and `attr_accessor` blocks in Ruby classes. ```ruby class MyClass attr_reader :name, :email attr_accessor :phone def initialize(name, email) @name = name @email = email @phone = phone end end ``` -------------------------------- ### Run OOD Shell App Locally Source: https://github.com/osc/ondemand/blob/master/apps/shell/README.md Starts the OOD Shell application locally using Node.js, allowing development and testing outside the Open OnDemand infrastructure. The app will listen on port 3000. ```javascript node app.js ``` -------------------------------- ### Ruby Hash Literal Example Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Demonstrates the preferred syntax for creating a hash literal in Ruby, with spaces around operators and after colons. ```ruby my_hash = { one: 'el1', two: 'el2' } ``` -------------------------------- ### Ruby Class Attributes Example Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Shows the preferred order of declarations within a Ruby class: attributes, singleton methods, and then the initializer. ```ruby class MyClass attr_reader :something, :another class << self def singleton_method ... end end def initialize ... end end ``` -------------------------------- ### Configure Preset App (bc_osc_jupyter) Source: https://github.com/osc/ondemand/wiki/Testing-the-Preset-App-Functionality Steps to clone and configure the bc_osc_jupyter Preset App. This includes creating a local directory, a choice.yml file, and a preset.yml file with specific attributes for the Jupyter environment. ```bash git clone bc_osc_jupyter, if you have not already done so. cd bc_osc_jupyter mkdir local cd local touch choice.yml ``` ```yaml caption: "small Rstudio environment for 6 hours" cluster: "pitzer" attributes: version: "app_jupyter" bc_num_hours: 6 node_type: "any" num_cores: 1 include_tutorials: false bc_email_on_started: false account: 'PZS0714' mode: 1 cuda_version: 'cuda/9.0.176' ``` -------------------------------- ### Exception Handling with Begin/Rescue (Ruby) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Demonstrates the correct usage of `begin...rescue` blocks in Ruby for exception handling. It shows how to catch specific exceptions like `Psych::SyntaxError` and re-raise them. The 'pass' example illustrates implicit `begin` usage, which is preferred. ```ruby # fail def some_method begin ... rescue Psych::SyntaxError => e ... raise e end # pass def some_method ... rescue Psych::SyntaxError => e ... raise e end ``` -------------------------------- ### Access OOD Shell Locally with Host/Directory Source: https://github.com/osc/ondemand/blob/master/apps/shell/README.md Demonstrates how to access the locally running OOD Shell application with specific host and directory parameters. This allows for testing different connection scenarios. ```http http://localhost:3000/ http://localhost:3000/ssh/ http://localhost:3000/ssh/default/ http://localhost:3000/ssh// ``` -------------------------------- ### Ruby Array Literal Example Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Illustrates the preferred syntax for array literals in Ruby, avoiding spaces around square brackets. ```ruby my_arr = [a, b, c] ``` -------------------------------- ### Modify iHPC Session Context via Rake Task (Bash) Source: https://github.com/osc/ondemand/wiki/start_interactive_app_from_command_line This example shows how to launch an iHPC session with a customized session context. By providing a JSON-formatted string to standard input, users can modify parameters such as walltime, number of nodes, and VNC resolution. The example uses a heredoc to pass the JSON context to the rake task. ```bash # Set environment for the Dashboard app of your choosing ... # Launch and Owens desktop session with user-defined context bin/rake batch_connect:new_session BC_APP_TOKEN=sys/bc_desktop_v2/owens <<-EOF { "bc_num_hours": "1", "bc_num_slots": "1", "node_type": ":ppn=28", "bc_account": "", "bc_vnc_resolution": "2048x1152", "bc_email_on_started": "0" } EOF ``` -------------------------------- ### Setting Container Capabilities Source: https://github.com/osc/ondemand/blob/master/DEVELOPMENT.md Example of setting additional Linux capabilities for the development container using the OOD_CTR_CAPABILITIES environment variable. A comma-separated list of capabilities can be provided. ```shell export OOD_CTR_CAPABILITIES=net_raw,net_admin ``` -------------------------------- ### Mounting Directories into the Container Source: https://github.com/osc/ondemand/blob/master/DEVELOPMENT.md Examples of how to mount host directories into the Open OnDemand development container using OOD_MNT_ environment variables. This allows overriding container contents with local files. ```shell # Mount ood-portal-generator export OOD_MNT_PORTAL=/ood-portal-generator # Mount nginx_stage export OOD_MNT_NGINX=/nginx_stage # Mount ood_proxy export OOD_MNT_PROXY=/ood_proxy ``` -------------------------------- ### Ruby Private Method Example Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Illustrates the indentation of private methods in Ruby, aligning `defs` with the block and keeping them after public methods. ```ruby class MyClass # public methods def public_method ... end private def my_private_method ... end end ``` -------------------------------- ### Custom Batch Connect Script Template with ERB Source: https://context7.com/osc/ondemand/llms.txt Defines the main job script template for Batch Connect applications, using ERB for dynamic content generation. This example sets up a Jupyter environment, including module loading and configuration file creation. ```bash #!/bin/bash # /var/www/ood/apps/sys/my_jupyter/template/script.sh.erb # Load required modules module purge module load <%= context.version %> # Set up Jupyter configuration export JUPYTER_CONFIG_DIR="${HOME}/.jupyter/ondemand" mkdir -p "${JUPYTER_CONFIG_DIR}" # Generate Jupyter config cat > "${JUPYTER_CONFIG_DIR}/jupyter_notebook_config.py" << EOF c.NotebookApp.ip = '0.0.0.0' c.NotebookApp.port = ${port} c.NotebookApp.base_url = '/node/${host}/${port}/' c.NotebookApp.open_browser = False c.NotebookApp.allow_origin = '*' c.NotebookApp.token = '' c.NotebookApp.password = '' EOF ``` -------------------------------- ### Environment Variables for .env.local Source: https://github.com/osc/ondemand/blob/master/DEVELOPMENT.md Example environment variables that can be set in a .env.local file to configure Open OnDemand. These variables are only set if they are not already defined. ```env OOD_BRAND_BG_COLOR="#c1a226" #OOD_LOAD_EXTERNAL_CONFIG=1 #OOD_LOAD_EXTERNAL_BC_CONFIG=1 OOD_APP_SHARING=true MOTD_PATH="/etc/motd" MOTD_FORMAT="osc" SHOW_ALL_APPS_LINK=1 OOD_CLUSTERS="/home/annie.oakley/ondemand/misc/clusters.d" OOD_CONFIG_D_DIRECTORY="/home/annie.oakley/ondemand/misc/config/ondemand.d" OOD_BALANCE_PATH="/home/annie.oakley/ondemand/misc/config/balances.json" OOD_BALANCE_THRESHOLD=50 OOD_QUOTA_PATH="/home/ondemand/misc/config/quotas/my_quota.json" OOD_QUOTA_THRESHOLD=0.1 ``` -------------------------------- ### Ruby Multiline Array Literal Example (Pass) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Demonstrates the correct way to format multiline array literals in Ruby, with closing brackets on their own line and no trailing commas. ```ruby arr = [ this = 1, that = 2 ] ``` -------------------------------- ### Generate Session Connection YAML Source: https://context7.com/osc/ondemand/llms.txt Example of a YAML file used by Batch Connect apps to store session connection details. This file is auto-generated and contains host, port, and password information for establishing a connection. ```yaml --- host: "compute-001.example.com" port: 5901 password: "random_vnc_password" display: 1 websocket: 6901 spassword: "random_web_password" ``` -------------------------------- ### Environment Variables for .env.overload Source: https://github.com/osc/ondemand/blob/master/DEVELOPMENT.md Example environment variables that can be set in a .env.overload file to override any existing environment variable, including system-level ones. This is useful for development overrides. ```env OOD_EDITOR_URL='/pun/dev/dashboard/files' OOD_FILES_URL='/pun/dev/dashboard/files' ``` -------------------------------- ### Write Connection Info to YAML (ERB) Source: https://context7.com/osc/ondemand/llms.txt An ERB template script that writes connection information to a YAML file after a VNC session starts. It dynamically retrieves the hostname, VNC port, password, and websocket port. ```erb <%# /var/www/ood/apps/sys/bc_desktop/template/after.sh.erb %> <%# Write connection info after VNC starts %> echo "host: $(hostname -f)" > "<%= session.staged_root %>/connection.yml" echo "port: ${VNC_PORT}" >> "<%= session.staged_root %>/connection.yml" echo "password: ${VNC_PASSWORD}" >> "<%= session.staged_root %>/connection.yml" echo "websocket: ${WEBSOCKET_PORT}" >> "<%= session.staged_root %>/connection.yml" ``` -------------------------------- ### Meaningful Variable Naming (Ruby) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Illustrates the importance of using meaningful variable names in Ruby, especially for loop iterators. It contrasts 'fail' examples with generic names like 'e' against 'pass' examples using descriptive names like 'str' or 'int' to improve code readability and maintainability in a dynamically typed language. ```ruby arr_1 = ['one', 'two', 'three'] arr_2 = [1, 2, 3] # fail arr_1.each { |e| puts e } arr_2.each { |e| puts e } # pass arr_1.each { |str| puts str } arr_2.each { |int| puts int } ``` -------------------------------- ### NGINX Stage Configuration for Resource Limits and Logging Source: https://context7.com/osc/ondemand/llms.txt Sets up per-user NGINX processes via `/etc/ood/config/nginx_stage.yml`. This configuration controls resource limits, logging, and application deployment paths for user environments (PUNs). ```yaml # /etc/ood/config/nginx_stage.yml --- ondemand_portal: "ondemand" ondemand_title: "My HPC Portal" # Passenger configuration passenger_pool_idle_time: 300 passenger_options: passenger_max_pool_size: 8 passenger_min_instances: 1 # File upload limit (10GB) nginx_file_upload_max: '10737420000' # Custom environment variables for all PUNs pun_custom_env: OOD_DASHBOARD_TITLE: "My HPC Portal" OOD_BRAND_BG_COLOR: "#003366" OOD_BRAND_LINK_ACTIVE_BG_COLOR: "#004488" # Minimum UID (prevent running as system users) min_uid: 1000 # Disabled shell to block certain users disabled_shell: '/sbin/nologin' # Application paths app_root: dev: '/var/www/ood/apps/dev/%{owner}/gateway/%{name}' usr: '/var/www/ood/apps/usr/%{owner}/gateway/%{name}' sys: '/var/www/ood/apps/sys/%{name}' ``` -------------------------------- ### Clone and Symlink Dashboard for Development Source: https://github.com/osc/ondemand/blob/master/DEVELOPMENT.md This snippet shows how to clone the Open OnDemand repository and create a symbolic link for the dashboard application in the development directory. This makes the dashboard discoverable by Open OnDemand as any other app in the development path. ```text mkdir -p ~/ondemand/dev git clone git@github.com:OSC/ondemand.git ~/ondemand/src cd ~/ondemand/dev ln -s ../src/apps/dashboard ``` -------------------------------- ### Configure Batch Connect Application Form Source: https://context7.com/osc/ondemand/llms.txt Defines the user-selectable options for an interactive Batch Connect application using YAML. Supports dynamic widgets, auto-populated fields, and cluster-aware configurations for a customized user experience. ```yaml --- cluster: "my_cluster" form: - bc_account - bc_num_hours - bc_num_slots - version - bc_queue - bc_email_on_started attributes: bc_num_hours: value: 4 min: 1 max: 24 step: 1 label: "Number of hours" help: "Maximum walltime for the job" bc_num_slots: widget: "number_field" value: 1 min: 1 max: 28 label: "Number of cores" version: widget: "select" label: "Jupyter Version" options: - ["3.0.0", "jupyter/3.0.0"] - ["2.7.0", "jupyter/2.7.0"] help: "Select the Jupyter notebook version" bc_queue: label: "Partition" value: "standard" ``` -------------------------------- ### Batch Connect Sessions API Source: https://context7.com/osc/ondemand/llms.txt Launch, monitor, and manage interactive computing sessions programmatically through the Batch Connect Sessions controller. ```APIDOC ## Batch Connect Sessions API ### Description Launch, monitor, and manage interactive computing sessions programmatically through the Batch Connect Sessions controller. ### Method GET, POST, DELETE ### Endpoint https://ondemand.example.com/pun/sys/dashboard/batch_connect ### Parameters #### Query Parameters (for GET requests) - None specific to listing sessions, typically accessed via `/sessions.json`. #### Request Body (for POST requests to create sessions) - **batch_connect_session_context** (object) - Contains context for the session. - **bc_account** (string) - The account to use for the job. - **bc_num_hours** (integer) - The duration of the session in hours. - **bc_num_slots** (integer) - The number of slots (cores) to request. - **version** (string) - The specific application/version to launch (e.g., "jupyter/3.0.0"). ### Request Example (List all active sessions) ```bash curl -H "Accept: application/json" \ -H "Cookie: $SESSION_COOKIE" \ "https://ondemand.example.com/pun/sys/dashboard/batch_connect/sessions.json" ``` ### Request Example (Create a new session - submit interactive job) ```bash curl -X POST \ -H "Cookie: $SESSION_COOKIE" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "batch_connect_session_context[bc_account]=myaccount" \ -d "batch_connect_session_context[bc_num_hours]=4" \ -d "batch_connect_session_context[bc_num_slots]=2" \ -d "batch_connect_session_context[version]=jupyter/3.0.0" \ "https://ondemand.example.com/pun/sys/dashboard/batch_connect/sys/jupyter/session_contexts" ``` ### Request Example (Cancel a running session) ```bash curl -X POST \ -H "Cookie: $SESSION_COOKIE" \ "https://ondemand.example.com/pun/sys/dashboard/batch_connect/sessions/abc123-uuid/cancel" ``` ### Request Example (Delete a session record) ```bash curl -X DELETE \ -H "Cookie: $SESSION_COOKIE" \ "https://ondemand.example.com/pun/sys/dashboard/batch_connect/sessions/abc123-uuid" ``` ### Response #### Success Response (200 for GET /sessions.json) - **sessions** (array) - An array of session objects. - **id** (string) - Session ID. - **name** (string) - Name of the session. - **status** (string) - Current status of the session. - ... (other session details) #### Success Response (200 for POST/DELETE) - **message** (string) - Confirmation message of the operation. #### Response Example (GET /sessions.json) ```json { "sessions": [ { "id": "abc123-uuid", "name": "Jupyter Notebook", "status": "Running" } ] } ``` #### Response Example (POST/DELETE) ```json { "message": "Session abc123-uuid cancelled successfully." } ``` ``` -------------------------------- ### Rake Tasks for Development Container Management Source: https://github.com/osc/ondemand/blob/master/DEVELOPMENT.md A list of common Rake tasks used to manage the Open OnDemand development container. These tasks facilitate starting, stopping, restarting, and executing commands within the container. ```ruby rake dev:start rake dev:stop rake dev:restart rake dev:exec rake dev:bash rake dev:rebuild ``` -------------------------------- ### Create Directory via Files API (Bash) Source: https://context7.com/osc/ondemand/llms.txt Uses curl to create a new directory on the filesystem via the Open OnDemand Files API. This demonstrates how to programmatically manage directories through RESTful endpoints. ```bash # Create a new directory curl -X PUT \ -H "Cookie: $SESSION_COOKIE" \ -d "dir=true" \ "https://ondemand.example.com/pun/sys/dashboard/files/fs/home/user/new_folder" ``` -------------------------------- ### Update hterm Library Source: https://github.com/osc/ondemand/blob/master/apps/shell/README.md Instructions for updating the hterm library, which is used for terminal emulation in the OOD Shell app. This involves cloning the hterm repository, running a build script, and replacing the existing hterm file in the Shell App repository. ```bash $ git clone https://chromium.googlesource.com/apps/libapps $ scl enable rh-python35 -- hterm/bin/mkdist.sh ``` -------------------------------- ### Dashboard Configuration for Layout, Pinned Apps, and Branding Source: https://context7.com/osc/ondemand/llms.txt Customizes the Open OnDemand dashboard layout, pinned applications, and branding using YAML files in `/etc/ood/config/ondemand.d/`. It also includes settings for quota warnings and support ticket configuration. ```yaml # /etc/ood/config/ondemand.d/dashboard.yml --- pinned_apps: - 'sys/jupyter' - 'sys/rstudio' - 'sys/bc_desktop' - 'sys/matlab' pinned_apps_menu_length: 6 pinned_apps_group_by: 'subcategory' # Dashboard layout customization dashboard_layout: rows: - columns: - width: 8 widgets: - pinned_apps - recently_used_apps - width: 4 widgets: - sessions - motd # Quota warnings quota_paths: - path: '/home' type: 'user' - path: '/scratch' type: 'fileset' # Support ticket configuration support_ticket: email: to: "hpc-support@example.com" delivery_method: "smtp" ``` -------------------------------- ### Configure Application Manifest Source: https://context7.com/osc/ondemand/llms.txt Defines metadata, category, and display properties for an application in manifest.yml. This helps organize applications within the Open OnDemand dashboard, providing users with essential information. ```yaml --- name: Jupyter Notebook icon: fa://book category: Interactive Apps subcategory: Servers role: batch_connect description: | Launch a Jupyter Notebook server on a compute node with access to your home directory and project storage. metadata: field_of_science: "Data Science" ``` -------------------------------- ### Configure HPC Cluster in YAML Source: https://context7.com/osc/ondemand/llms.txt Defines an HPC cluster's connection details, job adapter, and batch connect templates using YAML. This configuration is essential for Open OnDemand to interact with the cluster's resources and job scheduler. ```yaml --- v2: metadata: title: "My HPC Cluster" url: "https://docs.example.com/cluster" hidden: false login: host: "login.example.com" job: adapter: "slurm" cluster: "my_cluster" bin: "/usr/bin" batch_connect: basic: script_wrapper: "module restore\n%s" vnc: script_wrapper: "module restore\nmodule load turbovnc\n%s" custom: grafana: host: "grafana.example.com" orgId: 1 ``` -------------------------------- ### OOD Portal Generator Configuration (YAML) Source: https://context7.com/osc/ondemand/llms.txt Configuration file for the OnDemand portal generator, located at `/etc/ood/config/ood_portal.yml`. This YAML file defines server settings, SSL certificates, authentication methods (e.g., OpenID Connect), and user mapping. ```yaml # /etc/ood/config/ood_portal.yml --- servername: ondemand.example.com port: 443 ssl: - 'SSLCertificateFile "/etc/pki/tls/certs/ondemand.crt"' - 'SSLCertificateKeyFile "/etc/pki/tls/private/ondemand.key"' - 'SSLCertificateChainFile "/etc/pki/tls/certs/chain.crt"' # Authentication via OpenID Connect auth: - 'AuthType openid-connect' - 'Require valid-user' # User mapping - extract username from email user_map_match: '^([^@]+)@example\.com$' # Or use custom mapping script # user_map_cmd: '/opt/ood/scripts/user_map.py' ``` -------------------------------- ### Manage Batch Connect Sessions via Batch Connect Sessions API (curl) Source: https://context7.com/osc/ondemand/llms.txt Programmatically launch, monitor, and manage interactive computing sessions. Supports listing active sessions, creating new sessions with specified contexts, cancelling running sessions, and deleting session records. ```bash # List all active sessions curl -H "Accept: application/json" \ -H "Cookie: $SESSION_COOKIE" \ "https://ondemand.example.com/pun/sys/dashboard/batch_connect/sessions.json" # Create a new session (submit interactive job) curl -X POST \ -H "Cookie: $SESSION_COOKIE" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "batch_connect_session_context[bc_account]=myaccount" \ -d "batch_connect_session_context[bc_num_hours]=4" \ -d "batch_connect_session_context[bc_num_slots]=2" \ -d "batch_connect_session_context[version]=jupyter/3.0.0" \ "https://ondemand.example.com/pun/sys/dashboard/batch_connect/sys/jupyter/session_contexts" # Cancel a running session curl -X POST \ -H "Cookie: $SESSION_COOKIE" \ "https://ondemand.example.com/pun/sys/dashboard/batch_connect/sessions/abc123-uuid/cancel" # Delete a session record curl -X DELETE \ -H "Cookie: $SESSION_COOKIE" \ "https://ondemand.com/pun/sys/dashboard/batch_connect/sessions/abc123-uuid" ``` -------------------------------- ### Recompile Javascript Assets for Dashboard Source: https://github.com/osc/ondemand/blob/master/DEVELOPMENT.md This helper script, `bin/recompile_js`, is used to run the asset pipeline for changes made to CSS, JavaScript, or images within the dashboard application. Since the migration to esbuild, assets are not built automatically, making this script essential for development. ```bash bin/recompile_js ``` -------------------------------- ### Develop ood_core Gem Locally Source: https://github.com/osc/ondemand/blob/master/DEVELOPMENT.md This snippet demonstrates how to modify the Gemfile to point to a local source location for the `ood_core` gem (or any other gem). After updating the Gemfile, `bin/bundle update` is run to fetch the gem from the specified local path, allowing for direct development of the gem. ```ruby gem 'ood_core', :path=> '/full/path/to/checked/out/ood_core' ``` -------------------------------- ### Configure Batch Connect Submit Parameters Source: https://context7.com/osc/ondemand/llms.txt Configures job submission parameters for a Batch Connect application using ERB templating. Dynamically sets scheduler directives like native options, queue name, job name, and wall time based on user selections. ```erb --- batch_connect: template: "basic" script: native: - "-N" - "<%= bc_num_slots %>" - "--mem-per-cpu" - "4G" <% if bc_email_on_started == "1" %> - "--mail-type" - "BEGIN" <% end %> queue_name: "<%= bc_queue %>" job_name: "ondemand/jupyter" wall_time: "<%= (bc_num_hours.to_i * 3600) %>" ``` -------------------------------- ### Files API - Create Directory Source: https://context7.com/osc/ondemand/llms.txt Creates a new directory at the specified path. This endpoint is part of the Files API for managing file system operations. ```APIDOC ## PUT /pun/sys/dashboard/files/fs/{path} ### Description Creates a new directory at the specified path. This endpoint is part of the Files API for managing file system operations. ### Method PUT ### Endpoint `/pun/sys/dashboard/files/fs/{path}` ### Parameters #### Path Parameters - **path** (string) - Required - The absolute path where the new directory will be created. #### Query Parameters None #### Request Body - **dir** (boolean) - Required - Set to `true` to indicate directory creation. ### Request Example ```bash curl -X PUT \ -H "Cookie: $SESSION_COOKIE" \ -d "dir=true" \ "https://ondemand.example.com/pun/sys/dashboard/files/fs/home/user/new_folder" ``` ### Response #### Success Response (200 or 201) Indicates successful creation of the directory. The response body may be empty or contain confirmation details. #### Response Example (No specific example provided in the source text, typically an empty body or a success status code) ``` -------------------------------- ### Method Naming Conventions and Refactoring (Ruby) Source: https://github.com/osc/ondemand/blob/master/CONTRIBUTING.md Provides guidelines for Ruby method naming, including avoiding 'is_', using '?' for boolean return methods, and 'save'/'save!' for persistence. It also promotes refactoring complex conditional logic into separate methods (e.g., `conditions_true?`) to improve code clarity and adhere to the DRY principle. ```ruby # fail def some_method if var1 && bool2 && x > y || big % small > 1 ... end end def some_other_method if var1 && bool2 && x > y || big % small > 1 ... end end # pass def some_method if conditions_true? ... end end def some_other_method if conditions_true? ... end end def conditions_true? if var1 && bool2 && x > y || big % small > 1 end ``` -------------------------------- ### File Upload API Source: https://context7.com/osc/ondemand/llms.txt Uploads a file to the specified parent directory with a given name. ```APIDOC ## POST /pun/sys/dashboard/files/upload/fs ### Description Uploads a file to the specified parent directory with a given name. ### Method POST ### Endpoint https://ondemand.example.com/pun/sys/dashboard/files/upload/fs ### Parameters #### Form Data - **file** (file) - Required - The file to upload. - **parent** (string) - Required - The parent directory path. - **name** (string) - Required - The name of the file to be saved. ### Request Example ```bash curl -X POST \ -H "Cookie: $SESSION_COOKIE" \ -F "file=@local_script.py" \ -F "parent=/home/user/project" \ -F "name=script.py" \ "https://ondemand.example.com/pun/sys/dashboard/files/upload/fs" ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of successful upload. #### Response Example ```json { "message": "File uploaded successfully." } ``` ``` -------------------------------- ### Upload File via Files API (curl) Source: https://context7.com/osc/ondemand/llms.txt Uploads a local file to the OnDemand file system. Requires the session cookie, the file to upload, the parent directory, and the desired name for the file on the server. ```bash curl -X POST \ -H "Cookie: $SESSION_COOKIE" \ -F "file=@local_script.py" \ -F "parent=/home/user/project" \ -F "name=script.py" \ "https://ondemand.example.com/pun/sys/dashboard/files/upload/fs" ``` -------------------------------- ### Display Session Info (ERB) Source: https://context7.com/osc/ondemand/llms.txt An ERB template for an info.md.erb file used to display custom information within a session card on the Open OnDemand dashboard. It shows cluster details, job ID, creation time, and connection information if the session is running. ```erb <%# /var/www/ood/apps/sys/my_jupyter/info.md.erb %> <%# Displayed in the session card %> ### Jupyter Notebook Session **Cluster:** <%= session.cluster_id %> **Job ID:** <%= session.job_id %> **Created:** <%= Time.at(session.created_at).strftime("%Y-%m-%d %H:%M:%S") %> <% if session.running? %> **Host:** <%= session.connect.host %> **Port:** <%= session.connect.port %> Access your notebook at the URL shown when you click "Connect to Jupyter" <% end %> <% if context.respond_to?(:version) %> **Python Version:** <%= context.version %> <% end %> ``` -------------------------------- ### Dex Identity Provider Configuration Source: https://context7.com/osc/ondemand/llms.txt Configures the Dex identity provider, including SSL settings and LDAP connector details. It specifies the LDAP server host, bind credentials, and user search attributes for authentication. ```yaml dex: ssl: true connectors: - type: ldap id: ldap name: LDAP config: host: ldap.example.com:636 rootCA: /etc/ssl/certs/ldap-ca.pem bindDN: cn=readonly,dc=example,dc=com bindPW: "${LDAP_BIND_PASSWORD}" userSearch: baseDN: ou=People,dc=example,dc=com filter: "(objectClass=posixAccount)" username: uid idAttr: uid emailAttr: mail nameAttr: gecos preferredUsernameAttr: uid ``` -------------------------------- ### List Directory Contents via Files API (Bash) Source: https://context7.com/osc/ondemand/llms.txt Uses curl to request directory contents as JSON from the Open OnDemand Files API. This is useful for integrating file browsing capabilities into custom interfaces or scripts. ```bash # List directory contents as JSON curl -H "Accept: application/json" \ -H "Cookie: $SESSION_COOKIE" \ "https://ondemand.example.com/pun/sys/dashboard/files/fs/home/user/project" # Response: # { # "files": [ # { # "id": "dev-64769-inode-12345", # "name": "analysis.py", # "size": 4096, # "directory": false, # "date": 1704067200, # "owner": "user", # "mode": 33188, # "downloadable": true # }, # { # "id": "dev-64769-inode-12346", # "name": "data", # "size": null, # "directory": true, # "date": 1704067100, # "owner": "user", # "mode": 16877, # "downloadable": true # } # ] # } ```