Exemple #1
0
 def test_reads_yaml_stream(self):
     stream = """---
     x: y
     1: 2
     """
     config = reader.read(stream)
     assert config == {'x': 'y', 1: 2}
Exemple #2
0
def resume(ctx, file, u):  # pylint:disable=redefined-builtin
    """Resume experiment.

    Uses [Caching](/polyaxon_cli/introduction#Caching)

    Examples:

    \b
    ```bash
    $ polyaxon experiment --experiment=1 resume
    ```
    """
    config = None
    update_code = None
    if file:
        config = reader.read(file)

    # Check if we need to upload
    if u:
        ctx.invoke(upload, async=False)
        update_code = True

    user, project_name, _experiment = get_experiment_or_local(ctx.obj['project'],
                                                              ctx.obj['experiment'])
    try:
        response = PolyaxonClients().experiment.resume(
            user, project_name, _experiment, config=config, update_code=update_code)
    except (PolyaxonHTTPError, PolyaxonShouldExitError) as e:
        Printer.print_error('Could not resume experiment `{}`.'.format(_experiment))
        Printer.print_error('Error message `{}`.'.format(e))
        sys.exit(1)

    get_experiment_details(response)
    def __init__(self, values):
        self._values = to_list(values)

        self._data = reader.read(self._values)
        Parser.check_data(spec=self, data=self._data)
        headers = Parser.get_headers(spec=self, data=self._data)
        matrix = Parser.get_matrix(spec=self, data=self._data)
        try:
            self._matrix = validator.validate_matrix(matrix)
        except ValidationError as e:
            raise PolyaxonConfigurationError(e)
        try:
            self._headers = validator.validate_headers(spec=self, data=headers)
        except ValidationError as e:
            raise PolyaxonConfigurationError(e)
        self._parsed_data = []
        self._validated_data = []
        self._experiment_specs = []

        matrix_declarations = self.matrix_declarations if self.matrix_declarations else [
            {}
        ]
        for i, matrix_declaration in enumerate(matrix_declarations):
            parsed_data = Parser.parse(self, self._data, matrix_declaration)
            self._validated_data.append(
                validator.validate(spec=self, data=parsed_data))
            self._parsed_data.append(parsed_data)
            self._experiment_specs.append(
                Specification(experiment=i, values=parsed_data))
    def __init__(self, values):
        self._values = to_list(values)

        self._data = reader.read(self._values)
        Parser.check_data(spec=self, data=self._data)
        headers = Parser.get_headers(spec=self, data=self._data)
        try:
            self._headers = validator.validate_headers(spec=self, data=headers)
        except ValidationError as e:
            raise PolyaxonConfigurationError(e)
        parsed_data = Parser.parse(self, self._data, None)
        self._validated_data = validator.validate(spec=self, data=parsed_data)
        self._parsed_data = parsed_data
Exemple #5
0
    def __init__(self, values):
        self._values = to_list(values)

        self._data = reader.read(self._values)
        self.check_data()
        headers = Parser.get_headers(spec=self, data=self._data)
        try:
            self._headers = validator.validate_headers(spec=self, data=headers)
        except ValidationError as e:
            raise PolyaxonConfigurationError(e)
        self._parsed_data = None
        self._validated_data = None
        self._set_parsed_data()
        self._extra_validation()
 def __init__(self, filepaths):
     filepaths = to_list(filepaths)
     for filepath in filepaths:
         if not os.path.isfile(filepath):
             raise PolyaxonfileError(
                 "`{}` must be a valid file".format(filepath))
     self._filenames = [
         os.path.basename(filepath) for filepath in filepaths
     ]
     data = reader.read(filepaths)
     kind = BaseSpecification.get_kind(data=data)
     try:
         self.specification = SPECIFICATION_BY_KIND[kind](data)
     except PolyaxonConfigurationError as e:
         raise PolyaxonfileError(e)
    def __init__(self, filepath):
        self._filepath = filepath

        self._data = reader.read(self._filepath)
        self._parsed_data = Parser.parse(self._data)
        self._validated_data = validator.validate(self._parsed_data)
Exemple #8
0
 def read_configs(cls, config_values):
     config = reader.read(config_values)
     return cls(**config) if config else None
Exemple #9
0
 def read_configs(cls, config_values):  # pylint:disable=redefined-outer-name
     config = reader.read(config_values)  # pylint:disable=redefined-outer-name
     return cls(**config) if config else None
Exemple #10
0
 def read_configs(cls, config_values):  # pylint:disable=redefined-outer-name
     config = reader.read(config_values)  # pylint:disable=redefined-outer-name
     return cls(**config) if config else None
Exemple #11
0
 def test_reads_yaml_files(self):
     config = reader.read('tests/fixtures/simple_file.yml')
     assert config is not None
Exemple #12
0
 def test_reads_json_stream(self):
     stream = """---
     {x: y, 1: 2}
     """
     config = reader.read(stream)
     assert config is not None
Exemple #13
0
 def test_reads_confi_map(self):
     config = reader.read([{'x': 'y'}, {1: 2}, {'x': 'override y'}])
     assert config == {'x': 'override y', 1: 2}
Exemple #14
0
 def test_reads_json_files(self):
     config = reader.read('tests/fixtures/simple_json_file.json')
     assert config == {'x': 'y'}