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

Feature/SK-944 + SK-934 | Add flag for deleting the virtual env #661

Merged
merged 19 commits into from
Sep 2, 2024
Merged
Changes from 4 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
52 changes: 28 additions & 24 deletions fedn/cli/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ 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", "--venv", default=True,type=bool,required=False, help="flag if set to False doesn't remove venv")
Wrede marked this conversation as resolved.
Show resolved Hide resolved
@click.pass_context
def validate_cmd(ctx, path,input,output):
def validate_cmd(ctx, path,input,output,venv):
"""Execute 'validate' entrypoint in fedn.yaml.

:param ctx:
Expand All @@ -70,17 +71,18 @@ def validate_cmd(ctx, path,input,output):
dispatcher = Dispatcher(config, path)
_ = dispatcher._get_or_create_python_env()
dispatcher.run_cmd("validate {} {}".format(input, output))

# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
if venv:
# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
@run_cmd.command("train")
@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 parameters" )
@click.option("-o", "--output", required=True,help="Path to write the updated model parameters ")
@click.option("-v", "--venv", default=True,type=bool,required=False, help="flag if set to False doesn't remove venv")
@click.pass_context
def train_cmd(ctx, path,input,output):
def train_cmd(ctx, path,input,output,venv):
"""Execute 'train' entrypoint in fedn.yaml.

:param ctx:
Expand All @@ -102,15 +104,16 @@ def train_cmd(ctx, path,input,output):
dispatcher = Dispatcher(config, path)
_ = dispatcher._get_or_create_python_env()
dispatcher.run_cmd("train {} {}".format(input, output))

# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
if venv:
# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
@run_cmd.command("startup")
@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")
@click.pass_context
def startup_cmd(ctx, path):
def startup_cmd(ctx, path,venv):
"""Execute 'startup' entrypoint in fedn.yaml.

:param ctx:
Expand All @@ -132,16 +135,17 @@ def startup_cmd(ctx, path):
dispatcher = Dispatcher(config, path)
_ = dispatcher._get_or_create_python_env()
dispatcher.run_cmd("startup")

# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
if venv:
# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)

@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")
Copy link
Member

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?

Copy link
Contributor Author

@sowmyasris sowmyasris Jul 19, 2024

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

@click.pass_context
def build_cmd(ctx, path):
def build_cmd(ctx, path,venv):
"""Execute 'build' entrypoint in fedn.yaml.

:param ctx:
Expand All @@ -163,11 +167,11 @@ def build_cmd(ctx, path):
dispatcher = Dispatcher(config, path)
_ = dispatcher._get_or_create_python_env()
dispatcher.run_cmd("build")

# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
if venv:
# delete the virtualenv
if dispatcher.python_env_path:
Wrede marked this conversation as resolved.
Show resolved Hide resolved
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)


@run_cmd.command("client")
Expand Down
Loading