Daniel Gafni
03/18/2023, 8:33 AMAssetIn
behave like pydantic’s Field?
It would be possible to make assets more readable:
@asset
def my_asset(upstream: pd.DataFrame = AssetIn(metadata={"columns": ["A", "B"]})):
...
@sandy @schrocknDaniel Gafni
03/19/2023, 5:24 PMDaniel Gafni
03/28/2023, 8:03 AMschrockn
03/30/2023, 1:26 PMAssetIn
with the parameters they are associated with is potentially quite awesome actually.
I don’t think your original suggestion is possible because that would set the default value to AssetIn
unless that is leveraging some Python feature that I don’t know about.Daniel Gafni
03/30/2023, 5:17 PMimport typer
def main(name: str = typer.Argument(...)):
print(f"Hello {name}")
if __name__ == "__main__":
typer.run(main)
This CLI program would fail if you don't supply an argument, because Typer treats typer.Argument(...)
as a missing value for a required field. The ...
is an Ellipsis here (not some missing code).
Pydantic example:
from pydantic import BaseModel, Field
class Model(BaseModel):
a: int
b: int = ...
c: int = Field(...) # Ellipsis again
All a
, b
and c
fields are required.
You could do the same by handling default `AssetIn`s correctly. So this shouldn't be a problem.
Anyway, that's up to you to decide which of the approaches would be more clear and readable for the end-user and better for Dagster. But both should work.
I suggest to take a look at how FastAPI is using Annotated
.Daniel Gafni
03/30/2023, 7:17 PMDaniel Gafni
03/30/2023, 7:59 PM