-
-
Save colin-ho/2255c1b8c814155e8c47251c1b67b9ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pydantic_udf(pydantic_model: pydantic.BaseModel, udf: type, **kwargs): | |
pyarrow_schema = pydantic_to_pyarrow.get_pyarrow_schema(pydantic_model) | |
pyarrow_dtype = pa.struct([(c, pyarrow_schema.field(c).type) for c in pyarrow_schema.names]) | |
decorator = daft.udf(return_dtype=daft.DataType.from_arrow_type(pyarrow_dtype), **kwargs) | |
return decorator(udf) | |
class CommitQuality(BaseModel): | |
impact_to_project: int = Field( | |
ge=1, le=10, | |
description="Score from 1-10 indicating impact to project.", | |
) | |
technical_ability: int = Field( | |
ge=1, le=10, | |
description="Score from 1-10 indicating technical ability.", | |
) | |
reason: str | |
analyze_commit_udf = pydantic_udf(CommmitQuality, analyze_commit_message) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment