Example #1
0
 def release_wrapper(self,
                     config,
                     model_path,
                     storage,
                     image,
                     destination,
                     optimization_level=None,
                     gpuid=0,
                     push_model=True):
     local_config = self._finalize_config(config, training=False)
     objects = self.release(
         local_config,
         model_path,
         optimization_level=optimization_level,
         gpuid=gpuid)
     bundle_dependencies(objects, config, local_config)
     model_id = config['model'] + '_release'
     config['model'] = model_id
     config['modelType'] = 'release'
     config['imageTag'] = image
     for name in ("parent_model", "build", "data"):
         if name in config:
             del config[name]
     inference_options = config.get('inference_options')
     if inference_options is not None:
         schema = config_util.validate_inference_options(inference_options, config)
         options_path = os.path.join(self._output_dir, 'options.json')
         with open(options_path, 'w') as options_file:
             json.dump(schema, options_file)
         objects[os.path.basename(options_path)] = options_path
     objects_dir = os.path.join(self._models_dir, model_id)
     build_model_dir(objects_dir, objects, config, should_check_integrity)
     if push_model:
         storage.push(objects_dir, storage.join(destination, model_id))
Example #2
0
def test_inference_options_invalid_shema():
    opt = copy.deepcopy(_test_inference_options)
    opt["json_schema"]["type"] = "objects"
    with pytest.raises(jsonschema.SchemaError):
        config.validate_inference_options(opt, _test_config)
Example #3
0
def test_inference_options_validation():
    schema = config.validate_inference_options(_test_inference_options,
                                               _test_config)
    assert isinstance(schema, dict)