-
Notifications
You must be signed in to change notification settings - Fork 36
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
Feature/SK-944 + SK-934 | Add flag for deleting the virtual env #661
Conversation
fedn/cli/run_cmd.py
Outdated
|
||
@run_cmd.command("build") | ||
@click.option("-p", "--path", required=True, help="Path to package directory containing fedn.yaml") | ||
@click.option("-v", "--venv", default=True,type=bool,required=False, help="flag if set to False doesn't remove venv") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add space after ",", are you not using ruff in your IDE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I am using ruff in my IDE
logging the behaviour of venv not found
changed the import test cases for CLI command train,validate,startup,controller start and version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! Some changes requested
fedn/cli/run_cmd.py
Outdated
@@ -46,20 +53,18 @@ def run_cmd(ctx): | |||
@run_cmd.command("validate") | |||
@click.option("-p", "--path", required=True, help="Path to package directory containing fedn.yaml") | |||
@click.option("-i", "--input", required=True, help="Path to input model" ) | |||
@click.option("-o", "--output", required=True,help="Path to write the output JSON containing validation metrics") | |||
@click.option("-o", "--output", required=True, help="Path to write the output JSON containing validation metrics") | |||
@click.option("-v", "--remove-venv", default=True, type=bool, required=False, help="flag if set to False doesn't remove venv") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use is_flag=True here, since it's bool. It will be a better UX
fedn/cli/run_cmd.py
Outdated
if dispatcher.python_env_path: | ||
logger.info(f"Removing virtualenv {dispatcher.python_env_path}") | ||
shutil.rmtree(dispatcher.python_env_path) | ||
if remove_venv: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps move this if statement to a separate function that can be used within each subcommand? A lot of redundancy now
pyproject.toml
Outdated
@@ -31,6 +31,7 @@ requires-python = '>=3.8,<3.13' | |||
dependencies = [ | |||
"requests", | |||
"urllib3>=1.26.4", | |||
"gunicorn>=20.0.4,<21.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reason for the upper limit?
fedn/network/api/gunicorn_app.py
Outdated
def run_gunicorn(app, workers=4): | ||
workers=os.cpu_count() | ||
options = { | ||
"bind": "127.0.0.1:8000", # Specify the bind address and port here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hard coded host and port, should use host and port from config file, see debug case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more changes required
fedn/cli/run_cmd.py
Outdated
@@ -54,7 +61,7 @@ def run_cmd(ctx): | |||
@click.option("-p", "--path", required=True, help="Path to package directory containing fedn.yaml") | |||
@click.option("-i", "--input", required=True, help="Path to input model" ) | |||
@click.option("-o", "--output", required=True, help="Path to write the output JSON containing validation metrics") | |||
@click.option("-v", "--remove-venv", default=True, type=bool, required=False, help="flag if set to False doesn't remove venv") | |||
@click.option("-v", "--remove-venv", is_flag=True, default=True,required=False, help="flag if set to False doesn't remove venv") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need default=True when is_flag=True
fedn/cli/run_cmd.py
Outdated
shutil.rmtree(dispatcher.python_env_path) | ||
else: | ||
logger.warning("No virtualenv found to remove.") | ||
print(remove_venv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove print
fedn/network/api/gunicorn_app.py
Outdated
def run_gunicorn(app, workers=4): | ||
workers=os.cpu_count() | ||
def run_gunicorn(app, host,port,workers=4): | ||
bind_address=str(host)+":"+str(port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ok but a better way is:
bind_address = f"{host}:{port}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is very confusing, the flag can be called keep-venv which is by default true. then in the logic for the variable you can do:
if not keep_venv:
delete_virtual_environment(dispatcher)
In other words don't do the check if keep_venv is True or False in the function.
… feature/SK-944 merge master # the commit.
fedn/network/api/server.py
Outdated
app.run(debug=debug, port=port, host=host) | ||
|
||
|
||
config = get_controller_config() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check indent
"keep-venv" flag is added to run command
Default is set to True, removing the virtual environment after every command
Can be set to False, to reuse the environment for executing other commands
Tested with mnist-pytorch example
Added test cases for Fedn cli commans train, validate, startup, verifying version, controller start
Added Gunicorn server as production server if the debug is set to False