Fix TypeError when simpletuner.__file__ is None during training launch#2585
Merged
Fix TypeError when simpletuner.__file__ is None during training launch#2585
Conversation
Add _get_package_dir() helper to simpletuner/__init__.py that falls back to importlib.util.find_spec when __file__ is None (namespace packages, certain editable installs). Replace all bare simpletuner.__file__ usages with this helper across trainer.py, cli/train.py, paths.py, and tests. Co-authored-by: bghira <59658056+bghira@users.noreply.github.com>
…a test case Co-authored-by: bghira <59658056+bghira@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix TypeError occurring when starting training
Fix TypeError when simpletuner.__file__ is None during training launch
Feb 8, 2026
bghira
approved these changes
Feb 8, 2026
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.
simpletuner.__file__can beNoneunder certain install configurations (namespace packages, some editable installs), causingPath(None)to raiseTypeErrorat training start.Changes
simpletuner/__init__.py— Add_get_package_dir()helper that resolves the package directory via__file__, falling back toimportlib.util.find_spec(checking bothspec.originandspec.submodule_search_locations)trainer.py,cli/train.py,test_e2e_examples.py— Replace all barePath(simpletuner.__file__).parentcalls withsimpletuner._get_package_dir()paths.py— Remove duplicated__file__ is Noneguard inget_simpletuner_root(), delegate to the shared helpertests/test_get_package_dir.py— Tests covering normal path,__file__ = Nonewith importlib fallback, and unresolvable package casesOriginal prompt
This section details on the original issue you should resolve
<issue_title>Training start immediately fails with TypeError</issue_title>
<issue_description>Hi there, thanks for your work on this project. I have been able to run the Web UI in a venv in Linux + ROCm with success, but I get this error always a few seconds after I try to start training:
& Just in case you need the info: