Skip to content

Commit 4a4ec4e

Browse files
author
yuzelin
committed
T
1 parent a3f787a commit 4a4ec4e

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

pypaimon/py4j/gateway_server.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,15 @@ def preexec_func():
8080
def _get_classpath(env):
8181
classpath = []
8282

83-
jars = importlib.resources.files(_JAVA_DEPS_PACKAGE)
84-
one_jar = next(iter(jars.iterdir()), None)
85-
if not one_jar:
86-
raise ValueError("Haven't found necessary python-java-bridge jar, this is unexpected.")
87-
builtin_java_classpath = os.path.join(os.path.dirname(str(one_jar)), '*')
88-
classpath.append(builtin_java_classpath)
83+
# note that jars are not packaged in test
84+
test_mode = os.environ.get(constants.PYPAIMON4J_TEST_MODE)
85+
if not test_mode or test_mode.lower() != "true":
86+
jars = importlib.resources.files(_JAVA_DEPS_PACKAGE)
87+
one_jar = next(iter(jars.iterdir()), None)
88+
if not one_jar:
89+
raise ValueError("Haven't found necessary python-java-bridge jar, this is unexpected.")
90+
builtin_java_classpath = os.path.join(os.path.dirname(str(one_jar)), '*')
91+
classpath.append(builtin_java_classpath)
8992

9093
# user defined
9194
if constants.PYPAIMON_JAVA_CLASSPATH in env:

pypaimon/py4j/tests/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,18 @@ def _setup_bridge_jar(bridge_dir):
5454
if not os.path.exists(bridge_dir):
5555
os.mkdir(bridge_dir)
5656

57+
jar_path = os.path.join(bridge_dir, "paimon-python-java-bridge.jar")
5758
shutil.copy(
5859
os.path.join(java_bridge_module, 'target/{}-{}.jar'
5960
.format('paimon-python-java-bridge', _extract_bridge_version())),
60-
bridge_dir
61+
jar_path
6162
)
6263

64+
os.environ[constants.PYPAIMON_JAVA_CLASSPATH] = jar_path
65+
6366

6467
def _extract_bridge_version():
65-
pom_path = os.path.join(_find_java_bridge_module(), 'paimon-python-java-bridge', 'pom.xml')
68+
pom_path = os.path.join(_find_java_bridge_module(), 'pom.xml')
6669
return ElementTree.parse(pom_path).getroot().find(
6770
'POM:version',
6871
namespaces={
@@ -89,7 +92,8 @@ def setUpClass(cls):
8992
_setup_hadoop_bundle_jar(cls.tempdir)
9093
_setup_bridge_jar(cls.tempdir)
9194

92-
cls.catalog = Catalog.create({'warehouse': os.path.join(cls.tempdir, 'warehouse')})
95+
cls.warehouse = os.path.join(cls.tempdir, 'warehouse')
96+
cls.catalog = Catalog.create({'warehouse': cls.warehouse})
9397
cls.catalog.create_database('default', False)
9498

9599
@classmethod

pypaimon/py4j/tests/test_data_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class DataTypesTest(PypaimonTestBase):
2929

3030
@classmethod
3131
def setUpClass(cls):
32+
super().setUpClass()
3233
cls.simple_pa_schema = pa.schema([
3334
('f0', pa.int32()),
3435
('f1', pa.string())

pypaimon/py4j/tests/test_preicates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class PredicateTest(PypaimonTestBase):
4141

4242
@classmethod
4343
def setUpClass(cls):
44+
super().setUpClass()
4445
pa_schema = pa.schema([
4546
('f0', pa.int64()),
4647
('f1', pa.string()),

pypaimon/py4j/tests/test_write_and_read.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
# limitations under the License.
1717
################################################################################
1818

19-
import os
20-
import shutil
21-
import tempfile
22-
import unittest
2319
import pandas as pd
2420
import pyarrow as pa
2521
from py4j.protocol import Py4JJavaError
@@ -35,6 +31,7 @@ class TableWriteReadTest(PypaimonTestBase):
3531

3632
@classmethod
3733
def setUpClass(cls):
34+
super().setUpClass()
3835
cls.simple_pa_schema = pa.schema([
3936
('f0', pa.int32()),
4037
('f1', pa.string())

0 commit comments

Comments
 (0)