fix: sanitize hyphens in get_asset_key_str to prevent KeyError on hyphenated internal asset names#63
Open
connordouglashanna wants to merge 3 commits intoopensource-observer:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Howdy! I encountered a crash when attempting to add a SQLMesh pipeline that used a GCP project with a hyphen as the gateway, error message copied below. Fixes #62.
Comments indicated that the function
get_asset_key_str()intranslator.py:167had been intended to normalize hyphens, but that the code to do so hadn't been added. The fix is one line and a test that target that function. The new test passes, but some other tests failed because of what looks like a preexisting bug with DuckDB on Windows.Before the fix,
@sqlmesh_assetspassed hyphenatedasset_outsandinternal_asset_deps_mapdicts to Dagster. Dagster's@multi_asset()function would then hand off the names tobuild_named_outswhich normalized only the asset output names. Theasset_depsdon't get normalized bybuild_named_outs, retain their hyphens, and then fail to reconcile ondecorator_assets_definition_builder.py:461. Dagster validation on line 443 of the same file checks the pre-normalization names and thus returns no error.This is my first open source contribution! If you have any feedback on my code or anything else, please holler, I'm all ears! I considered whether there should maybe be a fix in Dagster too, but I don't know enough to say. I'd love to contribute there too if it's worth doing.
Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\myusername\Documents\my_project\dagster_defs.py", line 18, in <module> @sqlmesh_assets( ^^^^^^^^^^^^^^^ File "C:\Users\myusername\Documents\my_project\.venv\Lib\site-packages\dagster\_core\definitions\decorators\asset_decorator.py", line 744, in inner builder = DecoratorAssetsDefinitionBuilder.for_multi_asset(args=args, fn=fn) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\myusername\Documents\my_project\.venv\Lib\site-packages\dagster\_core\definitions\decorators\decorator_assets_definition_builder.py", line 328, in for_multi_asset return DecoratorAssetsDefinitionBuilder.from_asset_outs_in_asset_centric_decorator( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\myusername\Documents\my_project\.venv\Lib\site-packages\dagster\_core\definitions\decorators\decorator_assets_definition_builder.py", line 461, in from_asset_outs_in_asset_centric_decorator internal_deps = {keys_by_output_name[name]: asset_deps[name] for name in asset_deps} ~~~~~~~~~~~~~~~~~~~^^^^^^ KeyError: 'sqlmesh__my-gcp-project_my_schema_example_model'