schrodinger.ui.qt.config_dialog module¶
This module provides classes for config dialogs (for use with AppFramework). These are dialogs that allow the user to specify parameters for launching a job (jobname, host, #cpus, etc).
- class schrodinger.ui.qt.config_dialog.RequestedAction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
enum.Enum
- DoNothing = 1¶
- Run = 2¶
- Write = 3¶
- class schrodinger.ui.qt.config_dialog.GpuHostProductMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
enum.Enum
- NoGpus = 1¶
- Single = 2¶
- Multiple = 3¶
- SingleOnlyGpu = 4¶
- MultipleOnlyGpu = 5¶
- SingleCpuMultipleGpu = 6¶
- schrodinger.ui.qt.config_dialog.gui_validate_local_gpus()¶
Check for unsupported GPUs and if found, show a messagebox to the user. User may choose to permanently dismiss this via a “Don’t show again” checkbox.
The global bool gpu_validation_done is used to prevent validation from being performed more than once in a single session.
This function is safe to call outside the GUI, and will be a no-op.
- schrodinger.ui.qt.config_dialog.get_num_nprocs(cd_params)¶
Get the number of processes requested by the user
- Parameters
cd_params (
schrodinger.ui.qt.appframework.StartDialogParams
) – The current Config Dialog settings- Return type
int or None
- Returns
The number of CPUs requested by the user if they are using the CPUs option, or the number of simultaneous subjobs if they are using the MP subjobs option. Or None if neither of these are specified.
- class schrodinger.ui.qt.config_dialog.HostProduct(host_menu, cpus_sb, cpus_units_label, gpus_mode, num_processor_widget)¶
Bases:
object
A collection of widgets (e.g. host menu, processor spinbox, labels) for a host product and functionality to update the widgets as needed.
- __init__(host_menu, cpus_sb, cpus_units_label, gpus_mode, num_processor_widget)¶
- Parameters
host_menu (QtWidgets.QComboBox) – Host menu for this host product
cpus_sb (NumProcsSpinBox or None) – CPU entry field for this host product
cpus_units_label (QtWidgets.QLabel or None) – Processors units label for this host product
gpus_mode (int) – GPU mode for this host product. Should be one of GpuHostProductMode.NoGpus, GpuHostProductMode.Single, GpuHostProductMode.Multiple, GpuHostProductMode.SingleOnlyGpu or GpuHostProductMode.MultipleOnlyGpu
num_processor_widget (QtWidgets.QWidget or None) – Widget containing number of processor selection components
- class schrodinger.ui.qt.config_dialog.NumProcsSpinBox(parent=None, min=1, max=10000, default=1)¶
Bases:
PyQt6.QtWidgets.QSpinBox
Spin box specifically for setting number of processors.
- __init__(parent=None, min=1, max=10000, default=1)¶
- Parameters
parent (
QtWidgets.QWidget
) – Parent widgetmin (int) – Min value for this spinbox
max (int) – Max value for this spinbox
default (int) – Default value for this spinbox
- class schrodinger.ui.qt.config_dialog.ConfigDialog(parent, title='', jobname='', checkcommand=None, help_topic='MM_TOPIC_JOB_START_DIALOG', **kw)¶
Bases:
object
Toplevel Qt widget that mimics the Maestro Start dialog. Configuration options set via constructor keywords are…
- title - Title for the dialog window. Default is
‘<parent_title> - Start’.
command - Function to call (not used?).
- jobname - Initial string value for the job name entry field.
Default is ‘’.
- incorporation - Display a disposition selector for Maestro
incorporation. Maestro only. Default is True.
- allow_replace - Allow the ‘Replace existing entries’ incorporation
option. (Default = False)
- allow_in_place - Allow the ‘Append new entries in place’ incorporation
option. (Default = True)
- default_disp - The default disposition, if ‘incorporation’ is True.
Must be DISP_APPEND, DISP_APPENDINPLACE, DISP_REPLACE, or DISP_IGNORE. Default is DISP_IGNORE.
- disp_flags - Additional Maestro job disposition flags.
Currently, the only available flag is DISP_FLAG_FIT. The flags should be separated using DISP_FLAG_SEPARATOR. Default value is empty string (no flags).
- host - Display a pull-down menu (or a table) for selecting
the host for the job. Default is True.
- host_products Products that will get their own host menu and #cpus
box. Not compatible with cpus3. Takes a list of strings. Default is one host menu.
- gpu_host_products Optional map with keys being keys from host_products
that should allow GPU hosts and values being what GpuHostProductMode should be set.
- jobentry - Display widgets for setting the job name.
Default is True.
- cpus - Display additional options for distributed jobs,
including the number of CPUs. Default is False.
- cpus3 - Display additional options for Desmond distributed jobs
which includes 3 CPUS values: X, Y, and Z. Default is False.
- njobs - Display widgets for running the job as a specified
number of subjobs. Default is False.
- adjust - Whether to display the “Adjust” checkbox. Default is
False. Requires <njobs> to be True.
- tmpdir - Show the tmpdir for the currently selected host.
Default is False.
- save_host - Used the last saved host as the default host. Save any
new host chosen for the next start dialog from this panel.
- open_mp - True/False. Allow the user to specify either the total
number of cpus or the number of Open MP threads and subjobs. Default is False. open_mp is mutually exclusive with cpus as well as cpus3. open_mp is incompatible with host_products.
- set_resources - True/False. Allow the user to set or select queue
resources from the Python start panel
Job parameters passed out in the StartDialogParams object upon the dialog deactivating with via a “Start” (not “Cancel”) action…
- proj - The Project from which the job is launched (required for
incorporation). “” if not in Maestro.
- disp - Maestro disposition. ‘append’ or ‘ignore’ if
‘incorporation’ is True. “” if not in Maestro. Undefined if in Maestro but ‘incorporation’ is False.
jobname - Job name. Undefined if ‘jobentry’ is False.
host - Main host. Undefined if ‘host’ option is False.
njobs - Number of subjobs. Undefined if ‘njobs’ option is False.
adjust - Whether the user checked the “Adjust” checkbox.
- cpus - Number of CPUs. Undefined if ‘cpus’ option is False. Set
to ‘njobs’ if the “Distribute subjobs over maximum…” is chosen, otherwise set to the number of specified CPUs.
- cpus3 - Number of CPUs as 3 numbers: X, Y, & Z. Used by the Desmond
panels. Undefined if ‘cpus3’ option is False.
- openmpcpus - Number of total Open MP CPUs if the open_mp option was
used. If the open_mp options was used and threads is 0, then openmpcpus is just the number of CPUs. None if the open_mp option was not used.
- threads - Number of threads if the open_mp option was used and the user
chose to specify the number of Open MP threads and subjobs. If the open_mp option was used but the user only specifies CPUS, threads is 0. None if the open_mp option was not used.
- openmpsubjobs - Maximum number of subjobs that may be run
simultaneously, if the open_mp option was used.
queue_resources - Queue resource options
Please see the DialogParameters class below for usage instructions.
- START = 'Run'¶
- SAVE = 'OK'¶
- WRITE = 'Write'¶
- CANCEL = 'Cancel'¶
- HELP = 'Help'¶
- CPU_UNIT_LABEL = 'processors'¶
- GPU_UNIT_LABEL = 'GPUs'¶
- HOST_LABEL_TEXT = 'Host:'¶
- PRODUCT_HOSTS_KEY = 'product_hosts'¶
- __init__(parent, title='', jobname='', checkcommand=None, help_topic='MM_TOPIC_JOB_START_DIALOG', **kw)¶
See class docstring. Raises an Exception if the disposition specified as the default is not recognized.
If pre_close_command is specified, it will be run when the user presses the Start button. The dialog is only closed if that function returns 0.
- setUpButtonBox(can_start=True)¶
Set up the button box items for the dialog.
- Parameters
can_start – If True, add a Start button. Otherwise add a Write button.
- showHelp()¶
- validateNumProcs(silent=False)¶
Checks that the number of processors requested is reasonable. Here the validation is conditional on the ‘cpus’ option. In derived classes this may not be valid (i.e. the validation should be run regardless of the ncpus options.
- Parameters
menu (QComboBox) – The menu specifying the host selection to be validated
numfield (QLineEdit) – The widget specifying the requested # of processors
silent (bool) – suppresses warning dialogs when set to True
- validateNumCpus(host, editfield, silent=False)¶
Validate number of CPUs :type host: Host :param host: the host on which the CPUs reside :type editfield: QWidget :param editfield: widget specifying the number of CPUs :type silent: bool :param silent: suppresses warning dialogs when set to True
- validateNumGpus(host, editfield, silent=False)¶
Validate number of GPUs :type host: Host :param host: the host on which the GPUs reside :type editfield: QWidget :param editfield: widget specifying the number of GPUs :type silent: bool :param silent: suppresses warning dialogs when set to True
- validateNumOpenMP(host, silent=False)¶
Checks to make sure the number of requested processors and threads is consistent with what we know of the host capabilities.
- Parameters
host (Host) – The host on which the CPUs reside
silent (bool) – suppresses warning dialogs when set to True
- Return type
bool
- Returns
True if number of processors & threads is allowed, False if not
- validate()¶
Checks the panel to make sure settings are valid. Return False if any validation test fails, otherwise return True.
- validateAndAccept()¶
Validate the settings, and if no errors are found, close the dialog.
- savePressed()¶
Slot for Save button
- writePressed()¶
Slot for Write button
- startPressed()¶
Slot for OK and Run button
- setupHostLayout()¶
Setup the host layout, including hostlist/table and numbers of cpus (including cpus3).
- Returns
Whether the dialog should add a start button.
- Return type
bool
- getHostPref()¶
Get the stored host preference if available
- Returns
Stored host preference if available or None
- Return type
str or None
- updateCPULimits()¶
This method is called whenever host selection is changed. It updates maximum number of allowed CPUs.
- updateOpenMPInfo()¶
Show/Hide the proper frames and update the processors label
- getTotalOpenMPCPUs()¶
Compute the total number of Open MP CPUs to use based on the number of threads and subjobs the user entered
- Return type
int
- Returns
total number of CPUs
- getNumCpusToValidate(is_queue)¶
Return the maximum number of processors that the job could potentially use, for validation.
- Parameters
is_queue (bool) – If True, return number of threads per subjob requested, if False return number of threads * number of subjobs.
- updateQueueResources()¶
This updates the queue resources display when the host has changed.
- updateOpenMPLabel()¶
Update the Open MP label with the current number of processors requested
- setupHostCombo(combo, use_host=None, hosts=None)¶
- cpus3Edited(ignored=None)¶
- activate()¶
Display the dialog and return the dialog parameters as as StartDialogParam object. If the dialog was cancelled then return None and restore the prior state.
- getSettings(extra_kws=None)¶
- getOpenMPSettings()¶
- Based on Open MP settings, return a tuple of:
Maximum number of CPUs to use
Number of threads to use.
Maximum number of subjobs to create.
- Returns
(#cpus, #threads, #subjobs)
- Return type
(int, int, int)
- applySettings(settings)¶
Set dialog state using previously-saved parameters
- Parameters
settings (StartDialogParams) – saved dialog settings
- warning(text)¶
Display a warning window with the specified text.
- error(text)¶
Show an error message with the specified text.
- Parameters
msg (str) – Error to show.
- getHosts(ncpus=True, excludeGPGPUs=True)¶
Returns list of host entries from appropriate schrodinger.hosts file, with parenthetical entry of the number of available processors (if ‘ncpus’ is True). If excludeGPGPUs is True, hosts with GPGPUs will be excluded from the list
- currentHost(menu=None)¶
Returns the host currently selected in the menu parameter. If none is given, use self.host_menu. currentHost() can be overridden to use a different menu by default.
- Parameters
menu (
QtWidgets.QComboBox
) – Menu to check for current host
- getHostType()¶
- isGPUHost()¶
- isCPUHost()¶
- class schrodinger.ui.qt.config_dialog.GPUConfigDialog(parent, title='', jobname='', checkcommand=None, help_topic='MM_TOPIC_JOB_START_DIALOG', **kw)¶
Bases:
schrodinger.ui.qt.config_dialog.ConfigDialog
Subclass of the ConfigDialog that shows only GPU hosts.
- HOST_LABEL_TEXT = 'GPU host:'¶
- getHosts()¶
Return a list of GPU hosts
- Returns
List of GPU hosts
- Return type
list
- class schrodinger.ui.qt.config_dialog.DummyGpuHost¶
Bases:
schrodinger.tasks.hosts.Host
A dummy host to allow users to write job files to launch elsewhere when a GPU host is not available in their hosts file.
- __init__()¶
- schrodinger.ui.qt.config_dialog.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. In case of a missing/corrupt schrodinger.hosts file, a warning is shown and a list containing a dummy localhost is returned.
- 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
- schrodinger.ui.qt.config_dialog.gpu_hosts_available()¶
Determines whether any GPU host is available.
- Returns
returns True if any GPU host is available and False otherwise.
- Return type
bool
- schrodinger.ui.qt.config_dialog.get_host_from_hostname(hostname)¶
- Parameters
hostname (str) – The name of the desired host object.
- Returns
The host object associated with a host name.
- Return type
- class schrodinger.ui.qt.config_dialog.StartDialogParams¶
Bases:
object
A collection of parameter values from the StartDialog class.
- __init__()¶
Initialize. The defaults are used for options that were not requested njobs is not currently used as there is no uniform way to set it
- update(params)¶
Update the param’s attributes based on the given dictionary.
- commandLineArgs(include_njobs=True, add_cpus=True)¶
Convert this set of start dialog parameters into the canonical jobcontrol command line argument list. Generally used by AF1 panels.
- Return type
list
- Returns
list of job control command line flags
- formJaguarCPUFlags()¶
Determine the command line flags as requested by the user if openmp=True was used in creating the dialog. Used by AF1 panels.
- Return type
list
- Returns
The requested command line flags
- commandLineOptions()¶
Convert this set of start dialog parameters into the canonical jobcontrol command line options. Generally used by AF1 panels. NOTE: Does NOT export NJOBS for backward compatibility.
- schrodinger.ui.qt.config_dialog.form_jaguar_cpu_flags(host, cpus, subjobs, threads, use_parallel_flag=True)¶
Determine the command line flags for an Open MP job. NOTE: This function is also used in af2.py.
- Parameters
host (str) – The host name
cpus (int) – The number of CPUs requested. If
subjobs
andthreads
are non-zero, this value will be equal tosubjobs * threads
and can be ignored.subjobs (int) – The number of subjobs requested. Will be 0 if the user only specified the total number of CPUs.
threads (int) – The number of threads requested. Will be 0 if the user only specified the total number of CPUs.
use_parallel_flag (bool) – Whether requesting CPUs > 1 without specifying threads > 1 should be represented by the use of the -PARALLEL X flag (True) or -HOST host:X (False). -PARALLEL is a Jaguar flag and may not be appropriate for other programs.
- Returns
The appropriate command line flags.
- Return type
list
- class schrodinger.ui.qt.config_dialog.StartDialog(*args, **kwargs)¶
Bases:
schrodinger.ui.qt.config_dialog.ConfigDialog
- START = 'Start'¶
- __init__(*args, **kwargs)¶
See class docstring. Raises an Exception if the disposition specified as the default is not recognized.
If pre_close_command is specified, it will be run when the user presses the Start button. The dialog is only closed if that function returns 0.
- class schrodinger.ui.qt.config_dialog.JobParameters¶
Bases:
object
Class for holding job parameters. Required by AppFrameworkFrame.
- __init__()¶
All attributes are set directly after the instance is created.
- printout()¶
Print out the job parameters.
- class schrodinger.ui.qt.config_dialog.DialogParameters¶
Bases:
object
Class for holding dialog parameters. Required by AppFramework Frame Dialogs.
When creating an AppFramework instance, keyword ‘dialogs’ can be sent with dictionary. This dictionary should hold another dictionary of options for each dialog the user wants to set options for, and the key for that dictionary should be the name of the dialog.
Example:
dialogs = { 'start': { 'jobname': 'my_job', 'cpus': 0, }, 'read': { 'filetypes': [('Input Files', '*.in'),], }, 'write': {}, }
Options need not be set upon creation of the AppFramework instance, however. You can set options at any point, causing the next call for that dialog to generate itself with the new options.
The DialogParameters instance can be found as:
<AppFramework instance>.dialog_param
Thus if I wanted to turn off the number of cpus option in the start dialog, I would have:
<AppFramework instance>.dialog_param.start['cpus'] = 0
or to change the file type for the read dialog:
<AppFramework instance>.dialog_param.read['filetypes'] = [('<Type>', '<.ext>')]
See the individual Dialog classes for the supported configuration options.
- __init__()¶
See class docstring. Read dialogs parameters (askopenfilename options) are set to:
'initialdir': '.' 'filetypes': [('Input Files', '*.in')]
by default.
- update(dict)¶
Built in function for updating the DialogParameters class. Passing a dictionary of the values that need to be changed or added will change current values if he key already exists, or add a new key/value pair if it doesn’t.
Thus, if I wanted to change the start dialog behavior with regard to jobname and tmpdir, I would probably do something like:
dict = { "start": { 'jobname': '<my_new_jobname>', 'tmpdir': 1, } } <DialogParameters object>.update(dict)
The next time I brought up the dialog, the changes will have been made.
- set(dialog, **kw)¶
As an alternative to the update() method, I could change the same start dialog options with the command:
- <DialogParameters object>.set(‘start’,
jobname = ‘<my_new_jobname>’, tmpdir = 1)
The next time I brought up the dialog, the changes will have been made.