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

Make data explorer non-blocking with docker compose #731

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 9 additions & 2 deletions src/fondant/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ def run_explorer_app( # type: ignore # noqa: PLR0913
"--detach",
]

subprocess.call(cmd, stdout=subprocess.PIPE) # nosec
try:
subprocess.check_call(cmd, stdout=subprocess.PIPE) # nosec
except subprocess.CalledProcessError as e:
raise OSError(e.returncode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you choose an OSError here? I would probably have gone for a SystemExit exception myself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make more sense here indeed, updated


logging.info(
f"Running image from registry '{container}' with tag '{tag}' on port '{port}'",
Expand All @@ -174,7 +177,11 @@ def stop_explorer_app(
"stop",
]

subprocess.call(cmd, stdout=subprocess.PIPE) # nosec
try:
subprocess.check_call(cmd, stdout=subprocess.PIPE) # nosec
except subprocess.CalledProcessError as e:
raise OSError(e.returncode)

# check if the container is running
logging.info(
"Explorer app stopped successfully",
Expand Down
12 changes: 9 additions & 3 deletions tests/test_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def test_run_data_explorer_local_base_path(
tmp_path_factory,
):
"""Test that the data explorer can be run with a local base path."""
with tmp_path_factory.mktemp("temp") as fn, patch("subprocess.call") as mock_call:
with tmp_path_factory.mktemp("temp") as fn, patch(
"subprocess.check_call",
) as mock_call:
output_path = str(fn / OUTPUT_FILE)
run_explorer_app(
base_path=host_path,
Expand Down Expand Up @@ -86,7 +88,9 @@ def test_run_data_explorer_remote_base_path(
tmp_path_factory,
):
"""Test that the data explorer can be run with a remote base path."""
with tmp_path_factory.mktemp("temp") as fn, patch("subprocess.call") as mock_call:
with tmp_path_factory.mktemp("temp") as fn, patch(
"subprocess.check_call",
) as mock_call:
output_path = str(fn / OUTPUT_FILE)
run_explorer_app(
base_path=remote_path,
Expand Down Expand Up @@ -129,7 +133,9 @@ def test_stop_data_explorer(
tmp_path_factory,
):
"""Test that the data explorer can be run with a remote base path."""
with tmp_path_factory.mktemp("temp") as fn, patch("subprocess.call") as mock_call:
with tmp_path_factory.mktemp("temp") as fn, patch(
"subprocess.check_call",
) as mock_call:
output_path = str(fn / OUTPUT_FILE)
stop_explorer_app(
output_path=output_path,
Expand Down
Loading