David Tong
03/22/2023, 4:20 PMDavid Tong
03/22/2023, 4:20 PMfrom enum import Enum, auto
from pydantic import BaseModel, Field
from dagster import Config as DagsterConfig, op
class CompareOperator(Enum):
LT = "LT"
class ColumnFilter(DagsterConfig):
column: str = Field(description="column")
threshold: float = Field(description="threshold")
compare_operator: CompareOperator
class Config:
use_enum_values = True
ColumnFilter(column="col", threshold=0.1, compare_operator="LT") # Resolves just fine
@op
def my_op(context, config: ColumnFilter):
print(config)
David Tong
03/22/2023, 4:21 PMDagsterInvalidConfigDefinitionError: Error defining config. Original value passed: <enum 'CompareOperator'>. <enum 'CompareOperator'> 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]
jamie
03/22/2023, 4:39 PMDavid Tong
03/23/2023, 3:34 PMconfig_schema
again, but it’s a tad messier and would prefer to use the pydantic approach if possible.kelvyn scrupps
03/25/2023, 12:45 AMclass MyConfig(Config):
key: MyEnum
I then tried that approach:
from dagster import (
Enum as DagsterEnum,
Field
)
class MyConfig(Config):
key: Field(DagsterEnum.from_python_enum(MyEnum))
This however gives a pydantic validation error on the dagster Field
RuntimeError: error checking inheritance of Field(<dagster._config.config_type.Enum object at 0x0000021B87AD2440>, default=@, is_required=True) (type: Field)
...
File "pydantic\main.py", line 198, in pydantic.main.ModelMetaclass.__new__
File "pydantic\fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic\fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic\fields.py", line 557, in pydantic.fields.ModelField.prepare
File "pydantic\fields.py", line 831, in pydantic.fields.ModelField.populate_validators
File "pydantic\validators.py", line 760, in find_validators
The above exception occurred during handling of the following exception:
TypeError: issubclass() arg 1 must be a class
File "pydantic\validators.py", line 751, in pydantic.validators.find_validators
so, in short, no luck either.
Shame as its a neat feature, but I guess its early daysben
03/27/2023, 3:20 PMkelvyn scrupps
03/27/2023, 8:21 PMDavid Tong
03/29/2023, 9:52 PMben
03/29/2023, 9:52 PMben
03/29/2023, 9:52 PMDavid Tong
03/29/2023, 10:07 PMcontext.pdb.set_trace()
works? on older versions of dagster, im quite confident i was able to properly set breakpoints for local dagit instances using that line before, but now i immediately get the following error:
The above exception was caused by the following exception:
bdb.BdbQuit
File "/home/david.tong/miniconda3/envs/dagster3/lib/python3.8/site-packages/dagster/_core/execution/plan/utils.py", line 54, in op_execution_error_boundary
yield
File "/home/david.tong/miniconda3/envs/dagster3/lib/python3.8/site-packages/dagster/_utils/__init__.py", line 439, in iterate_with_context
next_output = next(iterator)
File "/home/david.tong/miniconda3/envs/dagster3/lib/python3.8/site-packages/dagster/_core/execution/plan/compute_generator.py", line 122, in _coerce_solid_compute_fn_to_iterator
result = invoke_compute_fn(
File "/home/david.tong/miniconda3/envs/dagster3/lib/python3.8/site-packages/dagster/_core/execution/plan/compute_generator.py", line 116, in invoke_compute_fn
return fn(context, **args_to_pass) if context_arg_provided else fn(**args_to_pass)
File "/home/david.tong/repos/dagster_workflows/dagster_workflows/dagster_modules/some_job/ops/new_op.py", line 25, in run_some_job_large
config = load_yaml("/home/david.tong/repos/dagster_workflows/nav_config.yaml")
File "/home/david.tong/repos/dagster_workflows/dagster_workflows/dagster_modules/some_job/ops/new_op.py", line 25, in run_some_job_large
config = load_yaml("/home/david.tong/repos/dagster_workflows/nav_config.yaml")
File "/home/david.tong/miniconda3/envs/dagster3/lib/python3.8/bdb.py", line 88, in trace_dispatch
return self.dispatch_line(frame)
File "/home/david.tong/miniconda3/envs/dagster3/lib/python3.8/bdb.py", line 113, in dispatch_line
if self.quitting: raise BdbQuit
jamie
03/30/2023, 2:25 PM