Skip to content

Commit

Permalink
[FLINK-33559] Externalize Kafka Python connector code
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Vary committed Nov 30, 2023
1 parent 979791c commit 6bd6942
Show file tree
Hide file tree
Showing 12 changed files with 2,655 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/push_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ jobs:
uses: apache/flink-connector-shared-utils/.github/workflows/ci.yml@ci_utils
with:
flink_version: ${{ matrix.flink }}

python_test:
strategy:
matrix:
flink: [ 1.17.1, 1.18.0 ]
uses: pvary/flink-connector-shared-utils/.github/workflows/python_ci.yml@ci_utils
with:
flink_version: ${{ matrix.flink }}
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,19 @@ out/
tools/flink
tools/flink-*
tools/releasing/release
tools/japicmp-output
tools/japicmp-output

# Generated file, do not store in git
flink-python/pyflink/datastream/connectors/kafka_connector_version.py
flink-python/apache_flink_connectors_kafka.egg-info/
flink-python/.tox/
flink-python/build
flink-python/dist
flink-python/dev/download
flink-python/dev/.conda/
flink-python/dev/log/
flink-python/dev/.stage.txt
flink-python/dev/install_command.sh
flink-python/dev/lint-python.sh
flink-python/dev/build-wheels.sh
flink-python/dev/dev-requirements.txt
21 changes: 21 additions & 0 deletions flink-python/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
################################################################################
# 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.
################################################################################

graft pyflink
global-exclude *.py[cod] __pycache__ .DS_Store

14 changes: 14 additions & 0 deletions flink-python/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This is official Apache Flink Kafka Python connector.

For the latest information about Flink connector, please visit our website at:

https://flink.apache.org

and our GitHub Account for Kafka connector

https://github.com/apache/flink-connector-kafka

If you have any questions, ask on our Mailing lists:

user@flink.apache.org
dev@flink.apache.org
54 changes: 54 additions & 0 deletions flink-python/dev/integration_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
################################################################################
# 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.
################################################################################

function test_module() {
module="$FLINK_PYTHON_DIR/pyflink/$1"
echo "test module $module"
pytest --durations=20 ${module} $2
if [[ $? -ne 0 ]]; then
echo "test module $module failed"
exit 1
fi
}

function test_all_modules() {
# test datastream module
test_module "datastream"
}

# CURRENT_DIR is "flink-connector-kafka/flink-python/dev/"
CURRENT_DIR="$(cd "$( dirname "$0" )" && pwd)"

# FLINK_PYTHON_DIR is "flink-connector-kafka/flink-python"
FLINK_PYTHON_DIR=$(dirname "$CURRENT_DIR")

# FLINK_SOURCE_DIR is "flink-connector-kafka"
FLINK_SOURCE_DIR=$(dirname "$FLINK_PYTHON_DIR")

# set the FLINK_TEST_LIB_DIR to "flink-connector-kafka"
export FLINK_TEST_LIB_DIR="$FLINK_SOURCE_DIR"

# Temporarily update the installed 'pyflink_gateway_server.py' files with the new one
# Needed only until Flink 1.19 release
echo "Checking ${FLINK_TEST_LIB_DIR} for 'pyflink_gateway_server.py'"
find "${FLINK_TEST_LIB_DIR}/flink-python" -name pyflink_gateway_server.py
find "${FLINK_TEST_LIB_DIR}/flink-python/.tox" -name pyflink_gateway_server.py -exec cp "${FLINK_TEST_LIB_DIR}/flink-python/pyflink/pyflink_gateway_server.py" {} \;

# python test
test_all_modules
209 changes: 209 additions & 0 deletions flink-python/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka-parent</artifactId>
<version>3.1-SNAPSHOT</version>
</parent>

<artifactId>flink-connector-kafka-python</artifactId>
<name>Flink : Connectors : SQL : Kafka : Python</name>

<packaging>jar</packaging>

<properties>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-sql-connector-kafka</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-runtime</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-test-utils</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-sql-avro</artifactId>
<version>${flink.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>clean</id>
<phase>clean</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete dir="${project.basedir}/.tox"/>
<delete dir="${project.basedir}/apache_flink_connectors_kafka.egg-info"/>
<delete dir="${project.basedir}/dev/.conda"/>
<delete dir="${project.basedir}/dev/download"/>
<delete dir="${project.basedir}/dev/log"/>
<delete dir="${project.basedir}/build"/>
<delete dir="${project.basedir}/dist"/>
<delete dir="${project.basedir}/pyflink/lib"/>
<delete file="${project.basedir}/dev/.stage.txt"/>
<delete file="${project.basedir}/dev/install_command.sh"/>
<delete file="${project.basedir}/dev/lint-python.sh"/>
<delete file="${project.basedir}/dev/build-wheels.sh"/>
<delete file="${project.basedir}/dev/dev-requirements.txt"/>
<delete file="${project.basedir}/pyflink/datastream/connectors/kafka_connector_version.py"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.apache.flink</groupId>
<artifactId>flink-sql-connector-kafka</artifactId>
</artifactItem>
<artifactItem>
<groupId>org.apache.flink</groupId>
<artifactId>flink-runtime</artifactId>
<!-- Don't use test-jar type because of a bug in the plugin (MDEP-587). -->
<classifier>tests</classifier>
</artifactItem>
<artifactItem>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<!-- Don't use test-jar type because of a bug in the plugin (MDEP-587). -->
<classifier>tests</classifier>
</artifactItem>
<artifactItem>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-test-utils</artifactId>
</artifactItem>
<artifactItem>
<groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils</artifactId>
</artifactItem>
<artifactItem>
<groupId>org.apache.flink</groupId>
<artifactId>flink-sql-avro</artifactId>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/test-dependencies</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>junit</includeGroupIds>
<outputDirectory>${project.build.directory}/test-dependencies</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- Download the testing infra sources from the Flink main repository -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
<id>download-install</id>
<phase>validate</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<url>https://raw.githubusercontent.com/apache/flink/release-${flink.version}/flink-python/dev/install_command.sh</url>
<toDir>${project.basedir}/dev</toDir>
<skip>${python.infra.download.skip}</skip>
</configuration>
</execution>
<execution>
<id>download-lint</id>
<phase>validate</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<url>https://raw.githubusercontent.com/apache/flink/release-${flink.version}/flink-python/dev/lint-python.sh</url>
<toDir>${project.basedir}/dev</toDir>
<skip>${python.infra.download.skip}</skip>
</configuration>
</execution>
<execution>
<id>download-build-wheels</id>
<phase>validate</phase>
<goals>
<goal>download-single</goal>
</goals>
<configuration>
<url>https://raw.githubusercontent.com/apache/flink/release-${flink.version}/flink-python/dev/build-wheels.sh</url>
<toDir>${project.basedir}/dev</toDir>
<skip>${python.infra.download.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 6bd6942

Please sign in to comment.