@@ -43,6 +43,38 @@ def run_cmd(ctx):
43
43
""":param ctx:
44
44
"""
45
45
pass
46
+ @run_cmd .command ("validate" )
47
+ @click .option ("-p" , "--path" , required = True , help = "Path to package directory containing fedn.yaml" )
48
+ @click .option ("-i" , "--input" , required = True , help = "Path to input model" )
49
+ @click .option ("-o" , "--output" , required = True ,help = "Path to write the output JSON containing validation metrics" )
50
+ @click .pass_context
51
+ def validate_cmd (ctx , path ,input ,output ):
52
+ """Execute 'validate' entrypoint in fedn.yaml.
53
+
54
+ :param ctx:
55
+ :param path: Path to folder containing fedn.yaml
56
+ :type path: str
57
+ """
58
+ path = os .path .abspath (path )
59
+ yaml_file = os .path .join (path , "fedn.yaml" )
60
+ if not os .path .exists (yaml_file ):
61
+ logger .error (f"Could not find fedn.yaml in { path } " )
62
+ exit (- 1 )
63
+
64
+ config = _read_yaml_file (yaml_file )
65
+ # Check that validate is defined in fedn.yaml under entry_points
66
+ if "validate" not in config ["entry_points" ]:
67
+ logger .error ("No validate command defined in fedn.yaml" )
68
+ exit (- 1 )
69
+
70
+ dispatcher = Dispatcher (config , path )
71
+ _ = dispatcher ._get_or_create_python_env ()
72
+ dispatcher .run_cmd ("validate {} {}" .format (input , output ))
73
+
74
+ # delete the virtualenv
75
+ if dispatcher .python_env_path :
76
+ logger .info (f"Removing virtualenv { dispatcher .python_env_path } " )
77
+ shutil .rmtree (dispatcher .python_env_path )
46
78
@run_cmd .command ("train" )
47
79
@click .option ("-p" , "--path" , required = True , help = "Path to package directory containing fedn.yaml" )
48
80
@click .option ("-i" , "--input" , required = True , help = "Path to input model parameters" )
0 commit comments