[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[HTCondor-users] Handy trick for checking for Python module installation



While this may be of limited use for Python on HTCondor with the availability of containerization tools, it may still come in handy:

-----
# Advertise HasTensorFlow Boolean if the module is installed
STARTD_CRON_JOBLIST                   = $(STARTD_CRON_JOBLIST) HasTensorFlow
STARTD_CRON_HASTENSORFLOW_MODE           = OneShot
STARTD_CRON_HASTENSORFLOW_RECONFIG_RERUN = True
STARTD_CRON_HASTENSORFLOW_EXECUTABLE     = /usr/bin/python
STARTD_CRON_HASTENSORFLOW_ARGS           = \
" -c 'import pkgutil; print(''HasTensorFlow = True\n--\n'' if pkgutil.find_loader(''tensorflow'') else '''')' "
-----

Note that the '' at ''HasTensorFlow are two single quotes, not a double quote.

The pkgutil trick can be used with any Python module, and the approach can be adapted to other system-provided capabilities like node-locked licenses or what have you.

Michael V. Pelletier
Information Technology
Digital Transformation & Innovation
Integrated Defense Systems
Raytheon Company