This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch try_fix_python
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/try_fix_python by this push:
new f7c9d1a1 Try
f7c9d1a1 is described below
commit f7c9d1a107a9fb93fe4257d526d043cb4e0e0897
Author: HTHou <[email protected]>
AuthorDate: Sun Aug 11 22:40:03 2024 +0800
Try
---
.gitignore | 1 +
python/pom.xml | 2 +-
python/setup.py | 28 ++++++++++++----------------
python/tsfile/tsfile.pxd | 2 +-
python/tsfile/tsfile_pywrapper.pyx | 9 +++++++++
5 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/.gitignore b/.gitignore
index 00adb1bf..4e0d2dc2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@ docs/src/.vuepress/dist/
# python files
python/build
+python/dist
python/tsfile/__pycache__
python/tsfile/*so*
python/tsfile/*dll*
diff --git a/python/pom.xml b/python/pom.xml
index 1a0180d8..277a0b32 100644
--- a/python/pom.xml
+++ b/python/pom.xml
@@ -130,7 +130,7 @@
<goal>exec</goal>
</goals>
<configuration>
- <executable>${python.venv.bin}pytest</executable>
+
<executable>${python.venv.bin}${python.exe.bin}</executable>
<arguments>
<argument>${project.basedir}/test.py</argument>
</arguments>
diff --git a/python/setup.py b/python/setup.py
index bdffcb3d..8d049674 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -25,23 +25,25 @@ import shutil
import os
-def copy_lib_files(system, source_dir, target_dir, suffix):
-
- lib_file_name = f"libtsfile.{suffix}"
- source = os.path.join(source_dir, lib_file_name)
- target = os.path.join(target_dir, lib_file_name)
- shutil.copyfile(source, target)
-
- if system == "Linux":
+def copy_lib_files(source_dir, target_dir):
+ if platform.system() == "Linux":
+ lib_file_name = f"libtsfile.so.1.0"
link_name = os.path.join(target_dir, f"libtsfile.so")
if os.path.exists(link_name):
os.remove(link_name)
os.symlink(lib_file_name, link_name)
- if system == "Darwin":
+ elif platform.system() == "Darwin":
+ lib_file_name = f"libtsfile.1.0.dylib"
link_name = os.path.join(target_dir, f"libtsfile.dylib")
if os.path.exists(link_name):
os.remove(link_name)
os.symlink(lib_file_name, link_name)
+ else:
+ lib_file_name = f"libtsfile.dll"
+
+ source = os.path.join(source_dir, lib_file_name)
+ target = os.path.join(target_dir, lib_file_name)
+ shutil.copyfile(source, target)
def copy_header(source, target):
@@ -62,13 +64,7 @@ libtsfile_dir = os.path.join(project_dir, "tsfile")
include_dir = os.path.join(project_dir, "tsfile")
source_file = os.path.join(project_dir, "tsfile", "tsfile_pywrapper.pyx")
-if platform.system() == "Darwin":
- copy_lib_files("Darwin", libtsfile_shard_dir, libtsfile_dir, "1.0.dylib")
-elif platform.system() == "Linux":
- copy_lib_files("Linux", libtsfile_shard_dir, libtsfile_dir, "so.1.0")
-else:
- copy_lib_files("Windows", libtsfile_shard_dir, libtsfile_dir, "dll")
-
+copy_lib_files(libtsfile_shard_dir, libtsfile_dir)
source_include_dir = os.path.join(
project_dir, "..", "cpp", "src", "cwrapper", "TsFile-cwrapper.h"
diff --git a/python/tsfile/tsfile.pxd b/python/tsfile/tsfile.pxd
index a41794e2..1480371f 100644
--- a/python/tsfile/tsfile.pxd
+++ b/python/tsfile/tsfile.pxd
@@ -89,7 +89,7 @@ cdef extern from "./TsFile-cwrapper.h":
# writer tsfile data
ErrorCode tsfile_register_table(CTsFileWriter writer, TableSchema* schema)
ErrorCode tsfile_register_table_column(CTsFileWriter writer, const char*
table_name, ColumnSchema* schema)
- TsFileRowData create_tsfile_row(const char* table_name, timestamp
timestamp, int column_length)
+ TsFileRowData create_tsfile_row(const char* table_name, timestamp time,
int column_length)
ErrorCode insert_data_into_tsfile_row_int32(TsFileRowData row_data, char*
column_name, int value)
ErrorCode insert_data_into_tsfile_row_int64(TsFileRowData row_data, char*
column_name, long long value)
ErrorCode insert_data_into_tsfile_row_float(TsFileRowData row_data, char*
column_name, float value)
diff --git a/python/tsfile/tsfile_pywrapper.pyx
b/python/tsfile/tsfile_pywrapper.pyx
index 5f1f505f..0fb605a1 100644
--- a/python/tsfile/tsfile_pywrapper.pyx
+++ b/python/tsfile/tsfile_pywrapper.pyx
@@ -112,21 +112,30 @@ cdef class tsfile_reader:
# open tsfile to read
res = pd.DataFrame()
not_null_maps = []
+ print(1)
if self.read_all_at_once:
while True:
+ print(2)
chunk, not_null_map = self.get_next_dataframe()
+ print(3)
if chunk is not None:
+ print(4)
res = pd.concat([res, chunk])
+ print(5)
not_null_maps.append(not_null_map)
+ print(6)
else:
break
else:
res, not_null_map = self.get_next_dataframe()
not_null_maps.append(not_null_map)
+ print(6)
self.free_resources()
+ print(7)
not_null_map_all = None
if not_null_maps:
+ print(8)
not_null_map_all = np.vstack(not_null_maps)
return res, not_null_map_all