schrodinger.application.livedesign.ldclient_proxy module¶
LDClient proxy module to maintain global access of LDClient in the entire session. Proxy delegates attribute access to the underlying LDClient instance and so can be used as a drop-in replacement for LDClient.
Proxy will notify listeners when the underlying LDClient instance is changed.
Listeners should reload any data that depends on the LDClient instance. See
LDClientProxy
for example usage.
Users should ensure ldclient package is installed and importable.
- class schrodinger.application.livedesign.ldclient_proxy.Version(major, minor)¶
Bases:
tuple
- major¶
Alias for field number 0
- minor¶
Alias for field number 1
- schrodinger.application.livedesign.ldclient_proxy.get_unique_session_id() str ¶
Return a unique session id for the current session.
- class schrodinger.application.livedesign.ldclient_proxy.LDMode¶
Bases:
str
,enum.Enum
Enumerate the different LiveDesign modes.
- DRUG_DISCOVERY = 'DRUG_DISCOVERY'¶
- MATERIALS_SCIENCE = 'MATERIALS_SCIENCE'¶
- class schrodinger.application.livedesign.ldclient_proxy.LDConnectionStatus¶
Bases:
enum.Enum
- NOT_SIGNED_IN = 0¶
- CONNECTED = 1¶
- DISCONNECTED = 2¶
- class schrodinger.application.livedesign.ldclient_proxy.LDClientLogger¶
Bases:
object
Logger class for the LDClient. It is a singleton class because it adds file handler to the
ldclient
logger and having multiple instances will add multiple file handlers to theldclient
logger. Logs from the ping task thread will be excluded. By default, the log level is set tologging.DEBUG
.Example usage:
logger = LDClientLogger.getInstance() logger.add_file_handler()
- classmethod getInstance() schrodinger.application.livedesign.ldclient_proxy.LDClientLogger ¶
Get singleton
LDClientLogger
instance.
- __init__()¶
- enable_debugging(enable: bool)¶
Enable/Disable adding debug logs to the LDClient log file.
- Parameters
enable – True to enable debug logs, False to disable.
- log(level: logging.Level, message: str)¶
Add log to the LDClient log file.
- Parameters
level – Log level.
message – Log message to be added.
- add_file_handler()¶
Add file handler to the logger if not already added.
- set_ping_task_thread_id(thread_id: int)¶
Set the ping task thread id. Logs from this thread will be excluded.
- Parameters
thread_id – Thread id of the ping task.
- exception schrodinger.application.livedesign.ldclient_proxy.LDClientConnectionError¶
Bases:
Exception
Exception when connection to LiveDesign fails.
- class schrodinger.application.livedesign.ldclient_proxy.LDClientProxy(*args, **kwargs)¶
Bases:
PyQt6.QtCore.QObject
Proxy class for LDClient. It’s a singleton class that will delegate attribute access to the underlying LDClient instance when one is connected.
Example usage for users fetching/uploading data from/to LiveDesign,
Usage:
class LDProjectsManager: def __init__(self): self.projects = [] self.ld_client = ldclient_proxy.LDClientProxy.getInstance() self.ld_client.connectionChanged.connect(self._reloadProjects) def _reloadProjects(self): # Get projects from the new LiveDesign server. projects = [] if ld_client.check_connection(): projects = ld_client.projects() self.projects = projects
Example usage for users connecting/disconnecting from LiveDesign,
Usage:
ld_client = ldclient_proxy.LDClientProxy.getInstance() ld_client.connect( host='https://livedesign.schrodinger.com', username='username', password='password', ) # Disconnect and log out from LiveDesign. ld_client.changeConnectionStatus(ldclient_proxy.LDConnectionStatus.NOT_SIGNED_IN)
- Variables
connectionChanged (QtCore.pyqtSignal) – Signal emitted when the underlying LDClient instance is changed on connecting to a LiveDesign server or disconnecting from the current LiveDesign server. Listeners should reload any data that depends on the LDClient instance.
connectToLiveDesignRequested (QtCore.pyqtSignal) – Signal emitted when we try to access attribute on underlying LDClient instance but aren’t connected.
connectionFailed (QtCore.pyqtSignal) – Signal emitted when we try to access attribute on underlying LDClient instance but the network is not available or LiveDesign server cannot be reached.
- connectionChanged¶
A
pyqtSignal
emitted by instances of the class.
- connectToLiveDesignRequested¶
A
pyqtSignal
emitted by instances of the class.
- connectionFailed¶
A
pyqtSignal
emitted by instances of the class.
- classmethod getInstance() schrodinger.application.livedesign.ldclient_proxy.LDClientProxy ¶
Get singleton
LDClientProxy
instance.
- connect(host: str, username: Optional[str] = None, password: Optional[str] = None, token: Optional[str] = None, compatibility_mode: Optional[schrodinger.application.livedesign.ldclient_proxy.Version] = Version(major=2024, minor=1))¶
Connect to LiveDesign and notify listeners. Username and password or refresh token is required to log in. Add file handler to the ldclient logger before creating the LDClient instance.
See
_create_ld_client()
for argument documentation.
- disconnect()¶
Logout and disconnect from LiveDesign and notify listeners if required.
- set_connection_status(status: schrodinger.application.livedesign.ldclient_proxy.LDConnectionStatus)¶
Set the connection status of LDClient Proxy and notify listeners.
- get_connection_status()¶
Get the connection status. In case of running in maestro, it will be updating pereodically via ld_connection_checker thread. Otherwise, it will be updated once we face any connection issue while calling any ldclient API.
- check_connection() bool ¶
Check if LDClient instance is available.
- get_host() Optional[str] ¶
- get_username() Optional[str] ¶
Return user connected to LiveDesign if connected else
None
.
- get_token() Optional[str] ¶
- get_password() Optional[str] ¶
- get_LD_version() Optional[schrodinger.application.livedesign.ldclient_proxy.Version] ¶
Version of the LD Server if connected, else None.
- get_config_key_value_dict() Optional[dict[str, str]] ¶
Return the config key-value pairs as a dictionary.
- get_LD_mode() Optional[str] ¶
Return the LD instance mode. For example, if the instance is in DRUG_DISCOVERY or MATERIAL_SCIENCE mode, etc. Note, that for older LD versions (< 8.6), there was no concept of a LD mode, and thus we assume the default mode of DRUG_DISCOVERY.
- supports_struct_group_search() Optional[bool] ¶
Checks if the current LD server supports structure group search
- Returns
True/False if supported, None if not connected to LD.
- __init__(*args, **kwargs)¶
- af2SettingsGetValue()¶
- af2SettingsSetValue(value)¶