-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Extract _get_op_def_compute_fn into wrap_source_asset_observe_fn_in_op_compute_fn #16618
Conversation
dee2615
to
ad61240
Compare
c1fea5a
to
9b37183
Compare
ad61240
to
2fa51cc
Compare
11f8bf6
to
e999885
Compare
808fc37
to
2e3b4a1
Compare
f47b698
to
5aabb85
Compare
@@ -50,10 +50,87 @@ | |||
from dagster._utils.merger import merge_dicts | |||
from dagster._utils.warnings import disable_dagster_warnings | |||
|
|||
# getting the following error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smackesey do you have any idea why ruff was firing this error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume if you uncomment [1] and [2] things should work - ruff just wants you to import in the TYPE_CHECKING block if you only use the type as a typehint like in [2]
its unclear to me if [1] is part of the error message you got for a import no longer present, or if you had [1] and commented it out and put the error above it
e999885
to
3df7ddc
Compare
# if TYPE_CHECKING: | ||
# from dagster._core.definitions.decorators.op_decorator import ( | ||
# DecoratedOpFunction, | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[1]
def wrap_source_asset_observe_fn_in_op_compute_fn( | ||
source_asset: "SourceAsset", | ||
): | ||
# ) -> "DecoratedOpFunction": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[2]
@@ -50,10 +50,87 @@ | |||
from dagster._utils.merger import merge_dicts | |||
from dagster._utils.warnings import disable_dagster_warnings | |||
|
|||
# getting the following error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume if you uncomment [1] and [2] things should work - ruff just wants you to import in the TYPE_CHECKING block if you only use the type as a typehint like in [2]
its unclear to me if [1] is part of the error message you got for a import no longer present, or if you had [1] and commented it out and put the error above it
5aabb85
to
4e8484e
Compare
3df7ddc
to
c1afec3
Compare
4e8484e
to
5f71dbf
Compare
…p_compute_fn This refactoring will be useful in a subsequent PR fix type hecking
c1afec3
to
4354aa0
Compare
…_fn_in_op_compute_fn (#16618)" (#16688) ## Summary & Motivation This caused bugs caught in manual testing: ``` Could not load location dagster_test.toys.repo to check for sensors due to the following error: TypeError: 'staticmethod' object is not callable Stack Trace: File "/Users/johann/dagster/python_modules/dagster/dagster/_grpc/server.py", line 295, in __init__ self._loaded_repositories: Optional[LoadedRepositories] = LoadedRepositories( File "/Users/johann/dagster/python_modules/dagster/dagster/_grpc/server.py", line 139, in __init__ loadable_targets = get_loadable_targets( File "/Users/johann/dagster/python_modules/dagster/dagster/_grpc/utils.py", line 47, in get_loadable_targets else loadable_targets_from_python_module(module_name, working_directory) File "/Users/johann/dagster/python_modules/dagster/dagster/_core/workspace/autodiscovery.py", line 35, in loadable_targets_from_python_module module = load_python_module( File "/Users/johann/dagster/python_modules/dagster/dagster/_core/code_pointer.py", line 135, in load_python_module return importlib.import_module(module_name) File "/Users/johann/.pyenv/versions/3.9.10/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/Users/johann/dagster/python_modules/dagster-test/dagster_test/toys/repo.py", line 201, in <module> def data_versions_repository(): File "/Users/johann/dagster/python_modules/dagster/dagster/_core/definitions/decorators/repository_decorator.py", line 405, in repository return _Repository()(definitions_fn) File "/Users/johann/dagster/python_modules/dagster/dagster/_core/definitions/decorators/repository_decorator.py", line 161, in __call__ else CachingRepositoryData.from_list( File "/Users/johann/dagster/python_modules/dagster/dagster/_core/definitions/repository_definition/repository_data.py", line 346, in from_list return build_caching_repository_data_from_list( File "/Users/johann/dagster/python_modules/dagster/dagster/_core/definitions/repository_definition/repository_data_builder.py", line 195, in build_caching_repository_data_from_list for job_def in get_base_asset_jobs( File "/Users/johann/dagster/python_modules/dagster/dagster/_core/definitions/assets_job.py", line 76, in get_base_asset_jobs for observable in [sa for sa in source_assets if sa.is_observable]: File "/Users/johann/dagster/python_modules/dagster/dagster/_core/definitions/assets_job.py", line 76, in <listcomp> for observable in [sa for sa in source_assets if sa.is_observable]: File "/Users/johann/dagster/python_modules/dagster/dagster/_core/definitions/source_asset.py", line 256, in is_observable return self.node_def is not None File "/Users/johann/dagster/python_modules/dagster/dagster/_core/definitions/source_asset.py", line 270, in node_def compute_fn=wrap_source_asset_observe_fn_in_op_compute_fn(self), ``` Reverting for now ## How I Tested These Changes BK
…p_compute_fn (Take two) (#16699) ## Summary & Motivation This is another shot at #16618 which was reverted in #16688 after @johannkm discovered a bug. It turns out I had spuriously left a `@staticmethod` decoration on wrap_source_asset_observe_fn_in_op_compute_fn which worked fine both locally and in CI. This because this only worked in Python 3.10 and later. https://docs.python.org/3/whatsnew/3.10.html#other-language-changes ``` Static methods (@staticmethod) and class methods (@classmethod) now inherit the method attributes (__module__, __name__, __qualname__, __doc__, __annotations__) and have a new __wrapped__ attribute. Moreover, static methods are now callable as regular functions. ``` We only run 3.10 in most CI now for cost control. However, sometimes we pay the iron price for this optimization. ## How I Tested These Changes Load original PR locally in python 3.9. Confirm error on original PR. Apply this patch. See no error.
Summary & Motivation
This is a simple refactoring so that I can use this function to implement #16620
How I Tested These Changes
BK