/
check.py
60 lines (55 loc) · 1.31 KB
/
check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import click
from clipped.formatting import Printer
from polyaxon._polyaxonfile.check import check_polyaxonfile
from polyaxon.logger import clean_outputs
@click.command()
@click.option(
"-f",
"--file",
"polyaxonfile",
multiple=True,
type=click.Path(exists=True),
help="The polyaxon file to check.",
)
@click.option(
"-pm",
"--python-module",
type=str,
help="The python module to run.",
)
@click.option(
"--version",
"-v",
is_flag=True,
default=False,
help="Checks and prints the version.",
)
@click.option(
"--params",
"--param",
"-P",
metavar="NAME=VALUE",
multiple=True,
help="A parameter to override the default params of the run, form -P name=value.",
)
@click.option(
"--lint",
"-l",
is_flag=True,
default=False,
help="To check the specification only without params validation.",
)
@clean_outputs
def check(polyaxonfile, python_module, version, params, lint):
"""Check a polyaxonfile."""
specification = check_polyaxonfile(
polyaxonfile=polyaxonfile,
python_module=python_module,
params=params,
validate_params=not lint,
)
if version:
Printer.decorate_format_value(
"The version is: {}", specification.version, "yellow"
)
return specification