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

Optimize Docker launcher's i18n setup, environment handling, and add automatic temp folder generation #193

Merged
merged 5 commits into from
Sep 6, 2024

Conversation

lcolok
Copy link
Contributor

@lcolok lcolok commented Sep 4, 2024

This PR introduces several improvements to our i18n setup and environment variable handling, as well as addressing the issue of automatic temp file generation. The changes aim to enhance the robustness, efficiency, and internationalization of our project.

Key Changes:

  1. Optimized i18n setup:

    • Improved the setup_i18n function to dynamically set the language based on system settings if not specified in the .env file.
    • Ensured that the chosen language is recorded in the .env file for future use.
  2. Enhanced environment variable handling:

    • Integrated the python-dotenv library for more reliable and efficient .env file operations.
    • Replaced custom .env file read/write operations with python-dotenv's built-in functions.
  3. Automatic temp file generation:

    • Implemented a check for the existence of necessary temp files.
    • Added functionality to automatically generate temp files if they don't exist.
  4. Internationalization improvements:

    • Updated all code comments to English for better international collaboration.
    • Ensured consistent use of lowercase for Docker project names while maintaining the original case for display purposes.
  5. Docker container management enhancements:

    • Improved the stop_and_remove_containers function to more accurately target project-specific containers.
    • Added safeguards against accidentally removing containers from other projects.

Implementation Details:

  • Added python-dotenv as a new dependency.
  • Modified msdl/translations/i18n_setup.py to use python-dotenv for .env file operations.
  • Updated stop_and_remove_containers function in Docker-related scripts to use project-specific naming conventions.
  • Implemented a new function to check and generate temp files as needed.

Testing:

  • Tested the i18n setup with various language settings and system configurations.
  • Verified the correct handling of .env files, including creation, reading, and updating.
  • Confirmed the proper stopping and removal of Docker containers specific to our project.
  • Ensured the automatic generation of temp files works as expected.

Notes:

  • This PR addresses the issue raised in #191 regarding automatic temp file generation.
  • The changes maintain backwards compatibility with existing setups while providing more robust functionality.

Please review these changes and let me know if any further modifications or clarifications are needed.


本 PR 对我们的 i18n 设置和环境变量处理进行了多项改进,同时解决了自动生成临时文件的问题。这些变更旨在提高我们项目的稳健性、效率和国际化水平。

主要更改:

  1. 优化 i18n 设置:

    • 改进了 setup_i18n 函数,使其在 .env 文件未指定语言时能够根据系统设置动态设置语言。
    • 确保选择的语言被记录在 .env 文件中以供将来使用。
  2. 增强环境变量处理:

    • 集成了 python-dotenv 库,以实现更可靠和高效的 .env 文件操作。
    • python-dotenv 的内置函数替换了自定义的 .env 文件读写操作。
  3. 自动生成临时文件:

    • 实现了对必要临时文件存在性的检查。
    • 添加了在临时文件不存在时自动生成的功能。
  4. 国际化改进:

    • 将所有代码注释更新为英文,以促进国际协作。
    • 确保 Docker 项目名称使用小写,同时为显示目的保留原始大小写。
  5. Docker 容器管理增强:

    • 改进了 stop_and_remove_containers 函数,使其更精确地针对特定项目的容器。
    • 增加了防止意外删除其他项目容器的安全措施。

实现细节:

  • 新增 python-dotenv 作为依赖项。
  • 修改 msdl/translations/i18n_setup.py,使用 python-dotenv 进行 .env 文件操作。
  • 更新 Docker 相关脚本中的 stop_and_remove_containers 函数,使用特定项目的命名约定。
  • 实现了新的函数来检查并按需生成临时文件。

测试:

  • 使用各种语言设置和系统配置测试了 i18n 设置。
  • 验证了 .env 文件的正确处理,包括创建、读取和更新。
  • 确认了特定于我们项目的 Docker 容器能够正确停止和移除。
  • 确保临时文件的自动生成功能按预期工作。

注意事项:

  • 本 PR 解决了 #191 中提出的关于自动生成临时文件的问题。
  • 这些更改在提供更强大功能的同时保持了与现有设置的向后兼容性。

请审查这些更改,如需任何进一步的修改或说明,请告知我。

@Harold-lkk Harold-lkk merged commit c32acc9 into InternLM:main Sep 6, 2024
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