From bf92cd8c49cdfdb314eba460586cba5f88acca5f Mon Sep 17 00:00:00 2001 From: Jeffrey Kinard Date: Mon, 23 Dec 2024 15:16:17 -0600 Subject: [PATCH] fix lint Signed-off-by: Jeffrey Kinard --- sdks/python/apache_beam/yaml/yaml_ml.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sdks/python/apache_beam/yaml/yaml_ml.py b/sdks/python/apache_beam/yaml/yaml_ml.py index fb255c5b0b02..c59d8123ebc5 100644 --- a/sdks/python/apache_beam/yaml/yaml_ml.py +++ b/sdks/python/apache_beam/yaml/yaml_ml.py @@ -155,7 +155,7 @@ def __init__( so that input data can be sent using an API request, and inferences can be received as a response. - This Model Handler also required a `preprocess` function to be defined. + This Model Handler also requires a `preprocess` function to be defined. Preprocessing and Postprocessing are described in more detail in the RunInference docs: https://beam.apache.org/releases/yamldoc/current/#runinference @@ -434,14 +434,13 @@ def fn(x: PredictionResult): if missing_params: raise ValueError(f'Missing parameters in model_handler: {missing_params}') typ = model_handler['type'] - model_handler_provider = ModelHandlerProvider.handler_types.get(typ, None) - if model_handler_provider and issubclass(model_handler_provider, - type(ModelHandlerProvider)): - model_handler_provider.validate(model_handler['config']) - else: + model_handler_provider_type = ModelHandlerProvider.handler_types.get( + typ, None) + if not model_handler_provider_type: raise NotImplementedError(f'Unknown model handler type: {typ}.') model_handler_provider = ModelHandlerProvider.create_handler(model_handler) + model_handler_provider.validate(model_handler['config']) user_type = RowTypeConstraint.from_user_type(pcoll.element_type.user_type) schema = RowTypeConstraint.from_fields( list(user_type._fields if user_type else []) +