schrodinger.application.matsci.jobdirdlg module

A dialog for obtaining a job directory of a previously submitted job

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.matsci.jobdirdlg.start_job_manager()

Start the job manager so that it begins an asynchronous update of the job list in the background. It is best to do this as soon as possible in a new process because obtaining the job list may take some time after the first access of the jobhub job manager.

In Maestro, this call doesn’t have any affect because Maestro starts the job manager at startup. But this call does have an effect for panels run from the command line.

This call cannot be done on import of this module because a QApplication needs to be started first, which often isn’t done at the point this module is imported.

class schrodinger.application.matsci.jobdirdlg.JobManager

Bases: PyQt6.QtCore.QObject

A class for managing job information and alerts when new jobs start

TIME_FORMAT = '%a %b %d %I:%M:%S %p'
UPDATED_TEXT = 'Last updated: {utime}'
NEW_DATA_TEXT = '<font color=green>New jobs available</font>'
UPDATING_TEXT = 'Updating job information...'
new_data_available

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

__init__()

Create a JobManager instance

connectToJobHub()

Connect to the job hub manager’s periodic callback

static getManager(*args, **kwargs)

Get JobManager singleton

Calling this method the first time starts the jobhub manager loading job information

getTime()

Get the current time in user-format

Return type

str

Returns

The current time

updateStatus(jobids)

Callback for the jobhub jobsChanged signal. This gets called periodically whether any job changed or not.

Parameters

jobids (list) – The job ids for jobs changing state

getAllJobs()

Get all jobs in the database

Return type

view

Returns

Each item in the view is a job object for a job in the database

getRunningJobIDs()

Get all running jobs

Return type

view

Returns

Each item in the view is a job ID for a running job

class schrodinger.application.matsci.jobdirdlg.NewJobDirFrame(master, layout=None, dclick_callback=None, show_subjobs=False)

Bases: schrodinger.ui.qt.swidgets.SFrame

A collection of widgets that reads in the JobDB and puts jobs in a table that can be selected. It also allows the user to specify a job directory manually.

__init__(master, layout=None, dclick_callback=None, show_subjobs=False)

Create a NewJobDirFrame instance

Parameters
  • master (QWidget) – The master panel for this frame, should have a warning method

  • layout (QBoxLayout) – The layout to place this frame into

  • dclick_callback (callable) – The function to call when the user double-clicks on a table cell. The function is called with 2 arguments, the first is the cell row, the second is the cell column.

  • show_subjobs (bool) – If False, only show top-level jobs in the table. Note that if programs are specified (see setAllowedPrograms), subjobs of that program type will be shown regardless of this setting.

newDataAlert()

Set the text label to alert user there are new jobs available

reset(load_jobs=True)

Reset the entire frame

Parameters

load_jobs (bool) – Whether the job database should be loaded back into the table after reset

resetTable()

Remove all rows from the table

setAllowedPrograms(programs)

Set the programs whose jobs are allowed to show up in the table

Parameters

programs (set) – The strings that show up in the job.Program field for programs whose jobs should show in the dialog. Use None to show all active jobs.

readJobsFromDatabase()

Read the jobs from the JobDB database

Return type

list, list

Returns

Two lists. The first contains the completed jobs, the second currently running jobs. All list items are schrodinger.job.jobcontrol.Job objects and the lists are sorted so that the newest jobs appear first

loadJobsIntoTable()

Load all the desired jobs from the job database into the table

loadToggled()

Whether to load from the job table or a manual directory has been toggled - react to that

getCurrentJobDir()

Get the currently selected job directory and the associated job if applicable

Return type

