diff --git a/README.md b/README.md index 4ff58c200649a06d9ecdcc8923ee63413f68fdf0..dff10b1736b69e8be641852b7e4b48e64a6a5cf5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,77 @@ # Batch Connect - Desktop -This app is distributed as a part of Open OnDemand. Read https://osc.github.io/ood-documentation/latest/enable-desktops.html -for instructions on how to configure it. \ No newline at end of file + +[](https://opensource.org/licenses/MIT) + +A Batch Connect app designed to launch a GUI desktop withing a batch job. + +## Prerequisites + +This Batch Connect app requires the following software be installed on the +**compute nodes** that the batch job is intended to run on (**NOT** the +OnDemand node). + +One of the following desktops: + +- [Xfce Desktop] 4+ +- [Mate Desktop] 1+ (*default*) +- [Gnome Desktop] 2 (currently we do not support Gnome 3) + +For VNC server support: + +- [TurboVNC] 2.1+ +- [websockify] 0.8.0+ + +For hardware rendering support: + +- [X server] +- [VirtualGL] 2.3+ + +[Xfce Desktop]: https://xfce.org/ +[Mate Desktop]: https://mate-desktop.org/ +[Gnome Desktop]: https://www.gnome.org/ +[TurboVNC]: http://www.turbovnc.org/ +[websockify]: https://github.com/novnc/websockify +[X server]: https://www.x.org/ +[VirtualGL]: http://www.virtualgl.org/ + +## Install + +Use git to clone this app and checkout the desired branch/version you want to +use: + +```sh +scl enable git19 -- git clone <repo> +cd <dir> +scl enable git19 -- git checkout <tag/branch> +``` + +You will not need to do anything beyond this as all necessary assets are +installed. You will also not need to restart this app as it isn't a Passenger +app. + +To update the app you would: + +```sh +cd <dir> +scl enable git19 -- git fetch +scl enable git19 -- git checkout <tag/branch> +``` + +Again, you do not need to restart the app as it isn't a Passenger app. + +## Configuration + +Please see the [Install Desktops] section in the [Open OnDemand Documentation] +to learn more about setting up and configuring a desktop at your HPC center. + +[Install Desktops]: https://osc.github.io/ood-documentation/master/enable-desktops.html +[Open OnDemand Documentation]: https://osc.github.io/ood-documentation/master/index.html + +## Contributing + +1. Fork it ( https://github.com/OSC/bc_desktop/fork ) +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create a new Pull Request diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..eb9e63b2ed9b7610a43f040ca026024d22cadb97 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v0.2.2 \ No newline at end of file diff --git a/form.js.bak b/form.js.bak new file mode 100644 index 0000000000000000000000000000000000000000..ed93a437965cb503ddd726a9ad7188be88bf830d --- /dev/null +++ b/form.js.bak @@ -0,0 +1,68 @@ +const table = { + "interactive": { "max_cpu": 48, "max_hour": 2, "max_gpu": -1 }, + "express": { "max_cpu": 48, "max_hour": 2, "max_gpu": -1 }, + "short": { "max_cpu": 48, "max_hour": 12, "max_gpu": -1 }, + "pascalnodes": { "max_cpu": 28, "max_hour": 12, "max_gpu": 4 }, + "pascalnodes-medium": { "max_cpu": 28, "max_hour": 48, "max_gpu": 4 }, + "medium": { "max_cpu": 48, "max_hour": 50, "max_gpu": -1 }, + "long": { "max_cpu": 48, "max_hour": 150, "max_gpu": -1 }, + "intel-dcb": { "max_cpu": 24, "max_hour": 150, "max_gpu": -1 }, + "amd-hdr100": { "max_cpu": 128, "max_hour": 150, "max_gpu": -1 }, + "largemem": { "max_cpu": 24, "max_hour": 50, "max_gpu": -1 }, + "largemem-long": { "max_cpu": 24, "max_hour": 150, "max_gpu": -1 }, + "amperenodes": { "max_cpu": 128, "max_hour": 12, "max_gpu": 2 }, + "amperenodes-medium": { "max_cpu": 128, "max_hour": 48, "max_gpu": 2 }, +} + +function set_max_value(form_id, value) { + const form_element = $(form_id); + form_element.attr({'max': value}); +} + +function set_partition_change_handler() { + let partition_select = $("#batch_connect_session_context_bc_partition"); + partition_select.change( function(e) { + toggle_gpu_visibility(e); + }); +} + +function toggle_gpu_visibility(event) { + const partition = event.target.value; + const cpu_selector = '#batch_connect_session_context_bc_num_slots'; + const gpu_selector = '#batch_connect_session_context_bc_num_gpus'; + const hour_selector = '#batch_connect_session_context_bc_num_hours'; + + toggle_visibilty_of_form_group(gpu_selector, table[partition]["max_gpu"] != -1); + set_max_value(cpu_selector, table[partition]["max_cpu"]); + set_max_value(gpu_selector, table[partition]["max_gpu"]); + set_max_value(hour_selector, table[partition]["max_hour"]); +} + +function toggle_visibilty_of_form_group(form_id, show) { + let form_element = $(form_id); + let parent = form_element; + + while ( + (! parent[0].classList.contains('form-group')) && + (! parent.is('html')) // ensure that we don't loop infinitely + ) { + parent = parent.parent(); + } + + // If parent is HTML then something has gone wrong and visibility should not be changed + if ( parent.is('html') ) { + return; + } + + if(show) { + parent.show(); + } else { + parent.hide(); + } +} + +toggle_gpu_visibility( + // Fake the event + { target: document.querySelector('#batch_connect_session_context_bc_partition') } +); +set_partition_change_handler(); diff --git a/form.yml b/form.yml index a31a49879ebf3937918d912d18c27f8925f747d1..47be78eac643f34d2493be874db115c7f07f1178 100644 --- a/form.yml +++ b/form.yml @@ -1,13 +1,6 @@ --- attributes: - desktop: - label: "Desktop Environment" - widget: select - options: - - "gnome" - - "kde" - - "mate" - - "xfce" + desktop: "mate" bc_vnc_idle: 0 bc_vnc_resolution: required: true diff --git a/submit.yml.erb b/submit.yml.erb index ad7153b5271e9e8b36114353df50b039eff83a11..c479578737da62bafd550df66a8d5fd7af9b60e5 100644 --- a/submit.yml.erb +++ b/submit.yml.erb @@ -1,31 +1,3 @@ -<%- - email = ENV['USER'] - if !email.include? '@' - email = email + '@uab.edu' - end --%> --- -script: - job_environment: - USER: "<%= ENV['USER'] %>" - native: - - "-N 1" - - "-n <%= bc_num_slots.blank? ? 1 : bc_num_slots.to_i %>" - - "--mem-per-cpu=<%= bc_num_mems.blank? ? 4 : bc_num_mems.to_i %>G" - - "--partition=<%= bc_partition %>" - - "--time=<%= bc_num_hours.blank? ? 1 : bc_num_hours.to_i %>:00:00" - - "--job-name=ood-vnc" -<%- if bc_partition.include? "pascalnodes" or bc_partition.include? "amperenodes" -%> - - "--gres=gpu:<%= bc_num_gpus.blank? ? 1 : bc_num_gpus.to_i %>" -<%- end -%> -<%- if bc_email_on_started == "1" -%> - - "--mail-type=BEGIN" - - "--mail-user=<%= email %>" -<%- end -%> -<%- if bc_email_on_started == "1" -%> - - "--mail-type=BEGIN" - - "--mail-user=<%= email %>" -<%- end -%> -<%- if bc_reservation != "" -%> - - "--reservation=<%= bc_reservation %> -<%- end -%> +batch_connect: + template: vnc diff --git a/template/desktops/gnome.sh b/template/desktops/gnome.sh index 2081558eea8cd1d077398d1fbde722584384dce9..5999fd0a74229ccde06ecc964bb7dd46f36345fd 100755 --- a/template/desktops/gnome.sh +++ b/template/desktops/gnome.sh @@ -13,33 +13,5 @@ if [[ -f "${HOME}/.config/monitors.xml" ]]; then mv "${HOME}/.config/monitors.xml" "${HOME}/.config/monitors.xml.bak" fi -# gnome won't start correctly without DBUS_SESSION_BUS_ADDRESS set. -eval $(dbus-launch --sh-syntax) - -source /etc/os-release - -function classic(){ - export XDG_SESSION_TYPE="${XDG_SESSION_TYPE:-x11}" - export GNOME_SHELL_SESSION_MODE="${GNOME_SHELL_SESSION_MODE:-classic}" - export GNOME_SESSION_MODE="${GNOME_SESSION_MODE:-classic}" -} - -function wayland() { - export XDG_SESSION_TYPE="${XDG_SESSION_TYPE:-x11}" - export GNOME_SHELL_SESSION_MODE="${GNOME_SHELL_SESSION_MODE:-wayland}" - export GNOME_SESSION_MODE="${GNOME_SESSION_MODE:-wayland}" -} - -if [[ "$ID_LIKE" =~ "fedora" ]]; then - if [[ "$VERSION_ID" < "8.0" ]]; then - # el7 will crash using wayland. - classic - else - wayland - fi -else - wayland -fi - # Start up Gnome desktop (block until user logs out of desktop) /etc/X11/xinit/Xsession gnome-session diff --git a/template/desktops/kde.sh b/template/desktops/kde.sh deleted file mode 100755 index a1695b8c200980cd25c9c2792af65c100b3ed0de..0000000000000000000000000000000000000000 --- a/template/desktops/kde.sh +++ /dev/null @@ -1 +0,0 @@ -startkde \ No newline at end of file diff --git a/template/desktops/mate.sh b/template/desktops/mate.sh index efd4d76b06b016074601b6d9b8ae6a6b05899635..5cfba959d885e1fe853b75bccd9be88ebba9da7f 100755 --- a/template/desktops/mate.sh +++ b/template/desktops/mate.sh @@ -14,9 +14,7 @@ AUTOSTART="${HOME}/.config/autostart" rm -fr "${AUTOSTART}" # clean up previous autostarts mkdir -p "${AUTOSTART}" for service in "gnome-keyring-gpg" "gnome-keyring-pkcs11" "gnome-keyring-secrets" "gnome-keyring-ssh" "mate-volume-control-applet" "polkit-mate-authentication-agent-1" "pulseaudio" "rhsm-icon" "spice-vdagent" "xfce4-power-manager"; do - if [[ -f "/etc/xdg/autostart/${service}.desktop" ]]; then - cat "/etc/xdg/autostart/${service}.desktop" <(echo "X-MATE-Autostart-enabled=false") > "${AUTOSTART}/${service}.desktop" - fi + cat "/etc/xdg/autostart/${service}.desktop" <(echo "X-MATE-Autostart-enabled=false") > "${AUTOSTART}/${service}.desktop" done # Disable pulseaudio diff --git a/template/desktops/xfce.sh b/template/desktops/xfce.sh index b438164015bf9877899a433b71133bd91a64c9e7..6e2e1ae92d79694bf7b15e3e82c0ba906b2d4bcc 100755 --- a/template/desktops/xfce.sh +++ b/template/desktops/xfce.sh @@ -36,9 +36,5 @@ else "${TERM_CONFIG}" fi -# launch dbus first through eval becuase it can conflict with a conda environment -# see https://github.com/OSC/ondemand/issues/700 -eval $(dbus-launch --sh-syntax) - # Start up xfce desktop (block until user logs out of desktop) xfce4-session diff --git a/template/script.sh.erb b/template/script.sh.erb index 713539d0561d28d3c66ecf28332974d69dc136d5..9d7d26fdeef37668e5b5a409f96b782942fa1330 100755 --- a/template/script.sh.erb +++ b/template/script.sh.erb @@ -9,12 +9,7 @@ module purge && module restore # Ensure that the user's configured login shell is used export SHELL="$(getent passwd $USER | cut -d: -f7)" -# use a safe PATH to boot the desktop because dbus-launch can be -# in another location from a python/conda installation and that will -# conflict and cause issues. See https://github.com/OSC/ondemand/issues/700 for more. -SAFE_PATH="/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin" - # Start up desktop echo "Launching desktop '<%= context.desktop %>'..." -PATH="$SAFE_PATH" source "<%= session.staged_root.join("desktops", "#{context.desktop}.sh") %>" -echo "Desktop '<%= context.desktop %>' ended with $? status..." +source "<%= session.staged_root.join("desktops", "#{context.desktop}.sh") %>" +echo "Desktop '<%= context.desktop %>' ended..."