From 4496ca52eb0b44464ec47e5996f7584781297ebc Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 5 Feb 2024 10:40:28 +0100 Subject: [PATCH 1/7] Fix mount points --- jupyterlite_xeus/add_on.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jupyterlite_xeus/add_on.py b/jupyterlite_xeus/add_on.py index 1b6b148..ec2c2c6 100644 --- a/jupyterlite_xeus/add_on.py +++ b/jupyterlite_xeus/add_on.py @@ -293,6 +293,7 @@ def pack_prefix(self, kernel_dir): ) host_path, mount_path = mount.split(":") + host_path = Path(host_path) mount_path = Path(mount_path) if not mount_path.is_absolute(): From be3e4abf7b2220a0f6738b792d401508d8f08a8e Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 5 Feb 2024 10:43:13 +0100 Subject: [PATCH 2/7] Add mount points test --- tests/test_xeus.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_xeus.py b/tests/test_xeus.py index 70cdd48..2333377 100644 --- a/tests/test_xeus.py +++ b/tests/test_xeus.py @@ -77,3 +77,21 @@ def test_python_env_from_file_2(): with pytest.raises(RuntimeError, match="Cannot install binary PyPI package"): for step in addon.post_build(manager): pass + + +def test_mount_point(): + app = LiteStatusApp(log_level="DEBUG") + app.initialize() + manager = app.lite_manager + + addon = XeusAddon(manager) + addon.mounts = ["environment-1.yml:/share/env-1.yml", "test-package:/share/test-package", ] + + assert os.path.isfile( + Path(addon.prefix) + / "share/env-1.yml" + ) + assert os.path.isdir( + Path(addon.prefix) + / "share/test-package" + ) From 82fb7fc967f108fcb3b5f5ebfa0cfaad92016e36 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 5 Feb 2024 11:07:33 +0100 Subject: [PATCH 3/7] Update test --- tests/test_xeus.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/test_xeus.py b/tests/test_xeus.py index 2333377..cd260ae 100644 --- a/tests/test_xeus.py +++ b/tests/test_xeus.py @@ -3,6 +3,7 @@ import os from tempfile import TemporaryDirectory from pathlib import Path +import tarfile import pytest @@ -85,13 +86,17 @@ def test_mount_point(): manager = app.lite_manager addon = XeusAddon(manager) - addon.mounts = ["environment-1.yml:/share/env-1.yml", "test-package:/share/test-package", ] + addon.mounts = ["environment-1.yml:/share/env-1.yml", "test-package:/share/test-package"] - assert os.path.isfile( - Path(addon.prefix) - / "share/env-1.yml" - ) - assert os.path.isdir( - Path(addon.prefix) - / "share/test-package" - ) + for step in addon.post_build(manager): + pass + + outpath = Path(addon.cwd.name) / "packed_env" + + with tarfile.open(outpath / "mount_0.tar.gz", "r") as fobj: + names = fobj.getnames() + assert "share/env-1.yml" in names + + with tarfile.open(outpath / "mount_1.tar.gz", "r") as fobj: + names = fobj.getnames() + assert "share/test-package/environment-3.yml" in names From 4142b04fbf0dce4b677a1dc88b65edb78afa4f70 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 5 Feb 2024 11:14:10 +0100 Subject: [PATCH 4/7] Fixed missing env --- tests/test_xeus.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_xeus.py b/tests/test_xeus.py index cd260ae..db1ae57 100644 --- a/tests/test_xeus.py +++ b/tests/test_xeus.py @@ -86,6 +86,7 @@ def test_mount_point(): manager = app.lite_manager addon = XeusAddon(manager) + addon.environment_file = "environment-1.yml" addon.mounts = ["environment-1.yml:/share/env-1.yml", "test-package:/share/test-package"] for step in addon.post_build(manager): From 3d827f5efe38ecf00a9b91ebdfea56726544d6ad Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 5 Feb 2024 11:22:47 +0100 Subject: [PATCH 5/7] Fix empack usage --- jupyterlite_xeus/add_on.py | 2 +- tests/test_xeus.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jupyterlite_xeus/add_on.py b/jupyterlite_xeus/add_on.py index ec2c2c6..4e5947c 100644 --- a/jupyterlite_xeus/add_on.py +++ b/jupyterlite_xeus/add_on.py @@ -316,7 +316,7 @@ def pack_prefix(self, kernel_dir): elif host_path.is_file(): pack_file( host_file=host_path, - mount_file=mount_path, + mount_dir=mount_path, outname=outname, outdir=out_path, ) diff --git a/tests/test_xeus.py b/tests/test_xeus.py index db1ae57..61ec237 100644 --- a/tests/test_xeus.py +++ b/tests/test_xeus.py @@ -87,7 +87,7 @@ def test_mount_point(): addon = XeusAddon(manager) addon.environment_file = "environment-1.yml" - addon.mounts = ["environment-1.yml:/share/env-1.yml", "test-package:/share/test-package"] + addon.mounts = ["environment-1.yml:/share", "test-package:/share/test-package"] for step in addon.post_build(manager): pass @@ -96,7 +96,7 @@ def test_mount_point(): with tarfile.open(outpath / "mount_0.tar.gz", "r") as fobj: names = fobj.getnames() - assert "share/env-1.yml" in names + assert "share/environment-1.yml" in names with tarfile.open(outpath / "mount_1.tar.gz", "r") as fobj: names = fobj.getnames() From fb18e5308e661fdfcc66390903774ebaff3b2a61 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 5 Feb 2024 11:31:15 +0100 Subject: [PATCH 6/7] Fix tests --- tests/test_xeus.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_xeus.py b/tests/test_xeus.py index 61ec237..cda4bb1 100644 --- a/tests/test_xeus.py +++ b/tests/test_xeus.py @@ -87,7 +87,10 @@ def test_mount_point(): addon = XeusAddon(manager) addon.environment_file = "environment-1.yml" - addon.mounts = ["environment-1.yml:/share", "test-package:/share/test-package"] + addon.mounts = [ + f"{(Path(__file__).parent / "environment-1.yml").resolve()}:/share", + f"{(Path(__file__).parent / "test_package").resolve()}:/share/test_package", + ] for step in addon.post_build(manager): pass From a2bb95d1258fe1dde683cdff85f9d67cdd8d7e17 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 5 Feb 2024 11:49:39 +0100 Subject: [PATCH 7/7] Fix test --- tests/test_xeus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_xeus.py b/tests/test_xeus.py index cda4bb1..eafc3a4 100644 --- a/tests/test_xeus.py +++ b/tests/test_xeus.py @@ -103,4 +103,4 @@ def test_mount_point(): with tarfile.open(outpath / "mount_1.tar.gz", "r") as fobj: names = fobj.getnames() - assert "share/test-package/environment-3.yml" in names + assert "share/test_package/environment-3.yml" in names