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

[1/3] Migrate Will's town close QC reports to dbt models #554

Merged
merged 42 commits into from
Aug 7, 2024

Conversation

jeancochrane
Copy link
Contributor

@jeancochrane jeancochrane commented Jul 25, 2024

Overview

This PR is the first of three following up on #534 by adding a bunch of models and Excel templates to recreate the QC reports that Will sends out on town close.

This PR migrates the following reports that all share common logic:

  • 0 land value
  • 0 value
  • Vacant class, bldg value
  • Improved class, no bldg value
  • Class does not equal LUC
  • 500k increase, 1m decrease

The subsequent PRs finishing the migration are #556 and #557. I've tried to group PRs according to reports that share common logic, with the third PR being a grab bag of miscellaneous reports.

We make a few other small changes to support this effort:

  • Existing QC report views (qc.vw_change_in_ahsap_values and qc.vw_report_town_close_neg_asmt_value) get refactored to remove hardcoded dates, in line with other QC models
  • The dbt/scripts/export_models.py script is extended to support reading a config.meta.export_format.columns attribute from the schema config, which is used to set formatting options for the output Excel workbooks that can't be set in the template (such as right-aligning text data columns)

Testing

To recreate 2024 Jefferson township reports for the purposes of testing, run the following command in the dbt/ subdirectory:

python3 scripts/export_models.py --select tag:qc_report_town_close --where "township_code = '71' and taxyr = '2024'" --rebuild

The reports will be output to the dbt/export/output/ directory.

@jeancochrane jeancochrane linked an issue Jul 25, 2024 that may be closed by this pull request
.flake8 Outdated
Comment on lines 1 to 6
[flake8]
ignore=
# Whitespace before ':', incompatible with black
E203,
# Line break before binary operator, incompatible with black
W503
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point should probably just switch this project over to ruff, but in the meantime this flake8 config change is necessary to fix some conflicts between black and flake8.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops I think I just biffed this with #564. Will probably need a run through with ruff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Ruff seems to make this config unnecessary so I removed it in 0e41f3e.

@@ -117,19 +138,213 @@ In contrast to `qc.vw_neg_asmt_value`, this view directly performs filtering
for negative values.
{% enddocs %}

# vw_sale_mydec_null_values
# vw_report_town_close_0_land_value
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the docs blocks for the new reports are listed in the order that Will runs them, which made it easier for me to track my progress during development, but I can rearrange them to be in alphabetical order if we have a strong preference for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just quickly order them alphanumerically yeah, for consistency with the other docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, done in 3744e48! Remind me whether we normally also order the schema files this way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema files should be alphanumerically ordered. The docs files are kind of a mixed bag (some are broken up by section), but are usually alphanumeric also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I also reordered the schema file in 10e033f. Sorry for the annoying diff! I didn't change anything and checked with a dbt compile that the graph still compiles correctly, which should hopefully rule out any obvious copy/paste errors.

dbt/models/qc/schema.yml Outdated Show resolved Hide resolved
@jeancochrane jeancochrane changed the title Migrate Will's town close QC reports to dbt models [Do not merge] Migrate Will's town close QC reports to dbt models Jul 26, 2024
@jeancochrane jeancochrane changed the title [Do not merge] Migrate Will's town close QC reports to dbt models [1/3] Migrate Will's town close QC reports to dbt models Jul 26, 2024
dbt/models/qc/docs.md Outdated Show resolved Hide resolved
Comment on lines 928 to 930
- name: '% Change'
index: M
horizontal_align: right
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the PR body, this is the new syntax for specifying formatting that should be applied to the export workbook at runtime. This is necessary because (as far as I can tell) you can't set horizontal alignment in an Excel template before you populate it with data using openpyxl.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: When you build up the docs for the QC reporting exports, let's be sure to enumerate the possible options here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good flag, I've added a note on this to #539.

dbt/scripts/export_models.py Outdated Show resolved Hide resolved
@jeancochrane jeancochrane requested a review from dfsnow July 26, 2024 22:09
@jeancochrane jeancochrane marked this pull request as ready for review July 30, 2024 21:33
@jeancochrane jeancochrane requested a review from a team as a code owner July 30, 2024 21:33
.flake8 Outdated
Comment on lines 1 to 6
[flake8]
ignore=
# Whitespace before ':', incompatible with black
E203,
# Line break before binary operator, incompatible with black
W503
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops I think I just biffed this with #564. Will probably need a run through with ruff.

@@ -117,19 +138,213 @@ In contrast to `qc.vw_neg_asmt_value`, this view directly performs filtering
for negative values.
{% enddocs %}

# vw_sale_mydec_null_values
# vw_report_town_close_0_land_value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just quickly order them alphanumerically yeah, for consistency with the other docs.

dbt/export/templates/assessed_and_market_values.xlsx Outdated Show resolved Hide resolved
Comment on lines 928 to 930
- name: '% Change'
index: M
horizontal_align: right
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: When you build up the docs for the QC reporting exports, let's be sure to enumerate the possible options here.

dbt/scripts/export_models.py Outdated Show resolved Hide resolved
@jeancochrane jeancochrane force-pushed the jeancochrane/migrate-more-will-qc-reports branch from 47810e9 to 3744e48 Compare August 5, 2024 19:59
@jeancochrane jeancochrane requested a review from dfsnow August 6, 2024 20:10
Copy link
Member

@dfsnow dfsnow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this looks great @jeancochrane!

@jeancochrane jeancochrane merged commit 26b998e into master Aug 7, 2024
9 checks passed
@jeancochrane jeancochrane deleted the jeancochrane/migrate-more-will-qc-reports branch August 7, 2024 14:46
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.

Automate Will's QC reports with dbt models and a simple script
3 participants