Source code for schrodinger.application.livedesign.job_utils

"""
LiveDesign protocol job launching utils.

Copyright Schrodinger, LLC. All rights reserved.
"""

import os

from distutils import util as dutil

from schrodinger.job import jobcontrol


# FIXME Will be obsolete when JOBCON-5976 is implemented
[docs]def get_procs(backend): """ Determine the HOST and number of CPUs to be used :param backend: Job backend object :type backend: 'schrodinger.job.jobcontrol._Backend', None :return: Hostname and the number of CPUs to run the job across :rtype: str, int """ if backend: host_list = jobcontrol.get_backend_host_list() else: host_list = jobcontrol.get_command_line_host_list() host = host_list[0][0] procs = host_list[0][1] or 1 return host, procs
[docs]def use_smart_dist(): """ Enable/disable Smart Distribution when running on a queuing system based on the 'SCHRODINGER_LD_SMARTDIST' env var. By default, backend drivers running on a jobdj will have smart distribution on by default. This function will detect this env var has been set and disable smart distribution if desired Default behavior (True) is to use Smart Distribution when the env var is not set :return: True/False based on the env var setting :rtype: bool """ smart_dist_env = os.getenv('SCHRODINGER_LD_SMARTDIST') if smart_dist_env is None: return True else: return bool(dutil.strtobool(smart_dist_env))