Skip to content

Commit

Permalink
changed flag to remove-venv
Browse files Browse the repository at this point in the history
logging the behaviour of venv not found
  • Loading branch information
sowmyasris committed Jul 19, 2024
1 parent 55e179a commit da5654d
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions fedn/cli/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ 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("-v", "--venv", default=True,type=bool,required=False, help="flag if set to False doesn't remove venv")
@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.pass_context
def validate_cmd(ctx, path,input,output,venv):
def validate_cmd(ctx, path,input,output,remove_venv):
"""Execute 'validate' entrypoint in fedn.yaml.
:param ctx:
Expand All @@ -71,18 +71,20 @@ def validate_cmd(ctx, path,input,output,venv):
dispatcher = Dispatcher(config, path)
_ = dispatcher._get_or_create_python_env()
dispatcher.run_cmd("validate {} {}".format(input, output))
if venv:
if remove_venv:
# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
else:
logger.warning("No virtualenv found to remove.")
@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.option("-o", "--output", required=True, help="Path to write the updated model parameters ")
@click.option("-v", "--remove-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,venv):
def train_cmd(ctx, path,input,output,remove_venv):
"""Execute 'train' entrypoint in fedn.yaml.
:param ctx:
Expand All @@ -104,16 +106,18 @@ def train_cmd(ctx, path,input,output,venv):
dispatcher = Dispatcher(config, path)
_ = dispatcher._get_or_create_python_env()
dispatcher.run_cmd("train {} {}".format(input, output))
if venv:
if remove_venv:
# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
else:
logger.warning("No virtualenv found to remove.")
@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.option("-v", "--remove-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,venv):
def startup_cmd(ctx, path,remove_venv):
"""Execute 'startup' entrypoint in fedn.yaml.
:param ctx:
Expand All @@ -135,17 +139,19 @@ def startup_cmd(ctx, path,venv):
dispatcher = Dispatcher(config, path)
_ = dispatcher._get_or_create_python_env()
dispatcher.run_cmd("startup")
if venv:
if remove_venv:
# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
else:
logger.warning("No virtualenv found to remove.")

@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")
@click.option("-v", "--remove-venv", default=True, type=bool, required=False, help="flag if set to False doesn't remove venv")
@click.pass_context
def build_cmd(ctx, path,venv):
def build_cmd(ctx, path,remove_venv):
"""Execute 'build' entrypoint in fedn.yaml.
:param ctx:
Expand All @@ -167,11 +173,13 @@ def build_cmd(ctx, path,venv):
dispatcher = Dispatcher(config, path)
_ = dispatcher._get_or_create_python_env()
dispatcher.run_cmd("build")
if venv:
if remove_venv:
# delete the virtualenv
if dispatcher.python_env_path:
logger.info(f"Removing virtualenv {dispatcher.python_env_path}")
shutil.rmtree(dispatcher.python_env_path)
else:
logger.warning("No virtualenv found to remove.")


@run_cmd.command("client")
Expand Down

0 comments on commit da5654d

Please sign in to comment.