Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate dbt_yml_files from pydantic classes #150

Closed

Conversation

aliceliu
Copy link

@aliceliu aliceliu commented Jul 25, 2024

Generated pydantic classes from existing jsonschema using datamodel-codegen --input /Users/alicejliu/git/dbt-jsonschema/schemas/latest/dbt_yml_files-latest.json --input-file-type jsonschema --output model.py --output-model-type=pydantic_v2.BaseModel --target-python-version=3.11 --use-title-as-name --field-constraints

However there are if/then/not statements in the jsonschema that cannot be translated to Pydantic. For those I manually fixed them:

  • Created ExpectDict, ExpectCSV, ExpectSQL to handle differences in expect fields
  • Created OwnerWithEmail and OwnerWithName to handle oneOf email/name being required
  • Created SimpleMetric, DerivedMetric, CumulativeMetric, ConversionMetric, RatioMetric to handle differences in type_params

There were also a couple of other manual fixes I had to make:

  • A typing error where FreshnessDefinition was using Any instead of None
  • Use Calculation.conversion_rate for default value instead of "conversion_rate"

@aliceliu aliceliu force-pushed the 07-24-generate_dbt_yml_files_from_pydantic_classes branch from eb115ad to 6484bab Compare July 25, 2024 19:55
@dave-connors-3 dave-connors-3 marked this pull request as ready for review August 5, 2024 23:40
@joellabes
Copy link
Collaborator

Closing in favor of #159

@joellabes joellabes closed this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants