itsayushpandey commented on code in PR #31657: URL: https://github.com/apache/beam/pull/31657#discussion_r1676572613
########## examples/notebooks/beam-ml/rag_usecase/redis_connector.py: ########## @@ -0,0 +1,406 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from __future__ import absolute_import + +import logging +from past.builtins import unicode + +import apache_beam as beam +import numpy as np + +from apache_beam.transforms import DoFn +from apache_beam.transforms import PTransform +from apache_beam.transforms import Reshuffle +from apache_beam.utils.annotations import deprecated +from apache_beam.options.value_provider import ValueProvider +from apache_beam.options.value_provider import StaticValueProvider +from apache_beam import coders + +import typing + +# Set the logging level to reduce verbose information +import logging + +logging.root.setLevel(logging.INFO) +logger = logging.getLogger(__name__) + +import redis + +__all__ = ['InsertDocInRedis', 'InsertEmbeddingInRedis'] + + +class Document(typing.NamedTuple): + id: str + url: str + title: str + text: str + + +coders.registry.register_coder(Document, coders.RowCoder) + +"""This module implements IO classes to read write data on Redis. + + +Insert Doc in Redis: +----------------- +:class:`InsertDocInRedis` is a ``PTransform`` that writes key and values to a +configured sink, and the write is conducted through a redis pipeline. + +The ptransform works by getting the first and second elements from the input, +this means that inputs like `[k,v]` or `(k,v)` are valid. + +Example usage:: + + pipeline | WriteToRedis(host='localhost', + port=6379, + batch_size=100) + + +No backward compatibility guarantees. Everything in this module is experimental. +""" + + +@deprecated(since='v.1') Review Comment: i removed it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org