Skip to content

Add dependencies necessary for LSP-based autocomplete. #1144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,14 @@ RUN pip install bleach && \
pip install jupyter-client && \
pip install jupyter-console && \
pip install jupyter-core && \
pip install jupyterlab-lsp && \
pip install MarkupSafe && \
pip install mistune && \
pip install nbconvert && \
pip install nbformat && \
pip install notebook && \
pip install papermill && \
pip install python-lsp-server[all] && \
pip install olefile && \
# b/198300835 kornia 0.5.10 is not compatible with our version of numpy.
pip install kornia==0.5.8 && \
Expand Down
31 changes: 31 additions & 0 deletions tests/test_jupyterlab_lsp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
import unittest

from jupyter_server.serverapp import ServerApp

# Adapted from:
# https://github.com/jupyter-lsp/jupyterlab-lsp/blob/ce76fab170feea506faf9ef47e4bd6a468c24313/python_packages/jupyter_lsp/jupyter_lsp/tests/test_extension.py
class TestJupyterLabLsp(unittest.TestCase):
def test_serverextension_path(self):
import jupyter_lsp
paths = jupyter_lsp._jupyter_server_extension_paths()
for path in paths:
self.assertTrue(__import__(path["module"]))


def test_serverextension(self):
app = ServerApp()
app.initialize(
["--ServerApp.jpserver_extensions={'jupyter_lsp.serverextension': True}"],
new_httpserver=False,
)
self.assertTrue(app.language_server_manager)

found_lsp = False
for r in app.web_app.default_router.rules:
for rr in r.target.rules:
if "/lsp/" in str(rr.matcher.regex):
found_lsp = True

self.assertTrue(found_lsp, "didn't install the /lsp/ route")

18 changes: 18 additions & 0 deletions tests/test_python_lsp_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import subprocess
import unittest


class TestPythonLspServer(unittest.TestCase):
def test_initialize(self):
server = subprocess.Popen(
'python -m pylsp --check-parent-process',
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)

response = server.communicate(input=
b'Content-Length: 67\r\n'
b'Content-Type: application/vscode-jsonrpc; charset=utf8\r\n'
b'\r\n'
b'{"id": "a", "jsonrpc": "2.0", "method": "initialize", "params": {}}')[0]
assert 'capabilities' in response.decode('utf-8')
2 changes: 1 addition & 1 deletion tests/test_tsfresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_extract_feature(self):
'time': np.array([0,1,2,0,1,2]),
'x': np.array([3,4,5,7,8,10])
})
extracted_features = extract_features(ts, column_id='id', column_sort='time')
extracted_features = extract_features(ts, column_id='id', column_sort='time', n_jobs=1)
self.assertEqual(2, len(extracted_features))