public class RunInference<OutputT> extends PTransform<PCollection<?>,PCollection<OutputT>>
RunInference
. @Experimentalname, resourceHints
Modifier and Type | Method and Description |
---|---|
PCollection<OutputT> |
expand(PCollection<?> input)
Override this method to specify how this
PTransform should be expanded on the given
InputT . |
static RunInference<Row> |
of(java.lang.String modelLoader,
Schema.FieldType exampleType,
Schema.FieldType inferenceType)
Instantiates a multi-language wrapper for a Python RunInference with a given model loader.
|
static RunInference<Row> |
of(java.lang.String modelLoader,
Schema schema)
Instantiates a multi-language wrapper for a Python RunInference with a given model loader.
|
static <KeyT> RunInference<KV<KeyT,Row>> |
ofKVs(java.lang.String modelLoader,
Schema.FieldType exampleType,
Schema.FieldType inferenceType,
Coder<KeyT> keyCoder)
|
static <KeyT> RunInference<KV<KeyT,Row>> |
ofKVs(java.lang.String modelLoader,
Schema schema,
Coder<KeyT> keyCoder)
|
RunInference<OutputT> |
withExpansionService(java.lang.String expansionService)
Sets an expansion service endpoint for RunInference.
|
void |
withExtraPackages(java.util.List<java.lang.String> extraPackages)
Specifies any extra Pypi packages required by the RunInference model handler.
|
RunInference<OutputT> |
withKwarg(java.lang.String key,
java.lang.Object arg)
Sets keyword arguments for the model loader.
|
compose, compose, getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setResourceHints, toString, validate, validate
public static RunInference<Row> of(java.lang.String modelLoader, Schema.FieldType exampleType, Schema.FieldType inferenceType)
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.RunInference
for the given model loader.public static <KeyT> RunInference<KV<KeyT,Row>> ofKVs(java.lang.String modelLoader, Schema.FieldType exampleType, Schema.FieldType inferenceType, Coder<KeyT> keyCoder)
RunInference#of(String, FieldType, FieldType)
but the input is a PCollection
of KV
s.
Also outputs a PCollection
of KV
s of the same key type.
For example, use this if you are using Python KeyedModelHandler
as the model
handler.
KeyT
- input and output Key type. Inferred by the provided coder.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
- a Coder
for the input and output Key type.RunInference
for the given model loader.public static RunInference<Row> of(java.lang.String modelLoader, Schema schema)
modelLoader
- A Python callable for a model loader class object.schema
- A schema for output rows.RunInference
for the given model loader.public static <KeyT> RunInference<KV<KeyT,Row>> ofKVs(java.lang.String modelLoader, Schema schema, Coder<KeyT> keyCoder)
KeyT
- input and output Key type. Inferred by the provided coder.modelLoader
- A Python callable for a model loader class object.schema
- A schema for output rows.keyCoder
- a Coder
for the input and output Key type.RunInference
for the given model loader.public RunInference<OutputT> withKwarg(java.lang.String key, java.lang.Object arg)
RunInference
with keyword arguments.public void withExtraPackages(java.util.List<java.lang.String> extraPackages)
This should only be specified when using the default expansion service, i.e. when not using
withExpansionService(String)
to provide an expansion service.
For model handlers provided by Beam Python SDK, the implementation will automatically try to infer correct packages needed, so this may be omitted.
extraPackages
- a list of PyPi packages. May include the version.public RunInference<OutputT> withExpansionService(java.lang.String expansionService)
expansionService
- A URL for a Python expansion service.RunInference
for the given expansion service endpoint.public PCollection<OutputT> expand(PCollection<?> input)
PTransform
PTransform
should be expanded on the given
InputT
.
NOTE: This method should not be called directly. Instead apply the PTransform
should
be applied to the InputT
using the apply
method.
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).
expand
in class PTransform<PCollection<?>,PCollection<OutputT>>