agni-eda 0.3.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. agni_eda-0.3.12/LICENSE +202 -0
  2. agni_eda-0.3.12/PKG-INFO +70 -0
  3. agni_eda-0.3.12/README.md +47 -0
  4. agni_eda-0.3.12/pyproject.toml +39 -0
  5. agni_eda-0.3.12/setup.cfg +4 -0
  6. agni_eda-0.3.12/src/agni/__init__.py +32 -0
  7. agni_eda-0.3.12/src/agni/client.py +245 -0
  8. agni_eda-0.3.12/src/agni/errors.py +40 -0
  9. agni_eda-0.3.12/src/agni/py.typed +0 -0
  10. agni_eda-0.3.12/src/agni/services.py +89 -0
  11. agni_eda-0.3.12/src/agni/tables.py +117 -0
  12. agni_eda-0.3.12/src/agni/transport.py +684 -0
  13. agni_eda-0.3.12/src/agni/v1/checks/checks_pb2.py +102 -0
  14. agni_eda-0.3.12/src/agni/v1/checks/checks_pb2.pyi +405 -0
  15. agni_eda-0.3.12/src/agni/v1/checks/ruledef_pb2.py +121 -0
  16. agni_eda-0.3.12/src/agni/v1/checks/ruledef_pb2.pyi +430 -0
  17. agni_eda-0.3.12/src/agni/v1/config/intent_pb2.py +61 -0
  18. agni_eda-0.3.12/src/agni/v1/config/intent_pb2.pyi +140 -0
  19. agni_eda-0.3.12/src/agni/v1/config/naming_pb2.py +53 -0
  20. agni_eda-0.3.12/src/agni/v1/config/naming_pb2.pyi +95 -0
  21. agni_eda-0.3.12/src/agni/v1/geom/geom_board_pb2.py +58 -0
  22. agni_eda-0.3.12/src/agni/v1/geom/geom_board_pb2.pyi +166 -0
  23. agni_eda-0.3.12/src/agni/v1/geom/geom_packed_pb2.py +53 -0
  24. agni_eda-0.3.12/src/agni/v1/geom/geom_packed_pb2.pyi +152 -0
  25. agni_eda-0.3.12/src/agni/v1/geom/geom_pb2.py +81 -0
  26. agni_eda-0.3.12/src/agni/v1/geom/geom_pb2.pyi +334 -0
  27. agni_eda-0.3.12/src/agni/v1/ir/ir_pb2.py +173 -0
  28. agni_eda-0.3.12/src/agni/v1/ir/ir_pb2.pyi +631 -0
  29. agni_eda-0.3.12/src/agni/v1/param/param_pb2.py +89 -0
  30. agni_eda-0.3.12/src/agni/v1/param/param_pb2.pyi +292 -0
  31. agni_eda-0.3.12/src/agni/v1/param/service_pb2.py +46 -0
  32. agni_eda-0.3.12/src/agni/v1/param/service_pb2.pyi +32 -0
  33. agni_eda-0.3.12/src/agni/v1/viewer/page_pb2.py +65 -0
  34. agni_eda-0.3.12/src/agni/v1/viewer/page_pb2.pyi +143 -0
  35. agni_eda-0.3.12/src/agni/v1/webapi/checks_pb2.py +96 -0
  36. agni_eda-0.3.12/src/agni/v1/webapi/checks_pb2.pyi +255 -0
  37. agni_eda-0.3.12/src/agni/v1/webapi/config_pb2.py +50 -0
  38. agni_eda-0.3.12/src/agni/v1/webapi/config_pb2.pyi +71 -0
  39. agni_eda-0.3.12/src/agni/v1/webapi/design_pb2.py +85 -0
  40. agni_eda-0.3.12/src/agni/v1/webapi/design_pb2.pyi +271 -0
  41. agni_eda-0.3.12/src/agni/v1/webapi/diff_pb2.py +88 -0
  42. agni_eda-0.3.12/src/agni/v1/webapi/diff_pb2.pyi +193 -0
  43. agni_eda-0.3.12/src/agni/v1/webapi/project_pb2.py +60 -0
  44. agni_eda-0.3.12/src/agni/v1/webapi/project_pb2.pyi +112 -0
  45. agni_eda-0.3.12/src/agni/v1/webapi/query_pb2.py +101 -0
  46. agni_eda-0.3.12/src/agni/v1/webapi/query_pb2.pyi +350 -0
  47. agni_eda-0.3.12/src/agni/v1/webapi/review_pb2.py +67 -0
  48. agni_eda-0.3.12/src/agni/v1/webapi/review_pb2.pyi +128 -0
  49. agni_eda-0.3.12/src/agni/v1/webapi/snapshot_pb2.py +70 -0
  50. agni_eda-0.3.12/src/agni/v1/webapi/snapshot_pb2.pyi +161 -0
  51. agni_eda-0.3.12/src/agni/v1/webapi/tables_pb2.py +65 -0
  52. agni_eda-0.3.12/src/agni/v1/webapi/tables_pb2.pyi +119 -0
  53. agni_eda-0.3.12/src/agni/v1/webapi/timing_pb2.py +45 -0
  54. agni_eda-0.3.12/src/agni/v1/webapi/timing_pb2.pyi +65 -0
  55. agni_eda-0.3.12/src/agni/v1/webapi/validate_pb2.py +43 -0
  56. agni_eda-0.3.12/src/agni/v1/webapi/validate_pb2.pyi +57 -0
  57. agni_eda-0.3.12/src/agni/v1/webapi/viewerroom_pb2.py +42 -0
  58. agni_eda-0.3.12/src/agni/v1/webapi/viewerroom_pb2.pyi +30 -0
  59. agni_eda-0.3.12/src/agni/v1/webapi/workspace_pb2.py +66 -0
  60. agni_eda-0.3.12/src/agni/v1/webapi/workspace_pb2.pyi +138 -0
  61. agni_eda-0.3.12/src/agni/values.py +37 -0
  62. agni_eda-0.3.12/src/agni_eda.egg-info/PKG-INFO +70 -0
  63. agni_eda-0.3.12/src/agni_eda.egg-info/SOURCES.txt +70 -0
  64. agni_eda-0.3.12/src/agni_eda.egg-info/dependency_links.txt +1 -0
  65. agni_eda-0.3.12/src/agni_eda.egg-info/requires.txt +13 -0
  66. agni_eda-0.3.12/src/agni_eda.egg-info/top_level.txt +1 -0
  67. agni_eda-0.3.12/tests/test_cross_transport.py +398 -0
  68. agni_eda-0.3.12/tests/test_example.py +91 -0
  69. agni_eda-0.3.12/tests/test_recover.py +120 -0
  70. agni_eda-0.3.12/tests/test_services.py +47 -0
  71. agni_eda-0.3.12/tests/test_tables.py +205 -0
  72. agni_eda-0.3.12/tests/test_transport.py +200 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,70 @@
