Skip to content

[MRG] Print survey link upon first launch of GUI or first import#1158

Merged
asoplata merged 6 commits intojonescompneurolab:masterfrom
sketch123456:add-message-upon-install
Feb 11, 2026
Merged

[MRG] Print survey link upon first launch of GUI or first import#1158
asoplata merged 6 commits intojonescompneurolab:masterfrom
sketch123456:add-message-upon-install

Conversation

@sketch123456
Copy link
Contributor

This PR is in regard to issue #1141 .

There is no reliable way to print a message after the user runs pip install that works across all installation methods. It may be done if the user runs the verbose install (pip install -v), but this may not be entirely user-friendly.

As such, my approach to this problem was to print a link to the survey upon the first successful import or the first successful launch of the GUI.

  1. First Import: When a user runs import hnn_core, the message is displayed via hnn_core/__init__.py
  2. First GUI Launch: When a user runs hnn-gui without importing the package directly, the message is displayed via hnn_core/gui/__init__.py

A persistent config file ~/.hnn_core_config.json ensures the message is only shown once, regardless of which interaction path the user takes first.

Changes Made:

  1. Created hnn_core/_first_run.py containing the check_first_run() function that:
  • Checks if ~/.hnn_core_config.json exists
  • Prints the survey message if this is the user's first run
  • Creates the config file to mark that the message has been shown
  1. Updated hnn_core/__init__.py to call check_first_run() to catch first import scenarios
  2. Updated hnn_core/gui/__init__.py to call check_first_run() to catch first GUI launch scenarios

Both implementations wrap the check in try-except blocks to ensure that any errors in displaying the message don't break core functionality.

@asoplata
Copy link
Collaborator

Thanks Karthikeya, unfortunately you seem to be correct, in that pip doesn't appear to have support for a "post-install message" that is separate from the potentially large amount of -v verbose output. I'll ask the dev team what we think about the solution of adding a hidden config file. If we decide that we don't want to spawn such files, we may end up deciding to cancel this feature request. I'll let you know, thanks for your work!

@asoplata asoplata force-pushed the add-message-upon-install branch from 0af4ca5 to 1afe3b7 Compare December 12, 2025 20:40
@asoplata
Copy link
Collaborator

@sketch123456 , I have finished going over your PR and making some changes. Thanks for your contribution! I think it's now ready for review by our other developers.

I've made some changes to the code, but mostly only minor things. However, in order to resolve some merge conflicts, it was easiest to "rebase" the branch, which I have done remotely. In other words, if you want to check out your branch locally on your computer, the history on origin has been changed, and you must delete (or overwrite) your local branch. You can find some guidance on how to do this at our Contributing Guide here https://jonescompneurolab.github.io/hnn-core/stable/contributing.html#keeping-your-code-up-to-date-by-rebasing

@asoplata asoplata moved this from Backlog to In progress in HNN Workspace Turbo 9000 Dec 12, 2025
@asoplata
Copy link
Collaborator

@ntolley @dylansdaniels This is now ready for review by another member of the team (since I edited a bunch of the code). The "flag" file for the survey is now saved to, essentially, <environment>/<python-version>/site-packages/hnn_core/survey_seen.json.

@asoplata asoplata changed the title Print survey link upon first launch of GUI or first import [MRG] Print survey link upon first launch of GUI or first import Dec 12, 2025
@asoplata
Copy link
Collaborator

This will resolve #1141 .

@asoplata asoplata enabled auto-merge (squash) February 5, 2026 19:38
@asoplata
Copy link
Collaborator

This was reviewed in a group Code Review meeting either last week or the week before. Merging after I add in a circleci fix commit.

Currently, both the script and notebook versions of our example file
`examples/workflows/plot_simulate_somato.py` fail because of an upstream
breakage in how the MNE sample data is downloaded and unpacked (see here
fatiando/pooch#518
This change fixes the issue by "capping" the Pooch version to a prior
version which does not contain the bug.
@asoplata asoplata merged commit 5ef4f80 into jonescompneurolab:master Feb 11, 2026
12 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants