Skip to content

Conversation

@ruck94301
Copy link
Contributor

@ruck94301 ruck94301 commented Dec 12, 2025

This PR introduces feature that assesses the config of userdata folders.

This feature is by default off, to allow developers to demo it on demand, for now.
To enable, give option like
LabGym --enable assess_userdata_folders
If you don't do that, then this feature does nothing, because the call to userdata_survey.survey returns early.

This addresses each of several conditions:
if the test for the condition is True, then, log a message, and
Action: show the message in a gui dialog

This PR is a first step towards a better action, which might yet be developed...

  • Action: display detailed user guidance to resolve, or,
  • or, Action: provide a reference to documentation
  • or, Action: automatically fix it

But either way, this PR is the basis to work from, because it has 4 conditions implemented.
This PR is important whether ultimately user-facing instructions are issued, or automated fix is implemented.

The four conditions whose assessment is implemented are:

  1. Verify the separation of configuration's userdata dirs.
    If not separate, then display an error message, then sys.exit().

  2. Check for userdata dirs that are defined/configured as
    "external" to LabGym, but don't exist. If any, then warn.

  3. Check for userdata dirs that are defined/configured as
    "internal" to LabGym. If any, then warn.

  4. For any userdata dirs configured as external to LabGym tree,
    if there is "orphaned" data, remaining in the "traditional"
    location (internal, within the LabGym tree), then warn.

bring_to_foreground is implemented as a method in the registration dialog object.
It's actually general, affecting the app, not specifically the dialog object.
This commit moves it to a function in mywx, so it can be used even if registration dialog isn't employed.
During the preliminary probes,
call  userdata_survey.survey()
(which for now is a skeleton implementation)
to check for user data in deprecated locations inside the LabGym software tree.
implement verify_userdata_dir_separation, and call it from userdata_survey.survey().
Implement offer_mkdir_userdata function, and call it from userdata_survey.survey().
Weird, somehow I inadvertantly deleted it??  Or poor git skils, IDK.
Remove mywx.App function implementation.
Instead, on load of mywx, patch wx.App to be a "strict singleton".
Reorganize imports so that the load of mywx happens prior to the load of wx.
45 unit tests 100% pass, all in one pytest session, and also each in a separate pytest session.
This addresses a deprecation warning :-/.
Although we think of modules as "singletons",
module py-files inside packages might be loaded/executed more than once, if developers don't maintain consistency of importing as pkg.modulename.  I don't see a way to ensure developer consistency, so I'm adding an attribute to the patched wx module so I no longer depend on wxpy.py being imported/loaded only once.
Eliminate superfluous bring_wxapp_to_foreground.
9 unit tests in test_userdata_survey.py
1 bugfix in mywx/patch.py
2 bugfix in userdata_survey.py
To enable, use
    --enable assess_userdata_folders
Also, scrub the early-exit developers crutch
    --enable userdata_survey_exit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mywx.py is replaced by mywx package

@ruck94301
Copy link
Contributor Author

ok, I see, this is a false alarm from unit test, so now I'll fix the unit test.

@yujiahu415
Copy link
Collaborator

And also, John, I think we should make the pipeline of using external Detector/Categorizer folder when using pyinstaller implementation parallel to the pypi implementation so that users who already installed LabGym with python3 and pypi don't need to go the other route for updating LabGym. And the pypi way should be the default since this GitHub repo is linked to pypi and directly generate releases pypi.

should have been removesuffix(), not rstrip
userdata_survey.open_html_in_browser() isn't used by the LabGym sw.
Taking it and it's unittest out, because although the unittest worked on Linux & macOS, it errored on Windows.
@yujiahu415 yujiahu415 merged commit 56b81de into umyelab:master Dec 15, 2025
4 checks passed
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.

2 participants