1
+ Metadata-Version: 2.4
2
+ Name: agni-eda
3
+ Version: 0.3.12
4
+ Summary: Typed Python client for the agni EDA engine, over its CLI or its Connect API
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/panyam/agni
7
+ Project-URL: Documentation, https://panyam.github.io/agni/build/other-languages/
8
+ Project-URL: Issues, https://github.com/panyam/agni/issues
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: protobuf<8,>=7.36.2
13
+ Provides-Extra: xlsx
14
+ Requires-Dist: openpyxl>=3.1; extra == "xlsx"
15
+ Provides-Extra: examples
16
+ Requires-Dist: openpyxl>=3.1; extra == "examples"
17
+ Requires-Dist: pyyaml>=6; extra == "examples"
18
+ Provides-Extra: test
19
+ Requires-Dist: pytest>=8; extra == "test"
20
+ Requires-Dist: openpyxl>=3.1; extra == "test"
21
+ Requires-Dist: pyyaml>=6; extra == "test"
22
+ Dynamic: license-file
23
+
24
+ # agni (Python client)
25
+
26
+ A typed Python client for agni. It calls the `agni` CLI or a running `agni serve` and returns the
27
+ wire contract's own message classes, generated from `protos/agni/v1`.
28
+
29
+ ```sh
30
+ pip install 'agni-eda[xlsx]' # a release, from PyPI
31
+ pip install -e 'clients/python[xlsx]' # a checkout
32
+ ```
33
+
34
+ The distribution is `agni-eda` because PyPI's `agni` is an unrelated project, and the import is
35
+ `agni`. Match its version to the `agni` binary or server it talks to.
36
+
37
+ ```python
38
+ from agni import Client, CliTransport, ConnectTransport
39
+
40
+ c = Client(CliTransport("agni", mounts={"tut": "examples/tutorial-project"}))
41
+ # or: c = Client(ConnectTransport("http://127.0.0.1:8080"))
42
+ snap = c.ingest("mount://tut/designs/gateway")
43
+ resp = c.run_query(snapshot=snap, query='component.class(?c, "resistor") => ?c')
44
+ c.delete_snapshot(snap)
45
+ ```
46
+
47
+ Every question names a snapshot, a design loaded once under one config (agni issue 1061). `ingest`
48
+ returns its name, and takes the `board_uri`, `as_named` and `overlay` a request used to carry, and
49
+ `flatten_hierarchy`, which reads a hierarchical EDIF netlist whole as `--flatten-hierarchy` does.
50
+ A server holds a snapshot until it is deleted or evicted, and refuses one whose files changed. The
51
+ client keeps the definition of each snapshot it ingested, so a question naming one the server lost is
52
+ asked again after ingesting it under the same name, and one whose files changed after updating it, as
53
+ the viewer does (agni issue 1067). A snapshot this client did not ingest, or deleted, still raises
54
+ `AgniError` with code `not_found`, and `AgniError.snapshot_unavailable` says which. The CLI transport has
55
+ no server, so it keeps each definition itself under a name it mints (`snapshots/cli-1`) and turns it
56
+ back into flags for every command it runs.
57
+
58
+ The guide, `docsite/content/build/other-languages.md`, covers choosing a transport, which rpcs the
59
+ CLI covers, where the two differ today, and writing tables to xlsx.
60
+
61
+ - `examples/audit_workbook.py` writes a five-sheet audit workbook of the tutorial board, asking its
62
+ four tables as one query set (`run_queries`) so the design is read once.
63
+ - `examples/revision_audit.py` compares two revisions of the gateway and audits the newer one, writing
64
+ a workbook and a markdown summary that lists each tab still to be built. `make
65
+ exercise-revision-audit` runs it with the checkout's binary (agni issue 843).
66
+ - `make proto-py` regenerates `src/agni/v1`. Never edit it by hand; `make proto-check` fails on drift.
67
+ - `make python-test` runs the suite against a built binary and a real server.
68
+ - `make python-dist V=vX.Y.Z` builds the sdist and wheel a release publishes into `dist/python` and
69
+ installs the wheel into a fresh venv to check it. The release workflow runs it, and the gate runs
70
+ `python-dist-check`.
@@ -0,0 +1,47 @@
1
+ # agni (Python client)
2
+
3
+ A typed Python client for agni. It calls the `agni` CLI or a running `agni serve` and returns the
4
+ wire contract's own message classes, generated from `protos/agni/v1`.
5
+
6
+ ```sh
7
+ pip install 'agni-eda[xlsx]' # a release, from PyPI
8
+ pip install -e 'clients/python[xlsx]' # a checkout
9
+ ```
10
+
11
+ The distribution is `agni-eda` because PyPI's `agni` is an unrelated project, and the import is
12
+ `agni`. Match its version to the `agni` binary or server it talks to.
13
+
14
+ ```python
15
+ from agni import Client, CliTransport, ConnectTransport
16
+
17
+ c = Client(CliTransport("agni", mounts={"tut": "examples/tutorial-project"}))
18
+ # or: c = Client(ConnectTransport("http://127.0.0.1:8080"))
19
+ snap = c.ingest("mount://tut/designs/gateway")
20
+ resp = c.run_query(snapshot=snap, query='component.class(?c, "resistor") => ?c')
21
+ c.delete_snapshot(snap)
22
+ ```
23
+
24
+ Every question names a snapshot, a design loaded once under one config (agni issue 1061). `ingest`
25
+ returns its name, and takes the `board_uri`, `as_named` and `overlay` a request used to carry, and
26
+ `flatten_hierarchy`, which reads a hierarchical EDIF netlist whole as `--flatten-hierarchy` does.
27
+ A server holds a snapshot until it is deleted or evicted, and refuses one whose files changed. The
28
+ client keeps the definition of each snapshot it ingested, so a question naming one the server lost is
29
+ asked again after ingesting it under the same name, and one whose files changed after updating it, as
30
+ the viewer does (agni issue 1067). A snapshot this client did not ingest, or deleted, still raises
31
+ `AgniError` with code `not_found`, and `AgniError.snapshot_unavailable` says which. The CLI transport has
32
+ no server, so it keeps each definition itself under a name it mints (`snapshots/cli-1`) and turns it
33
+ back into flags for every command it runs.
34
+
35
+ The guide, `docsite/content/build/other-languages.md`, covers choosing a transport, which rpcs the
36
+ CLI covers, where the two differ today, and writing tables to xlsx.
37
+
38
+ - `examples/audit_workbook.py` writes a five-sheet audit workbook of the tutorial board, asking its
39
+ four tables as one query set (`run_queries`) so the design is read once.
40
+ - `examples/revision_audit.py` compares two revisions of the gateway and audits the newer one, writing
41
+ a workbook and a markdown summary that lists each tab still to be built. `make
42
+ exercise-revision-audit` runs it with the checkout's binary (agni issue 843).
43
+ - `make proto-py` regenerates `src/agni/v1`. Never edit it by hand; `make proto-check` fails on drift.
44
+ - `make python-test` runs the suite against a built binary and a real server.
45
+ - `make python-dist V=vX.Y.Z` builds the sdist and wheel a release publishes into `dist/python` and
46
+ installs the wheel into a fresh venv to check it. The release workflow runs it, and the gate runs
47
+ `python-dist-check`.
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ # PyPI's `agni` is an unrelated project, so the distribution is `agni-eda` and the import stays
7
+ # `agni`. The version here is a placeholder: `make python-dist V=vX.Y.Z` stamps the release tag into
8
+ # the copy it builds, since the tag is the only place a version is recorded (RELEASING.md).
9
+ name = "agni-eda"
10
+ version = "0.3.12"
11
+ description = "Typed Python client for the agni EDA engine, over its CLI or its Connect API"
12
+ readme = "README.md"
13
+ license = "Apache-2.0"
14
+ requires-python = ">=3.10"
15
+ # The floor is the version buf.gen.py.yaml's plugins stamp into the generated modules, which refuse
16
+ # to import under an older runtime. Bump the two together.
17
+ dependencies = ["protobuf>=7.36.2,<8"]
18
+
19
+ [project.urls]
20
+ Homepage = "https://github.com/panyam/agni"
21
+ Documentation = "https://panyam.github.io/agni/build/other-languages/"
22
+ Issues = "https://github.com/panyam/agni/issues"
23
+
24
+ [project.optional-dependencies]
25
+ xlsx = ["openpyxl>=3.1"]
26
+ # The examples read a query set from YAML, the file `agni query --set` takes.
27
+ examples = ["openpyxl>=3.1", "pyyaml>=6"]
28
+ test = ["pytest>=8", "openpyxl>=3.1", "pyyaml>=6"]
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
32
+ # The generated agni.v1.* directories carry no __init__.py, so they are namespace packages.
33
+ namespaces = true
34
+
35
+ [tool.setuptools.package-data]
36
+ "*" = ["*.pyi", "py.typed"]
37
+
38
+ [tool.pytest.ini_options]
39
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,32 @@
1
+ """A typed Python client for agni.
2
+
3
+ The message classes under ``agni.v1`` are generated from the same protos the engine and the web
4
+ viewer use, so a response here is the wire contract rather than a dict shaped like it.
5
+ """
6
+
7
+ from agni.client import Client
8
+ from agni.errors import AgniError, CliUnsupported
9
+ from agni.tables import (
10
+ rows_as_dicts,
11
+ table_sheets,
12
+ tables_to_xlsx,
13
+ to_rows,
14
+ )
15
+ from agni.transport import CLI_COMMANDS, CLI_ONLY, CliTransport, ConnectTransport, parse
16
+ from agni.values import bindings
17
+
18
+ __all__ = [
19
+ "AgniError",
20
+ "bindings",
21
+ "CLI_COMMANDS",
22
+ "CLI_ONLY",
23
+ "Client",
24
+ "CliTransport",
25
+ "CliUnsupported",
26
+ "ConnectTransport",
27
+ "parse",
28
+ "rows_as_dicts",
29
+ "table_sheets",
30
+ "tables_to_xlsx",
31
+ "to_rows",
32
+ ]
@@ -0,0 +1,245 @@
1
+ """The client: one method per rpc, the same types on either transport."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, Mapping, Optional, Protocol, Union
6
+
7
+ from google.protobuf import empty_pb2
8
+ from google.protobuf.message import Message
9
+
10
+ from agni import services
11
+ from agni.errors import AgniError
12
+ from agni.v1.webapi import checks_pb2, config_pb2, design_pb2, diff_pb2, query_pb2, review_pb2, snapshot_pb2, tables_pb2, workspace_pb2
13
+
14
+
15
+ class Transport(Protocol):
16
+ def call(self, rpc: services.Rpc, request: Message) -> Message: ...
17
+
18
+
19
+ class Client:
20
+ """Asks agni questions through a transport.
21
+
22
+ Switching between the CLI and a server changes the constructor argument and nothing else, since
23
+ both return the rpc's own response message::
24
+
25
+ c = Client(CliTransport(mounts={"tut": "examples/tutorial-project"}))
26
+ c = Client(ConnectTransport("http://127.0.0.1:8080"))
27
+ snap = c.ingest("mount://tut/designs/gateway")
28
+ rows = c.run_query(snapshot=snap, query='component.class(?c,"resistor") => ?c')
29
+ c.delete_snapshot(snap)
30
+
31
+ Every question names a snapshot, the design loaded once under one config (agni issue 1061), so
32
+ a script ingests each design it asks about and passes the name ``ingest`` returns as
33
+ ``snapshot=``, or ``a_snapshot=`` and ``b_snapshot=`` to ``diff_designs``.
34
+
35
+ The named methods cover the questions an analysis script asks. Every other rpc is reachable
36
+ through ``call``, which resolves the request and response types from the generated descriptors.
37
+ """
38
+
39
+ def __init__(self, transport: Transport) -> None:
40
+ self.transport = transport
41
+ # The definition of each snapshot this client ingested, by name, so a question about one the
42
+ # server lost or saw change can be recovered (agni issue 1067).
43
+ self._definitions: Dict[str, snapshot_pb2.Snapshot] = {}
44
+
45
+ def call(self, service: str, method: str, request: Optional[Message] = None, **fields) -> Message:
46
+ """Call any rpc by name, e.g. ``call("ProjectService", "ListProjects")``.
47
+
48
+ Pass a request message, or its fields as keywords, not both. Raises ``KeyError`` for an rpc
49
+ agni does not declare, and ``TypeError`` for a request of the wrong message type.
50
+ """
51
+ rpc = services.lookup(service, method)
52
+ if request is None:
53
+ request = rpc.request(**fields)
54
+ elif fields:
55
+ raise TypeError("pass a request message or keyword fields, not both")
56
+ elif not isinstance(request, rpc.request):
57
+ raise TypeError(
58
+ f"{service}/{method} takes {rpc.request.DESCRIPTOR.full_name}, "
59
+ f"got {request.DESCRIPTOR.full_name}"
60
+ )
61
+ try:
62
+ resp = self.transport.call(rpc, request)
63
+ except AgniError as e:
64
+ # A server holds a snapshot until it evicts it or restarts, and refuses one whose files
65
+ # changed (agni issue 1061). Asked about a snapshot this client ingested, the client
66
+ # ingests it again under its name, or updates a stale one, and asks once more, as the
67
+ # viewer does (web/src/snapshots.ts). The CLI transport mints names locally and never
68
+ # raises this.
69
+ if service == "SnapshotService" or not self._recover(e):
70
+ raise
71
+ resp = self.transport.call(rpc, request)
72
+ self._remember(service, method, request, resp)
73
+ return resp
74
+
75
+ def _remember(self, service: str, method: str, request: Message, resp: Message) -> None:
76
+ """Keep, or forget, the definition of the snapshot a SnapshotService call named."""
77
+ if service != "SnapshotService":
78
+ return
79
+ if method == "Ingest":
80
+ definition = snapshot_pb2.Snapshot()
81
+ definition.CopyFrom(request.snapshot) # type: ignore[attr-defined]
82
+ definition.ClearField("name")
83
+ self._definitions[resp.name] = definition # type: ignore[attr-defined]
84
+ elif method == "UpdateSnapshot" and request.snapshot.name in self._definitions: # type: ignore[attr-defined]
85
+ definition = self._definitions[request.snapshot.name] # type: ignore[attr-defined]
86
+ if request.HasField("update_mask") and request.update_mask.paths: # type: ignore[attr-defined]
87
+ request.update_mask.MergeMessage(request.snapshot, definition) # type: ignore[attr-defined]
88
+ else:
89
+ definition.CopyFrom(request.snapshot) # type: ignore[attr-defined]
90
+ definition.ClearField("name")
91
+ elif method == "DeleteSnapshot":
92
+ self._definitions.pop(request.name, None) # type: ignore[attr-defined]
93
+
94
+ def _recover(self, e: AgniError) -> bool:
95
+ """Make the snapshot an error names answerable again, reporting whether it did anything."""
96
+ d = e.snapshot_unavailable
97
+ if d is None or e.code not in ("not_found", "failed_precondition"):
98
+ return False
99
+ definition = self._definitions.get(d.name)
100
+ if definition is None:
101
+ return False
102
+ if d.reason == snapshot_pb2.SnapshotUnavailable.REASON_STALE:
103
+ snap = snapshot_pb2.Snapshot()
104
+ snap.CopyFrom(definition)
105
+ snap.name = d.name
106
+ self.call("SnapshotService", "UpdateSnapshot", snapshot=snap)
107
+ else:
108
+ self.call("SnapshotService", "Ingest", snapshot=definition, snapshot_id=d.name.removeprefix("snapshots/"))
109
+ return True
110
+
111
+ def ingest(
112
+ self,
113
+ uri: str,
114
+ *,
115
+ board_uri: str = "",
116
+ geometry_uri: str = "",
117
+ as_named: bool = False,
118
+ flatten_hierarchy: bool = False,
119
+ overlay: Optional[Union[config_pb2.OverlayConfig, Mapping[str, Any]]] = None,
120
+ read_board: bool = False,
121
+ snapshot_id: str = "",
122
+ ) -> str:
123
+ """Load the design ``uri`` names and return the snapshot's name, ``snapshots/<id>``, which every
124
+ question takes as ``snapshot=``.
125
+
126
+ ``board_uri`` and ``geometry_uri`` attach a board or schematic other than the ones the design
127
+ declares, ``as_named`` reads exactly the artifact named, and ``overlay`` is the config every
128
+ question is answered under. ``flatten_hierarchy`` reads a hierarchical netlist (an EDIF export
129
+ whose top cell places blocks) whole, as the CLI's ``--flatten-hierarchy`` does; left off, every
130
+ question is answered over the top cell alone. ``ingest_snapshot`` returns the whole
131
+ ``Snapshot`` instead.
132
+ """
133
+ snap = snapshot_pb2.Snapshot(
134
+ uri=uri,
135
+ board_uri=board_uri,
136
+ geometry_uri=geometry_uri,
137
+ as_named=as_named,
138
+ flatten_hierarchy=flatten_hierarchy,
139
+ overlay=overlay,
140
+ )
141
+ resp = self.call("SnapshotService", "Ingest", snapshot=snap, read_board=read_board, snapshot_id=snapshot_id)
142
+ return resp.name # type: ignore[attr-defined]
143
+
144
+ def ingest_snapshot(self, request: Optional[snapshot_pb2.IngestRequest] = None, **fields) -> snapshot_pb2.Snapshot:
145
+ """Ingest a definition, ``snapshot={"uri": ...}``, and return the snapshot with what its tiers
146
+ resolved to. Over the CLI the snapshot carries its name and definition alone."""
147
+ return self.call("SnapshotService", "Ingest", request, **fields) # type: ignore[return-value]
148
+
149
+ def get_snapshot(self, request: Optional[Union[snapshot_pb2.GetSnapshotRequest, str]] = None, **fields) -> snapshot_pb2.Snapshot:
150
+ """The snapshot a name names, as ``get_snapshot("snapshots/x")`` or ``name=``."""
151
+ if isinstance(request, str):
152
+ request, fields = None, {"name": request, **fields}
153
+ return self.call("SnapshotService", "GetSnapshot", request, **fields) # type: ignore[return-value]
154
+
155
+ def list_snapshots(self, request: Optional[snapshot_pb2.ListSnapshotsRequest] = None, **fields) -> snapshot_pb2.ListSnapshotsResponse:
156
+ return self.call("SnapshotService", "ListSnapshots", request, **fields) # type: ignore[return-value]
157
+
158
+ def update_snapshot(self, request: Optional[snapshot_pb2.UpdateSnapshotRequest] = None, **fields) -> snapshot_pb2.Snapshot:
159
+ """Replace a snapshot's definition, whole or by ``update_mask``, and read it again under the same
160
+ name. The same definition again is how a stale snapshot is refreshed."""
161
+ return self.call("SnapshotService", "UpdateSnapshot", request, **fields) # type: ignore[return-value]
162
+
163
+ def delete_snapshot(self, request: Optional[Union[snapshot_pb2.DeleteSnapshotRequest, str]] = None, **fields) -> empty_pb2.Empty:
164
+ """Forget a snapshot, as ``delete_snapshot("snapshots/x")`` or ``name=``."""
165
+ if isinstance(request, str):
166
+ request, fields = None, {"name": request, **fields}
167
+ return self.call("SnapshotService", "DeleteSnapshot", request, **fields) # type: ignore[return-value]
168
+
169
+ def check_design(self, request: Optional[checks_pb2.CheckDesignRequest] = None, **fields) -> checks_pb2.CheckDesignResponse:
170
+ """Run the rule catalog. Over the CLI the response carries no ``verdicts``; see the README."""
171
+ return self.call("CheckService", "CheckDesign", request, **fields) # type: ignore[return-value]
172
+
173
+ def get_check_report(self, request: Optional[checks_pb2.GetCheckReportRequest] = None, **fields) -> checks_pb2.GetCheckReportResponse:
174
+ return self.call("CheckService", "GetCheckReport", request, **fields) # type: ignore[return-value]
175
+
176
+ def list_rules(self, request: Optional[checks_pb2.ListRulesRequest] = None, **fields) -> checks_pb2.ListRulesResponse:
177
+ return self.call("CheckService", "ListRules", request, **fields) # type: ignore[return-value]
178
+
179
+ def run_query(self, request: Optional[query_pb2.RunQueryRequest] = None, **fields) -> query_pb2.RunQueryResponse:
180
+ return self.call("QueryService", "RunQuery", request, **fields) # type: ignore[return-value]
181
+
182
+ def run_queries(self, request: Optional[query_pb2.RunQueriesRequest] = None, **fields) -> query_pb2.RunQueriesResponse:
183
+ """Answer a named list of queries over one read of the design.
184
+
185
+ A query that could not be answered carries ``error`` rather than ``result``; the call itself
186
+ succeeds, so check each result. ``tabulate(query_set=...)`` turns it into tables.
187
+ """
188
+ return self.call("QueryService", "RunQueries", request, **fields) # type: ignore[return-value]
189
+
190
+ def list_query_sets(self, request: Optional[query_pb2.ListQuerySetsRequest] = None, **fields) -> query_pb2.ListQuerySetsResponse:
191
+ """The query sets the design's project keeps in its ``queries/`` directory, inherited ones
192
+ first, each parsed. ``run_queries(set=...)`` runs one. An empty ``project`` means the design
193
+ belongs to none. Connect only."""
194
+ return self.call("QueryService", "ListQuerySets", request, **fields) # type: ignore[return-value]
195
+
196
+ def parse_query_set(self, request: Optional[query_pb2.ParseQuerySetRequest] = None, **fields) -> query_pb2.ParseQuerySetResponse:
197
+ """A query set file's ``text`` read into the ``QuerySet`` ``run_queries`` takes, checked as
198
+ ``agni query --set`` checks it. Connect only."""
199
+ return self.call("QueryService", "ParseQuerySet", request, **fields) # type: ignore[return-value]
200
+
201
+ def tabulate(self, request: Optional[tables_pb2.TabulateRequest] = None, **fields) -> tables_pb2.TabulateResponse:
202
+ """The engine's tables for an answer this client already holds: ``check=`` a CheckDesign
203
+ response, ``query=`` a query answer or ``query_set=`` a set's, with ``order_by`` such as
204
+ ``["rule", "-subject"]``. These are the rows ``agni check --format csv`` prints, so a workbook
205
+ built from them matches the csv of the same run. ``agni.tables_to_xlsx`` writes them.
206
+ """
207
+ return self.call("TableService", "Tabulate", request, **fields) # type: ignore[return-value]
208
+
209
+ def list_relations(self, request: Optional[query_pb2.ListRelationsRequest] = None, **fields) -> query_pb2.ListRelationsResponse:
210
+ return self.call("QueryService", "ListRelations", request, **fields) # type: ignore[return-value]
211
+
212
+ def diff_designs(self, request: Optional[diff_pb2.DiffDesignsRequest] = None, **fields) -> diff_pb2.DiffDesignsResponse:
213
+ return self.call("DiffService", "DiffDesigns", request, **fields) # type: ignore[return-value]
214
+
215
+ def get_design(self, request: Optional[design_pb2.GetDesignRequest] = None, **fields) -> design_pb2.GetDesignResponse:
216
+ return self.call("DesignService", "GetDesign", request, **fields) # type: ignore[return-value]
217
+
218
+ def trace_design(self, request: Optional[design_pb2.TraceDesignRequest] = None, **fields) -> design_pb2.TraceDesignResponse:
219
+ """Follow a signal between two pins. ``from`` is a Python keyword, so pass the request
220
+ message, or ``**{"from": ...}``."""
221
+ return self.call("DesignService", "TraceDesign", request, **fields) # type: ignore[return-value]
222
+
223
+ def get_layout_report(self, request: Optional[design_pb2.GetLayoutReportRequest] = None, **fields) -> design_pb2.GetLayoutReportResponse:
224
+ return self.call("DesignService", "GetLayoutReport", request, **fields) # type: ignore[return-value]
225
+
226
+ def create_review(self, request: Optional[review_pb2.CreateReviewRequest] = None, **fields) -> review_pb2.Review:
227
+ """Score a checklist. Connect only until agni issue 734 lands."""
228
+ return self.call("ReviewService", "CreateReview", request, **fields) # type: ignore[return-value]
229
+
230
+ def list_checklists(self, request: Optional[review_pb2.ListChecklistsRequest] = None, **fields) -> review_pb2.ListChecklistsResponse:
231
+ """The checklists the design's project declares, inherited ones included, the project's
232
+ default first. Each carries its manifest, which ``create_review(manifest=...)`` runs. An
233
+ empty ``project`` means the design belongs to none."""
234
+ return self.call("ReviewService", "ListChecklists", request, **fields) # type: ignore[return-value]
235
+
236
+ def render_review_report(self, request: Optional[review_pb2.RenderReviewReportRequest] = None, **fields) -> review_pb2.RenderReviewReportResponse:
237
+ """A review this client holds, ``review=`` as ``create_review`` returned it, written as the
238
+ checklist page ``agni review --format html`` writes. Nothing is re-run. Connect only."""
239
+ return self.call("ReviewService", "RenderReviewReport", request, **fields) # type: ignore[return-value]
240
+
241
+ def get_review_manifest(self, request: Optional[review_pb2.GetReviewManifestRequest] = None, **fields) -> review_pb2.GetReviewManifestResponse:
242
+ return self.call("ReviewService", "GetReviewManifest", request, **fields) # type: ignore[return-value]
243
+
244
+ def list_mounts(self, request: Optional[workspace_pb2.ListMountsRequest] = None, **fields) -> workspace_pb2.ListMountsResponse:
245
+ return self.call("WorkspaceService", "ListMounts", request, **fields) # type: ignore[return-value]