Esempio n. 1
0
def check_polyaxonfile(polyaxonfile,
                       params=None,
                       profile=None,
                       queue=None,
                       nocache=None,
                       log=True):
    if not polyaxonfile:
        polyaxonfile = PolyaxonFile.check_default_path(path=".")
    if not polyaxonfile:
        polyaxonfile = ""

    polyaxonfile = to_list(polyaxonfile)
    exists = [os.path.isfile(f) for f in polyaxonfile]

    parsed_params = None
    if params:
        parsed_params = parse_params(params)

    if not any(exists):
        Printer.print_error("Polyaxonfile is not present, "
                            "please run {}".format(constants.INIT_COMMAND))
        sys.exit(1)

    try:
        plx_file = PolyaxonFile(polyaxonfile)
        plx_file = plx_file.get_op_specification(params=parsed_params,
                                                 profile=profile,
                                                 queue=queue,
                                                 nocache=nocache)
        if log:
            Printer.print_success("Polyaxonfile valid")
        return plx_file
    except Exception as e:
        handle_cli_error(e, message="Polyaxonfile is not valid.")
        sys.exit(1)
Esempio n. 2
0
    def test_polyaxon_found(self):
        def create_file(path, filename, ext):
            fpath = "{}/{}.{}".format(path, filename, ext)
            open(fpath, "w")

        for filename in DEFAULT_POLYAXON_FILE_NAME:
            for ext in DEFAULT_POLYAXON_FILE_EXTENSION:
                path = tempfile.mkdtemp()
                create_file(path, filename, ext)
                assert PolyaxonFile.check_default_path(path=path)
Esempio n. 3
0
 def test_default_not_found(self):
     path = tempfile.mkdtemp()
     assert PolyaxonFile.check_default_path(path=path) is None