Repository navigation
An installed tiktoken that cannot load its encoding no longer takes the engine down (#3791) - #4064
Merged
Merged
Conversation
…takes the engine down detector.py loads tiktoken's cl100k_base at import time and caught only ImportError. Offline -- an air-gapped site, a proxy, a sandbox -- get_encoding raises a network error when the encoding is not cached, and `import gitgalaxy.core.detector` (galaxyscope, every engine test) failed. Any exception from loading the encoding now leaves HAS_TIKTOKEN False: token mass is NULL, missing_dependencies() reports tiktoken, the run is labelled Zero-Dependency Mode -- as when tiktoken is not installed -- and one warning names the cause and TIKTOKEN_CACHE_DIR. HAS_TIKTOKEN is set only after the encoding loads. The porting tickets' tokenizer already handled this (#3863). Test: a fresh interpreter with a tiktoken whose get_encoding raises ConnectionError imports the engine, HAS_TIKTOKEN is False and token mass is None (fails before the fix). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ
Contributor
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.
Closes #3791.
gitgalaxy/core/detector.pyloads tiktoken'scl100k_baseat import time and caught onlyImportError. Offline (an air-gapped site, a proxy, a sandbox),get_encodingraises a network error when the encoding is not cached. That madeimport gitgalaxy.core.detectorfail, which took downgalaxyscopeand every engine test.Fix
HAS_TIKTOKENFalse.HAS_TIKTOKENis set only after the encoding loads.missing_dependencies()reports tiktoken, and the run is labelled Zero-Dependency Mode.TIKTOKEN_CACHE_DIR.The porting tickets' tokenizer already handled this (#3863).
Test (
tests/core_engine/test_zero_dependency.py): a fresh interpreter, given atiktokenwhoseget_encodingraisesConnectionError, imports the engine withHAS_TIKTOKENFalse and token mass None. The test fails without the fix.tests/core_enginepasses (2,072), andaudit_checkis clear.🤖 Generated with Claude Code
https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