Skip to content

Commit a7b752a

Browse files
authored
Refactoring module structure and building (#15)
1 parent 5f18615 commit a7b752a

39 files changed

Lines changed: 203 additions & 101 deletions

.github/workflows/paimon-python-checks.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ on:
2222
push:
2323
pull_request:
2424
paths-ignore:
25-
- 'dev/**'
26-
- 'java_based_implementation/paimon-python-java-bridge/**'
2725
- '**/*.md'
2826

27+
env:
28+
JDK_VERSION: 8
29+
2930
concurrency:
3031
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
3132
cancel-in-progress: true
@@ -37,6 +38,11 @@ jobs:
3738
steps:
3839
- name: Checkout code
3940
uses: actions/checkout@v2
41+
- name: Set up JDK ${{ env.JDK_VERSION }}
42+
uses: actions/setup-java@v2
43+
with:
44+
java-version: ${{ env.JDK_VERSION }}
45+
distribution: 'adopt'
4046
- name: Run lint-python.sh
4147
run: |
4248
chmod +x dev/lint-python.sh

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ dev/.stage.txt
1515
dev/download
1616
dev/log
1717
dist/
18-
paimon_python.egg-info/
18+
*.egg-info/

README.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,28 @@ This repo is for Apache Paimon Python SDK.
2222
You can verify the setup by right-clicking on any file or folder in the flink-python project
2323
and running "External Tools" → "flake8".
2424

25-
# Usage
26-
27-
## Java-Based Implementation
25+
## Check
2826

29-
We can use `py4j` to leverage Java code to read Paimon data. This section describes how to use this implementation.
27+
We provide script to check codes.
3028

31-
### Set Environment Variables
29+
```shell
30+
./dev/lint-python.sh # execute all checks
31+
./dev/lint-python.sh -h # run this to see more usages
32+
```
3233

33-
`py4j` need to access a JVM, so we should set JVM arguments (optional) and Java classpath. A convenient way is using
34-
`os` packages to set environment variables which only affect current process.
34+
## Build
3535

36-
```python
37-
import os
36+
We provide script to build wheel.
3837

39-
os.environ['PYPAIMON_JAVA_CLASSPATH'] = '/path/to/dependent_jars/*'
40-
os.environ['_PYPAIMON_JVM_ARGS'] = 'jvm_arg1 jvm_arg2 ...'
38+
```shell
39+
./dev/build-wheels.sh
4140
```
4241

43-
NOTE: the package has set paimon core and hadoop dependencies. If you just test in local or run code in hadoop, you doesn't
44-
need to set classpath. If you need other dependencies such as OSS/S3 filesystem jars, or special catalog which isn't implemented
45-
in paimon core, please download jars and set classpath.
42+
The target wheel is under `dist/`
43+
44+
# Usage
4645

47-
# API Reference
48-
TODO
46+
See Apache Paimon Python API [Doc](https://paimon.apache.org/docs/master/program-api/python-api/).
4947

5048

5149

paimon_python_api/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,28 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#################################################################################
18+
19+
from .split import Split
20+
from .table_read import TableRead
21+
from .table_scan import TableScan, Plan
22+
from .read_builder import ReadBuilder
23+
from .commit_message import CommitMessage
24+
from .table_commit import BatchTableCommit
25+
from .table_write import BatchTableWrite
26+
from .write_builder import BatchWriteBuilder
27+
from .table import Table
28+
from .catalog import Catalog
29+
30+
__all__ = [
31+
'Split',
32+
'TableRead',
33+
'TableScan',
34+
'Plan',
35+
'ReadBuilder',
36+
'CommitMessage',
37+
'BatchTableCommit',
38+
'BatchTableWrite',
39+
'BatchWriteBuilder',
40+
'Table',
41+
'Catalog'
42+
]

paimon_python_api/catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#################################################################################
1818

1919
from abc import ABC, abstractmethod
20-
from paimon_python_api.table import Table
20+
from paimon_python_api import Table
2121

2222

2323
class Catalog(ABC):

paimon_python_api/read_builder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#################################################################################
1818

1919
from abc import ABC, abstractmethod
20-
from paimon_python_api.table_read import TableRead
21-
from paimon_python_api.table_scan import TableScan
20+
from paimon_python_api import TableRead, TableScan
2221
from typing import List
2322

2423

paimon_python_api/table.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#################################################################################
1818

1919
from abc import ABC, abstractmethod
20-
from paimon_python_api.read_builder import ReadBuilder
21-
from paimon_python_api.write_builder import BatchWriteBuilder
20+
from paimon_python_api import ReadBuilder, BatchWriteBuilder
2221

2322

2423
class Table(ABC):

paimon_python_api/table_commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#################################################################################
1818

1919
from abc import ABC, abstractmethod
20-
from paimon_python_api.commit_message import CommitMessage
20+
from paimon_python_api import CommitMessage
2121
from typing import List
2222

2323

paimon_python_api/table_read.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
# limitations under the License.
1717
#################################################################################
1818

19+
import pyarrow as pa
20+
1921
from abc import ABC, abstractmethod
20-
from pyarrow import RecordBatchReader
21-
from paimon_python_api.split import Split
22+
from paimon_python_api import Split
2223
from typing import List
2324

2425

2526
class TableRead(ABC):
2627
"""To read data from data splits."""
2728

2829
@abstractmethod
29-
def create_reader(self, splits: List[Split]) -> RecordBatchReader:
30+
def create_reader(self, splits: List[Split]) -> pa.RecordBatchReader:
3031
"""Return a reader containing batches of pyarrow format."""

paimon_python_api/table_scan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from abc import ABC, abstractmethod
2020
from typing import List
21-
from paimon_python_api.split import Split
21+
from paimon_python_api import Split
2222

2323

2424
class TableScan(ABC):

0 commit comments

Comments
 (0)