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

feat(framework) Install Python package(s) on flwr install #3816

Merged
merged 10 commits into from
Jul 17, 2024
16 changes: 16 additions & 0 deletions src/py/flwr/cli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


import shutil
import subprocess
import tempfile
import zipfile
from io import BytesIO
Expand Down Expand Up @@ -192,6 +193,21 @@ def validate_and_install(
else:
shutil.copy2(item, install_dir / item.name)

try:
subprocess.run(
["pip", "install", "-e", install_dir, "--no-deps"],
capture_output=True,
text=True,
check=True,
)
except subprocess.CalledProcessError as e:
typer.secho(
f"❌ Failed to `pip install` package(s) from {install_dir}:\n{e.stderr}",
fg=typer.colors.RED,
bold=True,
)
raise typer.Exit(code=1) from e

typer.secho(
f"🎊 Successfully installed {project_name} to {install_dir}.",
fg=typer.colors.GREEN,
Expand Down
10 changes: 1 addition & 9 deletions src/py/flwr/superexec/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Deployment engine executor."""

import subprocess
import sys
from logging import ERROR, INFO
from pathlib import Path
from typing import Dict, Optional
Expand Down Expand Up @@ -131,14 +130,7 @@ def start_run(
try:
# Install FAB to flwr dir
fab_version, fab_id = get_fab_metadata(fab_file)
fab_path = install_from_fab(fab_file, None, True)

# Install FAB Python package
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "--no-deps", str(fab_path)],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
install_from_fab(fab_file, None, True)

# Call SuperLink to create run
run_id: int = self._create_run(fab_id, fab_version, override_config)
Expand Down
Loading