cal-itp / data-analyses

Place for sharing quick reports, and works in progress
https://analysis.calitp.org
26 stars 5 forks source link

Feature Request: JupyterBook Layout Control #1036

Closed edasmalchi closed 3 months ago

edasmalchi commented 7 months ago

Where does your feature apply? Select from the below, and be sure to affix the appropriate label to this issue (e.g. dataset, jupyterhub, metabase, analytics.calitp.org)

Is your feature request related to a problem? Please describe. We've updated to the latest JupyterBook version, which makes things a little narrower by default. However, it also includes a way to designate cell outputs for additional width via tags.

Describe the solution you'd like Analysts able to specify cells for additional width (and possibly other page layout controls such as sidebar) when running parameterized notebooks via the portfolio script.

Describe alternatives you've considered

  1. Doing nothing and having analyses with large maps and figures being kinda squished.
  2. Following existing pattern in portfolio script, use a new cell magic such as %%full_width to signal the portfolio script to append the "full-width" tag to that cell. Requires corresponding change to calitp_data_analysis.magics
  3. Same as 2, but add corresponding magic/tag pair for sidebar as well.
  4. ~Use existing %%capture_parameters cell magic~ and portfolio logic. Revise portfolio script to append all tags provided in an iterable passed via ~capture_parameters~, i.e.
    
    ~%%capture_parameters~
    organization_name = rt_day.organization_name
    jupyterbook_append_tags = ['full-width']
    organization_name, jupyterbook_append_tags

output

{"organization_name": "Santa Barbara Metropolitan Transit District", "jupyterbook_append_tags": ["full-width"]}


No change required to calitp_data_analysis.magics, additionally provides flexibility to append any set of tags to any cell. Would require supporting documentation, since appended tags would necessarily be per-cell while all other user-set parameters would persist.
_edit, won't work with `%%capture_parameters` but overall concept would still work for a new magic allowing flexibility_
5. Something else?

@tiffanychu90 thoughts? I'm leaning towards 4.

**Additional context**
Current state with narrowed content:
![Screenshot 2024-02-21 175011](https://github.com/cal-itp/data-analyses/assets/54728455/1eb8f96b-76ea-4c5f-aac6-763a684cd399)
edasmalchi commented 6 months ago

Tried it out last week, was able to inject the "full-width" tag using the portfolio script but speedmaps didn't render properly. Reverted back for now and will revisit when time allows

tiffanychu90 commented 6 months ago
edasmalchi commented 3 months ago

@tiffanychu90 maybe we can close this one? Looks like you've set it up to do full-width by default, which is fine by me!

tiffanychu90 commented 3 months ago

@tiffanychu90 maybe we can close this one? Looks like you've set it up to do full-width by default, which is fine by me!

I think it has a workaround - which is someone manually tagging the cells (see pic), and then the portfolio.py can pick up that tag and overwrite it.