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

Error when running Config example #26077

Open
tobiascadee opened this issue Nov 21, 2024 · 0 comments
Open

Error when running Config example #26077

tobiascadee opened this issue Nov 21, 2024 · 0 comments
Labels
area: config Related to Configuration type: bug Something isn't working

Comments

@tobiascadee
Copy link

tobiascadee commented Nov 21, 2024

What's the issue?

I'm trying to define a Config class and using this but even the example provided in the docs gives an error.

class MyAssetConfig(Config):
    a_str: str

@asset
def my_asset(config: MyAssetConfig):
    assert config.a_str == "foo"

materialize(
    [my_asset],
    run_config=RunConfig(
        ops={"my_asset": MyAssetConfig(a_str="foo")}
    )
)

gives:

Traceback (most recent call last):
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_config/pythonic_config/conversion_utils.py", line 333, in infer_schema_from_config_annotation
    inner_config_type = _config_type_for_type_on_pydantic_field(model_cls)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_config/pythonic_config/conversion_utils.py", line 215, in _config_type_for_type_on_pydantic_field
    return convert_potential_field(potential_dagster_type).config_type
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_config/field_utils.py", line 432, in convert_potential_field
    return _convert_potential_field(potential_field, potential_field, [])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_config/field_utils.py", line 465, in _convert_potential_field
    raise DagsterInvalidConfigDefinitionError(original_root, potential_field, stack)
dagster._core.errors.DagsterInvalidConfigDefinitionError: Error defining config. Original value passed: 'MyAssetConfig'. 'MyAssetConfig' cannot be resolved.
This value can be a:
    - Field
    - Python primitive types that resolve to dagster config types
        - int, float, bool, str, list.
    - A dagster config type: Int, Float, Bool, Array, Optional, Selector, Shape, Permissive, Map
    - A bare python dictionary, which is wrapped in Field(Shape(...)). Any values
      in the dictionary get resolved by the same rules, recursively.
    - A python list with a single entry that can resolve to a type, e.g. [int]


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/dagster_etl/test.py", line 26, in <module>
    @asset
     ^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_core/decorator_utils.py", line 203, in wrapped_with_pre_call_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_core/decorator_utils.py", line 203, in wrapped_with_pre_call_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_core/decorator_utils.py", line 203, in wrapped_with_pre_call_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 6 more times]
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_core/definitions/decorators/asset_decorator.py", line 327, in asset
    return create_assets_def_from_fn_and_decorator_args(args, compute_fn)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_core/definitions/decorators/asset_decorator.py", line 532, in create_assets_def_from_fn_and_decorator_args
    return builder.create_assets_definition()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_core/definitions/decorators/decorator_assets_definition_builder.py", line 565, in create_assets_definition
    node_def=self.create_op_definition(),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_core/definitions/decorators/decorator_assets_definition_builder.py", line 546, in create_op_definition
    return _Op(
           ^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_core/definitions/decorators/op_decorator.py", line 104, in __call__
    self.config_schema = infer_schema_from_config_annotation(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tobiascadee/Documents/Ticketswap/Github/data-transformations/.venv/lib/python3.11/site-packages/dagster/_config/pythonic_config/conversion_utils.py", line 335, in infer_schema_from_config_annotation
    raise DagsterInvalidPythonicConfigDefinitionError(
dagster._core.errors.DagsterInvalidPythonicConfigDefinitionError: 
Error defining Dagster config class.
Unable to resolve config type 'MyAssetConfig' to a supported Dagster config type.


This config type can be a:
    - Python primitive type
        - int, float, bool, str, list
    - A Python Dict or List type containing other valid types
    - Custom data classes extending dagster.Config
    - A Pydantic discriminated union type (https://docs.pydantic.dev/usage/types/#discriminated-unions-aka-tagged-unions)

What did you expect to happen?

No error given.

How to reproduce?

I imagine there might be something wrong on my end but its just the config example and then run it.

Dagster version

1.9.1

Deployment type

None

Deployment details

No response

Additional information

No response

Message from the maintainers

Impacted by this issue? Give it a 👍! We factor engagement into prioritization.
By submitting this issue, you agree to follow Dagster's Code of Conduct.

@tobiascadee tobiascadee added the type: bug Something isn't working label Nov 21, 2024
@garethbrickman garethbrickman added the area: config Related to Configuration label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: config Related to Configuration type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants