Skip to content
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

[pyspark] Add type hint to basic utilities. #8375

Merged
merged 4 commits into from
Oct 25, 2022

Conversation

trivialfis
Copy link
Member

No description provided.

"""Whether it is Spark local mode"""
# pylint: disable=protected-access
return spark_context._jsc.sc().isLocal()


def _get_gpu_id(task_context) -> int:
def _get_gpu_id(task_context: BarrierTaskContext) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change it to TaskContext instead of BarrierTaskContext?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

Copy link
Member Author

@trivialfis trivialfis Oct 21, 2022

Choose a reason for hiding this comment

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

Reverted, getTaskInfos is exclusive to the barrier task context.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, only _get_host_ip needs BarrerTaskContext. for others, TaskContext is ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since get host ip is called by others, unless we want to perform a down cast we need to pass the type down.

@trivialfis trivialfis merged commit d0b99bd into dmlc:master Oct 25, 2022
@trivialfis trivialfis deleted the spark-type branch October 25, 2022 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants