Skip to content

Commit

Permalink
rename positron/positron_ipykernel to posit/positron (#6085)
Browse files Browse the repository at this point in the history
### Release Notes

#### New Features

- N/A

#### Bug Fixes

- Addresses bug where `positron-python` paths are too long in Windows
#4387


### QA Notes

<!--
  Add additional information for QA on how to validate the change,
  paying special attention to the level of risk, adjacent areas that
  could be affected by the change, and any important contextual
  information not present in the linked issues.
-->

should pass all tests. you should also still be able to run a local
build and the LSP works.
  • Loading branch information
isabelizimm authored Jan 24, 2025
1 parent 5868434 commit 48c9cf3
Show file tree
Hide file tree
Showing 70 changed files with 142 additions and 126 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/positron-python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
run: |
python -m pip --disable-pip-version-check install -t ./python_files/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
python -m pip install --upgrade -r build/test-requirements.txt
python -m pip install --upgrade -r ./python_files/positron/pinned-test-requirements.txt
python -m pip install --upgrade -r ./python_files/posit/pinned-test-requirements.txt
- name: Run Pyright
uses: jakebailey/pyright-action@v2
Expand Down Expand Up @@ -175,10 +175,10 @@ jobs:
run: python scripts/vendor.py

- name: Install Positron IPyKernel test requirements
run: python -m pip install --prefer-binary --upgrade -r python_files/positron/pinned-test-requirements.txt
run: python -m pip install --prefer-binary --upgrade -r python_files/posit/pinned-test-requirements.txt

- name: Run Positron IPyKernel unit tests
run: pytest python_files/positron
run: pytest python_files/posit

python-minimum-dependencies:
name: Test Minimum Positron IPyKernel Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/positron-python-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ jobs:
run: python scripts/vendor.py

- name: Install latest versions Positron IPyKernel test requirements
run: python -m pip install --prefer-binary --upgrade -r python_files/positron/test-requirements.txt
run: python -m pip install --prefer-binary --upgrade -r python_files/posit/test-requirements.txt

- name: Run Positron IPyKernel unit tests
run: pytest python_files/positron --junit-xml=python-test-results.xml
run: pytest python_files/posit --junit-xml=python-test-results.xml

- name: Upload test artifacts
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions extensions/positron-python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ dist/**
l10n/
tags
# --- Start Positron ---
python_files/positron/positron_ipykernel/tests/images
python_files/positron/positron_ipykernel/_vendor/**
python_files/posit/positron/tests/images
python_files/posit/positron/_vendor/**
# --- End Positron ---
python-env-tools/**
# coverage files produced as test output
Expand Down
2 changes: 1 addition & 1 deletion extensions/positron-python/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"python.testing.pytestArgs": [
"python_files/tests",
// --- Start Positron ---
"python_files/positron/positron_ipykernel"
"python_files/posit/positron"
// --- End Positron ---
],
"python.testing.unittestEnabled": false,
Expand Down
22 changes: 11 additions & 11 deletions extensions/positron-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ We provide a custom Positron Python Kernel based on the following open-source Py
- [**IPyKernel**](https://github.com/ipython/ipykernel), a Jupyter kernel for the Python programming language written in Python
- [**Jedi Language Server**](https://github.com/pappasam/jedi-language-server), a language server built on the [pygls](https://github.com/openlawlibrary/pygls) (Python Generic Language Server Framework) using the [Jedi](https://github.com/davidhalter/jedi) library for autocompletion, static analysis, and refactoring

The entrypoint to our kernel is the [`positron_language_server.py`](python_files/positron/positron_language_server.py) script. The core functionality of the kernel can be found in the [`positron_ipykernel`](python_files/positron/positron/positron_ipykernel/) package, which consists of these services:
The entrypoint to our kernel is the [`positron_language_server.py`](python_files/posit/positron_language_server.py) script. The core functionality of the kernel can be found in the [`positron`](python_files/posit/positron/) package, which consists of these services:

- [`positron_ipkernel`](python_files/positron/positron_ipykernel/positron_ipkernel.py), the Positron Python Kernel
- [`positron_jedilsp`](python_files/positron/positron_ipykernel/positron_jedilsp.py), the Positron Python Language Server
- [`variables`](python_files/positron/positron_ipykernel/variables.py), manages Positron's Variables pane
- [`ui`](python_files/positron/positron_ipykernel/ui.py), manages Positron's Frontend comm channel (a global channel for communication unscoped to any particular view)
- [`help`](python_files/positron/positron_ipykernel/help.py), manages Positron's Help pane
- [`lsp`](python_files/positron/positron_ipykernel/lsp.py), manages the language server
- [`plots`](python_files/positron/positron_ipykernel/plots.py), a custom [IPython display publisher](https://github.com/ipython/ipython/blob/main/IPython/core/displaypub.py) that displays to Positron's Plots pane
- [`data_explorer`](python_files/positron/positron_ipykernel/data_explorer.py), manages Positron's Data Viewer
- [`positron_ipkernel`](python_files/posit/positron/positron_ipkernel.py), the Positron Python Kernel
- [`positron_jedilsp`](python_files/posit/positron/positron_jedilsp.py), the Positron Python Language Server
- [`variables`](python_files/posit/positron/variables.py), manages Positron's Variables pane
- [`ui`](python_files/posit/positron/ui.py), manages Positron's Frontend comm channel (a global channel for communication unscoped to any particular view)
- [`help`](python_files/posit/positron/help.py), manages Positron's Help pane
- [`lsp`](python_files/posit/positron/lsp.py), manages the language server
- [`plots`](python_files/posit/positron/plots.py), a custom [IPython display publisher](https://github.com/ipython/ipython/blob/main/IPython/core/displaypub.py) that displays to Positron's Plots pane
- [`data_explorer`](python_files/posit/positron/data_explorer.py), manages Positron's Data Viewer

The various Positron services communicate with the front end via Jupyter's [comms](https://connect.rstudioservices.com/content/59a1f153-dcd8-44ac-849b-3371829b7002/positron-architecture.html#comms-and-ui-bindings) messaging protocol.

Expand All @@ -47,11 +47,11 @@ pyright
Install the test requirements that are used in CI:

```sh
pip install -r python_files/positron/pinned-test-requirements.txt
pip install -r python_files/posit/pinned-test-requirements.txt
```

Run Positron's unit tests with [pytest](https://docs.pytest.org/en/8.0.x/):

```sh
python -m pytest python_files/positron/
python -m pytest python_files/posit/
```
2 changes: 1 addition & 1 deletion extensions/positron-python/noxfile-positron.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@nox.parametrize('torch', ['1.12.1'])
@nox.parametrize('lightning', ['2.1.4'])
def test_minimum_reqs(session, pandas, torch, lightning):
session.install("-r", "python_files/positron/pinned-test-requirements.txt")
session.install("-r", "python_files/posit/pinned-test-requirements.txt")
session.install('--force-reinstall', f'pandas=={pandas}')
session.install('--force-reinstall', f'torch=={torch}')
session.install('--force-reinstall', f'lightning=={lightning}')
Expand Down
2 changes: 1 addition & 1 deletion extensions/positron-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@
"updateBuildNumber": "gulp updateBuildNumber",
"verifyBundle": "gulp verifyBundle",
"webpack": "webpack",
"positron:testMinimumPythonReqs": "nox --noxfile noxfile-positron.py -- python_files/positron"
"positron:testMinimumPythonReqs": "nox --noxfile noxfile-positron.py -- python_files/posit"
},
"dependencies": {
"@iarna/toml": "^2.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"python.testing.pytestArgs": [
"tests",
"positron/positron_ipykernel/tests"
"posit/positron/tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Licensed under the Elastic License 2.0. See LICENSE.txt for license information.
#

import os
import platform
from typing import Any, Tuple

from ._vendor.jedi import cache, debug
Expand Down Expand Up @@ -31,6 +33,7 @@
from ._vendor.jedi.inference.helpers import infer_call_of_leaf
from ._vendor.jedi.inference.value import ModuleValue
from ._vendor.jedi.parser_utils import cut_value_at_position
from ._vendor.jedi import settings
from .utils import safe_isinstance

#
Expand All @@ -43,6 +46,21 @@

_sentinel = object()

# update Jedi cache to not conflict with other Jedi instances
# adapted from jedi.settings.cache_directory

if platform.system().lower() == "windows":
_cache_directory = os.path.join(
os.getenv("LOCALAPPDATA") or os.path.expanduser("~"),
"Jedi",
"Positron-Jedi",
)
elif platform.system().lower() == "darwin":
_cache_directory = os.path.join("~", "Library", "Caches", "Positron-Jedi")
else:
_cache_directory = os.path.join(os.getenv("XDG_CACHE_HOME") or "~/.cache", "positron-jedi")
settings.cache_directory = os.path.expanduser(_cache_directory)


class PositronMixedModuleContext(MixedModuleContext):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ async def _stop(self):

def show_usage(self):
"""Show a usage message"""
self.kernel.help_service.show_help("positron_ipykernel.utils.positron_ipykernel_usage")
self.kernel.help_service.show_help("positron.utils.positron_ipykernel_usage")

@traitlets.observe("exit_now")
def _update_exit_now(self, change):
Expand Down Expand Up @@ -548,7 +548,7 @@ def init_gui_pylab(self):
# Matplotlib uses the MPLBACKEND environment variable to determine the backend to use.
# It imports the backend module when it's first needed.
if not os.environ.get("MPLBACKEND"):
os.environ["MPLBACKEND"] = "module://positron_ipykernel.matplotlib_backend"
os.environ["MPLBACKEND"] = "module://positron.matplotlib_backend"

return super().init_gui_pylab()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
from jupyter_client.session import Session
from traitlets.config import Config

import positron_ipykernel.utils as utils
from positron_ipykernel.connections import ConnectionsService
from positron_ipykernel.positron_ipkernel import (
import positron.utils as utils
from positron.connections import ConnectionsService
from positron.positron_ipkernel import (
PositronIPKernelApp,
PositronIPyKernel,
PositronShell,
)
from positron_ipykernel.session_mode import SessionMode
from positron_ipykernel.variables import VariablesService
from positron.session_mode import SessionMode
from positron.variables import VariablesService
from http.server import HTTPServer

utils.TESTING = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pytest
from fastcore.foundation import L

from positron_ipykernel.access_keys import decode_access_key, encode_access_key
from positron.access_keys import decode_access_key, encode_access_key

from .data import (
BOOL_CASES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import pytest
import sqlalchemy

from positron_ipykernel.access_keys import encode_access_key
from positron_ipykernel.connections import ConnectionsService
from positron.access_keys import encode_access_key
from positron.connections import ConnectionsService

from .conftest import DummyComm, PositronShell
from .utils import json_rpc_request, json_rpc_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from positron_ipykernel.docstrings import epytext_to_markdown, looks_like_epytext
from positron.docstrings import epytext_to_markdown, looks_like_epytext

BASIC_EXAMPLE = """Example of epytext docstring.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import pandas as pd
import pytest

from positron_ipykernel.help import HelpService, help
from positron_ipykernel.help_comm import HelpBackendRequest, HelpFrontendEvent, ShowHelpKind
from positron.help import HelpService, help
from positron.help_comm import HelpBackendRequest, HelpFrontendEvent, ShowHelpKind

from .conftest import DummyComm
from .utils import json_rpc_notification, json_rpc_request, json_rpc_response
Expand Down Expand Up @@ -120,7 +120,7 @@ def show_help_event(content: str, kind=ShowHelpKind.Url, focus=True):
# Keywords should resolve even though they aren't objects.
("async", "async"),
# The overrided help function should resolve.
(help, "positron_ipykernel.help.help"),
(help, "positron.help.help"),
],
)
def test_show_help(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
from fastcore.foundation import L
from shapely.geometry import Polygon

from positron_ipykernel.inspectors import (
from positron.inspectors import (
PRINT_WIDTH,
TRUNCATE_AT,
get_inspector,
)
from positron_ipykernel.utils import get_qualname
from positron_ipykernel.variables_comm import VariableKind
from positron.utils import get_qualname
from positron.variables_comm import VariableKind

from .data import (
BOOL_CASES,
Expand Down Expand Up @@ -598,7 +598,7 @@ def test_inspect_object(value: Any) -> None:
display_value=str(value),
kind=VariableKind.Other,
display_type="HelperClass",
type_info="positron_ipykernel.tests.test_inspectors.HelperClass",
type_info="positron.tests.test_inspectors.HelperClass",
supports_deepcopy=False,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from unittest.mock import Mock

from positron_ipykernel.positron_ipkernel import PositronShell
from positron.positron_ipkernel import PositronShell

from ..conftest import TestSession

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import pytest
from PIL import Image

from positron_ipykernel.plot_comm import PlotSize, PlotUnit
from positron_ipykernel.plots import PlotsService
from positron_ipykernel.positron_ipkernel import PositronIPyKernel, _CommTarget
from positron.plot_comm import PlotSize, PlotUnit
from positron.plots import PlotsService
from positron.positron_ipkernel import PositronIPyKernel, _CommTarget

from .conftest import DummyComm, PositronShell
from .utils import (
Expand All @@ -38,7 +38,7 @@
def setup_positron_matplotlib_backend() -> None:
# The backend is set in the kernel app, which isn't currently available in our tests,
# so set it here too.
matplotlib.use("module://positron_ipykernel.matplotlib_backend")
matplotlib.use("module://positron.matplotlib_backend")


@pytest.fixture(autouse=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from ipykernel.compiler import get_tmp_directory
from IPython.utils.syspathcontext import prepended_to_syspath

from positron_ipykernel.access_keys import encode_access_key
from positron_ipykernel.help import help
from positron_ipykernel.session_mode import SessionMode
from positron_ipykernel.utils import alias_home
from positron.access_keys import encode_access_key
from positron.help import help
from positron.session_mode import SessionMode
from positron.utils import alias_home

from .conftest import PositronShell
from .utils import assert_register_table_called
Expand Down Expand Up @@ -317,9 +317,7 @@ def test_question_mark_help(shell: PositronShell, mock_help_service: Mock) -> No

shell.run_cell("?")

mock_help_service.show_help.assert_called_once_with(
"positron_ipykernel.utils.positron_ipykernel_usage"
)
mock_help_service.show_help.assert_called_once_with("positron.utils.positron_ipykernel_usage")


def test_console_warning(shell: PositronShell, warning_kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import polars as pl
import pytest

from positron_ipykernel._vendor import cattrs
from positron_ipykernel._vendor.jedi_language_server import jedi_utils
from positron_ipykernel._vendor.lsprotocol.types import (
from positron._vendor import cattrs
from positron._vendor.jedi_language_server import jedi_utils
from positron._vendor.lsprotocol.types import (
ClientCapabilities,
CompletionClientCapabilities,
CompletionClientCapabilitiesCompletionItemType,
Expand All @@ -33,10 +33,10 @@
TextDocumentItem,
TextEdit,
)
from positron_ipykernel._vendor.pygls.workspace.text_document import TextDocument
from positron_ipykernel.help_comm import ShowHelpTopicParams
from positron_ipykernel.jedi import PositronInterpreter
from positron_ipykernel.positron_jedilsp import (
from positron._vendor.pygls.workspace.text_document import TextDocument
from positron.help_comm import ShowHelpTopicParams
from positron.jedi import PositronInterpreter
from positron.positron_jedilsp import (
HelpTopicParams,
PositronInitializationOptions,
PositronJediLanguageServer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pandas as pd
import pytest

from positron_ipykernel.pydoc import (
from positron.pydoc import (
_Attr,
_compact_signature,
_get_summary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import polars as pl
import pytest

from positron_ipykernel.positron_ipkernel import PositronIPyKernel, PositronShell
from positron_ipykernel.ui import UiService
from positron_ipykernel.utils import alias_home
from positron.positron_ipkernel import PositronIPyKernel, PositronShell
from positron.ui import UiService
from positron.utils import alias_home

from .conftest import DummyComm
from .utils import (
Expand Down
Loading

0 comments on commit 48c9cf3

Please sign in to comment.