From 30852be3494bc9cc9c69b7152e17c1369c495bf0 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Mon, 26 Feb 2024 16:16:38 -0800 Subject: [PATCH 1/4] fix: CompilerISA.dict() now uses the correct default field names: qubits and edges --- pyquil/external/rpcq.py | 12 ++++++------ test/unit/test_graph.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pyquil/external/rpcq.py b/pyquil/external/rpcq.py index 4cda09ef1..714f4f7cb 100644 --- a/pyquil/external/rpcq.py +++ b/pyquil/external/rpcq.py @@ -220,18 +220,18 @@ class CompilerISA: qubits: Dict[str, Qubit] = field(default_factory=dict) edges: Dict[str, Edge] = field(default_factory=dict) - def _dict(self) -> Dict[str, JsonValue]: + def _dict(self, by_alias=False) -> Dict[str, JsonValue]: return { - "1Q": {k: q._dict() for k, q in self.qubits.items()}, - "2Q": {k: e._dict() for k, e in self.edges.items()}, + "1Q" if by_alias else "qubits": {k: q._dict() for k, q in self.qubits.items()}, + "2Q" if by_alias else "edges": {k: e._dict() for k, e in self.edges.items()}, } @deprecated( version="4.6.2", reason="No longer requires serialization of RPCQ objects and is dropping Pydantic as a dependency.", # noqa: E501 ) - def dict(self): - return self._dict() + def dict(self, by_alias=False): + return self._dict(by_alias=by_alias) @classmethod def _parse_obj(cls, dictionary: Dict): @@ -288,7 +288,7 @@ def get_edge(quantum_processor: CompilerISA, qubit1: int, qubit2: int) -> Option def compiler_isa_to_target_quantum_processor(compiler_isa: CompilerISA) -> TargetQuantumProcessor: - return TargetQuantumProcessor(isa=compiler_isa._dict(), specs={}) + return TargetQuantumProcessor(isa=compiler_isa.dict(by_alias=True), specs={}) class Supported1QGate: diff --git a/test/unit/test_graph.py b/test/unit/test_graph.py index 837b3d7a1..902420512 100644 --- a/test/unit/test_graph.py +++ b/test/unit/test_graph.py @@ -19,7 +19,7 @@ def test_isa_from_graph_order(): # representation will have it as (16,15) fc = nx.from_edgelist([(16, 17), (15, 16)]) isa = graph_to_compiler_isa(fc) - isad = isa.dict() + isad = isa.dict(by_alias=True) for k in isad["2Q"]: q1, q2 = k.split("-") assert q1 < q2 From 499d5395da1749c87720d582e0e8f3c6c7200232 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Mon, 26 Feb 2024 16:33:30 -0800 Subject: [PATCH 2/4] ci: update poetry rtd config --- readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs.yml b/readthedocs.yml index f5d0120f1..15ab92dc9 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -14,7 +14,7 @@ build: post_install: # Install dependencies with 'docs' dependency group # https://python-poetry.org/docs/managing-dependencies/#dependency-groups - - poetry install --extras docs --extras latex + - poetry install --with docs --with latex sphinx: configuration: docs/source/conf.py From f6f294a90438dc44e94f488938e4540b8a9044e8 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Mon, 26 Feb 2024 16:37:33 -0800 Subject: [PATCH 3/4] with doesn't work --- readthedocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readthedocs.yml b/readthedocs.yml index 15ab92dc9..8b95e5560 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -8,13 +8,13 @@ build: post_create_environment: # Install poetry # https://python-poetry.org/docs/#installing-manually - - pip install poetry + - pip install poetry 'sphinx-rtd-theme==1.3.0' # Tell poetry to not use a virtual environment - poetry config virtualenvs.create false post_install: # Install dependencies with 'docs' dependency group # https://python-poetry.org/docs/managing-dependencies/#dependency-groups - - poetry install --with docs --with latex + - poetry install --extras docs --extras latex sphinx: configuration: docs/source/conf.py From d34d62c7a629cb02346af4064ef8c68a3b018051 Mon Sep 17 00:00:00 2001 From: Marquess Valdez Date: Mon, 26 Feb 2024 16:40:30 -0800 Subject: [PATCH 4/4] new poetry is borked --- readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs.yml b/readthedocs.yml index 8b95e5560..1f02e55d8 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -8,7 +8,7 @@ build: post_create_environment: # Install poetry # https://python-poetry.org/docs/#installing-manually - - pip install poetry 'sphinx-rtd-theme==1.3.0' + - pip install 'poetry==1.6.1' # Tell poetry to not use a virtual environment - poetry config virtualenvs.create false post_install: