Skip to content

Commit 05923f7

Browse files
committed
move up jedi script, print out more env and versions
1 parent d7f0bde commit 05923f7

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

ci/job.test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ jobs:
6666
- script: ${{ platform.activate }} && cd dist && python -m pip install jupyter_lsp-$(PY_JLSP_VERSION)-py3-none-any.whl --no-deps
6767
displayName: install python wheel
6868

69+
- script: ${{ platform.activate }} && python scripts/jedi_cache.py
70+
displayName: warm up jedi cache
71+
6972
- script: ${{ platform.activate }} && jlpm test
7073
displayName: run frontend unit tests
7174

@@ -106,9 +109,6 @@ jobs:
106109
- script: ${{ platform.activate }} && jupyter labextension list
107110
displayName: list labextensions after build
108111

109-
- script: ${{ platform.activate }} && python scripts/jedi_cache.py
110-
displayName: warm up jedi cache
111-
112112
- script: ${{ platform.activate }} && python scripts/atest.py
113113
displayName: run browser tests
114114

scripts/jedi_cache.py

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" utility script to warm up/validate the jedi cache
22
"""
3+
import os
34
import pathlib
45
import shutil
56
import sys
@@ -8,39 +9,73 @@
89
import IPython
910
import jedi
1011
import jupyterlab
12+
import notebook
13+
import parso
14+
import pyls
1115

1216
SOURCE_TEMPLATE = """
1317
import {module}
1418
{module}."""
1519

1620
MODULES_TO_CACHE = [
17-
"sys",
1821
"itertools",
19-
"IPython",
2022
"statistics",
21-
"os",
22-
"time",
2323
*sys.modules,
2424
]
2525

2626

2727
def warm_up_one(module):
28+
print(module, end="\t")
2829
start = time.time()
2930
script = jedi.Script(SOURCE_TEMPLATE.format(module=module))
3031
completions = len(script.complete(3, len("{}.".format(module))))
3132
end = time.time()
32-
print(module, completions, end - start)
33+
print("\t", completions, end - start)
3334

3435

35-
if __name__ == "__main__":
36-
jedi_cache = pathlib.Path(jedi.settings.cache_directory)
36+
def print_versions():
37+
print(".".join(map(str, sys.version_info[:3])), "\t", "python")
38+
print(IPython.__version__, "\t", "ipython")
39+
print(jedi.__version__, "\t", "jedi")
40+
print(jupyterlab.__version__, "\t", "jupyterlab")
41+
print(notebook.__version__, "\t", "notebook")
42+
print(parso.__version__, "\t", "parso")
43+
print(pyls.__version__, "\t", "pyls")
44+
45+
46+
def print_env():
47+
[
48+
print(key, "\t", value)
49+
for key, value in sorted(os.environ.items())
50+
if "CONDA" in key
51+
]
52+
53+
54+
def setup_jedi():
55+
print("default jedi environment", jedi.api.environment.get_default_environment())
56+
jedi_cache = pathlib.Path(
57+
jedi.settings.cache_directory, environment=jedi.InterpreterEnvironment()
58+
)
3759
if jedi_cache.exists():
3860
shutil.rmtree(jedi_cache)
39-
print(IPython.__version__)
40-
print(jupyterlab.__version__)
61+
print("removed jedi cache!")
62+
else:
63+
print("no jedi cache was found!")
64+
65+
66+
def warm_up(modules):
67+
print_env()
68+
print("-" * 80)
69+
print_versions()
70+
print("-" * 80)
71+
setup_jedi()
72+
print("-" * 80)
4173
start = time.time()
42-
modules = sorted(set(sys.argv[1:] or MODULES_TO_CACHE))
4374
[warm_up_one(module) for module in modules]
4475
end = time.time()
45-
print("------------------")
76+
print("-" * 80)
4677
print(len(modules), "modules in", jedi.settings.cache_directory, end - start)
78+
79+
80+
if __name__ == "__main__":
81+
warm_up(sorted(set(sys.argv[1:] or MODULES_TO_CACHE)))

0 commit comments

Comments
 (0)