Skip to content

Commit a4ed2c2

Browse files
authored
[dagster-aws] Honor configured EMR s3 job package path (#33733)
## Summary & Motivation Closes #3679. Patched the EMR step launcher so --py-files now matches the configured distribution mode in python_modules/libraries/dagster- aws/dagster_aws/emr/pyspark_step_launcher.py:436. If s3_job_package_path is set, it uses that URI; if deploy_local_job_package=True, it uses the staged code.zip; otherwise it omits --py-files entirely instead of pointing at a non-uploaded artifact. ## Test Plan ## Changelog - [dagster-aws] honor configured EMR s3 job package path
1 parent fb8f5fb commit a4ed2c2

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

python_modules/libraries/dagster-aws/dagster_aws/emr/pyspark_step_launcher.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,12 @@ def _get_emr_step_def(self, run_id, step_key, solid_name):
433433
).format(conf.get("spark.master")),
434434
)
435435

436+
py_files = []
437+
if self.s3_job_package_path:
438+
py_files = ["--py-files", self.s3_job_package_path]
439+
elif self.deploy_local_job_package:
440+
py_files = ["--py-files", self._artifact_s3_uri(run_id, step_key, CODE_ZIP_NAME)]
441+
436442
command = (
437443
[
438444
EMR_SPARK_HOME + "bin/spark-submit",
@@ -442,9 +448,8 @@ def _get_emr_step_def(self, run_id, step_key, solid_name):
442448
conf.get("spark.submit.deployMode", "client"),
443449
]
444450
+ format_for_cli(list(flatten_dict(conf)))
451+
+ py_files
445452
+ [
446-
"--py-files",
447-
self._artifact_s3_uri(run_id, step_key, CODE_ZIP_NAME),
448453
self._artifact_s3_uri(run_id, step_key, self._main_file_name()),
449454
self.staging_bucket,
450455
self._artifact_s3_key(run_id, step_key, PICKLED_STEP_RUN_REF_FILE_NAME),

python_modules/libraries/dagster-aws/dagster_aws_tests/emr_tests/test_pyspark_step_launcher.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,41 @@ def test_emr_pyspark_step_launcher_legacy_arguments():
112112
}
113113
)
114114
)
115+
116+
117+
def test_emr_step_def_uses_configured_s3_job_package_path():
118+
launcher = EmrPySparkStepLauncher(
119+
region_name="us-west-1",
120+
staging_bucket="bucket",
121+
staging_prefix="prefix",
122+
wait_for_logs=False,
123+
action_on_failure="CANCEL_AND_WAIT",
124+
cluster_id="j-123",
125+
spark_config={},
126+
local_job_package_path=os.path.abspath(os.path.dirname(__file__)),
127+
deploy_local_job_package=False,
128+
s3_job_package_path="s3://configured/code.zip",
129+
)
130+
131+
args = launcher._get_emr_step_def("run1", "step1", "op1")["HadoopJarStep"]["Args"] # noqa: SLF001
132+
133+
assert "--py-files" in args
134+
assert args[args.index("--py-files") + 1] == "s3://configured/code.zip"
135+
136+
137+
def test_emr_step_def_omits_py_files_when_code_is_preinstalled():
138+
launcher = EmrPySparkStepLauncher(
139+
region_name="us-west-1",
140+
staging_bucket="bucket",
141+
staging_prefix="prefix",
142+
wait_for_logs=False,
143+
action_on_failure="CANCEL_AND_WAIT",
144+
cluster_id="j-123",
145+
spark_config={},
146+
local_job_package_path=os.path.abspath(os.path.dirname(__file__)),
147+
deploy_local_job_package=False,
148+
)
149+
150+
args = launcher._get_emr_step_def("run1", "step1", "op1")["HadoopJarStep"]["Args"] # noqa: SLF001
151+
152+
assert "--py-files" not in args

0 commit comments

Comments
 (0)