Part 3 of retiring the legacy analytics report formats — do this only after #4910 and #4911 are merged (they remove the in-repo consumers of the code deleted here). Completing the dependency-burden rationale from #4910: after this ticket, the package's install_requires no longer pulls gspread, gspread-formatting, or matplotlib, and consuming repos (anvil-portal, ncpi-dataset-catalog) can drop those pins from their dependabot-watched requirements.
Current structure (verified)
sheets_api.py (493 lines) — pure gspread/Drive/Sheets formatting; only legacy consumers.
sheets_elements.py (606 lines) — mostly GA4 element functions the static site needs (get_page_views_change, get_page_views_over_time_df, get_outbound_links_change, get_index_filter_selected_change, get_index_table_download_df, get_bounds_for_month_and_prev, ADDITIONAL_DATA_BEHAVIOR), plus Sheets-only *_FORMATTING dicts importing COLUMN_FORMAT_OPTIONS from sheets_api.
charts.py (454 lines) — core GA fetch helpers (get_data_df, get_df_over_time) needed by _sheets_utils, mixed with matplotlib/IPython notebook plotting.
api.py, entities.py, _sheets_utils.py, static_site/ — the keep-side core.
Steps
- Extract
get_data_df / get_df_over_time (and any pure-fetch helpers they need) from charts.py into a new module (e.g. ga_data.py); update _sheets_utils.py imports.
- Delete the remainder of
charts.py (matplotlib/IPython plotting), and delete sheets_api.py.
- Strip the
*_FORMATTING dicts and the from .sheets_api import COLUMN_FORMAT_OPTIONS import from sheets_elements.py; rename it (e.g. elements.py) and update static_site/fetch.py (from .. import sheets_elements as elements → the new name). Optionally rename _sheets_utils.py similarly.\n4. setup.py: remove gspread, gspread-formatting, matplotlib from install_requires; bump the version (breaking change for any straggler consumer of the deleted modules).
- Regenerate
analytics/requirements.txt without the removed packages.
Verification
python -c 'from analytics.static_site import generate_site' succeeds in a fresh venv without gspread/matplotlib installed.
- Run one full
generate_static_site.py (anvil-explorer) — output data unchanged.
Downstream
After merge, anvilproject/anvil-portal (which installs this package from main) and NIH-NCPI/ncpi-dataset-catalog can finish slimming their requirements — tracked in their per-repo retirement tickets.
Part 3 of retiring the legacy analytics report formats — do this only after #4910 and #4911 are merged (they remove the in-repo consumers of the code deleted here). Completing the dependency-burden rationale from #4910: after this ticket, the package's
install_requiresno longer pulls gspread, gspread-formatting, or matplotlib, and consuming repos (anvil-portal, ncpi-dataset-catalog) can drop those pins from their dependabot-watched requirements.Current structure (verified)
sheets_api.py(493 lines) — pure gspread/Drive/Sheets formatting; only legacy consumers.sheets_elements.py(606 lines) — mostly GA4 element functions the static site needs (get_page_views_change,get_page_views_over_time_df,get_outbound_links_change,get_index_filter_selected_change,get_index_table_download_df,get_bounds_for_month_and_prev,ADDITIONAL_DATA_BEHAVIOR), plus Sheets-only*_FORMATTINGdicts importingCOLUMN_FORMAT_OPTIONSfromsheets_api.charts.py(454 lines) — core GA fetch helpers (get_data_df,get_df_over_time) needed by_sheets_utils, mixed with matplotlib/IPython notebook plotting.api.py,entities.py,_sheets_utils.py,static_site/— the keep-side core.Steps
get_data_df/get_df_over_time(and any pure-fetch helpers they need) fromcharts.pyinto a new module (e.g.ga_data.py); update_sheets_utils.pyimports.charts.py(matplotlib/IPython plotting), and deletesheets_api.py.*_FORMATTINGdicts and thefrom .sheets_api import COLUMN_FORMAT_OPTIONSimport fromsheets_elements.py; rename it (e.g.elements.py) and updatestatic_site/fetch.py(from .. import sheets_elements as elements→ the new name). Optionally rename_sheets_utils.pysimilarly.\n4.setup.py: removegspread,gspread-formatting,matplotlibfrominstall_requires; bump the version (breaking change for any straggler consumer of the deleted modules).analytics/requirements.txtwithout the removed packages.Verification
python -c 'from analytics.static_site import generate_site'succeeds in a fresh venv without gspread/matplotlib installed.generate_static_site.py(anvil-explorer) — output data unchanged.Downstream
After merge, anvilproject/anvil-portal (which installs this package from
main) and NIH-NCPI/ncpi-dataset-catalog can finish slimming their requirements — tracked in their per-repo retirement tickets.