schrodinger.application.glide.http_server module

Glide HTTP Server

This module implements the functions necessary to turn Glide into a persistent HTTP server that accepts ligands via POST requests and sends the poses back.

To use, just add the following lines to a Glide input file:

CLIENT_MODULE schrodinger.application.glide.http_server CLIENT_OPTIONS “host=localhost; port=8000”

The server may then be tested using a web browser by opening http://localhost:8000/. For programmatic access, see schrodinger.application.glide.http_client.py.

The server responds to the following paths:

/ a form that can be used for testing from a browser /shutdown break out of the ligand loop and terminate /dock_ligand POST a ligand and get the poses back

NOTE: the server is single-threaded, single-process, hence it’s not designed to accept concurrent connections. While Glide is busy docking a ligand, the server won’t be accepting connections. This server is meant for uses where there is a single client that only needs to do one ligand at a time!

class schrodinger.application.glide.http_server.GlideHTTPHandler(request, client_address, server)

Bases: http.server.BaseHTTPRequestHandler

This class, derived from BaseHTTPRequestHandler, implements the do_GET and do_POST methods. Unlike the parent class, this handler does not “finish” immediately after calling do_GET/do_POST, but waits until glide_finish() is called.

Properties:

Variables
  • glide_data (dict[str, list]) – a dictionary containing the posted form data.

  • glide_stop (bool) – a boolean, set to True if the client asked us to stop.

glide_data = Ellipsis
glide_stop = Ellipsis
setup()
do_POST()
do_GET()
glide_send_response(ctype, body)

Convenience method to send the response line, content-type header, and body in just one call.

finish()
glide_finish()

Finish the handler by calling the finish() method from the parent class. Among other things, this closes the connection.

class schrodinger.application.glide.http_server.GlideHTTPServer(server_address, RequestHandlerClass, bind_and_activate=True)

Bases: http.server.HTTPServer

This is a variant on HTTPServer that doesn’t shut down requests immediately, but keeps them around until glide_shutdown_request is called. This allows us to split the processing of the request into two steps: one to get the request, and the other to respond to it.

In the meantime, the handler object is kept around in the glide_http_handler property.

Variables
  • glide_http_handler (GlideHTTPHandler) – The request handler.

  • glide_request (socket) – The request object.

  • glide_timeout (bool) – Whether the request has timed out.

glide_http_handler = Ellipsis
glide_request = Ellipsis
glide_timeout = Ellipsis
finish_request(request, client_address)

Finish one request by instantiating RequestHandlerClass.

shutdown_request(request)

Called to shutdown and close an individual request.

glide_shutdown_request()

Shut down the current request by calling the shutdown_request method from the parent class.

handle_request()

Handle one request, possibly blocking.

Respects self.timeout.

handle_timeout()

Called if no new request arrives within self.timeout.

Overridden by ForkingMixIn.

schrodinger.application.glide.http_server.start(options)

Start the HTTP server. Takes a string as an argument that may specify the host and port as, for example, “host=localhost; port=8000; timeout=0”. These are in fact the default values. To accept connections from remote hosts, set host to an empty string (i.e., “host=”). If the timeout value is greater than zero, pull_ligand will return -1, indicating no more ligands, after waiting for that time in seconds.

schrodinger.application.glide.http_server.get_config_as_json(ip_addr, port, backend=None)

Return the body of the config file as a JSON string.

Parameters
  • ip_addr (str) – server IP address

  • port (int) – server port

  • backend (schrodinger.job.jobcontrol._Backend or NoneType) – optional jobcontrol backend object

schrodinger.application.glide.http_server.write_config(httpd)

Write a JSON file with host and port information so the client knows that the server is ready and where to connect. This is particularly needed when using automated port selection.

When running under job control as a Glide job, the file is copied back to the launch directory immediately.

schrodinger.application.glide.http_server.pull_ligand()

Wait until someone POSTs a ligand and return its mmct handle. If we were asked to shut down by the client, return -1.

schrodinger.application.glide.http_server.push_ligand(pose_handles, msg)

Send the HTTP response as an m2io file of docked poses. Takes an array of mmct handles and an error message (the latter is currently unused.)

Parameters
  • pose_handles – mmct handles for docked poses

  • msg (str) – status message from Glide

Type

iterable of int

schrodinger.application.glide.http_server.stop()

Delete the HTTP server object and stop listening.

schrodinger.application.glide.http_server.get_reflig()

Return the mmct handle to the new reference ligand (MMCT_INVALID_CT if there’s no new reference ligand). The handle is then owned by the caller and the function call has the side effect of making this module forget the current handle.

Returns

mmct handle

Return type

int