Skip to content

Commit

Permalink
Merge pull request #55 from lunarc/develop
Browse files Browse the repository at this point in the history
Merge from develop
  • Loading branch information
jonaslindemann authored Aug 7, 2024
2 parents edcce3e + 2ddf6d1 commit 1d2f4f5
Show file tree
Hide file tree
Showing 96 changed files with 265 additions and 143 deletions.
8 changes: 8 additions & 0 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ Directories and files for the **gfxconvert** menu generation is given in this se
+----------------------------+-------------------------------------------------------------------------------+
| directdesktop_entry_prefix | Prefix added to desktop-shortcut files generated by gfxmenu. |
+----------------------------+-------------------------------------------------------------------------------+
| menu_location | Location of the menu files (applications-merged). |
+----------------------------+-------------------------------------------------------------------------------+
| app_location | Location of the application files (applications). |
+----------------------------+-------------------------------------------------------------------------------+
| dir_location | Location of the desktop files (desktop-directories). |
+----------------------------+-------------------------------------------------------------------------------+
| ondemand_location | Location where to write the generation timestamp |
+----------------------------+-------------------------------------------------------------------------------+

VirtualGL section - [vgl]
-------------------------
Expand Down
8 changes: 7 additions & 1 deletion docs/source/gfxmenu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To use the **gfxmenu** tool to generate menus, every application that should be

An example of a script filename is shown below:

``blender-3.1.0.sh``
``blender-3.5.1.sh``

The main purpose of the script is to launch the application and provide launcher tags customising the **gfxlaunch** user interface. If the application requires hardware accelerated graphics it is usually started with the **vglrun** command in this script. An example of such a script is shown below:

Expand Down Expand Up @@ -51,6 +51,8 @@ The following attributes are supported by **gfxmenu**:
+------------------------+-------------------------------------------------------------------+
| ##LDT part_disable | Hide the partition selection combi |
+------------------------+-------------------------------------------------------------------+
| ##LDT no_launcher | Creates a direct launch of the script, bypassing the backend (yes)|
+------------------------+-------------------------------------------------------------------+

When the job attribute is specified the script can be empty except for the attribute declarations.

Expand All @@ -65,6 +67,10 @@ A script for a Jupyter Lab session is shown below:
##LDT part = "lu"
##LDT job = "jupyterlab"
.. note::

The **gfxmenu** the no_launcher attribute is used to create a direct launch of the script, bypassing the backend. This is useful for applications that do not require a backend job to be started. However, as the gnome shell is launched early it is not certain that module commands are available. The start scripts needs to set the paths to the applications manually.

Generating menus and desktop entries
------------------------------------

Expand Down
8 changes: 7 additions & 1 deletion etc/gfxlauncher.conf
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ group_mathem = lu48, lu32
group_all = lu48,lu32,gpua100,gpua40
group_cpuintel = lu32
group_cpuamd = lu48
group_cpuall = lu48, lu32

group_ondemand_tasks = 4
group_ondemand_memory = -1
group_ondemand_exclusive = no

group_mathem_tasks=4
group_mathem_tasks = 4
group_cpuall_tasks = 1

default_tasks = 1
default_memory = 5300
default_exclusive = no

use_sacctmgr = yes

