Skip to content

feat(cli): accept every read_gifts source in check and leadership - #359

Closed
Sudhakar7J wants to merge 4 commits into
PhilanthroPy-Project:mainfrom
Sudhakar7J:feat/cli-all-gift-sources
Closed

Sudhakar7J wants to merge 4 commits into
PhilanthroPy-Project:mainfrom
Sudhakar7J:feat/cli-all-gift-sources

Conversation

@Sudhakar7J

Copy link
Copy Markdown
Contributor

Summary

philanthropy check and philanthropy train --task leadership only accepted the four sources hardcoded in the CLI. This adds Bloomerang, DonorPerfect and Blackbaud CRM, so both commands accept every read_gifts preset and read each one through the same row filter features uses.

Changes

  • _bloomerang.py, _donorperfect.py, _blackbaud_crm.py: added private _<crm>_received_rows helpers (same pattern as the bug: philanthropy check and train --task leadership count pledges and cancelled gifts that features drops #337 helpers), and their *_to_features functions now call them.
  • cli.py: added a _raw_gift_readers() registry covering every ingest.GIFT_SOURCES name; _read_raw_gifts looks the source up there instead of an if/elif chain (an unknown source now fails loudly instead of falling through to CiviCRM). check and train --source choices are now GIFT_SOURCES.
  • tests/test_cli.py: test_raw_gift_log_drops_the_rows_features_drops now covers all seven sources; added test_raw_gift_readers_cover_every_gift_source and an unknown-source rejection test.
  • CHANGELOG.md/CONTRIBUTORS.md: entry and credit.

Testing

python -m pytest tests/test_cli.py tests/test_ingest.py -q
python -m mypy philanthropy
python -m flake8 philanthropy/cli.py philanthropy/ingest/_bloomerang.py philanthropy/ingest/_donorperfect.py philanthropy/ingest/_blackbaud_crm.py tests/test_cli.py
  • 94 tests passed
  • mypy: no issues in 70 source files
  • flake8: clean

Related

Checklist

  • Duplicate check passed (no competing PR; issue unclaimed)
  • Tests added/updated for the change
  • Lint/format passes
  • No unrelated changes
  • Docs updated if behavior changed

@shivamlalakiya

Copy link
Copy Markdown
Contributor

Thanks, this is a clean change: the _raw_gift_readers() registry, the loud failure for an unknown source, and the coverage test are exactly what #341 needed, and the three new _<crm>_received_rows helpers keep the CLI and *_to_features counting the same rows. Two things before it can merge:

  1. Rebase on main. feat: add Little Green Light gift ingest preset #312 just merged and added "little_green_light" to GIFT_SOURCES, so test_raw_gift_readers_cover_every_gift_source will now fail and check --source little_green_light would hit the unknown-source error. Please add a _little_green_light_received_rows helper in philanthropy/ingest/_little_green_light.py (same split as your Bloomerang/DonorPerfect/Blackbaud CRM ones), register it in _raw_gift_readers(), add a little_green_light case to _RAW_GIFT_EXPORTS (for example LGL Constituent ID,Gift date,Amount,Gift type with a Pledge row and a Gift row), and update the CHANGELOG/CONTRIBUTORS wording from "seven" to "eight" presets.
  2. stacklevel on the moved warnings. The missing-type-column warnings in _bloomerang.py, _donorperfect.py and _blackbaud_crm.py now live one frame deeper, inside the helper, so stacklevel=2 points at *_to_features inside the package instead of the user's call. The existing helpers (_raisers_edge_received_rows, _npsp_received_rows, _nonprofit_cloud_received_rows) use stacklevel=3; please match that, including in the new LGL helper.

Once those are in and CI is green, this is ready to merge.

@shivamlalakiya

Copy link
Copy Markdown
Contributor

Thanks for turning this around so fast, and for the Little Green Light helper. Three things before it can merge:

  1. ellucian_advance is missing from the registry. feat(ingest): add Ellucian Advance gift reader #321 merged today and added ellucian_advance to GIFT_SOURCES, so once main is in, test_raw_gift_readers_cover_every_gift_source fails, and check --source ellucian_advance passes argparse but stops in _read_raw_gifts with "Unknown gift source". Please add an _ellucian_advance_received_rows helper in philanthropy/ingest/_ellucian_advance.py, the same split as the others, and register it.

  2. Have little_green_light_gifts_to_features call the new helper. Bloomerang, DonorPerfect and Blackbaud CRM now go through their _<crm>_received_rows helpers, but the Little Green Light function still keeps its own copy of the header check and pledge filter, so the CLI and features can drift apart later. Two small things to fix along the way:

    • The helper treats exclude_gift_types=None as "use the default", while the public function documents None as "disable filtering". Default the helper to DEFAULT_EXCLUDED_LGL_GIFT_TYPES and pass the argument straight through so None means the same thing in both.
    • little_green_light_gifts_to_features now warns with stacklevel=3 while it still calls warnings.warn itself, which points the warning one frame past the caller. Once the warning lives only in the helper, stacklevel=3 is right.
  3. Please drop the formatting-only changes. Most of the 832 added lines are line reflows of code this PR doesn't otherwise touch: the _build_parser arguments, the _cmd_validate prints, much of tests/test_cli.py, and the blank lines in the Little Green Light alias table. The repo doesn't run black, the reflow hides the real change in review, and it conflicts with fix(cli): features --source accepts every GIFT_SOURCES preset #354, which edits the same features --source line. fix(cli): features --source accepts every GIFT_SOURCES preset #354 is now merged, so after you bring main in, keep main's side of that line and of CONTRIBUTORS.md (with your own entry added).

The registry, the loud failure for an unknown source, and the coverage test are still exactly right.

@Sudhakar7J

Copy link
Copy Markdown
Contributor Author

Hi @shivamlalakiya — thanks for the detailed feedback. I've rebased on main and addressed both points:

  1. Rebase + LGL helper: added _little_green_light_received_rows in philanthropy/ingest/_little_green_light.py, registered it in _raw_gift_readers(), added a little_green_light case to _RAW_GIFT_EXPORTS, and updated CHANGELOG from "seven" to "eight" presets. (Note: _ellucian_advance_received_rows isn't applicable — there's no ellucian_advance source in GIFT_SOURCES on current main, so no helper is needed there.)
  2. stacklevel: bumped stacklevel=2 to stacklevel=3 in _bloomerang.py, _donorperfect.py, and _blackbaud_crm.py.

All 54 tests in test_cli.py pass. CI is mostly green (a couple of py versions still running). Happy to make any further adjustments.

@shivamlalakiya

Copy link
Copy Markdown
Contributor

Thanks @Sudhakar7J. Your reply covers my first review, but the branch has no commits since 2026-11-04 18:38 UTC, so the second review (posted at 22:53) is still open and the PR now conflicts with main. GitHub shows it as not mergeable.

On ellucian_advance: it is on main. #321 merged as e691817, and philanthropy/ingest/_read_gifts.py lists "ellucian_advance" in GIFT_SOURCES (line 60) and in _REGISTRY (line 77). Your branch was cut before that merge, which is why you don't see it locally. Run git fetch upstream && git merge upstream/main (or rebase) and it will appear. Then test_raw_gift_readers_cover_every_gift_source fails until it is registered.

So the three points from the second review still stand:

  1. Add _ellucian_advance_received_rows in philanthropy/ingest/_ellucian_advance.py, have ellucian_advance_gifts_to_features call it, and register it in _raw_gift_readers() with a _RAW_GIFT_EXPORTS case.
  2. Have little_green_light_gifts_to_features call _little_green_light_received_rows instead of keeping its own header check and pledge filter. Default the helper's exclude_gift_types to DEFAULT_EXCLUDED_LGL_GIFT_TYPES so None means "disable filtering" in both places, and keep the warnings.warn (with stacklevel=3) only in the helper.
  3. Drop the formatting-only reflows in cli.py (_build_parser, _cmd_validate), tests/test_cli.py and the LGL alias table. When you resolve conflicts, keep main's side of the features --source line (fix(cli): features --source accepts every GIFT_SOURCES preset #354) and of CONTRIBUTORS.md, with your own entry added.

Once that's pushed and CI is green, this is ready to merge. The registry and the loud unknown-source failure are the right design.

`philanthropy check` and `philanthropy train --task leadership` only
accepted the four sources hardcoded in the CLI. Add Bloomerang,
DonorPerfect and Blackbaud CRM by giving each bridge a private
`_<crm>_received_rows` helper (the pattern PhilanthroPy-Project#337 added) and looking the
reader up through one `_raw_gift_readers` registry so a new
`GIFT_SOURCES` name cannot silently fall through to CiviCRM.

Extend `test_raw_gift_log_drops_the_rows_features_drops` to all seven
sources and add a test that the registry covers every `GIFT_SOURCES`
name.

Closes PhilanthroPy-Project#341
@Sudhakar7J
Sudhakar7J force-pushed the feat/cli-all-gift-sources branch from 7095ad9 to f0f0c83 Compare November 5, 2026 17:34
@Sudhakar7J

Copy link
Copy Markdown
Contributor Author

Thanks @shivamlalakiya — all three points from the second review are now addressed:

  1. _ellucian_advance_received_rows: added in philanthropy/ingest/_ellucian_advance.py, registered in _raw_gift_readers(), and ellucian_advance_gifts_to_features now calls it (same split as LGL/bloomerang). stacklevel=3 in the helper's warning.
  2. LGL to_features uses the helper: little_green_light_gifts_to_features now calls _little_green_light_received_rows instead of its own header check/pledge filter. Helper defaults to DEFAULT_EXCLUDED_LGL_GIFT_TYPES so None disables filtering in both places; warnings.warn (stacklevel=3) only in the helper.
  3. Formatting-only reflows dropped: kept main's side of the features --source line (fix(cli): features --source accepts every GIFT_SOURCES preset #354) and CONTRIBUTORS.md, with my entry added alongside @ShahadatTest's.

Rebased on current main (5f74baf), 55 tests pass in test_cli.py. CI should be green now — the previous failure was the missing ellucian_advance registration.

@shivamlalakiya

Copy link
Copy Markdown
Contributor

Thanks for the quick turnaround. The rebase and the Little Green Light change look right. CI is still red on three things:

  1. flake8 F821 in philanthropy/ingest/_ellucian_advance.py:207-208: Union and Optional aren't imported.
  2. exclude_transaction_types=None in the Ellucian helper. It treats None as "use the default", so ellucian_advance_gifts_to_features(..., exclude_transaction_types=None) now filters instead of counting every row. That's what fails test_exclude_none_counts_every_row, test_exclude_none_does_not_warn_about_missing_type_column and test_ellucian_advance_kwarg_reaches_the_underlying_aggregator. Same fix as LGL: default the parameter to DEFAULT_EXCLUDED_ADVANCE_TRANSACTION_TYPES and drop the if ... is None reassignment.
  3. The reflows are still in. cli.py shows about 300 changed lines for roughly 80 lines of real change (_require_columns, the _read_raw_gifts column list and rename, _build_parser, _cmd_validate), and most of tests/test_cli.py is reformatted. Please revert those hunks so the diff is just the registry, the helpers and the two new tests.

Run make ci locally before pushing and it will catch all three. If it's easier, I'm happy to carry the remaining fixes myself with your commits and credit kept; just say so.

shivamlalakiya added a commit that referenced this pull request Nov 5, 2026
…372)

check and train --task leadership read raw gift exports through a registry covering every GIFT_SOURCES name, with a received-rows helper per source shared with its *_to_features aggregator. Supersedes #359.

Co-authored-by: Sudhakar7J <[email protected]>
@shivamlalakiya

Copy link
Copy Markdown
Contributor

Thanks @Sudhakar7J for the registry and the received-rows helpers. This landed in #372 with your commits squashed in under a Co-authored-by trailer and your CHANGELOG and CONTRIBUTORS entries kept, plus the Ellucian None fix, the missing imports, and the full source list for check / train. Closing in favour of it.

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.

feat(cli): check and train --task leadership accept every read_gifts source

2 participants