You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have enforced the sample PG in the document and would like to know about the following two items.
1. the type is optional and not required
In the sample PG of Required config fields, there is the following annotation.
The ellipsis indicates that input is mandatory even if the type is optional.
However, I tried the sample PG as it is, but it does not result in an error.
Neither of the following fields is an error.
person_first_name: Optional[str] = ...
Field(default=... description=“The last name of the person to greet”)
I tried using pydantic's ValidationError to verify, but
It still doesn't show an error.
The result is returned without error.
Goodbye, None None
or
Goodbye, Alice Alice
The PG I tried is described below.
I tried by executing as follows.
python -c 'import advanced_config_types; advanced_config_types.test_required_field_error()'
2. error occurs in data type of person_last_name
In the sample PG, the data type of person_last_name is as follows.
person_last_name: Optional[Callable].
When reloading Code Locations in Dagster UI, the following error occurs.
For example, if I rewrite it to Optional[str], the error does not occur.
Is there a mistake in the data type description, or do I need to import some other module?
I know this is not a Dagste question, but please enlighten me.
I am using a translation site to write the sentences.
Sorry if the text is rude.
Sample PGs tried:
from typing import Optional, Callable
from dagster import asset, Config
from pydantic import Field
from pydantic import ValidationError
class MyAssetConfig_required_field(Config):
person_first_name: Optional[str] = ...
# person_last_name: Optional[Callable] = Field(
person_last_name: Optional[str] = Field(
default=..., description="The last name of the person to greet"
)
・Error output in 2:
dagster._core.errors.DagsterInvalidPythonicConfigDefinitionError:
Error defining Dagster config class <class 'my_dagster_learning.Resources_and_configuration.advanced_config_types.advanced_config_types.MyAssetConfig_required_field'> on field 'person_last_name'.
Unable to resolve config type typing.Callable to a supported Dagster config type.
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_grpc\server.py", line 421, in init
self.loaded_repositories: Optional[LoadedRepositories] = LoadedRepositories(
^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_grpc\server.py", line 255, in init
loadable_targets = get_loadable_targets(
^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_grpc\utils.py", line 50, in get_loadable_targets
else loadable_targets_from_python_module(module_name, working_directory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\workspace\autodiscovery.py", line 31, in loadable_targets_from_python_module
module = load_python_module(
^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\code_pointer.py", line 134, in load_python_module
return importlib.import_module(module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\python\python312\Lib\importlib_init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 995, in exec_module
File "", line 488, in call_with_frames_removed
File "D:\pg\project\Personalized_Learning_Environment\dagster\my-dagster-learning\my_dagster_learning_init.py", line 39, in
from .Resources_and_configuration.advanced_config_types import advanced_config_types
File "D:\pg\project\Personalized_Learning_Environment\dagster\my-dagster-learning\my_dagster_learning\Resources_and_configuration\advanced_config_types\advanced_config_types.py", line 120, in @asset
^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\decorator_utils.py", line 203, in wrapped_with_pre_call_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\decorator_utils.py", line 203, in wrapped_with_pre_call_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\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 "D:\pg\project.venv.venv_dagster_latest\Lib\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 "D:\pg\project.venv.venv_dagster_latest\Lib\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 "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\definitions\decorators\decorator_assets_definition_builder.py", line 565, in create_assets_definition
node_def=self.create_op_definition(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\definitions\decorators\decorator_assets_definition_builder.py", line 546, in create_op_definition
return _Op(
^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\definitions\decorators\op_decorator.py", line 104, in call
self.config_schema = infer_schema_from_config_annotation(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\conversion_utils.py", line 328, in infer_schema_from_config_annotation
return infer_schema_from_config_class(model_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\config.py", line 459, in infer_schema_from_config_class
raise DagsterInvalidPythonicConfigDefinitionError(
The above exception occurred during handling of the following exception:
dagster._core.errors.DagsterInvalidConfigDefinitionError: Error defining config. Original value passed: typing.Callable. typing.Callable 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]
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\config.py", line 457, in infer_schema_from_config_class
fields[resolved_field_name] = _convert_pydantic_field(pydantic_field_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\conversion_utils.py", line 123, in _convert_pydantic_field
config_type = _config_type_for_type_on_pydantic_field(field_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\conversion_utils.py", line 186, in _config_type_for_type_on_pydantic_field
return Noneable(_config_type_for_type_on_pydantic_field(optional_inner_type))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\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 "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\field_utils.py", line 432, in convert_potential_field
return _convert_potential_field(potential_field, potential_field, [])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\field_utils.py", line 465, in _convert_potential_field
raise DagsterInvalidConfigDefinitionError(original_root, potential_field, stack)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Target Document Locations
https://docs.dagster.io/concepts/configuration/advanced-config-types#required-config-fields
Version used: v1.8.13
I have enforced the sample PG in the document and would like to know about the following two items.
1. the type is optional and not required
In the sample PG of Required config fields, there is the following annotation.
The ellipsis indicates that input is mandatory even if the type is optional.
However, I tried the sample PG as it is, but it does not result in an error.
Neither of the following fields is an error.
person_first_name: Optional[str] = ...
Field(default=... description=“The last name of the person to greet”)
I tried using pydantic's ValidationError to verify, but
It still doesn't show an error.
The result is returned without error.
Goodbye, None None
or
Goodbye, Alice Alice
Is there a mistake in the way it is executed, or is there a mistake in the way it is specified as required?
In Pydantic's Optional documentation, there is no mention of ... is a required field in Pydantic's Optional documentation.
https://docs.pydantic.dev/2.9/migration/#required-optional-and-nullable-fields
The PG I tried is described below.
I tried by executing as follows.
python -c 'import advanced_config_types; advanced_config_types.test_required_field_error()'
2. error occurs in data type of person_last_name
In the sample PG, the data type of person_last_name is as follows.
person_last_name: Optional[Callable].
When reloading Code Locations in Dagster UI, the following error occurs.
For example, if I rewrite it to Optional[str], the error does not occur.
Is there a mistake in the data type description, or do I need to import some other module?
I know this is not a Dagste question, but please enlighten me.
I am using a translation site to write the sentences.
Sorry if the text is rude.
Sample PGs tried:
from typing import Optional, Callable
from dagster import asset, Config
from pydantic import Field
from pydantic import ValidationError
class MyAssetConfig_required_field(Config):
person_first_name: Optional[str] = ...
@asset
def goodbye_required_field(config: MyAssetConfig_required_field) -> str:
full_name = f"{config.person_first_name} {config.person_last_name}".strip()
if full_name:
return f"Goodbye, {full_name}"
else:
return "Goodbye"
def test_required_field_error():
try:
MyAssetConfig_required_field()
except ValidationError as e:
print(e)
def test_required_field_success():
goodbye_required_field(MyAssetConfig_required_field(person_first_name="Alice", person_last_name="Alice"))
・Error output in 2:
dagster._core.errors.DagsterInvalidPythonicConfigDefinitionError:
Error defining Dagster config class <class 'my_dagster_learning.Resources_and_configuration.advanced_config_types.advanced_config_types.MyAssetConfig_required_field'> on field 'person_last_name'.
Unable to resolve config type typing.Callable 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)
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_grpc\server.py", line 421, in init
self.loaded_repositories: Optional[LoadedRepositories] = LoadedRepositories(
^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_grpc\server.py", line 255, in init
loadable_targets = get_loadable_targets(
^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_grpc\utils.py", line 50, in get_loadable_targets
else loadable_targets_from_python_module(module_name, working_directory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\workspace\autodiscovery.py", line 31, in loadable_targets_from_python_module
module = load_python_module(
^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\code_pointer.py", line 134, in load_python_module
return importlib.import_module(module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\python\python312\Lib\importlib_init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 995, in exec_module
File "", line 488, in call_with_frames_removed
File "D:\pg\project\Personalized_Learning_Environment\dagster\my-dagster-learning\my_dagster_learning_init.py", line 39, in
from .Resources_and_configuration.advanced_config_types import advanced_config_types
File "D:\pg\project\Personalized_Learning_Environment\dagster\my-dagster-learning\my_dagster_learning\Resources_and_configuration\advanced_config_types\advanced_config_types.py", line 120, in
@asset
^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\decorator_utils.py", line 203, in wrapped_with_pre_call_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\decorator_utils.py", line 203, in wrapped_with_pre_call_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\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 "D:\pg\project.venv.venv_dagster_latest\Lib\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 "D:\pg\project.venv.venv_dagster_latest\Lib\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 "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\definitions\decorators\decorator_assets_definition_builder.py", line 565, in create_assets_definition
node_def=self.create_op_definition(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\definitions\decorators\decorator_assets_definition_builder.py", line 546, in create_op_definition
return _Op(
^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_core\definitions\decorators\op_decorator.py", line 104, in call
self.config_schema = infer_schema_from_config_annotation(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\conversion_utils.py", line 328, in infer_schema_from_config_annotation
return infer_schema_from_config_class(model_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\config.py", line 459, in infer_schema_from_config_class
raise DagsterInvalidPythonicConfigDefinitionError(
The above exception occurred during handling of the following exception:
dagster._core.errors.DagsterInvalidConfigDefinitionError: Error defining config. Original value passed: typing.Callable. typing.Callable 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]
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\config.py", line 457, in infer_schema_from_config_class
fields[resolved_field_name] = _convert_pydantic_field(pydantic_field_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\conversion_utils.py", line 123, in _convert_pydantic_field
config_type = _config_type_for_type_on_pydantic_field(field_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\pythonic_config\conversion_utils.py", line 186, in _config_type_for_type_on_pydantic_field
return Noneable(_config_type_for_type_on_pydantic_field(optional_inner_type))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\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 "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\field_utils.py", line 432, in convert_potential_field
return _convert_potential_field(potential_field, potential_field, [])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\pg\project.venv.venv_dagster_latest\Lib\site-packages\dagster_config\field_utils.py", line 465, in _convert_potential_field
raise DagsterInvalidConfigDefinitionError(original_root, potential_field, stack)
Beta Was this translation helpful? Give feedback.
All reactions