From d2491183cbbb086b74924d6d239a6e7fbed71931 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Thu, 14 Feb 2019 13:48:43 -0500 Subject: [PATCH] Add quilc protocol check and update quilc server docs (#805) * 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 --- docs/source/advanced_usage.rst | 2 +- docs/source/compiler.rst | 4 ++-- docs/source/start.rst | 6 +++++- pyquil/api/_compiler.py | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/source/advanced_usage.rst b/docs/source/advanced_usage.rst index bff66bbd8..e9514b5d2 100644 --- a/docs/source/advanced_usage.rst +++ b/docs/source/advanced_usage.rst @@ -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:: diff --git a/docs/source/compiler.rst b/docs/source/compiler.rst index dbfccdc7e..4dee01d20 100644 --- a/docs/source/compiler.rst +++ b/docs/source/compiler.rst @@ -19,11 +19,11 @@ Interacting with the Compiler ----------------------------- After :ref:`downloading the SDK `, 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 | diff --git a/docs/source/start.rst b/docs/source/start.rst index 226f6c14b..0d1639310 100644 --- a/docs/source/start.rst +++ b/docs/source/start.rst @@ -218,7 +218,7 @@ terminal. ### CONSOLE 2 - $ quilc -R + $ quilc -S ... - Launching quilc. ... - Spawning server at (tcp://*:5555) . @@ -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! diff --git a/pyquil/api/_compiler.py b/pyquil/api/_compiler.py index e842ef2b9..f9c7f71fd 100644 --- a/pyquil/api/_compiler.py +++ b/pyquil/api/_compiler.py @@ -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()) @@ -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())