Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue-624] Python API support for the new unified sink #625

Conversation

thekingofcity
Copy link
Contributor

Signed-off-by: thekingofcity [email protected]

Change log description

Upgrade the Python wrapper to match the new unified sink API implemented in #460.

Purpose of the change

Fix #624

What the code does

Add a Python PravegaSink wrapper that inherits Sink.

How to verify it

from pyflink.common.serialization import SimpleStringSchema
from pyflink.common.typeinfo import Types
from pyflink.datastream import StreamExecutionEnvironment, CheckpointingMode

from pravega_config import PravegaConfig
from pravega_writer import PravegaSink, PravegaWriterMode

CONTROLLER_URI = 'tcp://localhost:9090'
SCOPE = 'scope'
STREAM = 'stream'

env = StreamExecutionEnvironment.get_execution_environment()
env.set_parallelism(1)
env.enable_checkpointing(1000, CheckpointingMode.EXACTLY_ONCE)

pravega_config = PravegaConfig(uri=CONTROLLER_URI, scope=SCOPE)
pravega_sink = PravegaSink(stream=STREAM,
                           pravega_config=pravega_config,
                           writer_mode=PravegaWriterMode.ATLEAST_ONCE,
                           serialization_schema=SimpleStringSchema())

ds = env.from_collection(collection=['a', 'bb', 'ccc'],
                         type_info=Types.STRING())
ds.sink_to(pravega_sink)

env.execute("writer_test")

This simple test could run as expected with the connector jar attached either in Flink environment or manually linked in the run command.

@codecov
Copy link

codecov bot commented Dec 14, 2021

Codecov Report

Merging #625 (7c3e8f5) into master (b7ba932) will increase coverage by 0.37%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #625      +/-   ##
============================================
+ Coverage     82.43%   82.80%   +0.37%     
- Complexity      497      531      +34     
============================================
  Files            49       50       +1     
  Lines          2420     2484      +64     
  Branches        210      214       +4     
============================================
+ Hits           1995     2057      +62     
  Misses          262      262              
- Partials        163      165       +2     
Impacted Files Coverage Δ
...vega/connectors/flink/FlinkPravegaInputFormat.java 98.64% <0.00%> (-1.36%) ⬇️
...tors/flink/serialization/CheckpointSerializer.java 77.77% <0.00%> (ø)
...pravega/connectors/flink/ReaderCheckpointHook.java 95.40% <0.00%> (+3.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b7ba932...7c3e8f5. Read the comment docs.

Copy link
Contributor

@crazyzhou crazyzhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except one little word.

documentation/src/docs/python.md Outdated Show resolved Hide resolved
Signed-off-by: thekingofcity <[email protected]>
@crazyzhou
Copy link
Contributor

I would suggest we leave this after we finished our SinkV2 work with Flink 1.15, so Close it for now. Please reopen this PR when that is available.

@crazyzhou crazyzhou closed this Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python API support for the new unified sink
2 participants