Class RunInference<OutputT>
- All Implemented Interfaces:
Serializable,HasDisplayData
RunInference.- See Also:
-
Field Summary
Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints -
Method Summary
Modifier and TypeMethodDescriptionexpand(PCollection<?> input) Override this method to specify how thisPTransformshould be expanded on the givenInputT.static RunInference<Row> Instantiates a multi-language wrapper for a Python RunInference with a given model loader.static RunInference<Row> of(String modelLoader, Schema.FieldType exampleType, Schema.FieldType inferenceType) Instantiates a multi-language wrapper for a Python RunInference with a given model loader.static <KeyT> RunInference<KV<KeyT, Row>> ofKVs(String modelLoader, Schema.FieldType exampleType, Schema.FieldType inferenceType, Coder<KeyT> keyCoder) static <KeyT> RunInference<KV<KeyT, Row>> withExpansionService(String expansionService) Sets an expansion service endpoint for RunInference.withExtraPackages(List<String> extraPackages) Specifies any extra packages required by the RunInference model handler.Sets keyword arguments for the model loader.Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setDisplayData, setResourceHints, toString, validate, validate
-
Method Details
-
of
public static RunInference<Row> of(String modelLoader, Schema.FieldType exampleType, Schema.FieldType inferenceType) Instantiates a multi-language wrapper for a Python RunInference with a given model loader.- Parameters:
modelLoader- A Python callable for a model loader class object.exampleType- A schema field type for the example column in output rows.inferenceType- A schema field type for the inference column in output rows.- Returns:
- A
RunInferencefor the given model loader.
-
ofKVs
public static <KeyT> RunInference<KV<KeyT,Row>> ofKVs(String modelLoader, Schema.FieldType exampleType, Schema.FieldType inferenceType, Coder<KeyT> keyCoder) Similar toof(String, FieldType, FieldType)but the input is aPCollectionofKVs.Also outputs a
PCollectionofKVs of the same key type.For example, use this if you are using Python
KeyedModelHandleras the model handler.- Type Parameters:
KeyT- input and output Key type. Inferred by the provided coder.- Parameters:
modelLoader- A Python callable for a model loader class object.exampleType- A schema field type for the example column in output rows.inferenceType- A schema field type for the inference column in output rows.keyCoder- aCoderfor the input and output Key type.- Returns:
- A
RunInferencefor the given model loader.
-
of
Instantiates a multi-language wrapper for a Python RunInference with a given model loader.- Parameters:
modelLoader- A Python callable for a model loader class object.schema- A schema for output rows.- Returns:
- A
RunInferencefor the given model loader.
-
ofKVs
public static <KeyT> RunInference<KV<KeyT,Row>> ofKVs(String modelLoader, Schema schema, Coder<KeyT> keyCoder) - Type Parameters:
KeyT- input and output Key type. Inferred by the provided coder.- Parameters:
modelLoader- A Python callable for a model loader class object.schema- A schema for output rows.keyCoder- aCoderfor the input and output Key type.- Returns:
- A
RunInferencefor the given model loader.
-
withKwarg
Sets keyword arguments for the model loader.- Returns:
- A
RunInferencewith keyword arguments.
-
withExtraPackages
Specifies any extra packages required by the RunInference model handler.This should only be specified when using the default expansion service, i.e. when not using
withExpansionService(String)to provide an expansion service.The package can either be a PyPi package or the path to a locally available Python package.
For model handlers provided by Beam Python SDK, the implementation will automatically try to infer correct packages needed, so this may be omitted.
- Parameters:
extraPackages- a list of PyPi packages. May include the version.- Returns:
- A
RunInferencewith extra packages.
-
withExpansionService
Sets an expansion service endpoint for RunInference.- Parameters:
expansionService- A URL for a Python expansion service.- Returns:
- A
RunInferencefor the given expansion service endpoint.
-
expand
Description copied from class:PTransformOverride this method to specify how thisPTransformshould be expanded on the givenInputT.NOTE: This method should not be called directly. Instead apply the
PTransformshould be applied to theInputTusing theapplymethod.Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
- Specified by:
expandin classPTransform<PCollection<?>,PCollection<OutputT>>
-