Skip to content

feat: [KEP-107] Support spark_conf for Spark batch job submission - #697

Open
Goku2099 wants to merge 2 commits into
kubeflow:mainfrom
Goku2099:spark-conf-feature
Open

feat: [KEP-107] Support spark_conf for Spark batch job submission#697
Goku2099 wants to merge 2 commits into
kubeflow:mainfrom
Goku2099:spark-conf-feature

Conversation

@Goku2099

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for spark_conf when submitting Spark batch jobs with SparkClient.

Previously, passing spark_conf to SparkClient.submit_job() resulted in a NotImplementedError. With this change, user-provided Spark configuration is propagated to the generated SparkApplication resource.

Changes

  • Remove NotImplementedError for spark_conf in SparkClient.submit_job().
  • Forward spark_conf through the Kubernetes backend.
  • Populate SparkApplication.spec.sparkConf with the provided Spark configuration.
  • Update public API docstrings.
  • Add unit tests covering spark_conf propagation to the generated SparkApplication.

Example

client.submit_job(
    job=FileJob(
        file_source="s3://bucket/job.py",
    ),
    spark_conf={
        "spark.sql.shuffle.partitions": "8",
        "spark.sql.adaptive.enabled": "true",
    },
)

closes: #646
ref: #520

Signed-off-by: Sameer_yadav <159073326+Goku2099@users.noreply.github.com>
@google-oss-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign electronic-waste for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Goku2099

Copy link
Copy Markdown
Contributor Author

Signed-off-by: Sameer_yadav <159073326+Goku2099@users.noreply.github.com>

@tariq-hasan tariq-hasan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @Goku2099! I have added a few comments.


print("test execution complete")


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the cases of test_get_spark_application_cr_from_file_job and test_get_spark_application_cr_from_func_job I think probably a good idea to have dedicated test cases per behavior (spark_conf included) similar to what we have for test_build_spark_connect_cr.

num_executors=None,
resources_per_executor=None,
spark_conf=None,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think better to combine test_submit_job_validation and test_submit_job_success and have all test cases grouped under test_submit_job for consistency with how unit tests in the packages are structured in general - using the TestCase pattern.

Comment on lines 741 to +747
arguments=arguments or None,
driver=get_spark_job_driver_spec(),
executor=get_spark_job_executor_spec(
num_executors=num_executors,
resources_per_executor=resources_per_executor,
),
spark_conf=spark_conf,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can do spark_conf=spark_conf or None, to match arguments=arguments or None,.

Same in get_spark_application_cr_from_func_job

)

return instances, cores, memory

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to have a precedence rule here for the case when executor resources are passed in via spark_conf.

In the case when executor resources are passed in via spark_conf they should have precedence over any other resource specification.

Granted - a user would not necessarily want to use spark_conf to pass in executor resources. They'd want to use spark_conf for advanced settings. But either way this is a correctness issue so it would need to be addressed.

Comment on lines -100 to -106
(
FileJob(file_source="s3://bucket/job.py"),
{"spark.executor.memory": "4g"},
None,
None,
NotImplementedError,
),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add a test case to have coverage for spark_conf?

Comment on lines 281 to 282
else:
raise ValueError(f"Invalid CPU type '{type(cpu)}'. Expected str or int.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar to how we validate cpu do we also want to validate the type for spark_conf key and value?

spark_conf=spark_conf,
)

try:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Having spark_conf test cases for the backend would be nice as well.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KEP-107: Wire spark_conf through submit_job() for batch SparkApplication jobs

2 participants