Skip to content

[SPARK-37014][PYTHON] Inline type hints for python/pyspark/streaming/context.py#34293

Closed
dchvn wants to merge 7 commits intoapache:masterfrom
dchvn:SPARK-37014
Closed

[SPARK-37014][PYTHON] Inline type hints for python/pyspark/streaming/context.py#34293
dchvn wants to merge 7 commits intoapache:masterfrom
dchvn:SPARK-37014

Conversation

@dchvn
Copy link
Contributor

@dchvn dchvn commented Oct 15, 2021

What changes were proposed in this pull request?

Inline type hints for python/pyspark/streaming/context.py from Inline type hints for python/pyspark/streaming/context.pyi.

Why are the changes needed?

Currently, there is type hint stub files python/pyspark/streaming/context.pyi to show the expected types for functions, but we can also take advantage of static type checking within the functions by inlining the type hints.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existing test.

@SparkQA
Copy link

SparkQA commented Oct 15, 2021

Test build #144297 has finished for PR 34293 at commit e4f0c74.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 15, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48776/

@SparkQA
Copy link

SparkQA commented Oct 15, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48776/

@dchvn
Copy link
Contributor Author

dchvn commented Oct 21, 2021

CC @HyukjinKwon @ueshin @zero323 FYI. Thanks!

@SparkQA
Copy link

SparkQA commented Oct 26, 2021

Test build #144608 has finished for PR 34293 at commit 2e2283d.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dchvn
Copy link
Contributor Author

dchvn commented Oct 26, 2021

CC @HyukjinKwon @ueshin @zero323 FYI. Thanks! Seem jenkins fail because jenkins server is down.

@SparkQA
Copy link

SparkQA commented Oct 26, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49079/

@SparkQA
Copy link

SparkQA commented Oct 26, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49079/

@HyukjinKwon
Copy link
Member

retest this please

@SparkQA
Copy link

SparkQA commented Oct 28, 2021

Test build #144696 has finished for PR 34293 at commit 2e2283d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 28, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49165/

@SparkQA
Copy link

SparkQA commented Oct 28, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49165/

@SparkQA
Copy link

SparkQA commented Nov 11, 2021

Test build #145101 has finished for PR 34293 at commit 7a70727.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Nov 11, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49570/

@SparkQA
Copy link

SparkQA commented Nov 11, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49570/

@HyukjinKwon
Copy link
Member

cc @itholic mind reviewing this please?

Copy link
Contributor

@itholic itholic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, looks fine to me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can directly use DStream[str] here.

"DStream[str]" -> DStream[str] should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you reviewing!
We need to wait to inline type hints python/pyspark/streaming/dstream.py and have DStream(Generic[T_co]) before use DStream[str] directly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be precise, for DStream[T] you need DStream to be runtime generic. To avoid further rewrites, we can mark them as generics within this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@zero323
Copy link
Member

zero323 commented Mar 6, 2022

This should be resynced with master.

@dchvn dchvn requested a review from zero323 March 8, 2022 08:27
@itholic
Copy link
Contributor

itholic commented Apr 4, 2022

Seems fine to me.

Would you mind taking a last look for this, @zero323 ??

@zero323
Copy link
Member

zero323 commented Apr 11, 2022

Seems fine to me.

Would you mind taking a last look for this, @zero323 ??

It requires re-syncing with master and removal of obsolete ignores, but looks OK otherwise.

@itholic
Copy link
Contributor

itholic commented Apr 12, 2022

@dchvn Would you mind rebasing to the master?

@dchvn
Copy link
Contributor Author

dchvn commented Apr 12, 2022

I don't know why my GA has failed, I will update my other PRs once I know how to fix it. Thanks, @itholic @zero323 for your reviews.

@zero323
Copy link
Member

zero323 commented Apr 13, 2022

I don't know why my GA has failed, I will update my other PRs once I know how to fix it. Thanks, @itholic @zero323 for your reviews.

@dchvn This error is thrown by explicit checks in our wokflow, see this and this.

@HyukjinKwon
Copy link
Member

(BTW, there's a bug in GitHub Actions' RESTful API so the check fails. I sent an email to dev mailing list "PR builder not working now")

Copy link
Contributor

@itholic itholic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Btw, test is passed in @dchvn 's forked repository: https://github.com/dchvn/spark/actions/runs/2152211443

@zero323 zero323 closed this in c0c1f35 Apr 14, 2022
zero323 pushed a commit that referenced this pull request Apr 14, 2022
…context.py

### What changes were proposed in this pull request?
Inline type hints for python/pyspark/streaming/context.py from Inline type hints for python/pyspark/streaming/context.pyi.

### Why are the changes needed?
Currently, there is type hint stub files python/pyspark/streaming/context.pyi to show the expected types for functions, but we can also take advantage of static type checking within the functions by inlining the type hints.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Existing test.

Closes #34293 from dchvn/SPARK-37014.

Authored-by: dch nguyen <dchvn.dgd@gmail.com>
Signed-off-by: zero323 <mszymkiewicz@gmail.com>
(cherry picked from commit c0c1f35)
Signed-off-by: zero323 <mszymkiewicz@gmail.com>
@zero323
Copy link
Member

zero323 commented Apr 14, 2022

Thanks for looking into the this @HyukjinKwon and @itholic. LGTM (all tests passed locally).

@zero323
Copy link
Member

zero323 commented Apr 14, 2022

Merged into master and branch-3.3.

@dchvn
Copy link
Contributor Author

dchvn commented Apr 14, 2022

Thank all ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments