Skip to content

fix(core): let remote Spark jobs use pre_execution_script - #6448

Open
AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/remote-spark-pre-execution-script
Open

AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/remote-spark-pre-execution-script

Conversation

@AkshayShah03

Copy link
Copy Markdown

Issue #, if available: N/A

Description of changes:

#5816 made _JobSettings add the sagemaker-feature-store-pyspark install and JAR-copy commands to pre_execution_commands for Spark jobs. They are added before the check that only one of pre_execution_commands and pre_execution_script is set. So

@remote(spark_config=SparkConfig(), pre_execution_script="setup.sh", ...)

always fails with ValueError: Only one of pre_execution_commands or pre_execution_script can be specified!, even though the user only set the script. This worked in v2. The commands were also appended to the caller's own pre_execution_commands list in place.

This change:

  • runs the mutual-exclusion check on the user's configuration, before the Spark commands are added;
  • leaves the setup to the user's script when one is set, since only one of the two can run, and logs a warning that sagemaker-feature-store-pyspark isn't installed automatically;
  • appends the Spark commands to a copy of the user's list.

Testing:

  • New _JobSettings tests:
    • Spark plus a script doesn't raise;
    • the user's command list isn't modified;
    • the user supplying both commands and a script still raises.
  • The first two fail before this change.
  • tests/unit/remote_function: 233 passed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

aws#5816 made _JobSettings add the sagemaker-feature-store-pyspark install and
JAR-copy commands to pre_execution_commands for Spark jobs, before the
check that only one of pre_execution_commands and pre_execution_script is
set. So @Remote(spark_config=SparkConfig(), pre_execution_script=...) always
failed with 'Only one of pre_execution_commands or pre_execution_script can
be specified!' although the user set only the script (this worked in v2).
The commands were also appended to the caller's own list in place.

Check the user's configuration before adding the Spark commands; when a
script is set, leave the setup to it (with a warning), and append the
commands to a copy of the user's list.

This branch is waiting to be deployed

1 waiting deployment
manual-approval — 44db4560 Waiting Oct 12, 2026 by AkshayShah03 via wait-for-approval #632
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.

1 participant