sycommon-python-lib 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sycommon-python-lib might be problematic. Click here for more details.

@@ -0,0 +1,11 @@
1
+ import uuid
2
+
3
+
4
+ class Snowflake:
5
+ @staticmethod
6
+ def next_id():
7
+ hex = uuid.uuid4().hex
8
+ uuid_int = int(hex, 16)
9
+ uuid_str = str(uuid_int).zfill(32)
10
+ id_str = uuid_str[:19]
11
+ return str(int(id_str))
@@ -0,0 +1,73 @@
1
+ from decorator import decorator
2
+ import time
3
+ from typing import Any
4
+
5
+ from sycommon.logging.kafka_log import SYLogger
6
+
7
+
8
+ @decorator
9
+ def timing(func, tag: str = None, *args, **kw):
10
+ """
11
+ 记录函数执行耗时的装饰器,支持普通函数、生成器和异步生成器
12
+
13
+ 参数:
14
+ tag: 日志前缀标签
15
+ """
16
+ start_time = time.perf_counter()
17
+
18
+ try:
19
+ result = func(*args, **kw)
20
+ except Exception as e:
21
+ end_time = time.perf_counter()
22
+ _log_timing(func, end_time - start_time, tag, error=str(e))
23
+ raise e
24
+
25
+ # 处理同步生成器
26
+ if _is_generator(result):
27
+ def wrapped_generator():
28
+ try:
29
+ yield from result
30
+ finally:
31
+ end_time = time.perf_counter()
32
+ _log_timing(func, end_time - start_time, tag)
33
+ return wrapped_generator()
34
+
35
+ # 处理异步生成器
36
+ elif _is_async_generator(result):
37
+ async def wrapped_async_generator():
38
+ try:
39
+ async for item in result:
40
+ yield item
41
+ finally:
42
+ end_time = time.perf_counter()
43
+ _log_timing(func, end_time - start_time, tag)
44
+ return wrapped_async_generator()
45
+
46
+ # 普通函数返回值
47
+ else:
48
+ end_time = time.perf_counter()
49
+ _log_timing(func, end_time - start_time, tag)
50
+ return result
51
+
52
+
53
+ def _is_generator(obj: Any) -> bool:
54
+ """检查对象是否为生成器"""
55
+ return hasattr(obj, '__iter__') and hasattr(obj, '__next__')
56
+
57
+
58
+ def _is_async_generator(obj: Any) -> bool:
59
+ """检查对象是否为异步生成器"""
60
+ return hasattr(obj, '__aiter__') and hasattr(obj, '__anext__')
61
+
62
+
63
+ def _log_timing(func, duration: float, tag: str = None, error: str = None):
64
+ """格式化并记录耗时信息"""
65
+ base_msg = f"Function '{func.__name__}' executed in {duration:.4f} seconds"
66
+
67
+ if tag:
68
+ base_msg = f"{tag} {base_msg}"
69
+
70
+ if error:
71
+ SYLogger.error(f"{base_msg} (Error: {error})")
72
+ else:
73
+ SYLogger.info(base_msg)
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.4
2
+ Name: sycommon-python-lib
3
+ Version: 0.1.0
4
+ Summary: Add your description here
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: aiohttp>=3.12.13
8
+ Requires-Dist: cx-oracle>=8.3.0
9
+ Requires-Dist: decorator>=5.2.1
10
+ Requires-Dist: fastapi>=0.115.14
11
+ Requires-Dist: kafka>=1.3.5
12
+ Requires-Dist: kafka-python>=2.2.14
13
+ Requires-Dist: loguru>=0.7.3
14
+ Requires-Dist: mysql-connector-python>=9.3.0
15
+ Requires-Dist: nacos-sdk-python>=2.0.6
16
+ Requires-Dist: pydantic>=2.11.7
17
+ Requires-Dist: python-dotenv>=1.1.1
18
+ Requires-Dist: pyyaml>=6.0.2
19
+ Requires-Dist: sqlalchemy>=2.0.41
20
+ Requires-Dist: uuid>=1.30
21
+
22
+ # sycommon-python-lib
23
+
24
+ 常用 python 依赖库
25
+
26
+ pip install sycommon-python-lib -i http://192.168.2.174:8081/repository/pypy-group/simple/ --trusted-host 192.168.2.174
27
+
28
+ ## Getting started
29
+
30
+ To make it easy for you to get started with GitLab, here's a list of recommended next steps.
31
+
32
+ Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
33
+
34
+ ## Add your files
35
+
36
+ - [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
37
+ - [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
38
+
39
+ ```
40
+ cd existing_repo
41
+ git remote add origin http://git.syf.com/syai/sycommon-python-lib.git
42
+ git branch -M main
43
+ git push -uf origin main
44
+ ```
45
+
46
+ ## Integrate with your tools
47
+
48
+ - [ ] [Set up project integrations](http://git.syf.com/syai/sycommon-python-lib/-/settings/integrations)
49
+
50
+ ## Collaborate with your team
51
+
52
+ - [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
53
+ - [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
54
+ - [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
55
+ - [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
56
+ - [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
57
+
58
+ ## Test and Deploy
59
+
60
+ Use the built-in continuous integration in GitLab.
61
+
62
+ - [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
63
+ - [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
64
+ - [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
65
+ - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
66
+ - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
67
+
68
+ ---
69
+
70
+ # Editing this README
71
+
72
+ 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](https://www.makeareadme.com/) for this template.
73
+
74
+ ## Suggestions for a good README
75
+
76
+ 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.
77
+
78
+ ## Name
79
+
80
+ Choose a self-explaining name for your project.
81
+
82
+ ## Description
83
+
84
+ 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.
85
+
86
+ ## Badges
87
+
88
+ 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.
89
+
90
+ ## Visuals
91
+
92
+ 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.
93
+
94
+ ## Installation
95
+
96
+ 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.
97
+
98
+ ## Usage
99
+
100
+ 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.
101
+
102
+ ## Support
103
+
104
+ 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.
105
+
106
+ ## Roadmap
107
+
108
+ If you have ideas for releases in the future, it is a good idea to list them in the README.
109
+
110
+ ## Contributing
111
+
112
+ State if you are open to contributions and what your requirements are for accepting them.
113
+
114
+ 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.
115
+
116
+ 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.
117
+
118
+ ## Authors and acknowledgment
119
+
120
+ Show your appreciation to those who have contributed to the project.
121
+
122
+ ## License
123
+
124
+ For open source projects, say how it is licensed.
125
+
126
+ ## Project status
127
+
128
+ 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.
@@ -0,0 +1,35 @@
1
+ sycommon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ sycommon/services.py,sha256=rEp_CWbqnVQCWxeoSD-4K1cvlQiejf59UIuxkTWxr50,1111
3
+ sycommon/config/Config.py,sha256=rSqr-6QIf4ISbfkGffqKhrZrSV4K_9QEXEmTPjnJ28c,3023
4
+ sycommon/config/DatabaseConfig.py,sha256=ILiUuYT9_xJZE2W-RYuC3JCt_YLKc1sbH13-MHIOPhg,804
5
+ sycommon/config/EmbeddingConfig.py,sha256=IttRubiVOVG30F15HJsnBoF-j5HrC6IX63Y_eAtGt4k,363
6
+ sycommon/config/LLMConfig.py,sha256=yU-aIqePIeF6msfRVEtGq7SXZVDfHyTi6JduKjhMO_4,371
7
+ sycommon/config/RerankerConfig.py,sha256=dohekaY_eTynmMimIuKHBYGXXQO6rJjSkm94OPLuMik,322
8
+ sycommon/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ sycommon/database/database_service.py,sha256=B9tCaMsKGK87XF20YQh-eGupa3dq0JXymKnAAJvS2DQ,3060
10
+ sycommon/health/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ sycommon/health/health_check.py,sha256=KhRkHEvTMH0Ygtaq7IByFevMnaTPD1NnU6EAirRnqO8,387
12
+ sycommon/health/ping.py,sha256=FTlnIKk5y1mPfS1ZGOeT5IM_2udF5aqVLubEtuBp18M,250
13
+ sycommon/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ sycommon/logging/kafka_log.py,sha256=BvKKWQgb3GV1rK72fl6RqIT4XW77h9H1cRRO2UuHWmg,21377
15
+ sycommon/logging/logger_wrapper.py,sha256=TiHsrIIHiQMzXgXK12-0KIpU9GhwQJOoHslakzmq2zc,357
16
+ sycommon/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ sycommon/middleware/context.py,sha256=_5ghpv4u_yAvjkgM-XDx8OnO-YI1XtntHrXsHJHZkwo,88
18
+ sycommon/middleware/cors.py,sha256=bGwDPI5Bfr0yH0hM-K7wK8mur5YqTy_XVZqlsdY_WdU,301
19
+ sycommon/middleware/exception.py,sha256=Bk8IchNND1wg6tUX9hf4xWeEJhvA-E_zE9ysBpRZrqE,3010
20
+ sycommon/middleware/middleware.py,sha256=US14Y2dF1vgxxoMLi5o3PAJ6A46CaleKzmc4_D8hVzs,990
21
+ sycommon/middleware/monitor_memory.py,sha256=pYRK-wRuDd6enSg9Pf8tQxPdYQS6S0AyjyXeKFRLKEs,628
22
+ sycommon/middleware/timeout.py,sha256=fImlAPLm4Oa8N9goXtT_0os1GZPCi9F92OgXU81DgDU,656
23
+ sycommon/middleware/traceid.py,sha256=2QtyyOlSOB6QnGyZatevxUYyrzicbVD1ROA3KXn2SEo,5470
24
+ sycommon/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
+ sycommon/models/log.py,sha256=rZpj6VkDRxK3B6H7XSeWdYZshU8F0Sks8bq1p6pPlDw,500
26
+ sycommon/synacos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ sycommon/synacos/feign.py,sha256=oXRPqBY95UumhhNcy3-v3gSFb-32NgLdk_V3dHfdAaY,12311
28
+ sycommon/synacos/nacos_service.py,sha256=uhXBfldoV_tOPi_GlbGLnjQl7kk_ps5wL9FAfIuDCx0,29497
29
+ sycommon/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ sycommon/tools/snowflake.py,sha256=rc-VUjBMMpdAvbnHroVwfVt1xzApJbTCthUy9mglAuw,237
31
+ sycommon/tools/timing.py,sha256=OiiE7P07lRoMzX9kzb8sZU9cDb0zNnqIlY5pWqHcnkY,2064
32
+ sycommon_python_lib-0.1.0.dist-info/METADATA,sha256=KtaZG_RGceNzvW9oMSIgdxn5lnhhClUiNqRaUArGCso,7003
33
+ sycommon_python_lib-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ sycommon_python_lib-0.1.0.dist-info/top_level.txt,sha256=qb-vRf3lrmIaCLrGZxsv6k8Q8l3_lGuAeFtwjh0wYCQ,9
35
+ sycommon_python_lib-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ sycommon