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

move requires_typed_event_stream and type_event_stream_error_message to op context #18521

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def __init__(self, step_execution_context: StepExecutionContext):
self._events: List[DagsterEvent] = []
self._output_metadata: Dict[str, Any] = {}

self._requires_typed_event_stream = False
self._typed_event_stream_error_message = None

@public
@property
def op_config(self) -> Any:
Expand Down Expand Up @@ -1337,14 +1340,16 @@ def asset_check_spec(self) -> AssetCheckSpec:
# allowed.
@property
def requires_typed_event_stream(self) -> bool:
return self._step_execution_context.requires_typed_event_stream
return self._requires_typed_event_stream

@property
def typed_event_stream_error_message(self) -> Optional[str]:
return self._step_execution_context.typed_event_stream_error_message
return self._typed_event_stream_error_message

def set_requires_typed_event_stream(self, *, error_message: Optional[str] = None) -> None:
self._step_execution_context.set_requires_typed_event_stream(error_message=error_message)
# Error message will be appended to the default error message.
def set_requires_typed_event_stream(self, *, error_message: Optional[str] = None):
self._requires_typed_event_stream = True
self._typed_event_stream_error_message = error_message

@staticmethod
def get() -> "OpExecutionContext":
Expand Down
18 changes: 0 additions & 18 deletions python_modules/dagster/dagster/_core/execution/context/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,24 +575,6 @@ def __init__(
self._is_external_input_asset_version_info_loaded = False
self._data_version_cache: Dict[AssetKey, "DataVersion"] = {}

self._requires_typed_event_stream = False
self._typed_event_stream_error_message = None

# In this mode no conversion is done on returned values and missing but expected outputs are not
# allowed.
@property
def requires_typed_event_stream(self) -> bool:
return self._requires_typed_event_stream

@property
def typed_event_stream_error_message(self) -> Optional[str]:
return self._typed_event_stream_error_message

# Error message will be appended to the default error message.
def set_requires_typed_event_stream(self, *, error_message: Optional[str] = None):
self._requires_typed_event_stream = True
self._typed_event_stream_error_message = error_message

@property
def step(self) -> ExecutionStep:
return self._step
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def execute_core_compute(
output.name
for output in step.step_outputs
# checks are required if we're in requires_typed_event_stream mode
if step_context.requires_typed_event_stream or output.properties.asset_check_key
if compute_context.requires_typed_event_stream or output.properties.asset_check_key
}
omitted_outputs = expected_op_output_names.difference(emitted_result_names)
if omitted_outputs:
Expand All @@ -254,9 +254,9 @@ def execute_core_compute(
f"expected outputs {omitted_outputs!r}."
)

if step_context.requires_typed_event_stream:
if step_context.typed_event_stream_error_message:
message += " " + step_context.typed_event_stream_error_message
if compute_context.requires_typed_event_stream:
if compute_context.typed_event_stream_error_message:
message += " " + compute_context.typed_event_stream_error_message
raise DagsterInvariantViolationError(message)
else:
step_context.log.info(message)