Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Kinard <[email protected]>
  • Loading branch information
Polber committed Dec 21, 2024
1 parent cda2ee1 commit 063890c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sdks/python/apache_beam/yaml/yaml_ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

"""This module defines yaml wrappings for some ML transforms."""
from typing import Any
from typing import Callable
from typing import Dict
from typing import List
from typing import Optional
Expand All @@ -40,7 +41,7 @@


class ModelHandlerProvider:
handler_types: Dict[str, "ModelHandlerProvider"] = {}
handler_types: Dict[str, Callable[..., "ModelHandlerProvider"]] = {}

def __init__(
self,
Expand Down Expand Up @@ -435,16 +436,15 @@ def fn(x: PredictionResult):
typ = model_handler['type']
model_handler_provider = ModelHandlerProvider.handler_types.get(typ, None)
if model_handler_provider and issubclass(model_handler_provider,
ModelHandlerProvider):
type(ModelHandlerProvider)):
model_handler_provider.validate(model_handler['config'])
else:
raise NotImplementedError(f'Unknown model handler type: {typ}.')

model_handler_provider = ModelHandlerProvider.create_handler(model_handler)
user_type = RowTypeConstraint.from_user_type(pcoll.element_type.user_type)
schema = RowTypeConstraint.from_fields(
list(
RowTypeConstraint.from_user_type(
pcoll.element_type.user_type)._fields) +
list(user_type._fields if user_type else []) +
[(inference_tag, model_handler_provider.inference_output_type())])

return (
Expand Down
1 change: 1 addition & 0 deletions sdks/python/apache_beam/yaml/yaml_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
#

import logging
import unittest

import yaml
Expand Down

0 comments on commit 063890c

Please sign in to comment.