Skip to content
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
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

awwaawwa
Copy link
Contributor

@awwaawwa awwaawwa commented Dec 23, 2024

#216

Currently, I have it running locally, with the effect shown in the following figure:
CleanShot 2024-12-24 at 02 56 48@2x

Breaking Change:

  1. Progress bar is inaccurate
  2. Added some temporary log prints, will change to logger later
  3. The relevant code is written in high_level.translate, and the API backend does not benefit from it.
  4. Forced decoupling, the code looks very messy and difficult
  5. Cancel might be temporarily broken too? Let's check it out later.

- 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
- 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
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.

1 participant