schrodinger.tasks.hosts module

schrodinger.tasks.hosts.strip_gpu_from_localhost(hostname)

Check host strings to see if ‘localhost-gpu’ was specified and, if so, replace with ‘localhost’

Parameters

hostname (str) – Host name to be checked

Returns

The actual hostname value to be used in a job command.

Return type

str

schrodinger.tasks.hosts.get_GPGPUs(hostname)
class schrodinger.tasks.hosts.Host(name, processors=0, num_gpus=0, gpulist=None)

Bases: schrodinger.models.json.JsonableClassMixin, schrodinger.job.jobcontrol.Host

Extension of jobcontrol.Host class with GPUs.

CPUTYPE = 'cpu'
GPUTYPE = 'gpu'
__init__(name, processors=0, num_gpus=0, gpulist=None)
toJsonImplementation()

Abstract method that must be defined by all derived classes. Converts an instance of the derived class into a jsonifiable object.

Returns

A dict made up of JSON native datatypes or Jsonable objects. See the link below for a table of such types. https://docs.python.org/2/library/json.html#encoders-and-decoders

classmethod fromJsonImplementation(json_dict)

Abstract method that must be defined by all derived classes. Takes in a dictionary and constructs an instance of the derived class.

Parameters

json_dict (dict) – A dictionary loaded from a JSON string or file.

Returns

An instance of the derived class.

Return type

cls

classmethod fromJobControlHost(jchost, ncpus)
setGpuList(gpulist)
autoSetGpuList()
hostType()

Used to determine what type of host this is.

label()

Returns the string to show in controls, etc.

units()

Return the unit string for the type of processors provided by this host.

maxNum()

Returns the number of processors for the type of host - for GPU host, return the number of GPUs, for non-GPU hosts, return the number of CPUs.

classmethod fromJson(json_obj)

A factory method which constructs a new object from a given dict loaded from a json string or file.

Parameters

json_obj (dict) – A json-loaded dictionary to create an object from.

Returns

An instance of this class.

Return type

cls

getHost() str

Return the name of the host, which defaults to ‘name’ if a separate ‘host’ attribute wasn’t specified.

get_version()

Method to get the version of a particular object. Defaults to the current version of mmshare. This class can be overridden for custom versioning behavior.

property host: str

Return the name of the host, which defaults to ‘name’ if a separate ‘host’ attribute wasn’t specified.

isQueue() bool

Check to see whether the host represents a batch queue. Returns True if the host is a HPC queueing system.

setHost(host: str)

Store host as _host to allow us to use a property for the ‘host’ attr.

toJson(_mark_version=True)

Create and returns a data structure made up of jsonable items.

Return type

An instance of one the classes from NATIVE_JSON_DATATYPES

to_hostentry() str

Return a string representation of the Host object suitable for including in a hosts file.

class schrodinger.tasks.hosts.Gpu(index, desc)

Bases: schrodinger.models.json.JsonableClassMixin

__init__(index, desc)
toJsonImplementation()

Abstract method that must be defined by all derived classes. Converts an instance of the derived class into a jsonifiable object.

Returns

A dict made up of JSON native datatypes or Jsonable objects. See the link below for a table of such types. https://docs.python.org/2/library/json.html#encoders-and-decoders

classmethod fromJsonImplementation(json_dict)

Abstract method that must be defined by all derived classes. Takes in a dictionary and constructs an instance of the derived class.

Parameters

json_dict (dict) – A dictionary loaded from a JSON string or file.

Returns

An instance of the derived class.

Return type

cls

classmethod fromJson(json_obj)

A factory method which constructs a new object from a given dict loaded from a json string or file.

Parameters

json_obj (dict) – A json-loaded dictionary to create an object from.

Returns

An instance of this class.

Return type

cls

get_version()

Method to get the version of a particular object. Defaults to the current version of mmshare. This class can be overridden for custom versioning behavior.

toJson(_mark_version=True)

Create and returns a data structure made up of jsonable items.

Return type

An instance of one the classes from NATIVE_JSON_DATATYPES

schrodinger.tasks.hosts.get_hosts(ncpus=True, excludeGPGPUs=True)

Return a list of Host objects for use in config dialogs. Note these are a subclass of jobcontrol.Host which has additional features for text labels and accounting for GPUs. If schrodinger.hosts file is missing, only localhost will be returned. If it is unreadable, then jobcontrol.UnreadableHostsFileException will be raised.

Parameters
  • ncpus (bool) – whether host text labels should include number of processors

  • excludeGPGPUs (bool) – whether to exclude GPU hosts from the list

Returns

a list of Host objects

Return type

list

Raises

jobcontrol.UnreadableHostsFileException – If host file cannot be read

schrodinger.tasks.hosts.get_host_by_name(name)

Get the Host object from the hosts list that matches the specified hostname.