Expand Down
2 changes: 1 addition & 1 deletion gfxlaunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
under certain conditions; see LICENSE for details.
"""
gfxlaunch_copyright_short = """LUNARC HPC Desktop On-Demand - %s"""
gfxlaunch_version = "0.9.10"
gfxlaunch_version = "0.9.11"

# --- Fix search path for tool

Expand Down
13 changes: 9 additions & 4 deletions gfxmenu.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env python
#
# LUNARC HPC Desktop On-Demand graphical launch tool
# Copyright (C) 2017-2023 LUNARC, Lund University
# Copyright (C) 2017-2024 LUNARC, Lund University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -29,19 +29,20 @@
import getpass
import argparse
import time
import logging

from lhpcdt import integration as it
from lhpcdt import scripts as scr
from lhpcdt import config

gfxmenu_copyright = """LUNARC HPC Desktop On-Demand - Version %s
Copyright (C) 2017-2023 LUNARC, Lund University
Copyright (C) 2017-2024 LUNARC, Lund University
This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.
This is free software, and you are welcome to redistribute it
under certain conditions; see LICENSE for details.
"""
gfxmenu_copyright_short = """LUNARC HPC Desktop On-Demand - %s"""
gfxmenu_version = "0.9.4"
gfxmenu_version = "0.9.11"

if __name__ == "__main__":

Expand All @@ -51,17 +52,21 @@
parser.add_argument("--no-launcher", help="Generate menus and scripts with direct launch.", action="store_true")
parser.add_argument("--config", help="Show configuration", action="store_true")
parser.add_argument("--silent", help="Run without output", action="store_true")
parser.add_argument("--verbose", help="Verbose logging", action="store_true")
args = parser.parse_args()

# ----- Show version information

if not args.silent:
print(("LUNARC HPC Desktop - User menu tool - Version %s" % gfxmenu_version))
print("Written by Jonas Lindemann (jonas.lindemann@lunarc.lu.se)")
print("Copyright (C) 2018-2023 LUNARC, Lund University")
print("Copyright (C) 2018-2024 LUNARC, Lund University")

# ----- Read configuration

if args.verbose:
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S', level=logging.DEBUG)

cfg = config.GfxConfig.create()

if args.config:
Expand Down
6 changes: 3 additions & 3 deletions gfxusage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env python
#
# LUNARC HPC Desktop On-Demand graphical job status display
# Copyright (C) 2017-2023 LUNARC, Lund University
# Copyright (C) 2017-2024 LUNARC, Lund University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -24,13 +24,13 @@
# --- Version information

gfxlaunch_copyright = """LUNARC HPC Desktop On-Demand GfxUsage - Version %s
Copyright (C) 2017-2022 LUNARC, Lund University
Copyright (C) 2017-2024 LUNARC, Lund University
This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.
This is free software, and you are welcome to redistribute it
under certain conditions; see LICENSE for details.
"""
gfxlaunch_copyright_short = """LUNARC HPC Desktop On-Demand GfxUsage - %s"""
gfxlaunch_version = "0.9.4"
gfxlaunch_version = "0.9.11"

# --- Fix search path for tool

Expand Down
42 changes: 24 additions & 18 deletions intrun
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,36 @@ CURR_DIR=$(pwd)

# Define the options

TEMP=$(getopt -o s,n --long silent,tasks-per-node: -n 'intrun' -- "$@")
#TEMP=$(getopt -o s,n --long silent,tasks-per-node,dbus: -n 'intrun' -- "$@")

# Exit if the options have not been successfully parsed

if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi
#if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi

# Note the quotes around `$TEMP`: they are essential!

eval set -- "$TEMP"
#eval set -- "$TEMP"

# Default values for options
# Parse options meant for the script itself

silent=''
tasks_per_node=1
dbus=''

while [[ "$#" -gt 0 ]]; do
case $1 in
--silent) silent='--silent'; shift ;;
--dbus) dbus='--dbus'; shift ;;
--tasks-per-node) tasks_per_node="$2"; shift 2 ;;
--) shift; break ;; # Explicitly split script options from command
*) echo "Unknown option: $1"; exit 1 ;;
esac
done

# Default values for options

# Extract options and their arguments into variables

while true; do
case "$1" in
--silent)
silent='--silent'; shift ;;
--tasks-per-node)
tasks_per_node="$2"; shift 2 ;;
--)
shift; break ;;
*)
echo "Internal error!"; exit 1 ;;
esac
done

if [ -z $1 ]; then
echo "Error: No arguments provided."
Expand All @@ -63,17 +64,22 @@ EXE_NAME=$(basename "${FULL_PATH_BIN}")

shift

if [ ! -z $dbus ]; then
DBUS_LAUNCH_CMD="dbus-launch --exit-with-session"
DBUS_CLEANUP_CMD="killall dbus-launch"
fi

# Launch the graphics application with the provided arguments

if [ -f "$FULL_PATH" ]; then
CMD="export PATH=$OLD_PATH;export LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH;export PYTHONPATH=$OLD_PYTHONPATH;cd ${FULL_PATH};./${EXE_NAME} $@"
CMD="export PATH=$OLD_PATH;export LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH;export PYTHONPATH=$OLD_PYTHONPATH;cd ${FULL_PATH};${DBUS_LAUNCH_CMD} ./${EXE_NAME} $@;${DBUS_CLEANUP_CMD}"
TMP_SCRIPT=$(mktemp -p ${FULL_PATH})
echo ${CMD} >> ${TMP_SCRIPT}
chmod +x ${TMP_SCRIPT}
gfxlaunch --group $GFX_GROUP --title "Interactive Local Run" $silent --tasks-per-node=$tasks_per_node --feature-disable --cmd ${TMP_SCRIPT}
rm ${TMP_SCRIPT}
else
CMD="export PATH=$OLD_PATH;export LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH;export PYTHONPATH=$OLD_PYTHONPATH;cd $CURR_DIR;${EXE_NAME} $@"
CMD="export PATH=$OLD_PATH;export LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH;export PYTHONPATH=$OLD_PYTHONPATH;cd $CURR_DIR;${DBUS_LAUNCH_CMD} ${EXE_NAME} $@;${DBUS_CLEANUP_CMD}"
TMP_SCRIPT=$(mktemp -p ${FULL_PATH})
echo ${CMD} >> ${TMP_SCRIPT}
chmod +x ${TMP_SCRIPT}
Expand Down
64 changes: 53 additions & 11 deletions lhpcdt/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/env python
#
# LUNARC HPC Desktop On-Demand graphical launch tool
# Copyright (C) 2017-2023 LUNARC, Lund University
# Copyright (C) 2017-2024 LUNARC, Lund University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -101,7 +101,12 @@ def _default_props(self):
self.directories_direct_dir = "/home/bmjl/test-menu/share/desktop-directories"
self.menu_direct_dir = "/home/bmjl/test-menu/etc/xdg/menus/applications-merged"
self.menu_direct_filename = "Lunarc-On-Demand-Direct.menu"


self.menu_location = "~/.config/menus/applications-merged"
self.app_location = "~/.local/share/applications"
self.dir_location = "~/.local/share/desktop-directories"
self.ondemand_location = "~/.local/share/ondemand-dt"

self.menu_prefix = "LUNARC - "
self.desktop_entry_prefix = "gfx-"

Expand Down Expand Up @@ -137,6 +142,10 @@ def _default_props(self):
self.part_groups = {}
self.part_groups_defaults = {}

self.default_tasks = 1
self.default_memory = 3000
self.default_exclusive = False


def print_config(self):
"""Print configuration"""
Expand Down Expand Up @@ -176,19 +185,25 @@ def print_config(self):
print("Menu settings")
print("")

print("application_dir = %s" % self.applications_dir)
print("directories_dir = %s" % self.directories_dir)
print("menu_dir = %s" % self.menu_dir)
print("menu_filename = %s" % self.menu_filename)

print("application_direct_dir = %s" % self.applications_dir)
print("directories_direct_dir = %s" % self.directories_dir)
print("menu_direct_dir = %s" % self.menu_dir)
print("menu_direct_filename = %s" % self.menu_filename)
print("menu_location = %s" % self.menu_location)
print("app_location = %s" % self.app_location)
print("dir_location = %s" % self.dir_location)
print("ondemand_location = %s" % self.ondemand_location)

print("menu_prefix = '%s'" % self.menu_prefix)
print("desktop_entry_prefix = %s" % self.desktop_entry_prefix)

# print("application_dir = %s" % self.applications_dir)
# print("directories_dir = %s" % self.directories_dir)
# print("menu_dir = %s" % self.menu_dir)
# print("menu_filename = %s" % self.menu_filename)

# print("application_direct_dir = %s" % self.applications_dir)
# print("directories_direct_dir = %s" % self.directories_dir)
# print("menu_direct_dir = %s" % self.menu_dir)
# print("menu_direct_filename = %s" % self.menu_filename)


print("")
print("VGL settings")
print("")
Expand Down Expand Up @@ -297,6 +312,11 @@ def parse_config_file(self):
self.menu_prefix = self._config_get(config, "menus", "menu_prefix").replace('"', '')
self.desktop_entry_prefix = self._config_get(config, "menus", "desktop_entry_prefix").replace('"', '')

self.menu_location = self._config_get(config, "menus", "menu_location", self.menu_location)
self.app_location = self._config_get(config, "menus", "app_location", self.app_location)
self.dir_location = self._config_get(config, "menus", "dir_location", self.dir_location)
self.ondemand_location = self._config_get(config, "menus", "ondemand_location", self.ondemand_location)

self.applications_direct_dir = self._config_get(
config, "menus-direct", "applications_dir")
self.directories_direct_dir = self._config_get(
Expand Down Expand Up @@ -398,4 +418,26 @@ def parse_config_file(self):
self.print_error(e)
return False

try:
tasks = self._config_get(
config, "slurm", "default_tasks", "1")
memory = self._config_get(
config, "slurm", "default_memory", "3000")
exclusive = self._config_get(
config, "slurm", "default_exclusive", "no")

if exclusive == "yes":
exclusive = True
else:
exclusive = False

self.default_tasks = int(tasks)
self.default_memory = int(memory)
self.default_exclusive = exclusive

except configparser.Error as e:
self.print_error(e)
return False


return True
Loading

0 comments on commit 1d2f4f5

Please sign in to comment.