Skip to content

feat: add vendor lazy-loader, storage settings - #1482

Merged
SAKURA-CAT merged 3 commits into
mainfrom
feat/vendor
Mar 10, 2026
Merged

SAKURA-CAT merged 3 commits into
mainfrom
feat/vendor

Conversation

@SAKURA-CAT

@SAKURA-CAT SAKURA-CAT commented Mar 10, 2026 •

Copy link
Copy Markdown
Member

Description

添加提供商懒加载和save的s3协议参数,后者主要为未来功能做准备

懒加载的背景是,在之前的开发中有很多按需倒入的包,每次使用try...catch首先比较容易出错,其次无法统一管理报错信息,因此增加了这一特性

同时添加了boto3和botocore的依赖项

此外还修复了一些测试问题

最后更新了issue模版

Introduce an 's3' optional dependency in pyproject.toml (boto3>=1.35.49 and botocore) and update the internal vendor package to advertise and lazily expose boto3 and botocore. The vendor __init__ changes add them to TYPE_CHECKING, __all__, _LAZY_IMPORTS and _EXTRA_DEPS so they can be imported via the vendoring helper and mapped to the new 's3' extra to enable S3-related integrations.
@SAKURA-CAT
SAKURA-CAT requested review from Nexisato and Zeyi-Lin March 10, 2026 07:16
@SAKURA-CAT SAKURA-CAT self-assigned this Mar 10, 2026
@SAKURA-CAT SAKURA-CAT added the 💪 enhancement New feature or request label Mar 10, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求主要引入了第三方库的延迟加载功能,旨在提高应用程序的性能和可维护性,特别是在处理按需导入的包时。同时,它为未来的文件存储功能奠定了基础,通过添加S3协议的配置参数,并引入了相关的依赖项。此外,还对GitHub的Issue模板进行了标准化更新。

Highlights

  • 供应商库延迟加载: 引入了供应商库的延迟加载机制,以优化性能并统一错误管理,避免了在按需导入包时频繁使用try...catch。
  • S3存储设置: 添加了S3存储配置,为未来的文件存储功能奠定了基础,并引入了boto3和botocore作为相关依赖。
  • Issue模板更新: 更新了GitHub Issue模板,增加了type字段以标准化问题分类,使问题管理更加清晰。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .github/ISSUE_TEMPLATE/01_bug_report.yml
    • 添加了type: bug字段。
  • .github/ISSUE_TEMPLATE/02_network_report.yml
    • 添加了type: bug字段。
  • .github/ISSUE_TEMPLATE/03_web_report.yml
    • 添加了type: bug字段。
  • .github/ISSUE_TEMPLATE/04_feature_request.yml
    • 添加了type: feature字段。
  • pyproject.toml
    • 添加了s3可选依赖组,包含boto3和botocore。
  • swanlab/sdk/internal/pkg/vendor/init.py
    • 新增文件,实现了供应商包的延迟加载机制,包括boto3和botocore。
  • swanlab/sdk/internal/settings/init.py
    • 将SaveSettings集成到主Settings类中。
  • swanlab/sdk/internal/settings/s3.py
    • 新增文件,定义了S3存储配置的S3Settings,包含端点验证逻辑。
  • swanlab/sdk/internal/settings/save.py
    • 新增文件,定义了SaveSettings作为各种文件存储设置的容器,初步包含S3。
Activity
  • 此拉取请求目前没有其他活动记录。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a lazy-loading mechanism for optional dependencies and adds S3 configuration for future file storage. While the lazy-loading implementation is well-structured and secure, a critical security concern exists: the S3Settings model in swanlab/sdk/internal/settings/s3.py uses plain strings for sensitive credentials (access_key and secret_key), risking accidental leakage. It is highly recommended to update these fields to use Pydantic's SecretStr for enhanced security. Additionally, the PR could benefit from improvements in dependency management, API design, and the robustness of configuration validation, as detailed in the specific review comments.

Comment thread swanlab/sdk/internal/settings/s3.py
Comment thread swanlab/sdk/internal/settings/s3.py
Comment thread pyproject.toml Outdated
Comment thread swanlab/sdk/internal/pkg/vendor/__init__.py Outdated
Comment thread swanlab/sdk/internal/pkg/vendor/__init__.py Outdated
Add Pydantic before-model validators to reassemble flattened environment variables into nested dicts for Integration (webhook, dashboard) and Save (s3) settings so env-splitting (max_split=1) produces correct nested structures. Change S3 endpoint validation to reject values that include http:// or https:// (guide to use s3_use_ssl instead) instead of silently stripping protocol. Remove botocore from vendor imports and project optional-dependencies, and add unit tests covering integration env parsing and S3 validation/behavior.
@SAKURA-CAT
SAKURA-CAT merged commit a0cf210 into main Mar 10, 2026
21 checks passed
@SAKURA-CAT
SAKURA-CAT deleted the feat/vendor branch March 10, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant