Skip to content
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

Bugfix: data explorer artifact mounting #310

Merged
merged 22 commits into from
Jul 20, 2023
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
9 changes: 7 additions & 2 deletions src/fondant/explorer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import logging
import os
import shlex
import subprocess # nosec
import typing as t
from pathlib import Path

DEFAULT_CONTAINER = "ghcr.io/ml6team/data_explorer"
DEFAULT_TAG = "latest"
Expand Down Expand Up @@ -41,9 +43,12 @@ def run_explorer_app(

# mount the local data directory to the container
if data_directory:
print(data_directory)
data_directory_path = Path(data_directory).resolve()
host_machine_path = str(data_directory_path)
container_path = os.path.join("/", data_directory_path.name)

cmd.extend(
["-v", f"{shlex.quote(data_directory)}:{shlex.quote(data_directory)}"],
["-v", f"{shlex.quote(host_machine_path)}:{shlex.quote(container_path)}"],
)

# add the image name
Expand Down
16 changes: 10 additions & 6 deletions tests/test_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ def test_run_data_explorer_default():

def test_run_data_explorer_with_data_dir():
"""Test that the data explorer can be run with a data directory."""
data_directory = "/path/to/source"
host_machine_path = "/path/to/source"
container_path = "/source"

args = {
"data_directory": data_directory,
"data_directory": host_machine_path,
}

with patch("subprocess.call") as mock_call:
Expand All @@ -48,7 +50,7 @@ def test_run_data_explorer_with_data_dir():
"-p",
f"{DEFAULT_PORT}:8501",
"-v",
f"{data_directory}:{data_directory}",
f"{host_machine_path}:{container_path}",
f"{DEFAULT_CONTAINER}:{DEFAULT_TAG}",
],
stdout=subprocess.PIPE,
Expand Down Expand Up @@ -85,15 +87,17 @@ def test_run_data_explorer_with_credentials():
def test_run_data_explorer_full_option():
"""Test that the data explorer can be run with all options."""
credentials = "/path/to/credentials"
data_directory = "/path/to/source"
host_machine_path = "/path/to/source"
container_path = "/source"

container = "ghcr.io/ml6team/data_explorer_test"
tag = "earliest"
port = 1234

with patch("subprocess.call") as mock_call:
run_explorer_app(
credentials=credentials,
data_directory=data_directory,
data_directory=host_machine_path,
container=container,
tag=tag,
port=port,
Expand All @@ -111,7 +115,7 @@ def test_run_data_explorer_full_option():
"-v",
"/path/to/credentials:ro",
"-v",
"/path/to/source:/path/to/source",
f"{host_machine_path}:{container_path}",
"ghcr.io/ml6team/data_explorer_test:earliest",
],
stdout=-1,
Expand Down