List only micromamba environments with jupyter kernel(s)

This commit is contained in:
Benoît Seignovert 2024-03-07 15:46:13 +01:00
parent c4c8fa33aa
commit 1a7f5f102f
Signed by: Benoît Seignovert
GPG key ID: F5D8895227D18A0B
8 changed files with 49 additions and 17 deletions

View file

@ -0,0 +1,14 @@
{
"argv": [
"/micromamba/global/envs/baz/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Baz (GLOBAL)",
"language": "python",
"metadata": {
"debugger": true
}
}

View file

@ -0,0 +1,14 @@
{
"argv": [
"/micromamba/john-doe/envs/bar/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Bar (USER)",
"language": "python",
"metadata": {
"debugger": true
}
}

View file

@ -0,0 +1,14 @@
{
"argv": [
"/micromamba/john-doe/envs/foo/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Custom Foo (USER)",
"language": "python",
"metadata": {
"debugger": true
}
}

View file

@ -11,15 +11,15 @@ def test_micromamba_envs_getter(monkeypatch):
"""Test micromamba envs getter."""
monkeypatch.setattr(micromamba, 'MICROMAMBA_ROOT', MICROMAMBA_ROOT)
monkeypatch.setattr(micromamba, 'GLOBAL_USER', 'global')
monkeypatch.setattr(micromamba, 'GLOBAL_EXCLUDED', 'qux')
# User with micromamba envs
envs = micromamba.get_envs('john-doe')
assert len(envs) == 3
assert [env.scope for env in envs] == ['USER', 'USER', 'GLOBAL']
assert [env.name for env in envs] == ['bar', 'foo', 'baz']
assert [env.name for env in envs] == ['bar', 'foo', 'baz'] # `qux` doesn't have `kernel.json`
assert [env.path for env in envs] == [
# Sorted by groups (user > team > global)
str(MICROMAMBA_ROOT / 'john-doe' / 'envs' / 'bar'),
str(MICROMAMBA_ROOT / 'john-doe' / 'envs' / 'foo'),
str(MICROMAMBA_ROOT / 'global' / 'envs' / 'baz'),