-
-
Notifications
You must be signed in to change notification settings - Fork 953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(translation): decouple translation from typesetting #330
Draft
awwaawwa
wants to merge
40
commits into
Byaidu:main
Choose a base branch
from
awwaawwa:fast_translate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+642
−245
Conversation
This file contains 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
- add tortoise-orm>=0.22.2 to dependencies for database support
- update runner image to python 3.12 bookworm-slim for better compatibility - use uv instead of pip
- update runner to 'ubuntu-latest'
- update uv pip install command to include --system flag
- include creation of virtual environment using `uv venv`
- set ignore rules for specific flake8 checks - configure max line length to 88 characters
- include pep8-naming in the dev dependencies array - aim to improve code style adherence to PEP 8 naming conventions
This reverts commit ace5eb2.
- rename findSID to find_sid to align with snake_case naming convention
- remove tortoise-orm>=0.22.2 from dependencies - add peewee>=3.17.8 to dependencies
- introduce peewee ORM for database management - add `_TranslationCache` model with unique constraints - implement `TranslationCache` class for clean API usage - add `init_db` function to initialize database - improve translation cache handling with database storage
- bind and initialize in-memory test database for isolated testing - add tests for translation cache operations and engine distinction - include additional scenarios for parameter-based cache separation - ensure cleanup and teardown after tests to maintain test consistency
…test has no practical significance Although this test set the number of threads to 2, it did not test parallel translation paths. This test was actually directly testing BaseTranslator.
- implement a method to recursively sort dictionaries and lists in translation parameters - ensure translation engine parameters are serialized consistently for caching
- include tests for non-string parameter serialization to JSON - test consistent serialization of dicts regardless of key order - validate cache behavior with sorted parameter inputs - add tests for nested and complex parameter structures
- fix issue with incorrect handling of translate_engine_params types - ensure nested dictionaries are sorted recursively before conversion to JSON
- separate `update_params` method for better readability
- update parameter type annotations for clarity - improve default parameter handling in update_params method - ensure thread safety considerations are noted in comments
- add tests for thread safety in cache operations - ensure that all operations are consistent and correct under load
- rename update_params to replace_params for clarity - refactor related method calls to maintain consistency
- change method name for clarity and consistency - update related test cases to reflect the new method name
- rename the `translate` function to `do_translate`, making it easier for subclasses to override. - Implement cache-related processing in BaseTranslator. - Add parameters that affect translation results to the cache key.
- implement unit tests for translation caching functionalities - ensure cache interacts correctly with different input cases - verify cache behavior with overridden translations and parameters
- add test case to check translation without cache - assert results are not equal when ignoring cache
- implement test to ensure BaseTranslator raises NotImplementedError - verify that the translate method is not implemented for base class
- First phase generates translation cache - Second phase reformats using cache
Open
Closed
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.
#216
Currently, I have it running locally, with the effect shown in the following figure:
Breaking Change: