Package: rpcq
rpcqThe asynchronous RPC client-server framework and message specification forRigetti Quantum Cloud Services (QCS).Implements an efficient transport protocol by usingZeroMQ(ZMQ) sockets andMessagePack(msgpack) serialization.Not intended to be a full-featured replacement for other frameworks likegRPCorApache Thrift.Python InstallationTo install directly from the source, runpip install -e .from within the top-level
directory of therpcqrepository. To additionally install the requirements for testing,
make sure to runpip install -r requirements.txt.To instead install the latest released verson ofrpcqfrom the Python package manager PyPi,
runpip install rpcq.NOTE: We strongly encourage users ofrpcqto install the software within a (Python)
virtual environment (read up onvirtualenv,pyenv, orcondafor more info).Lisp InstallationInstallation is easier with QuickLisp. After placing the source for RPCQ within your local
Lisp projects directory (cf.ql:*local-project-directories*), run(ql:quickload :rpcq)and QuickLisp will download the necessary Lisp dependencies.In addition to the Lisp dependencies, RPCQ depends on ZeroMQ.  Be sure to install both the
libraryandits development headers (which are necessary for the Lisp foreign-function
interface to get its bearings).Using the Client-Server FrameworkThe following two code samples (first in Python, then in Lisp) demonstrate how to create a server, add a test handler, and spin it up.fromrpcqimportServerserver=Server()@server.rpc_handlerdeftest():return'test'server.run('tcp://*:5555')(defuntest()"test")(let((dt(rpcq:make-dispatch-table)))(rpcq:dispatch-table-add-handlerdt'test)(rpcq:start-server:dispatch-tabledt:listen-addresses'("tcp://*:5555")))In another window, we can (again first in Python, then in Lisp) create a client that points to the same socket, and call the test method.fromrpcqimportClientclient=Client('tcp://localhost:5555')client.call('test')(rpcq:with-rpc-client(client"tcp://localhost:5555")(rpcq:rpc-callclient"test"))In all cases (including interoperating a client/server pair written in different languages), this will return the string'test'.Using the Message SpecThe message spec as defined insrc/messages.lisp(which in turn producesrpcq/messages.py)
is meant to be used with theRigetti QCSplatform. Therefore,
these messages are used inpyquil, in order
to allow users to communicate with the Rigetti Quil compiler and quantum processing units (QPUs).
PyQuil provides utilities for users to interact with the QCS API and write programs inQuil, the quantum instruction language developed at Rigetti.Thus, most users will not interact withrpcq.messagesdirectly. However, for those interested
in building their own implementation of the QCS API utilities in pyQuil, becoming acquainted
with the client-server framework, the available messages in the message spec, and how they
are used in thepyquil.apimodule would be a good place to start!Updating the Python Message BindingsCurrently only Python bindings are available for the message spec, but more language bindings
are in the works. To update the Python message bindings after editingsrc/messages.lisp,
openrlwrap sbcland run:(ql:quickload:rpcq)(with-open-file(f"rpcq/messages.py":direction:output:if-exists:supersede)(rpcq:python-message-specf))NOTE: Requires pre-installedsbcl,quicklisp, and
(optionally)rlwrap.We can also use the rpcq docker container to update the message spec without to install the
requirements../docker_update_python_spec.shRunning the Unit TestsTherpcqrepository is configured with GitLab CI to automatically run the unit tests.
The tests run within a container based off of therigetti/lispDocker image, which is pinned to a specific
tag. If you need a more recent version of the image, update the tag in the.gitlab-ci.yml.The Python unit tests can be executed locally by runningpytestfrom the top-level
directory of the repository (assuming you have installed the test requirements).The Lisp unit tests can be run locally by doing the following from withinrlwrap sbcl:(ql:quickload:rpcq)(asdf:test-system:rpcq)There may be some instances ofSTYLE-WARNING, but if the test run successfully,
there should be something near the bottom of the output that looks like:RPCQ-TESTS (Suite)
  TEST-DEFMESSAGE                                                         [ OK ]Automated Packaging with DockerThe CI pipeline forrpcqproduces a Docker image, available atrigetti/rpcq. To get the latest stable
version ofrpcq, rundocker pull rigetti/rpcq. The image is built from therigetti/lispDocker image, which is pinned to a specific
tag. If you need a more recent version of the image, update the tag in theDockerfile.To learn more about therigetti/lispDocker image, check out thedocker-lisprepository.Release ProcessUpdateVERSION.txtand dependency versions (if applicable) and push the commit tomaster.Push a git tagvX.Y.Zthat contains the same version number as inVERSION.txt.Verify that the resulting build (triggered by pushing the tag) completes successfully.Push the tagged commit topypiand verify it appearshere.Publish areleaseusing the tag as the name.Close themilestoneassociated with this release,
and migrate incomplete issues to the next one.AuthorsDeveloped atRigetti ComputingbyNikolas Tezak,Steven Heidel,Eric Peterson,Colm Ryan,Peter Karalekas,Guen Prawiroatmodjo,Erik Davis, andRobert Smith.