apache-hamilton-lsp 0.2.0.dev0__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.
- apache_hamilton_lsp-0.2.0.dev0/DISCLAIMER +10 -0
- apache_hamilton_lsp-0.2.0.dev0/LICENSE +228 -0
- apache_hamilton_lsp-0.2.0.dev0/NOTICE +5 -0
- apache_hamilton_lsp-0.2.0.dev0/PKG-INFO +65 -0
- apache_hamilton_lsp-0.2.0.dev0/README.md +32 -0
- apache_hamilton_lsp-0.2.0.dev0/hamilton_lsp/__init__.py +18 -0
- apache_hamilton_lsp-0.2.0.dev0/hamilton_lsp/__main__.py +34 -0
- apache_hamilton_lsp-0.2.0.dev0/hamilton_lsp/server.py +289 -0
- apache_hamilton_lsp-0.2.0.dev0/pyproject.toml +89 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Apache Hamilton (incubating) is an effort undergoing incubation at the Apache
|
|
2
|
+
Software Foundation (ASF), sponsored by the Apache Incubator PMC.
|
|
3
|
+
|
|
4
|
+
Incubation is required of all newly accepted projects until a further review
|
|
5
|
+
indicates that the infrastructure, communications, and decision making process
|
|
6
|
+
have stabilized in a manner consistent with other successful ASF projects.
|
|
7
|
+
|
|
8
|
+
While incubation status is not necessarily a reflection of the completeness
|
|
9
|
+
or stability of the code, it does indicate that the project has yet to be
|
|
10
|
+
fully endorsed by the ASF.
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
203
|
+
-------------------------------
|
|
204
|
+
|
|
205
|
+
hamilton/experimental/databackend.py is copied from https://github.com/machow/databackend
|
|
206
|
+
and is licensed under the MIT License.
|
|
207
|
+
|
|
208
|
+
MIT License
|
|
209
|
+
|
|
210
|
+
Copyright (c) 2024 databackend contributors
|
|
211
|
+
|
|
212
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
213
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
214
|
+
in the Software without restriction, including without limitation the rights
|
|
215
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
216
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
217
|
+
furnished to do so, subject to the following conditions:
|
|
218
|
+
|
|
219
|
+
The above copyright notice and this permission notice shall be included in all
|
|
220
|
+
copies or substantial portions of the Software.
|
|
221
|
+
|
|
222
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
223
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
224
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
225
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
226
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
227
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
228
|
+
SOFTWARE.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apache-hamilton-lsp
|
|
3
|
+
Version: 0.2.0.dev0
|
|
4
|
+
Summary: Apache Hamilton Language Server powering IDE features.
|
|
5
|
+
Keywords: hamilton,dagworks,vscode,extension,data science,pipelines,lsp,language-server
|
|
6
|
+
Author-email: Thierry Jean <thierry@dagworks.io>
|
|
7
|
+
Requires-Python: >=3.10, <4
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
Classifier: Topic :: Text Editors :: Integrated Development Environments (IDE)
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
License-File: DISCLAIMER
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
License-File: NOTICE
|
|
23
|
+
Requires-Dist: pygls>=1.3.1
|
|
24
|
+
Requires-Dist: apache-hamilton[visualization]==1.90.0.dev0
|
|
25
|
+
Requires-Dist: prek ; extra == "test"
|
|
26
|
+
Requires-Dist: pytest ; extra == "test"
|
|
27
|
+
Project-URL: documentation, https://hamilton.apache.org/
|
|
28
|
+
Project-URL: homepage, https://www.tryhamilton.dev/
|
|
29
|
+
Project-URL: issues, https://github.com/apache/hamilton/issues
|
|
30
|
+
Project-URL: source, https://github.com/apache/hamilton/tree/main/dev_tools/language_server
|
|
31
|
+
Provides-Extra: test
|
|
32
|
+
|
|
33
|
+
<!--
|
|
34
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
35
|
+
or more contributor license agreements. See the NOTICE file
|
|
36
|
+
distributed with this work for additional information
|
|
37
|
+
regarding copyright ownership. The ASF licenses this file
|
|
38
|
+
to you under the Apache License, Version 2.0 (the
|
|
39
|
+
"License"); you may not use this file except in compliance
|
|
40
|
+
with the License. You may obtain a copy of the License at
|
|
41
|
+
|
|
42
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
43
|
+
|
|
44
|
+
Unless required by applicable law or agreed to in writing,
|
|
45
|
+
software distributed under the License is distributed on an
|
|
46
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
47
|
+
KIND, either express or implied. See the License for the
|
|
48
|
+
specific language governing permissions and limitations
|
|
49
|
+
under the License.
|
|
50
|
+
-->
|
|
51
|
+
|
|
52
|
+
# Apache Hamilton Language Server (`hamilton_lsp`)
|
|
53
|
+
|
|
54
|
+
> **Disclaimer**
|
|
55
|
+
>
|
|
56
|
+
> Apache Hamilton is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC.
|
|
57
|
+
>
|
|
58
|
+
> Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
|
|
59
|
+
>
|
|
60
|
+
> While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
|
|
61
|
+
|
|
62
|
+
This is an implementation of the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) to provide a rich IDE experience when creating Apache Hamilton dataflows.
|
|
63
|
+
|
|
64
|
+
It currently powers the Apache Hamilton VSCode extension and could be integrated into other IDEs.
|
|
65
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
-->
|
|
19
|
+
|
|
20
|
+
# Apache Hamilton Language Server (`hamilton_lsp`)
|
|
21
|
+
|
|
22
|
+
> **Disclaimer**
|
|
23
|
+
>
|
|
24
|
+
> Apache Hamilton is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC.
|
|
25
|
+
>
|
|
26
|
+
> Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
|
|
27
|
+
>
|
|
28
|
+
> While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
|
|
29
|
+
|
|
30
|
+
This is an implementation of the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) to provide a rich IDE experience when creating Apache Hamilton dataflows.
|
|
31
|
+
|
|
32
|
+
It currently powers the Apache Hamilton VSCode extension and could be integrated into other IDEs.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
|
12
|
+
# software distributed under the License is distributed on an
|
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
# KIND, either express or implied. See the License for the
|
|
15
|
+
# specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
|
|
18
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
|
12
|
+
# software distributed under the License is distributed on an
|
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
# KIND, either express or implied. See the License for the
|
|
15
|
+
# specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
|
|
18
|
+
from hamilton_lsp.server import HamiltonLanguageServer, register_server_features
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# TODO use argparse to allow
|
|
22
|
+
# - io, tcp, websocket modes
|
|
23
|
+
# - select host and port
|
|
24
|
+
def main():
|
|
25
|
+
language_server = HamiltonLanguageServer()
|
|
26
|
+
language_server = register_server_features(language_server)
|
|
27
|
+
|
|
28
|
+
language_server.start_io()
|
|
29
|
+
# tcp is good for debugging
|
|
30
|
+
# server.start_tcp("127.0.0.1", 8087)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if __name__ == "__main__":
|
|
34
|
+
main()
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
|
12
|
+
# software distributed under the License is distributed on an
|
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
# KIND, either express or implied. See the License for the
|
|
15
|
+
# specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
|
|
18
|
+
import inspect
|
|
19
|
+
import re
|
|
20
|
+
|
|
21
|
+
from lsprotocol.types import (
|
|
22
|
+
TEXT_DOCUMENT_COMPLETION,
|
|
23
|
+
TEXT_DOCUMENT_DID_CHANGE,
|
|
24
|
+
TEXT_DOCUMENT_DID_OPEN,
|
|
25
|
+
TEXT_DOCUMENT_DOCUMENT_SYMBOL,
|
|
26
|
+
CompletionItem,
|
|
27
|
+
CompletionItemKind,
|
|
28
|
+
CompletionItemLabelDetails,
|
|
29
|
+
CompletionList,
|
|
30
|
+
CompletionParams,
|
|
31
|
+
DidChangeTextDocumentParams,
|
|
32
|
+
DidOpenTextDocumentParams,
|
|
33
|
+
DocumentSymbolParams,
|
|
34
|
+
Location,
|
|
35
|
+
Position,
|
|
36
|
+
Range,
|
|
37
|
+
SymbolInformation,
|
|
38
|
+
SymbolKind,
|
|
39
|
+
VersionedTextDocumentIdentifier,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# Handle both pygls 1.x and 2.x
|
|
43
|
+
try:
|
|
44
|
+
# pygls 2.0+
|
|
45
|
+
from pygls.lsp.server import LanguageServer
|
|
46
|
+
except ImportError:
|
|
47
|
+
# pygls 1.x
|
|
48
|
+
from pygls.server import LanguageServer
|
|
49
|
+
|
|
50
|
+
from hamilton import ad_hoc_utils
|
|
51
|
+
from hamilton.graph import FunctionGraph, create_graphviz_graph
|
|
52
|
+
from hamilton.graph_types import HamiltonGraph
|
|
53
|
+
from hamilton_lsp import __version__
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _type_to_string(type_: type):
|
|
57
|
+
"""Return the full path of type, but may not be accessible from document
|
|
58
|
+
For example, `pandas.core.series.Series` while document defines `pandas as pd`
|
|
59
|
+
"""
|
|
60
|
+
if type_.__module__ == "builtins":
|
|
61
|
+
type_string = str(type_.__name__)
|
|
62
|
+
else:
|
|
63
|
+
type_string = f"{str(type_.__module__)}.{str(type_.__name__)}"
|
|
64
|
+
|
|
65
|
+
return type_string
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _parse_function_tokens(source: str) -> dict[str, str]:
|
|
69
|
+
"""Get a more precise type definition"""
|
|
70
|
+
# re.DOTALL allows for multiline definition
|
|
71
|
+
FUNCTION_PATTERN = re.compile(r"def\s+(\w+)\((.*?)\)\s*->\s*([^\n:]+)", re.DOTALL)
|
|
72
|
+
|
|
73
|
+
# {function_name: type}
|
|
74
|
+
results = {}
|
|
75
|
+
for matching in FUNCTION_PATTERN.finditer(source):
|
|
76
|
+
function_name = matching.group(1)
|
|
77
|
+
return_type = matching.group(3)
|
|
78
|
+
results[function_name] = return_type
|
|
79
|
+
|
|
80
|
+
argument_string = matching.group(2)
|
|
81
|
+
if argument_string:
|
|
82
|
+
for arg_with_type in argument_string.split(","):
|
|
83
|
+
arg, _, arg_type = arg_with_type.strip().partition(":")
|
|
84
|
+
arg_type, _, _ = arg_type.partition("=")
|
|
85
|
+
results[arg.strip()] = arg_type.strip()
|
|
86
|
+
|
|
87
|
+
return results
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class HamiltonLanguageServer(LanguageServer):
|
|
91
|
+
CMD_VIEW_REQUEST = "lsp-view-request"
|
|
92
|
+
CMD_VIEW_RESPONSE = "lsp-view-response"
|
|
93
|
+
|
|
94
|
+
def __init__(self, server: str = "HamiltonServer", version: str = __version__, loop=None):
|
|
95
|
+
super().__init__(server, version, loop=loop, max_workers=2)
|
|
96
|
+
|
|
97
|
+
self.active_uri: str = ""
|
|
98
|
+
self.active_version: str = ""
|
|
99
|
+
self.orientation = "LR"
|
|
100
|
+
self.node_locations = {}
|
|
101
|
+
self.fn_graph = FunctionGraph({}, {})
|
|
102
|
+
self.h_graph = HamiltonGraph.from_graph(self.fn_graph)
|
|
103
|
+
|
|
104
|
+
# def get_range(self, node):
|
|
105
|
+
# FUNCTION = re.compile(r"^fn ([a-z]\w+)\(")
|
|
106
|
+
# ARGUMENT = re.compile(r"(?P<name>\w+): (?P<type>\w+)")
|
|
107
|
+
|
|
108
|
+
# origin = node.originating_functions[0]
|
|
109
|
+
# name = node.name
|
|
110
|
+
# # get node type icon (function, inputs, config, materializers)
|
|
111
|
+
# # get location
|
|
112
|
+
# lines, linenum = inspect.getsourcelines(origin)
|
|
113
|
+
|
|
114
|
+
# for incr, line in enumerate(lines):
|
|
115
|
+
# if (match := FUNCTION.match(line)) is not None:
|
|
116
|
+
# symbol_name = match.group(1)
|
|
117
|
+
# if name in symbol_name:
|
|
118
|
+
# start_char = match.start() + line.find(name)
|
|
119
|
+
# return Range(
|
|
120
|
+
# start=Position(line=linenum+incr, character=start_char),
|
|
121
|
+
# end=Position(line=linenum+incr, character=start_char + len(name)),
|
|
122
|
+
# )
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def register_server_features(ls: HamiltonLanguageServer) -> HamiltonLanguageServer:
|
|
126
|
+
@ls.feature(TEXT_DOCUMENT_DID_CHANGE)
|
|
127
|
+
def did_change(server: HamiltonLanguageServer, params: DidChangeTextDocumentParams):
|
|
128
|
+
"""try to build the dataflow and cache it on the server by creating
|
|
129
|
+
a temporary module from the document's source code
|
|
130
|
+
"""
|
|
131
|
+
uri = params.text_document.uri
|
|
132
|
+
document = server.workspace.get_document(uri)
|
|
133
|
+
server.active_uri = uri
|
|
134
|
+
|
|
135
|
+
try:
|
|
136
|
+
config = {}
|
|
137
|
+
module = ad_hoc_utils.module_from_source(document.source)
|
|
138
|
+
fn_graph = FunctionGraph.from_modules(module, config=config)
|
|
139
|
+
h_graph = HamiltonGraph.from_graph(fn_graph)
|
|
140
|
+
# store the updated HamiltonGraph on server state
|
|
141
|
+
server.fn_graph = fn_graph
|
|
142
|
+
server.h_graph = h_graph
|
|
143
|
+
except BaseException:
|
|
144
|
+
pass
|
|
145
|
+
|
|
146
|
+
# refresh the visualization if new graph version
|
|
147
|
+
if server.active_version != server.h_graph.version:
|
|
148
|
+
server.active_version = server.h_graph.version
|
|
149
|
+
hamilton_view(server, [{}])
|
|
150
|
+
|
|
151
|
+
@ls.feature(TEXT_DOCUMENT_DID_OPEN)
|
|
152
|
+
def did_open(server: HamiltonLanguageServer, params: DidOpenTextDocumentParams):
|
|
153
|
+
"""trigger the did_change() event"""
|
|
154
|
+
did_change(
|
|
155
|
+
server,
|
|
156
|
+
DidChangeTextDocumentParams(
|
|
157
|
+
text_document=VersionedTextDocumentIdentifier(
|
|
158
|
+
version=0,
|
|
159
|
+
uri=params.text_document.uri,
|
|
160
|
+
),
|
|
161
|
+
content_changes=[],
|
|
162
|
+
),
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
@ls.feature(TEXT_DOCUMENT_COMPLETION) # , CompletionOptions(trigger_characters=["(", ","]))
|
|
166
|
+
def on_completion(server: HamiltonLanguageServer, params: CompletionParams) -> CompletionList:
|
|
167
|
+
"""Return completion items based on the cached dataflow nodes name and type."""
|
|
168
|
+
uri = params.text_document.uri
|
|
169
|
+
document = server.workspace.get_document(uri)
|
|
170
|
+
|
|
171
|
+
tokens = _parse_function_tokens(document.source)
|
|
172
|
+
|
|
173
|
+
# could be refactored to a single loop, but this logic might be reused elsewhere
|
|
174
|
+
local_node_types = {}
|
|
175
|
+
for node in server.h_graph.nodes:
|
|
176
|
+
origin = node.originating_functions[0]
|
|
177
|
+
|
|
178
|
+
origin_name = getattr(origin, "__original_name__", origin.__name__)
|
|
179
|
+
type_ = tokens.get(origin_name, _type_to_string(node.type))
|
|
180
|
+
local_node_types[node.name] = type_
|
|
181
|
+
|
|
182
|
+
return CompletionList(
|
|
183
|
+
is_incomplete=False,
|
|
184
|
+
items=[
|
|
185
|
+
CompletionItem(
|
|
186
|
+
label=node.name,
|
|
187
|
+
label_details=CompletionItemLabelDetails(
|
|
188
|
+
detail=f" {local_node_types[node.name]}",
|
|
189
|
+
description="Node",
|
|
190
|
+
),
|
|
191
|
+
kind=CompletionItemKind(3), # 3 is the enum for `Function` kind
|
|
192
|
+
documentation=node.documentation,
|
|
193
|
+
insert_text=f"{node.name}: {local_node_types[node.name]}",
|
|
194
|
+
)
|
|
195
|
+
for node in server.h_graph.nodes
|
|
196
|
+
],
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
@ls.feature(TEXT_DOCUMENT_DOCUMENT_SYMBOL)
|
|
200
|
+
def document_symbols(
|
|
201
|
+
server: HamiltonLanguageServer, params: DocumentSymbolParams
|
|
202
|
+
) -> list[SymbolInformation]:
|
|
203
|
+
symbols = []
|
|
204
|
+
|
|
205
|
+
for node in server.h_graph.nodes:
|
|
206
|
+
origin = node.originating_functions[0]
|
|
207
|
+
name = node.name
|
|
208
|
+
# get node type icon (function, inputs, config, materializers)
|
|
209
|
+
node_kind = SymbolKind.Function
|
|
210
|
+
if node.is_external_input:
|
|
211
|
+
node_kind = SymbolKind.Field
|
|
212
|
+
|
|
213
|
+
# get location
|
|
214
|
+
_, starting_line = inspect.getsourcelines(origin)
|
|
215
|
+
loc = Location(
|
|
216
|
+
uri=params.text_document.uri,
|
|
217
|
+
range=Range(
|
|
218
|
+
start=Position(line=starting_line - 1, character=0),
|
|
219
|
+
end=Position(line=starting_line, character=0),
|
|
220
|
+
),
|
|
221
|
+
)
|
|
222
|
+
server.node_locations[name] = loc
|
|
223
|
+
|
|
224
|
+
# create symbol
|
|
225
|
+
symbol = SymbolInformation(
|
|
226
|
+
name=name,
|
|
227
|
+
kind=node_kind,
|
|
228
|
+
location=loc,
|
|
229
|
+
container_name="Hamilton",
|
|
230
|
+
)
|
|
231
|
+
symbols.append(symbol)
|
|
232
|
+
|
|
233
|
+
return symbols
|
|
234
|
+
|
|
235
|
+
# @ls.feature(TEXT_DOCUMENT_REFERENCES)
|
|
236
|
+
# def find_references(
|
|
237
|
+
# server: HamiltonLanguageServer,
|
|
238
|
+
# params: ReferenceParams
|
|
239
|
+
# ) -> list[Location]:
|
|
240
|
+
# doc = ls.workspace.get_text_document(params.text_document.uri)
|
|
241
|
+
|
|
242
|
+
# input_position = params.position
|
|
243
|
+
# if not server.node_locations:
|
|
244
|
+
# server.send_notification(TEXT_DOCUMENT_DOCUMENT_SYMBOL, DocumentSymbolParams(params.text_document))
|
|
245
|
+
|
|
246
|
+
# word = doc.word_at_position(input_position)
|
|
247
|
+
# server.show_message_log(f"{word}")
|
|
248
|
+
|
|
249
|
+
# # server.show_message_log(input_node)
|
|
250
|
+
# depend_on_input = []
|
|
251
|
+
# for node in server.h_graph.nodes:
|
|
252
|
+
# dependencies = [*node.optional_dependencies, *node.required_dependencies]
|
|
253
|
+
# for dep in dependencies:
|
|
254
|
+
# if word != dep:
|
|
255
|
+
# continue
|
|
256
|
+
# depend_on_input.append(node.name)
|
|
257
|
+
|
|
258
|
+
# return [server.node_locations[name] for name in depend_on_input]
|
|
259
|
+
|
|
260
|
+
@ls.thread()
|
|
261
|
+
@ls.command(HamiltonLanguageServer.CMD_VIEW_REQUEST)
|
|
262
|
+
def hamilton_view(server: HamiltonLanguageServer, args: list[dict]):
|
|
263
|
+
"""View the cached dataflow and send the graphviz string to the extension host."""
|
|
264
|
+
params = args[0]
|
|
265
|
+
|
|
266
|
+
if params.get("rotate"):
|
|
267
|
+
if server.orientation == "LR":
|
|
268
|
+
server.orientation = "TB"
|
|
269
|
+
else:
|
|
270
|
+
server.orientation = "LR"
|
|
271
|
+
|
|
272
|
+
dot = create_graphviz_graph(
|
|
273
|
+
nodes=set(server.fn_graph.get_nodes()),
|
|
274
|
+
comment="vscode-dataflow",
|
|
275
|
+
node_modifiers=dict(),
|
|
276
|
+
strictly_display_only_nodes_passed_in=True,
|
|
277
|
+
graphviz_kwargs=dict(
|
|
278
|
+
graph_attr=dict(bgcolor="transparent"),
|
|
279
|
+
edge_attr=dict(color="white"),
|
|
280
|
+
),
|
|
281
|
+
orient=server.orientation,
|
|
282
|
+
config={},
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
server.send_notification(
|
|
286
|
+
HamiltonLanguageServer.CMD_VIEW_RESPONSE, dict(uri=server.active_uri, dot=dot.source)
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
return ls
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
2
|
+
# or more contributor license agreements. See the NOTICE file
|
|
3
|
+
# distributed with this work for additional information
|
|
4
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
5
|
+
# to you under the Apache License, Version 2.0 (the
|
|
6
|
+
# "License"); you may not use this file except in compliance
|
|
7
|
+
# with the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
|
12
|
+
# software distributed under the License is distributed on an
|
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
# KIND, either express or implied. See the License for the
|
|
15
|
+
# specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
requires = ["flit_core >=3.11,<4"]
|
|
20
|
+
build-backend = "flit_core.buildapi"
|
|
21
|
+
|
|
22
|
+
[project]
|
|
23
|
+
name = "apache-hamilton-lsp"
|
|
24
|
+
version = "0.2.0.dev0"
|
|
25
|
+
description = "Apache Hamilton Language Server powering IDE features."
|
|
26
|
+
readme = "README.md"
|
|
27
|
+
requires-python = ">=3.10, <4"
|
|
28
|
+
license = "Apache-2.0"
|
|
29
|
+
license-files = ["LICENSE", "NOTICE", "DISCLAIMER"]
|
|
30
|
+
keywords = [
|
|
31
|
+
"hamilton",
|
|
32
|
+
"dagworks",
|
|
33
|
+
"vscode",
|
|
34
|
+
"extension",
|
|
35
|
+
"data science",
|
|
36
|
+
"pipelines",
|
|
37
|
+
"lsp",
|
|
38
|
+
"language-server",
|
|
39
|
+
]
|
|
40
|
+
authors = [
|
|
41
|
+
{name = "Thierry Jean", email = "thierry@dagworks.io"},
|
|
42
|
+
]
|
|
43
|
+
classifiers = [
|
|
44
|
+
"Topic :: Text Editors :: Integrated Development Environments (IDE)",
|
|
45
|
+
"Intended Audience :: Developers",
|
|
46
|
+
"Programming Language :: Python",
|
|
47
|
+
"Programming Language :: Python :: 3",
|
|
48
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
49
|
+
"Programming Language :: Python :: 3.10",
|
|
50
|
+
"Programming Language :: Python :: 3.11",
|
|
51
|
+
"Programming Language :: Python :: 3.12",
|
|
52
|
+
"Programming Language :: Python :: 3.13",
|
|
53
|
+
"Programming Language :: Python :: 3.14",
|
|
54
|
+
]
|
|
55
|
+
dependencies = [
|
|
56
|
+
"pygls>=1.3.1",
|
|
57
|
+
"apache-hamilton[visualization]==1.90.0.dev0",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[project.urls]
|
|
61
|
+
homepage = "https://www.tryhamilton.dev/"
|
|
62
|
+
documentation = "https://hamilton.apache.org/"
|
|
63
|
+
issues = "https://github.com/apache/hamilton/issues"
|
|
64
|
+
source = "https://github.com/apache/hamilton/tree/main/dev_tools/language_server"
|
|
65
|
+
|
|
66
|
+
[project.optional-dependencies]
|
|
67
|
+
test = [
|
|
68
|
+
"prek",
|
|
69
|
+
"pytest",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[project.scripts]
|
|
73
|
+
hamilton-lsp = "hamilton_lsp.__main__:main"
|
|
74
|
+
|
|
75
|
+
[tool.flit.module]
|
|
76
|
+
name = "hamilton_lsp"
|
|
77
|
+
|
|
78
|
+
[tool.flit.sdist]
|
|
79
|
+
include = [
|
|
80
|
+
"LICENSE",
|
|
81
|
+
"NOTICE",
|
|
82
|
+
"DISCLAIMER",
|
|
83
|
+
]
|
|
84
|
+
exclude = [
|
|
85
|
+
"tests/**",
|
|
86
|
+
".git/**",
|
|
87
|
+
"**/__pycache__/**",
|
|
88
|
+
"**/*.pyc",
|
|
89
|
+
]
|