Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

sycommon-python-lib

盛业 Python 公共库 — AI/LLM 生态(langchain/langgraph/deepagents/MCP/ACP/pi)的集成层 + 公司 Java starter jar 包的 Python 原生等价物。与 sycommon-go-lib 契约三端一致(同一 Java 上游、同一键名/键值/阈值/退避参数)。

安装(内网 Nexus):

pip install sycommon-python-lib -i http://192.168.2.174:8081/repository/pypy-group/simple/ --trusted-host 192.168.2.174

包结构

包 说明
sycommon/agent/ DeepAgents/多 Agent 团队/沙箱(HOME 泄露封堵+seatbelt)/ACP/sensitive·skill-write·sandbox-path 守卫中间件
sycommon/llm/ LLM 客户端封装、tiktoken 缓存、Langfuse/LangSmith
sycommon/pi/ pi coding agent 移植
sycommon/alert/ 分级告警(对齐 Java alert-sdk,见下)
sycommon/logging/ Kafka 日志 + L1-L4 分级脱敏引擎
sycommon/rabbitmq/ MQ 客户端/延迟队列/审计存储(对齐 Java starter-mq)
sycommon/synacos/ Nacos 注册/配置/Feign/BizReject
sycommon/database/ MySQL/Redis/ES/分布式锁/TxnRef
sycommon/config/ YAML 单例 + nacos 分层读(read_key_layered)
sycommon/middleware/ CORS/Trace/上下文
sycommon/notice/ 企微通知/进程监控
sycommon/xxljob/ XXL-Job + 分片广播
sycommon/tools/ audit/excel/tree/money/sso_token/usercache 等基础件
sycommon/services.py Services.plugins 统一装配入口(FastAPI 生命周期、默认挂载件)

与 Java jar 包的对齐(分级告警/日志/MQ/基础件)

公司 Java starter/common jar 包(字节码反编译逐类对齐)的 Python 原生等价物。sycommon-go-lib 的对应包与这里契约三端一致(同一 Java 上游),跨语言互通按下列对照表核验:

分级告警 — sycommon/alert/ ↔ Java shengye-platform-alert-sdk(1.0.0-SNAPSHOT,47 类反编译)

Java jar 组件 Python 实现 说明
AlertSdk 四级告警(fatal/critical/warn/info × title/detail/Throwable 重载矩阵) alert/api.py:fatal/critical/warn/info + biz_*(templateNo 前置=BizAlertSdk) AlertAo 15 字段/优先级(fatal=100/critical=50/warn=20)/compareTo 排序序/hutool 4.6.1 JSON 序列化形态逐字段对齐
InnerSdk 发送通道(批量投递/优先级队列) alert/sdk.py + queue.py(BoundedAlarmQueue) 队列满驱逐最低优先最旧、SelfCheck 自检通道、网关 URL 按 profile 路由(wsdev/wsuat1/prod)对齐
AlertEnv 配置读取 alert/env.py relaxed binding(SY_ALERT_MONITOR_ENABLE ↔ sy-alert.monitor.enable)/nacos 分层(read_key_layered)对齐
GcMonitor(排除 young GC 的 GC 占比监控) alert/monitor.py _gc_monitor_loop gc.callbacks start/stop 计时差累计(真·时间占比);阈值 falt 0.5/critical 0.2/warning 0.05;msg 模板逐字节同;告警 msg 追加分代窗口增量 (分代: gen0=+N ... /stats gen0=X)(Go 侧无分代概念,此为 Python 独有诊断增强)
DatasourceMonitor(连接池饱和度) monitor.py register_db_stats + bridge.py SQLAlchemy engine.pool.status() 注入;阈值 0.7/0.8/0.95 与 4 字段 desc 对齐
spring.factories 自动挂载 services.py 生命周期 6.5 步 → bridge.init_alert_monitors() 引入基础包即集成;sy-alert.monitor.enable 默认 false 零行为变化

分级日志脱敏 — sycommon/logging/ ↔ Java shengye-platform-starter-log 2.0.0-SNAPSHOT

Java jar 组件 Python 实现 说明
MaskEngine/MaskUtil L1-L4 分级脱敏 logging/mask_engine.py + log_masker.py 快照构建/levels 解析/shouldMask 状态机/慢告警/nacos 热更新(MaskConfigRefresher 同款 reload 回调);len≤7 全 x/全串匹配/逐键分层三锚点
LogModel 三方 29 字段表 logging/kafka_log.py pSpanId/pAgentId 等逐字段对齐;msg 819200/detail 102400 双限长分离;getFormattedMessage 解包对齐
Kafka 日志投递 logging/bounded_kafka_sink.py 有界队列治 loguru enqueue 无界 OOM;信封与 Java starter-log 平台侧契约一致

MQ — sycommon/rabbitmq/ + synacos/ ↔ Java shengye-platform-starter-mq(1.0.0-SNAPSHOT,22 类逆向)

