Skip to content

Commit

Permalink
Add quilc protocol check and update quilc server docs (#805)
Browse files Browse the repository at this point in the history
* add quilc protocol check

* Change quilc -R to quilc -S in the docs, add note about -p

* Fix style warnings and drop mention of -p
  • Loading branch information
ecpeterson authored and karalekas committed Feb 14, 2019
1 parent 24b276e commit d249118
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/source/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
- ``compiler_server_address``: This is the endpoint where pyQuil will try to communicate with the compiler server. On a
QMI, this points to a provided compiler server instance. On a local installation, this should be set to the server
endpoint for a locally running ``quilc`` instance. However, pyQuil will use the default value ``tcp://localhost:5555``
if this isn't set, which is the correct endpoint when you run ``quilc`` locally with ``quilc -R``.
if this isn't set, which is the correct endpoint when you run ``quilc`` locally with ``quilc -S``.

.. note::

Expand Down
4 changes: 2 additions & 2 deletions docs/source/compiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Interacting with the Compiler
-----------------------------

After :ref:`downloading the SDK <sdkinstall>`, the Quil Compiler, ``quilc`` is available on your local machine.
You can initialize a local ``quilc`` server by typing ``quilc -R`` into your terminal. You should see the following message.
You can initialize a local ``quilc`` server by typing ``quilc -S`` into your terminal. You should see the following message.

.. code:: python
$ quilc -R
$ quilc -S
+-----------------+
| W E L C O M E |
| T O T H E |
Expand Down
6 changes: 5 additions & 1 deletion docs/source/start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ terminal.


### CONSOLE 2
$ quilc -R
$ quilc -S

... - Launching quilc.
... - Spawning server at (tcp://*:5555) .
Expand All @@ -227,6 +227,10 @@ terminal.
That's it! You're all set up to run pyQuil locally. Your programs will make requests to these server endpoints to compile your Quil
programs to native Quil, and to simulate those programs on the QVM.

**NOTE**: We are transitioning from using an HTTP ``quilc`` server to an RPCQ one.
In the near term, ``-S`` will spawn an HTTP server at port 6000 and an RPCQ server
at port 5555 (accessible via ``tcp://localhost:5555``).

Run Your First Program
----------------------
Now that our local endpoints are up and running, we can start running pyQuil programs!
Expand Down
19 changes: 19 additions & 0 deletions pyquil/api/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ def __init__(self,
:param name: Name of the lattice being targeted
"""

if not endpoint.startswith('tcp://'):
raise ValueError(f"PyQuil versions >= 2.4 can only talk to quilc "
f"versions >= 1.4 over network RPCQ. You've supplied the "
f"endpoint '{endpoint}', but this doesn't look like a network "
f"ZeroMQ address, which has the form 'tcp://domain:port'. "
f"You might try clearing (or correcting) your COMPILER_URL "
f"environment variable and removing (or correcting) the "
f"compiler_server_address line from your .forest_config file.")

self.client = Client(endpoint, timeout=timeout)
self.target_device = TargetDevice(isa=device.get_isa().to_dict(),
specs=device.get_specs().to_dict())
Expand Down Expand Up @@ -196,6 +205,16 @@ def __init__(self, endpoint: str, device: AbstractDevice, timeout: float = None)
:param endpoint: TCP or IPC endpoint of the Compiler Server
:param device: PyQuil Device object to use as compilation target
"""

if not endpoint.startswith('tcp://'):
raise ValueError(f"PyQuil versions >= 2.4 can only talk to quilc "
f"versions >= 1.4 over network RPCQ. You've supplied the "
f"endpoint '{endpoint}', but this doesn't look like a network "
f"ZeroMQ address, which has the form 'tcp://domain:port'. "
f"You might try clearing (or correcting) your COMPILER_URL "
f"environment variable and removing (or correcting) the "
f"compiler_server_address line from your .forest_config file.")

self.client = Client(endpoint, timeout=timeout)
self.target_device = TargetDevice(isa=device.get_isa().to_dict(),
specs=device.get_specs().to_dict())
Expand Down

0 comments on commit d249118

Please sign in to comment.