public class ServableReadWriteUtils extends Object
Constructor and Description |
---|
ServableReadWriteUtils() |
Modifier and Type | Method and Description |
---|---|
static InputStream |
loadModelData(String path)
Opens an FSDataInputStream to read the model data file in the directory.
|
static List<TransformerServable<?>> |
loadPipeline(String path)
Loads the servables of a
PipelineModelServable from the given path. |
static <T extends TransformerServable<T>> |
loadServableParam(String path,
Class<T> clazz)
Loads the
TransformerServable with the saved parameters from the given path. |
public static List<TransformerServable<?>> loadPipeline(String path) throws IOException
PipelineModelServable
from the given path.
The method throws RuntimeException if the expectedClassName is not empty AND it does not match the className of the previously saved PipelineModel.
path
- The parent directory to load the PipelineModelServable metadata and its
servables.IOException
public static <T extends TransformerServable<T>> T loadServableParam(String path, Class<T> clazz) throws IOException
TransformerServable
with the saved parameters from the given path. This
method reads the metadata file under the given path, instantiates the servable using its
no-argument constructor, and loads the servable with the paramMap from the metadata file.
Note: This method does not attempt to read model data from the given path. Caller needs to read and deserialize model data from the given path.
Required: the class with type T must have a no-argument constructor.
T
- The class type of the TransformerServable subclass.path
- The parent directory of the metadata file.IOException
public static InputStream loadModelData(String path) throws IOException
path
- The parent directory of the model data file.IOException
Copyright © 2019–2023 The Apache Software Foundation. All rights reserved.