Skip to content

Commit f1fcb98

Browse files
Merge branch 'feature/spark-declarative-pipelines-component' of https://github.com/michalcabir-ui/dagster into feature/spark-declarative-pipelines-component
2 parents ff9d221 + 1ff8979 commit f1fcb98

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

python_modules/libraries/dagster-spark/dagster_spark/components/spark_declarative_pipeline/component.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ def _resolve_spark_pipelines_resource(_context: Any, value: Any) -> SparkPipelin
4242
return value
4343
if value is None:
4444
return SparkPipelinesResource()
45-
return SparkPipelinesResource(**value) if isinstance(value, dict) else SparkPipelinesResource()
45+
if isinstance(value, dict):
46+
return SparkPipelinesResource(**value)
47+
raise ValueError(
48+
f"Cannot resolve spark_pipelines field: expected a SparkPipelinesResource, dict, or None, "
49+
f"got {type(value).__name__!r}: {value!r}"
50+
)
4651

4752

4853
@scaffold_with(SparkDeclarativePipelineScaffolder)

python_modules/libraries/dagster-spark/dagster_spark/components/spark_declarative_pipeline/resource.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def run_and_observe(
8484
8585
Uses Popen to stream stdout/stderr line-by-line and logs each line via context.log.info.
8686
Passes --full-refresh or --refresh based on execution_mode, then optional comma-separated
87-
dataset list from asset_keys. returncode == 0; otherwise raises SparkPipelinesExecutionError with the captured log.
87+
dataset list from asset_keys. Yields MaterializeResult per asset on success when
88+
returncode == 0; otherwise raises SparkPipelinesExecutionError with the captured log.
8889
8990
Args:
9091
context: Asset execution context (used for context.log.info).
@@ -133,14 +134,16 @@ def run_and_observe(
133134
bufsize=1,
134135
)
135136
log_lines: deque[str] = deque(maxlen=1000)
136-
if process.stdout:
137-
for raw_line in process.stdout:
138-
line = raw_line.rstrip("\n\r")
139-
if line:
140-
log_lines.append(line)
141-
if context is not None and hasattr(context, "log"):
142-
context.log.info(line)
143-
process.wait()
137+
try:
138+
if process.stdout:
139+
for raw_line in process.stdout:
140+
line = raw_line.rstrip("\n\r")
141+
if line:
142+
log_lines.append(line)
143+
if context is not None and hasattr(context, "log"):
144+
context.log.info(line)
145+
finally:
146+
process.wait()
144147
returncode = process.returncode
145148

146149
if returncode != 0:

0 commit comments

Comments
 (0)