Java jar 组件 Python 实现 说明
消费失败告警 MqAlertHelper alert/mq_alert.py Redis SETNX 限频(mq:alert:throttle:{topic},300s)/topic 维度/manualFlag 不进计数链
BizRejectException(588) synacos/feign.py BizRejectError 588 业务拒绝语义化;必须在 except Exception 之前放行(语义化拒绝不被兜底吞掉)
消费重投退避 RabbitAwareBeanPostProcessor rabbitmq/delay_queue.py 20s/×5/120s cap(可配 MQ_RETRY_BACKOFF_MS);DLX/retry-wait 档位拓扑
MqHelperDao/MqRetryThread rabbitmq/mq_store.py tk_mq_msg 持久化 + 重试线程,自动建表 DDL 同款;无 DB/Redis 静默降级纯直发
FeignRequestInterceptor synacos/feign.py token 重签(reqSource=服务名/全键 ALWAYS/password 剥离/username 派生/时间格式归一)+ inner=1
消费 ACK 语义/header/traceId 契约 rabbitmq/rabbitmq_client.py 等 handler 成功后 ack + Redis 计数重试;SSOUser 消费链路恢复

Java 基础件九件套(与 go-lib α.65 同基线)

Java 上游 Python 实现
starter-redis DistributedLock database/distlock.py(锁键前缀 dstc:lock: 三端统一;Lua 值相等才删)
common-web TxnRefUtils database/txnref.py
common-web AuditUtils.log tools/audit.py
common-core ExcelHelper tools/excel.py
common-core TreeUtils tools/tree.py
starter-task ShardingUtils xxljob/sharding.py
CrossTenantContext models/ 跨租户上下文
common-web 用户缓存 tools/usercache.py
common-core MoneyUtils tools/money.py(金额大写)

对齐方法论:Java 侧以字节码反编译为唯一事实源,逐常量池/逐分支核对;每项对齐后跑对抗复审。历史轮次见 git log(Java/jar 关键词):0.2.10a11 信封字段、a15/a17 feign 重签 + MQ 全量、a22 GC 真实时长占比。sycommon-go-lib(infra/alert/、infra/logs/mask_engine.go、infra/rabbitmq/、infra/redis/{distlock,txnref,usercache}.go、core/{excel,tree,money}.go 等)与这里共享同一 Java 基线,跨语言契约(键前缀/阈值/退避参数/信封字段)变更时三端同步。


Getting started

To make it easy for you to get started with GitLab, here's a list of recommended next steps.

Already a pro? Just edit this README.md and make it your own. Want to make it easy? Use the template at the bottom!

Add your files

cd existing_repo
git remote add origin http://git.syf.com/syai/sycommon-python-lib.git
git branch -M main
git push -uf origin main

Integrate with your tools

Collaborate with your team

Test and Deploy

Use the built-in continuous integration in GitLab.


Editing this README

When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to makeareadme.com for this template.

Suggestions for a good README

Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.

Name

Choose a self-explaining name for your project.

Description

Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.

Badges

On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.

Visuals

Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.

Installation

Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.

Usage

Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.

Support

Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.

Roadmap

If you have ideas for releases in the future, it is a good idea to list them in the README.

Contributing

State if you are open to contributions and what your requirements are for accepting them.

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.

Authors and acknowledgment

Show your appreciation to those who have contributed to the project.

License

For open source projects, say how it is licensed.

Project status

If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

Metadata

Release files for sycommon-python-lib 0.2.12a20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sycommon-python-lib 0.2.12a20
File Size Uploaded Provenance Actions
sycommon_python_lib-0.2.12a20.tar.gz 3.7 MB Without provenance Details for sycommon_python_lib-0.2.12a20.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sycommon-python-lib 0.2.12a20
File Interpreter ABI Platform Actions
sycommon_python_lib-0.2.12a20-py3-none-any.whl Python 3 none any Details for sycommon_python_lib-0.2.12a20-py3-none-any.whl

Total release size: 7.6 MB

Release files / sycommon_python_lib-0.2.12a20.tar.gz

Download URL sycommon_python_lib-0.2.12a20.tar.gz
Size 3.7 MB
Tags Source
SHA-256 checksum
How to use checksums
7bdacb2f0c977c702191b8aa35a42026c8ff07dd33fdace98c10e857b006575e
BLAKE2b-256 checksum
How to use checksums
a7f8e2c435d01efc3f7546bd8c07de5a32893808dcfd4b834d4c353ab49b0a93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / sycommon_python_lib-0.2.12a20-py3-none-any.whl

Download URL sycommon_python_lib-0.2.12a20-py3-none-any.whl
Size 3.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1ee3bd642b95e63caeb0cfa3665b4c33d7fe959fe2fbff5788757df7e945b8b9
BLAKE2b-256 checksum
How to use checksums
c22bae404fa1db44c2ff47cd126990cdee1265af0e9a705050b4d994e3bc3e24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for sycommon-python-lib 0.2.12a20

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page