Visualization: Simplify 'author' app, make it linkable and linked from 'contributors' app#107
Merged
Visualization: Simplify 'author' app, make it linkable and linked from 'contributors' app#107
Conversation
This should make the interface a bit more understandable for someone who is not well versed in how PatchScope and this web app works. While at it, rename the controls for selecting JSON file with timeline data, and for selecting specific subset of this JSON file.
The Sankey flow diagram is better suited for showing contributions of an individual author, rather than showing distribution of paths and line types in repository commits.
This function is used to turn full path to input JSON file to the key that is used to select said file. Currently this is the part of basename up to the first '.' - a convention introduced in an earlier commit 377b8e1. With this it would be easy to use this key as query parameter.
Because we want to use the key and not the value of the Select widget, we cannot use pn.state.location.sync(). Instead, we have to synchronize query parameter and the Select widget manually: - setting the value from the query param and setting query param from the value on page load (so that it is always present) follows https://discourse.holoviz.org/t/manually-setting-url-state-with-update-query/3445/2 - setting the query parameter on change is done via param watcher, see https://panel.holoviz.org/how_to/links/watchers.html TODO: do the same for 'author' app, and maybe also to explore apps
Save the values of resample frequency ('freq') and date range ('from')
as query parameters, and recover it from them - synchronize them.
https://panel.holoviz.org/how_to/state/url.html#sync-and-unsync
The idea was copied from 02-contributors_graph.py notebook.
Making it work in similar way to the query parameter with the same name that GitHub now uses for it's per-repo Contributors graph: https://github.blog/changelog/2025-02-25-repositories-updated-insight-views-general-availability/
The function was using %a symbol for abbreviated weekday name, instead of the correct %b symbol for abbreviated month name.
If DEBUG is False, and debbugging and exploratory panels are not shown, there is no need to add extensions useful only for this type of panels.
Not in all cases the name of the author (contributor) is given a name, sometimes what is given is pseudonym; it doesn't look nice if we have mixture of proper names and pseudonyms. Unfortunately in query params are passed URI-encoded, for example 'tycho@tycho.ws' is present in URL as 'tycho%40tycho.ws'.
Make list of authors (author emails) in the Select widget for "author" sorted by the number of contributions (number of commits), descending. This change means that default author would be one with the most commits authored. TODO: Use "<Name> <email>" as user-visible selector, or maybe even "<Name> <email>: <number of commits>".
By itself it does not bring much, but coupled with putting 'repo' into query params it will allow to link to per-author information (the 'author' app) from per-repo information (the 'contributors' app).
Note that fixing this issue exposed another problem with the NaN:
Error running application handler <panel.io.handlers.ScriptHandler object at 0x000001D24E97A6B0>:
ufunc 'isfinite' not supported for the input types, and the inputs
could not be safely coerced to any supported types according to the casting rule ''safe''
File '.venv/[...]/numpy/ma/core.py', line 2415, in masked_invalid:
res = masked_where(~(np.isfinite(a)), a, copy=copy)
Because we want to use the key and not the value of the Select widget, we cannot use pn.state.location.sync(). Instead, we have to synchronize query parameter and the Select widget manually, like it was done for the 'contributors' app in d78a6e9.
Split CMD into multiple lines for better readability, add EXPOSE instruction as a kind of documentation for person running the container: https://docs.docker.com/reference/dockerfile/#expose The container builds and runs without problems.
Configure `panel serve` to to reuse sessions when serving the initial request (there is no per-user state), and to add a global loading spinner to the applications.
This follows the setup for multi-page apps from the documentation: https://panel.holoviz.org/how_to/streamlit_migration/multipage_apps.html The consequence is that with this configuration both of the following URLs points to the same page: http://localhost:7860/ http://localhost:7860/contributors Solving this would probably involve using other server than Bokeh, for example using FastAPI, or something like that. We need to run both 'contributors' and 'author' apps to be able to provide working hyperlinks from 'contributors' to 'author' pages for individual authors.
This link makes it possible to examine specific author in the authors grid part of the 'contributors' app, by going to 'author' page for specific repo and author. Note that currently there is no link in the reverse direction.
In almost all cases path_to_name() was used on strings, and had to convert string to pathlib.Path itself. Make path_to_name() more robust by accepting 'str' typed parameter. Make use of this new feature in the code, simplifying callers.
In the case where there is 'repo' query parameter set, which value is the key that defines input JSON file, the widget that denotes part of data from that file that we want to analyze also needs to be updated. Without this change, when reloading page where 'repo' parameter is set, the second widget in the sidebar gets empty value.
This commit is to have all those different plots available, even when the 'author' app will get simplified.
This turns on exploratory panes: JSON view, tabulators, perspectives, and terminal with debug (log) output. Those were turned off by default in the 'author' app, and remain turned off.
Leave for now only the following plots: - number of commits over time per sample period, full width - -/+ plot of aggregate of -/+ changed lines per sample period - bi-histogram of -/+ change lines per commit - heatmap of -/+ line types over time, full width - local day of the week vs local hour heatmap with marginal histograms, to show periodic behavior, full width TODO: Sankey flow diagram for contributions by given author. NOTE: some variables might be present even if they are not used. Due to the use of reactive expressions (*.rx()), they should not introduce any performance penalty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This series of commits makes both 'contributors' and 'author' parameters to be present as URL. This way they are linkable; there is a link from individual author's cards in 'contributors' app leading to 'author' app with appropriate repo and author selected.
Simplify both 'contributors' and 'author' app by removing exploratory (and debugging) panes at the bottom of each page, moving it to corresponding exploration page (either alone - only the exploratory panes - like in the case of 'contributions', or providing old look - like in the case of 'author').
Improve Dockerfile, to create a multi-page app, instead of starting with app selector.