Stephen Bailey
03/12/2023, 11:38 AMNone
default but that still results in a requirement to specify a string.
from dagster import Config, asset, RunConfig, materialize
class AssetConfig(Config):
name: str = "stephen"
optional_adverb: str = None
@asset
def foo(config: AssetConfig) -> str:
msg = f"{config.name} is {config.optional_adverb} cool."
print(msg)
return msg
# these should be valid configs
materialize([foo], run_config=RunConfig({"foo": AssetConfig(optional_adverb="really")}))
materialize([foo], run_config=RunConfig({"foo": AssetConfig()}))
error
Error 1: Value at path root:ops:foo:config:optional_adverb must not be None. Expected "(String | { env: String })"
Chris Zubak-Skees
03/12/2023, 12:51 PMfrom typing import Optional
...
class AssetConfig(Config):
optional_adverb: Optional[str]
Vinnie
03/13/2023, 7:53 AMpydantic.Field
though:
class MyConfig(Config):
my_required_config: str = Field(..., description="Some description")
my_optional_config: str = Field(None, description="Some other description")
Stephen Bailey
03/13/2023, 2:37 PMfrom dagster import Config, asset, RunConfig, materialize
from typing import Optional
from pydantic import Field
class AssetConfig(Config):
name: str = "stephen"
optional_adverb: str = Field(None)
@asset
def foo(config: AssetConfig) -> str:
msg = f"{config.name} is {config.optional_adverb} cool."
print(msg)
return msg
# these should be valid configs
materialize([foo], run_config=RunConfig({"foo": AssetConfig()}))
Vinnie
03/13/2023, 2:39 PM@graph(config=config)
to be able to materialize without supplying extra configben
03/14/2023, 12:46 AMRunConfig
adapter’s conversion to the underlying Dagster configStephen Bailey
03/14/2023, 1:01 PM