(str, schrodinger.job.jobcontrol.Job or (str, None) or (None, None)

Returns

The path to the selected job directory and if possible, the associated Job object. If the user specified a job directory manually, the Job object will be None. If no job directory has been specified, the return value is (None, None)

browseDirectory()

Allow the user to browse to a new directory via file dialog

setWaitCursor(app_wide=True)

Set the cursor to the wait cursor. This will be an hourglass, clock or similar. Call restoreCursor() to return to the default cursor. If ‘app_wide’ is True then it will apply to the entire application (including Maestro if running there). If it’s False then it will apply only to this panel.

Added for the wait_cursor decorator

restoreCursor(app_wide=True)

Restore the application level cursor to the default. If ‘app_wide’ is True then if will be restored for the entire application, if it’s False, it will be just for this panel.

Added for the wait_cursor decorator

class schrodinger.application.matsci.jobdirdlg.NewJobDirDialog(*args, show_subjobs=False, **kwargs)

Bases: schrodinger.ui.qt.swidgets.SDialog

SDialog to allow the user to read in information for a new job. Should be created with the user_accept_function parameter set to a function that accepts (path, job=job) api, where path is the path to the job directory and job is a Job object if available.

__init__(*args, show_subjobs=False, **kwargs)

Create a NewJobDirDialog instance

Parameters

show_subjobs (bool) – If False, only show top-level jobs in the table. Note that if programs are specified (see setAllowedPrograms), subjobs of that program type will be shown regardless of this setting.

All other arguments are passed to the parent class

layOut()

Lay out the widgets for the dialog

We use a wait cursor because searching the job database may take a few seconds (or more)

accept()

The user has pressed the Accept button. Call the user_accept_function with the chosen job information.

class schrodinger.application.matsci.jobdirdlg.InteractiveFileDownloader(head, *args, **kwargs)

Bases: schrodinger.application.matsci.jobutils.FileDownloader

Check for files on the server and download them while allowing the user to cancel the processes via a procgress dialog.

See parent class for additional information.

DLG_TITLE = 'Contacting Job Server'
__init__(head, *args, **kwargs)

Create an InteractiveFileDownloader instance

Parameters

head (QtWidgets.QWidget) – The parent widget for dialogs posted by this class

listAvailableFiles(*args, **kwargs)

Find all files available on the server for the given job. Posts a dialog during the server query to allow the user to cancel the process.

If the user cancels the process, and empty list is returned.

See the parent method for additional information

downloadFilesToDir(job, filenames, dirname)

Download a series of files from the server. The dialog will remain open during the entire duration but will update text to inform the user which file is currently downloading.

Use of this function versus looping over downloadJobFileToTemp avoids the dialog flickering and constantly taking focus.

Parameters
  • job (jobconrol.Job) – The job the files belong to

  • filenames (list) – The list of file names to download

  • dirname (str) – The directory to download the files to

Return type

list or None

Returns

filenames is returned if everything completes successfully, otherwise None is returned.

Raises

jobutils.FileDownloadError – If an error occurs while downloading

downloadJobFileToTemp(text, *args, persistent=False, **kwargs)

Download the requested file from the server. Posts a dialog during the download to allow the user to cancel the process.

If the user cancels the process, None is returned.

Parameters

persistent (bool) – If False, the dialog is closed when the download completes. If True, the dialog remains open for additional use - see downloadManyFilesToDirectory for instance. It is up to the caller to handle closing the dialog by eventually calling self.dialog.accept or calling this function with persistent=False.

See the parent method for additional information

class schrodinger.application.matsci.jobdirdlg.DownloadingMonitorMixin(*args, **kwargs)

Bases: object

A mixin class for panels that monitor running jobs and have to download files from running job server jobs in order to function

DOWNLOAD_FILE_ENDINGS = []
ALWAYS_REDOWNLOAD = []
__init__(*args, **kwargs)

Create a Downloading Monitor Mixin object

downloadJobFiles(job)

Download available files from a running Job Server job

Parameters

job (jobcontrol.Job) – The job to download files for

Return type

str or None

Returns

The path to the directory where files were downloaded, or None if the process failed or was killed by the user

:raise jobutils.FileDownloadError if a process fails

downloadJobFilesIfNecessary(job, path)

Download required files if this is a running Job Server job

Parameters
  • job (jobcontrol.Job) – The job to check and download files for

  • path (str) – The current path to the job directory

Return type

str

Returns

The path to the directory the files were downloaded into

myResetMethod()

Reset data