示例#1
0
def trained_model_directory(
    model_collection_directory: str, config_str: str, gordo_name: str
):
    """
    Fixture: Train a basic AutoEncoder and save it to a given directory
    will also save some metadata with the model
    """

    # Model specific to the model being trained here
    model_dir = os.path.join(model_collection_directory, gordo_name)
    os.makedirs(model_dir, exist_ok=True)

    builder = local_build(config_str=config_str)
    model, metadata = next(builder)  # type: ignore
    serializer.dump(model, model_dir, metadata=metadata.to_dict())
    yield model_dir
示例#2
0
def trained_model_directories(model_collection_directory: str,
                              config_str: str):
    """
    Fixture: Train a basic AutoEncoder and save it to a given directory
    will also save some metadata with the model
    """

    # Model specific to the model being trained here
    builder = local_build(config_str=config_str)
    model_directories = {}
    for model, metadata in builder:
        metadata_dict = metadata.to_dict()
        model_name = metadata_dict.get("name")
        model_dir = os.path.join(model_collection_directory, model_name)
        os.makedirs(model_dir, exist_ok=True)
        serializer.dump(model, model_dir, metadata=metadata.to_dict())
        model_directories[model_name] = model_dir
    yield model_directories