From 898494662213b980ac5569dde16016cb8790f16a Mon Sep 17 00:00:00 2001 From: JamieDeMaria Date: Thu, 7 Dec 2023 15:49:41 -0500 Subject: [PATCH] add test for doc strings --- .../_core/execution/context/compute.py | 11 ++--------- .../test_asset_execution_context.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 python_modules/dagster/dagster_tests/core_tests/execution_tests/test_asset_execution_context.py diff --git a/python_modules/dagster/dagster/_core/execution/context/compute.py b/python_modules/dagster/dagster/_core/execution/context/compute.py index 48e741bd3d6da..2fe5778e58bcb 100644 --- a/python_modules/dagster/dagster/_core/execution/context/compute.py +++ b/python_modules/dagster/dagster/_core/execution/context/compute.py @@ -3,7 +3,6 @@ from contextvars import ContextVar from inspect import ( _empty as EmptyAnnotation, - isfunction, ) from typing import ( AbstractSet, @@ -21,8 +20,6 @@ import dagster._check as check from dagster._annotations import ( - T_Annotatable, - _get_annotation_target, deprecated, experimental, public, @@ -59,7 +56,6 @@ from dagster._core.instance import DagsterInstance from dagster._core.log_manager import DagsterLogManager from dagster._core.storage.dagster_run import DagsterRun -from dagster._utils.cached_method import cached_method from dagster._utils.forked_pdb import ForkedPdb from dagster._utils.warnings import ( deprecation_warning, @@ -1363,10 +1359,8 @@ def get() -> "OpExecutionContext": return ctx.get_op_execution_context() -def _copy_docs_from_op_execution_context(obj: T_Annotatable) -> T_Annotatable: - target = _get_annotation_target(obj) - if isfunction(target): - setattr(target, "__doc__", getattr(OpExecutionContext, target.__name__).__doc__) +def _copy_docs_from_op_execution_context(obj): + setattr(obj, "__doc__", getattr(OpExecutionContext, obj.__name__).__doc__) return obj @@ -1739,7 +1733,6 @@ def typed_event_stream_error_message(self) -> Optional[str]: def set_requires_typed_event_stream(self, *, error_message: Optional[str] = None) -> None: self.op_execution_context.set_requires_typed_event_stream(error_message=error_message) - @cached_method def get_op_execution_context(self) -> "OpExecutionContext": return self.op_execution_context diff --git a/python_modules/dagster/dagster_tests/core_tests/execution_tests/test_asset_execution_context.py b/python_modules/dagster/dagster_tests/core_tests/execution_tests/test_asset_execution_context.py new file mode 100644 index 0000000000000..2c5773688cad3 --- /dev/null +++ b/python_modules/dagster/dagster_tests/core_tests/execution_tests/test_asset_execution_context.py @@ -0,0 +1,19 @@ +from dagster import AssetExecutionContext, OpExecutionContext + + +def test_doc_strings(): + ignores = [ + "_abc_impl", + "_events", + "_output_metadata", + "_pdb", + "_step_execution_context", + ] + for attr_name in dir(OpExecutionContext): + if attr_name.startswith("__") or attr_name in ignores: + continue + if hasattr(AssetExecutionContext, attr_name): + op_attr = getattr(OpExecutionContext, attr_name) + asset_attr = getattr(AssetExecutionContext, attr_name) + + assert op_attr.__doc__ == asset_attr.__doc__