-
Notifications
You must be signed in to change notification settings - Fork 655
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-#4245: Define base interface for dataframe exchange protocol #4246
FEAT-#4245: Define base interface for dataframe exchange protocol #4246
Conversation
… protocol Signed-off-by: Igoshev, Yaroslav <yaroslav.igoshev@intel.com>
Codecov Report
@@ Coverage Diff @@
## master #4246 +/- ##
==========================================
+ Coverage 86.80% 89.82% +3.02%
==========================================
Files 201 205 +4
Lines 16795 16977 +182
==========================================
+ Hits 14579 15250 +671
+ Misses 2216 1727 -489
Continue to review full report at Codecov.
|
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
b95a8c6
to
2296535
Compare
Signed-off-by: Igoshev, Yaroslav <yaroslav.igoshev@intel.com>
65d9dad
to
c83c529
Compare
modin/pandas/base.py
Outdated
@@ -556,35 +556,6 @@ def __constructor__(self, *args, **kwargs): | |||
""" | |||
return type(self)(*args, **kwargs) | |||
|
|||
def __dataframe__(self, nan_as_null: bool = False, allow_copy: bool = True) -> dict: |
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.
Why moved? We should be able to export both kinds of objects (Series and DataFrame), so the __dataframe__
method has to be located in the base class.
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.
The spec is only about a DataFrame object, but not a Series.
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
.github/workflows/ci.yml
Outdated
@@ -256,6 +256,7 @@ jobs: | |||
- run: python -m pytest -n 2 modin/test/test_partition_api.py | |||
- run: python -m pytest modin/test/test_utils.py | |||
- run: python -m pytest asv_bench/test/test_utils.py | |||
- run: python -m pytest modin/test/exchange_protocol/base |
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.
The most convenient location for the tests to be placed would be near the protocol's code (modin/core/dataframe/base/dataframe/protocol/tests
). However, this location creates import conflicts between conftest.py
and modin.utils
, in particular, this assertion is failing:
Lines 24 to 26 in dae9891
assert ( | |
"modin.utils" not in sys.modules | |
), "Do not import modin.utils before patching, or tests could fail" |
So it was decided to move the tests to a higher level.
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.
That is okay. We actually want to move all tests in one place as part of #3645. However, I would like to generalize the structure a bit. See latest commit.
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.
In order to be ready for adding other exchange protocols.
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.
Agree with @YarShev.
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.
Overall structure LGTM!
Signed-off-by: Igoshev, Yaroslav <yaroslav.igoshev@intel.com>
@YarShev this looks much improved. Is it ready to merge? |
@devin-petersohn, yes, the structure looks good to me too. I think we can merge this. |
@@ -363,6 +363,61 @@ def to_numpy(self, **kwargs): # noqa: PR02 | |||
|
|||
# END To NumPy | |||
|
|||
# Dataframe exchange protocol | |||
|
|||
def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True) -> dict: |
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.
Why not use @abc.abstractmethod
decorator? How it's done for to_pandas
method. Same for from_dataframe
.
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.
In order to be able to instantiate a DataFrame with the underlying QC at this line - https://github.com/modin-project/modin/pull/4246/files#diff-028a94e3db5c73c7ddedc6f7b6efb79e07e1360bb1401531b0a9f5d0ca1f1928R55. Otherwise, you will get the error: Can't instantiate abstract class ... with abstract methods from_dataframe, to_dataframe.
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.
I see, but isn't that the main way Modin defines an interface?
I propose to define the method as abstract in BaseQueryCompiler
class, and let the child classes: PandasQueryCompiler
and DFAlgQueryCompiler
throw NotImplementedError
exception.
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.
Yes, BaseQueryCompiler should define the interface to be overridden by child classes. We could either make the methods abstract now or as part of efforts discussed here. I don't have strong preferences on this. However, doing that what you proposed
I propose to define the method as abstract in BaseQueryCompiler class, and let the child classes: PandasQueryCompiler and DFAlgQueryCompiler throw NotImplementedError exception.
You will still be getting the error mentioned above. We should override the methods in TestQC.
Do you think we should make the methods abstract in the Base QC as part of this PR?
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.
If there is no hurry, we can do it here. Otherwise, we need to flag this question and implement it elsewhere. (Yes, it also need to de done in TestQC
)
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.
There shouldn't be strong efforts to do that so let's put it here. However, this PR should be merged by end of today.
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.
Yes, it also need to de done in TestQC
That is not quite correct. We should override the methods in TestQC only, PandasQC and OmnisciQC will override the methods as part of new issues.
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.
fixed
I would rather we first get data-apis/dataframe-api#74 merged, then vendor that. |
To not block development of the implementations for pandas and omnisci storage formats, we can merge this PR after @anmyachev's comment is resolved. Once the API is stabilized in the data-apis repo, we'll just copy it from there and paste it here. |
6e6a1e8
to
743ecaf
Compare
743ecaf
to
b6db18e
Compare
Signed-off-by: Igoshev, Yaroslav <yaroslav.igoshev@intel.com>
b6db18e
to
4fc997b
Compare
TeamCity jobs failed because of our internal fault. TeamCity agents should be added/registered newly. We are working on that. Meanwhile, I think we can omit these jobs and the changes are ready to be merged |
if is_datetime64_dtype(dtype): | ||
# Selecting the first char of resolution string: | ||
# dtype.str -> '<M8[ns]' | ||
resolution = re.findall(r"\[(.*)\]", dtype.str)[0][:1] |
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.
isn't there a better way?.. looks weird
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.
cc @dchigarev
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.
We can fix that as part of a separate PR too.
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.
Let's Get This Moving!
Signed-off-by: Igoshev, Yaroslav yaroslav.igoshev@intel.com
What do these changes do?
flake8 modin/ asv_bench/benchmarks scripts/doc_checker.py
black --check modin/ asv_bench/benchmarks scripts/doc_checker.py
git commit -s
docs/development/architecture.rst
is up-to-date