-
Notifications
You must be signed in to change notification settings - Fork 333
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
feat: add PyO3(Hence CPython as a Optional Backend #976
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license-eye has totally checked 752 files.
Valid | Invalid | Ignored | Fixed |
---|---|---|---|
583 | 5 | 164 | 0 |
Click to see the invalid file list
- src/script/src/ffi_types.rs
- src/script/src/pyo3.rs
- src/script/src/pyo3/vector_impl.rs
- src/script/src/rspython.rs
- src/script/src/rspython/tests.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license-eye has totally checked 758 files.
Valid | Invalid | Ignored | Fixed |
---|---|---|---|
587 | 7 | 164 | 0 |
Click to see the invalid file list
- src/script/src/ffi_types.rs
- src/script/src/ffi_types/vector/tests.rs
- src/script/src/pyo3.rs
- src/script/src/pyo3/corp_impl.rs
- src/script/src/pyo3/vector_impl.rs
- src/script/src/rspython.rs
- src/script/src/rspython/tests.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license-eye has totally checked 773 files.
Valid | Invalid | Ignored | Fixed |
---|---|---|---|
593 | 8 | 172 | 0 |
Click to see the invalid file list
- src/script/src/ffi_types.rs
- src/script/src/ffi_types/vector/tests.rs
- src/script/src/pyo3.rs
- src/script/src/pyo3/copr_impl.rs
- src/script/src/pyo3/vector_impl.rs
- src/script/src/rspython.rs
- src/script/src/rspython/copr_impl.rs
- src/script/src/rspython/tests.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license-eye has totally checked 792 files.
Valid | Invalid | Ignored | Fixed |
---|---|---|---|
606 | 8 | 178 | 0 |
Click to see the invalid file list
- src/script/src/python/ffi_types/testcases_builtins.rs
- src/script/src/python/ffi_types/utils.rs
- src/script/src/python/pyo3/builtins.rs
- src/script/src/python/pyo3/copr_impl.rs
- src/script/src/python/pyo3/utils.rs
- src/script/src/python/pyo3/vector_impl.rs
- src/script/src/python/rspython.rs
- src/script/src/python/rspython/tests.rs
As we have two backends, I suggest to add feature gate for the optional one and ci to check correctness for both. |
@discord9 A lot of conflicts, please fix them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license-eye has totally checked 795 files.
Valid | Invalid | Ignored | Fixed |
---|---|---|---|
615 | 2 | 178 | 0 |
Click to see the invalid file list
- src/script/src/python/ffi_types/pair_tests/sample_testcases.rs
- src/script/src/python/pyo3/dataframe_impl.rs
Codecov Report
@@ Coverage Diff @@
## develop #976 +/- ##
===========================================
- Coverage 85.33% 84.95% -0.39%
===========================================
Files 459 471 +12
Lines 66885 68513 +1628
===========================================
+ Hits 57078 58202 +1124
- Misses 9807 10311 +504 |
Test failure on mac:
Reply: fixed, used epsilon for float array comparsion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is huge. Plesase let me take a break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we gain the ability to interact with cpython via pyo3, I'm wondering if it's possible to directly forward array compute functions to Arrow's python (which is from C or CPP) native implementation? This may reduce lots of FFI calls and make our code slimmer.
Wouldn't that complex our dependecy management? Like have to maintance both cargo and python pip or conda to get python arrow? |
@discord9 There is a conflict file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM. But we stil have to refactor this crate, make it more clear and clean.
One thing I'm thinking of while reviewing is, the |
Some types&function are way too similar to put in same file(i.e. dataframe&builtins functions), which are basically the same expect error handling and some impl details, so at least them should be put into different folder I guess? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give my thumb up to this brilliant work 👍
* refactor: ffi_types * style: fmt * refactor: use `String` for return when possible * todo: vector_impl * feat: pyobj_try_typed_val * refactor: more backend indep function * feat: +-*/ magic methods * refactor: copr * style: fmt * feat: add paired tests * refactor: more * refactor: move inside `python` folder * refactor: all but test code * feat: builtins for PyO3 * chore: add licenses * chore: remove unused&add todos * refactor: remove old files * chore: mark unused * chore: fmt * chore: license * feat: query in PyO3 * test: paired testcases for rspy&pyo3 * feat: PyDataFrame(Untested) * feat: some allow_threads * style: fmt * style: add license * feat: rebase manually of GreptimeTeam#962 * feat: more `allow_threads` * chore: typo * chore: remove some `TODO` * test: allow margin of epsilon * chore: code review advices * chore: more CR adjust * chore: more adjust * feat: kwargs&its test * chore: remove some `dbg!` * chore: allow params * fix: put `dataframe` into scope * chore: newline * fix: adjust after rebase * fix: test serde skip attr * style: taplo * feat: add `pyo3_backend` feature * doc: update CI&readme
I hereby agree to the terms of the GreptimeDB CLA
What's changed and what's your intention?
Add PyO3 as a Optional Backend
Pros: C API(numpy etc.), faster python execute speed
Cons: GIL might have concurrent problem, i.e. too many parallel python thread may slow script execution down
Please explain IN DETAIL what the changes are in this PR and why they are needed:
Refactor scripts into three folder:
ffi_types
,rspython
andpyo3
, whereffi_types
store common type defination(Yes those types can be used both in RustPython and PyO3) and other two store respective impl detailsMajor Changes:
Added cpython PyVector impls & cpython coprocessor impls
Added cpython
greptime
python modules i.e.import greptime as gt
Paired tests for both RustPython and CPython
Refactor of old RustPython codes, now backend-independ code is in
ffi_types
folder with RustPython detailed impls inrspython
folder and cpython relevant methods incpython
folderSummarize your change (mandatory)
How does this PR work? Need a brief introduction for the changed logic (optional)
Describe clearly one logical change and avoid lazy messages (optional)
Describe any limitations of the current code (optional)
TODO: Refactor(move into greptime module)&Unit tests in PyO3 for PyDataFrame&SQL query in python&More
allow_thread
so that it release GIL as much as possible for maximizing parallelismChecklist
Refer to a related PR or issue link (optional)