From a558bdcc915ff5903122a1a785d4b7b596b4e0af Mon Sep 17 00:00:00 2001 From: JamieDeMaria Date: Fri, 17 Nov 2023 10:26:17 -0500 Subject: [PATCH] update error message --- .../_core/execution/context/invocation.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/python_modules/dagster/dagster/_core/execution/context/invocation.py b/python_modules/dagster/dagster/_core/execution/context/invocation.py index 3ee1f74dc8118..b7bac277aac06 100644 --- a/python_modules/dagster/dagster/_core/execution/context/invocation.py +++ b/python_modules/dagster/dagster/_core/execution/context/invocation.py @@ -59,10 +59,8 @@ from .system import StepExecutionContext, TypeCheckContext -def _property_msg(prop_name: str, method_name: str) -> str: - return ( - f"The {prop_name} {method_name} is not set on the context when an op is directly invoked." - ) +def _property_msg(prop_name: str, method_name: str, step_type: str) -> str: + return f"The {prop_name} {method_name} is not set on the context when an {step_type} is directly invoked." class DirectInvocationOpExecutionContext(OpExecutionContext): @@ -153,7 +151,7 @@ def __del__(self): def _check_bound(self, fn_name: str, fn_type: str): if not self._bound: - raise DagsterInvalidPropertyError(_property_msg(fn_name, fn_type)) + raise DagsterInvalidPropertyError(_property_msg(fn_name, fn_type, "op")) def bind( self, @@ -286,7 +284,7 @@ def resources(self) -> Resources: @property def dagster_run(self) -> DagsterRun: - raise DagsterInvalidPropertyError(_property_msg("dagster_run", "property")) + raise DagsterInvalidPropertyError(_property_msg("dagster_run", "property", "op")) @property def instance(self) -> DagsterInstance: @@ -311,7 +309,7 @@ def debug_solid(context): @property def step_launcher(self) -> Optional[StepLauncher]: - raise DagsterInvalidPropertyError(_property_msg("step_launcher", "property")) + raise DagsterInvalidPropertyError(_property_msg("step_launcher", "property", "op")) @property def run_id(self) -> str: @@ -330,11 +328,11 @@ def run_config(self) -> dict: @property def job_def(self) -> JobDefinition: - raise DagsterInvalidPropertyError(_property_msg("job_def", "property")) + raise DagsterInvalidPropertyError(_property_msg("job_def", "property", "op")) @property def job_name(self) -> str: - raise DagsterInvalidPropertyError(_property_msg("job_name", "property")) + raise DagsterInvalidPropertyError(_property_msg("job_name", "property", "op")) @property def log(self) -> DagsterLogManager: @@ -343,15 +341,15 @@ def log(self) -> DagsterLogManager: @property def node_handle(self) -> NodeHandle: - raise DagsterInvalidPropertyError(_property_msg("node_handle", "property")) + raise DagsterInvalidPropertyError(_property_msg("node_handle", "property", "op")) @property def op(self) -> Node: - raise DagsterInvalidPropertyError(_property_msg("op", "property")) + raise DagsterInvalidPropertyError(_property_msg("op", "property", "op")) @property def solid(self) -> Node: - raise DagsterInvalidPropertyError(_property_msg("solid", "property")) + raise DagsterInvalidPropertyError(_property_msg("solid", "property", "op")) @property def op_def(self) -> OpDefinition: @@ -414,7 +412,9 @@ def alias(self) -> str: return cast(str, self._alias) def get_step_execution_context(self) -> StepExecutionContext: - raise DagsterInvalidPropertyError(_property_msg("get_step_execution_context", "method")) + raise DagsterInvalidPropertyError( + _property_msg("get_step_execution_context", "method", "op") + ) def get_events(self) -> Sequence[UserEvent]: """Retrieve the list of user-generated events that were logged via the context. @@ -655,7 +655,7 @@ def __init__(self, op_execution_context: DirectInvocationOpExecutionContext): def _check_bound(self, fn_name: str, fn_type: str): if not self._bound: - raise DagsterInvalidPropertyError(_property_msg(fn_name, fn_type)) + raise DagsterInvalidPropertyError(_property_msg(fn_name, fn_type, "asset")) def bind( self,