danwen-eval 0.1.0__tar.gz
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.
- danwen_eval-0.1.0/LICENSE_POLICY.md +5 -0
- danwen_eval-0.1.0/MANIFEST.in +4 -0
- danwen_eval-0.1.0/PKG-INFO +92 -0
- danwen_eval-0.1.0/README.md +78 -0
- danwen_eval-0.1.0/docs//345/217/221/345/270/203/344/270/216/347/273/264/346/212/244/346/214/207/345/215/227.md +72 -0
- danwen_eval-0.1.0/pyproject.toml +30 -0
- danwen_eval-0.1.0/setup.cfg +4 -0
- danwen_eval-0.1.0/src/danwen_eval/__init__.py +1 -0
- danwen_eval-0.1.0/src/danwen_eval/__main__.py +3 -0
- danwen_eval-0.1.0/src/danwen_eval/cli.py +48 -0
- danwen_eval-0.1.0/src/danwen_eval/third_party/MLflow-LICENSE.txt +202 -0
- danwen_eval-0.1.0/src/danwen_eval/third_party/THIRD_PARTY_NOTICES.txt +10 -0
- danwen_eval-0.1.0/src/danwen_eval.egg-info/PKG-INFO +92 -0
- danwen_eval-0.1.0/src/danwen_eval.egg-info/SOURCES.txt +17 -0
- danwen_eval-0.1.0/src/danwen_eval.egg-info/dependency_links.txt +1 -0
- danwen_eval-0.1.0/src/danwen_eval.egg-info/entry_points.txt +2 -0
- danwen_eval-0.1.0/src/danwen_eval.egg-info/requires.txt +4 -0
- danwen_eval-0.1.0/src/danwen_eval.egg-info/top_level.txt +1 -0
- danwen_eval-0.1.0/tests/test_cli.py +65 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: danwen-eval
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Danwen branded installation and CLI wrapper for MLflow
|
|
5
|
+
Author: 但问智能
|
|
6
|
+
Project-URL: Homepage, https://www.huicewang.com
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE_POLICY.md
|
|
10
|
+
Requires-Dist: mlflow==3.17.2
|
|
11
|
+
Provides-Extra: test
|
|
12
|
+
Requires-Dist: pytest<10,>=8; extra == "test"
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# 但问智测 · danwen-eval
|
|
16
|
+
|
|
17
|
+
北京慧测 · 但问智能 | www.huicewang.com | 官方微信 huice666
|
|
18
|
+
|
|
19
|
+
## 本次交付的定位
|
|
20
|
+
|
|
21
|
+
这是安装与启动封装,不是MLflow源码改名或独立评测引擎。产品名但问智测,Python分发名danwen-eval,模块名danwen_eval,命令名danwen。底层依赖固定为mlflow==3.17.2。不会改变上游网页Logo、标题、路由、SDK/API、认证、存储格式或模型配置。
|
|
22
|
+
|
|
23
|
+
当前为本地构建的0.1.0交付包,**未发布PyPI、没有注册包名,也没有创建线上服务**。在公司正式发布之前,不能宣称直接执行`pip install danwen-eval`就能安装本次包。
|
|
24
|
+
|
|
25
|
+
## 1. 安装交付的wheel(当前即可使用)
|
|
26
|
+
|
|
27
|
+
建议Python3.10及以上,优先使用独立虚拟环境。请先检查交付校验文件,再安装。
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python -m venv .venv
|
|
31
|
+
# Linux / macOS
|
|
32
|
+
source .venv/bin/activate
|
|
33
|
+
# Windows PowerShell改用:.\.venv\Scripts\Activate.ps1
|
|
34
|
+
python -m pip install --upgrade pip
|
|
35
|
+
python -m pip install ./packages/danwen_eval-0.1.0-py3-none-any.whl
|
|
36
|
+
danwen --version
|
|
37
|
+
danwen server --help
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
wheel不包含底层MLflow及其传递依赖;安装时需能够从配置的可信包源下载依赖。仅有本wheel不构成离线安装包。
|
|
41
|
+
|
|
42
|
+
## 2. 本地启动
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
danwen server --host 127.0.0.1 --port 5000
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
浏览器访问http://127.0.0.1:5000。服务器运行在前台,使用Ctrl+C停止。默认数据库与Artifact行为继承上游;请在固定工作目录运行,先验证再迁移实际资产。
|
|
49
|
+
|
|
50
|
+
也可以显式设置数据库与文件Artifact根(示例路径需确保可写):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
danwen server --host 127.0.0.1 --port 5000 \
|
|
54
|
+
--backend-store-uri sqlite:///danwen.db \
|
|
55
|
+
--default-artifact-root ./artifacts
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
模块入口等价:`python -m danwen_eval server --help`。除`danwen --help/-h`和`danwen --version`外,参数原样传递给上游CLI,包含未知参数和上游返回码。客户端仍使用真实`mlflow` SDK及`MLFLOW_TRACKING_URI`。
|
|
59
|
+
|
|
60
|
+
## 3. 远程访问与安全边界
|
|
61
|
+
|
|
62
|
+
若要让客户远程连接,需另行配置监听地址、上游allowed-hosts、反向代理TLS、认证与网络访问控制。不要在公网直接暴露未经认证的服务,也不要将allowed-hosts设置为通配符作为生产配置。公司包名不会自动提供登录、RBAC、数据隔离或企业许可校验。
|
|
63
|
+
|
|
64
|
+
## 4. 源码开发与测试
|
|
65
|
+
|
|
66
|
+
在project目录下执行:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
python -m pip install -e '.[test]'
|
|
70
|
+
python -m pytest -q
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 5. 构建与发布
|
|
74
|
+
|
|
75
|
+
详见docs/发布与维护指南.md。公开PyPI、私有仓库和离线分发是不同的交付方式。发布账户、包名所有权、软件许可和生产安全需由公司确认。
|
|
76
|
+
|
|
77
|
+
## 第三方来源
|
|
78
|
+
|
|
79
|
+
底层MLflow:https://github.com/mlflow/mlflow ,Apache License 2.0。上游原名、版权与许可保留;本包不声明上游引擎为自主原创。许可证及说明随wheel中的danwen_eval/third_party交付。公司自有封装代码许可在正式对外发布前另行确认,见LICENSE_POLICY.md。
|
|
80
|
+
|
|
81
|
+
## 本次服务验证与资源提示
|
|
82
|
+
|
|
83
|
+
在Linux/Python3.13独立虚拟环境,wheel安装和14项测试通过。真实服务HTTP验证采用单worker,显式设置`MLFLOW_SERVER_ENABLE_JOB_EXECUTION=false`:首页、/version、/health均200,服务正常关闭。这只验证基础服务,不验证后台评测任务。
|
|
84
|
+
|
|
85
|
+
首次保留默认后台任务的尝试到达启动日志后进程被终止,未完成HTTP验收,终止根因未确定。低资源环境可临时用以下命令排查基础启动;这不是完整功能或生产建议:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Linux / macOS,仅基础服务排查;禁用后台任务会影响相关异步功能
|
|
89
|
+
MLFLOW_SERVER_ENABLE_JOB_EXECUTION=false danwen server --host 127.0.0.1 --port 5000 --workers 1
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Windows PowerShell需先设置`$env:MLFLOW_SERVER_ENABLE_JOB_EXECUTION="false"`,排查后移除该环境变量;Windows本次未实测。正式使用后台任务前需单独验证资源、依赖、任务执行与停止行为。封装包自身不会默认关闭后台任务,也不会自动降低上游worker数量。
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# 但问智测 · danwen-eval
|
|
2
|
+
|
|
3
|
+
北京慧测 · 但问智能 | www.huicewang.com | 官方微信 huice666
|
|
4
|
+
|
|
5
|
+
## 本次交付的定位
|
|
6
|
+
|
|
7
|
+
这是安装与启动封装,不是MLflow源码改名或独立评测引擎。产品名但问智测,Python分发名danwen-eval,模块名danwen_eval,命令名danwen。底层依赖固定为mlflow==3.17.2。不会改变上游网页Logo、标题、路由、SDK/API、认证、存储格式或模型配置。
|
|
8
|
+
|
|
9
|
+
当前为本地构建的0.1.0交付包,**未发布PyPI、没有注册包名,也没有创建线上服务**。在公司正式发布之前,不能宣称直接执行`pip install danwen-eval`就能安装本次包。
|
|
10
|
+
|
|
11
|
+
## 1. 安装交付的wheel(当前即可使用)
|
|
12
|
+
|
|
13
|
+
建议Python3.10及以上,优先使用独立虚拟环境。请先检查交付校验文件,再安装。
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
python -m venv .venv
|
|
17
|
+
# Linux / macOS
|
|
18
|
+
source .venv/bin/activate
|
|
19
|
+
# Windows PowerShell改用:.\.venv\Scripts\Activate.ps1
|
|
20
|
+
python -m pip install --upgrade pip
|
|
21
|
+
python -m pip install ./packages/danwen_eval-0.1.0-py3-none-any.whl
|
|
22
|
+
danwen --version
|
|
23
|
+
danwen server --help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
wheel不包含底层MLflow及其传递依赖;安装时需能够从配置的可信包源下载依赖。仅有本wheel不构成离线安装包。
|
|
27
|
+
|
|
28
|
+
## 2. 本地启动
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
danwen server --host 127.0.0.1 --port 5000
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
浏览器访问http://127.0.0.1:5000。服务器运行在前台,使用Ctrl+C停止。默认数据库与Artifact行为继承上游;请在固定工作目录运行,先验证再迁移实际资产。
|
|
35
|
+
|
|
36
|
+
也可以显式设置数据库与文件Artifact根(示例路径需确保可写):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
danwen server --host 127.0.0.1 --port 5000 \
|
|
40
|
+
--backend-store-uri sqlite:///danwen.db \
|
|
41
|
+
--default-artifact-root ./artifacts
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
模块入口等价:`python -m danwen_eval server --help`。除`danwen --help/-h`和`danwen --version`外,参数原样传递给上游CLI,包含未知参数和上游返回码。客户端仍使用真实`mlflow` SDK及`MLFLOW_TRACKING_URI`。
|
|
45
|
+
|
|
46
|
+
## 3. 远程访问与安全边界
|
|
47
|
+
|
|
48
|
+
若要让客户远程连接,需另行配置监听地址、上游allowed-hosts、反向代理TLS、认证与网络访问控制。不要在公网直接暴露未经认证的服务,也不要将allowed-hosts设置为通配符作为生产配置。公司包名不会自动提供登录、RBAC、数据隔离或企业许可校验。
|
|
49
|
+
|
|
50
|
+
## 4. 源码开发与测试
|
|
51
|
+
|
|
52
|
+
在project目录下执行:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python -m pip install -e '.[test]'
|
|
56
|
+
python -m pytest -q
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 5. 构建与发布
|
|
60
|
+
|
|
61
|
+
详见docs/发布与维护指南.md。公开PyPI、私有仓库和离线分发是不同的交付方式。发布账户、包名所有权、软件许可和生产安全需由公司确认。
|
|
62
|
+
|
|
63
|
+
## 第三方来源
|
|
64
|
+
|
|
65
|
+
底层MLflow:https://github.com/mlflow/mlflow ,Apache License 2.0。上游原名、版权与许可保留;本包不声明上游引擎为自主原创。许可证及说明随wheel中的danwen_eval/third_party交付。公司自有封装代码许可在正式对外发布前另行确认,见LICENSE_POLICY.md。
|
|
66
|
+
|
|
67
|
+
## 本次服务验证与资源提示
|
|
68
|
+
|
|
69
|
+
在Linux/Python3.13独立虚拟环境,wheel安装和14项测试通过。真实服务HTTP验证采用单worker,显式设置`MLFLOW_SERVER_ENABLE_JOB_EXECUTION=false`:首页、/version、/health均200,服务正常关闭。这只验证基础服务,不验证后台评测任务。
|
|
70
|
+
|
|
71
|
+
首次保留默认后台任务的尝试到达启动日志后进程被终止,未完成HTTP验收,终止根因未确定。低资源环境可临时用以下命令排查基础启动;这不是完整功能或生产建议:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Linux / macOS,仅基础服务排查;禁用后台任务会影响相关异步功能
|
|
75
|
+
MLFLOW_SERVER_ENABLE_JOB_EXECUTION=false danwen server --host 127.0.0.1 --port 5000 --workers 1
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Windows PowerShell需先设置`$env:MLFLOW_SERVER_ENABLE_JOB_EXECUTION="false"`,排查后移除该环境变量;Windows本次未实测。正式使用后台任务前需单独验证资源、依赖、任务执行与停止行为。封装包自身不会默认关闭后台任务,也不会自动降低上游worker数量。
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# 但问智测封装包发布与维护指南
|
|
2
|
+
|
|
3
|
+
## 一、命名与版本
|
|
4
|
+
- 公司:但问智能;产品:但问智测。
|
|
5
|
+
- 分发包danwen-eval;模块danwen_eval;命令danwen。
|
|
6
|
+
- 当前封装0.1.0依赖MLflow3.17.2,二者版本独立。
|
|
7
|
+
- PyPI名称规范化会将连字符/下划线/点视为等价;名称可用性以实际上传审核为准,不能仅凭查询404认定已拥有名称。
|
|
8
|
+
|
|
9
|
+
## 二、公开发布前的检查清单
|
|
10
|
+
1. 公司账号、邮箱、2FA及项目权限归公司管理,确认包名可创建。
|
|
11
|
+
2. 确认自有封装的分发许可;本工程未擅自替公司授予开源许可。需要时增加LICENSE文件、pyproject license及license-files配置,重建wheel。
|
|
12
|
+
3. 保留第三方许可与归属,检查固定发行版及传递依赖的适用许可/NOTICE。包内上游许可证与来源URL不替代完整的生产合规审查。
|
|
13
|
+
4. 在目标Python/操作系统/安装源上验证;本次实测环境以验证记录为准,不把跨平台元数据等同实际兼容性。
|
|
14
|
+
5. 固定底层依赖,执行单测、wheel安装、help/版本、真实服务启停、存储持久化与升级回滚验证。
|
|
15
|
+
6. 只将公司认可的发行物上传仓库。打包前检查无密钥、数据库、缓存、个人配置与客户数据。
|
|
16
|
+
|
|
17
|
+
## 三、构建
|
|
18
|
+
在project目录执行:
|
|
19
|
+
```bash
|
|
20
|
+
python -m pip install --upgrade build twine
|
|
21
|
+
python -m build
|
|
22
|
+
python -m twine check dist/*
|
|
23
|
+
```
|
|
24
|
+
构建wheel和sdist。这是源代码构建步骤,交付包中的packages已包含本次构建产物。
|
|
25
|
+
|
|
26
|
+
## 四、TestPyPI验证
|
|
27
|
+
注册https://test.pypi.org/,使用安全配置的凭据:
|
|
28
|
+
```bash
|
|
29
|
+
python -m twine upload --repository testpypi dist/*
|
|
30
|
+
```
|
|
31
|
+
在全新虚拟环境中先从正式可信包源安装MLflow依赖,再仅从TestPyPI安装自己的包:
|
|
32
|
+
```bash
|
|
33
|
+
python -m pip install 'mlflow==3.17.2'
|
|
34
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps 'danwen-eval==0.1.0'
|
|
35
|
+
danwen --version
|
|
36
|
+
danwen server --help
|
|
37
|
+
```
|
|
38
|
+
--no-deps仅用于此依赖已准备好的测试步骤,不是客户正常安装方式。不要为解决测试依赖而随意混用不受控包源。
|
|
39
|
+
|
|
40
|
+
## 五、正式PyPI发布
|
|
41
|
+
https://pypi.org/与TestPyPI是独立仓库,账户/名称/Token需分别配置。自动发布优先使用Trusted Publishing;手工发布使用公司安全管理的Token,禁止写入源码或交付包。
|
|
42
|
+
```bash
|
|
43
|
+
python -m twine upload dist/*
|
|
44
|
+
```
|
|
45
|
+
**以上上传命令本次均未执行。** 上传成功并验证后,客户才使用:
|
|
46
|
+
```bash
|
|
47
|
+
python -m pip install --upgrade danwen-eval
|
|
48
|
+
danwen server
|
|
49
|
+
```
|
|
50
|
+
PyPI同一文件/版本不能当作可覆盖发布物。修复后提高版本号,重建、重新测试再发布。
|
|
51
|
+
|
|
52
|
+
## 六、私有仓库
|
|
53
|
+
如只面向企业客户,可使用受控私有索引。将实际私有/simple地址作为唯一index-url,并确保仓库能够代理/提供完整依赖。HTTPS、认证、名称保留与依赖混淆防护须单独验收,不把客户Token写到命令样例或仓库。
|
|
54
|
+
|
|
55
|
+
## 七、离线安装
|
|
56
|
+
当前wheel不包含依赖。联网构建机需为客户目标Python/平台准备完整wheelhouse,并检查所有依赖的许可证。可在匹配目标环境执行:
|
|
57
|
+
```bash
|
|
58
|
+
python -m pip download --dest wheelhouse ./danwen_eval-0.1.0-py3-none-any.whl
|
|
59
|
+
```
|
|
60
|
+
客户安装:
|
|
61
|
+
```bash
|
|
62
|
+
python -m pip install --no-index --find-links ./wheelhouse danwen-eval
|
|
63
|
+
```
|
|
64
|
+
涉及无预编译wheel的依赖须先完成目标平台构建。不同操作系统、CPU或Python版本不可直接共用依赖集合。本次未构建完整离线wheelhouse。
|
|
65
|
+
|
|
66
|
+
## 八、维护策略
|
|
67
|
+
升级上游时调整明确的依赖版本、提高封装版本并重新验证。保存Python、上游和封装版本、数据库备份和升级脚本。本包只固定直接依赖,传递依赖不是完整锁定;生产应维护分平台锁文件或验证后的wheelhouse。
|
|
68
|
+
|
|
69
|
+
当前CLI使用os.execv调用当前Python的mlflow模块,不启动额外shell。POSIX下进程替换有利于继承退出/信号;Windows/macOS及systemd、Docker、Kubernetes托管行为仍须目标环境验证。正式运行使用进程管理与备份策略,不将CLI当作高可用服务管理器。
|
|
70
|
+
|
|
71
|
+
## 九、后续网页品牌化
|
|
72
|
+
本次不修改网页。如要改Logo/标题/文案,建立固定版本源码分支,构建前端和发行产物;不要安装后直接覆盖site-packages。新增企业规则、DeepSeek接入与回归报告可作为自有模块逐步加入,不以换名替代实际研发。
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "danwen-eval"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Danwen branded installation and CLI wrapper for MLflow"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [{name = "但问智能"}]
|
|
12
|
+
dependencies = ["mlflow==3.17.2"]
|
|
13
|
+
|
|
14
|
+
[project.optional-dependencies]
|
|
15
|
+
test = ["pytest>=8,<10"]
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://www.huicewang.com"
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
danwen = "danwen_eval.cli:main"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["src"]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.package-data]
|
|
27
|
+
danwen_eval = ["third_party/*"]
|
|
28
|
+
|
|
29
|
+
[tool.pytest.ini_options]
|
|
30
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""但问智测品牌安装与命令行入口;底层依赖MLflow。"""
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Thin CLI wrapper: preserve upstream arguments, exit status and process signals."""
|
|
2
|
+
from importlib import metadata
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
HELP = """但问智测 · 智能体评测平台
|
|
7
|
+
北京慧测 · 但问智能
|
|
8
|
+
|
|
9
|
+
用法:
|
|
10
|
+
danwen server [参数] 启动底层服务
|
|
11
|
+
danwen server --help 查看服务参数
|
|
12
|
+
danwen --version 查看封装包与底层版本
|
|
13
|
+
python -m danwen_eval ... 等价模块入口
|
|
14
|
+
|
|
15
|
+
除本页帮助和--version外,参数原样转交MLflow CLI。
|
|
16
|
+
本包仅封装安装和启动,不修改MLflow网页、API或Python SDK。
|
|
17
|
+
官网:www.huicewang.com | 官方微信:huice666
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _version(name):
|
|
22
|
+
try:
|
|
23
|
+
return metadata.version(name)
|
|
24
|
+
except metadata.PackageNotFoundError:
|
|
25
|
+
return None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def main(argv=None):
|
|
29
|
+
args = list(sys.argv[1:] if argv is None else argv)
|
|
30
|
+
if not args or args in (["--help"], ["-h"]):
|
|
31
|
+
print(HELP)
|
|
32
|
+
return 0
|
|
33
|
+
if args == ["--version"]:
|
|
34
|
+
print(f"但问智测 danwen-eval {_version('danwen-eval') or 'not-installed'}")
|
|
35
|
+
print(f"MLflow backend {_version('mlflow') or 'not-installed'}")
|
|
36
|
+
return 0
|
|
37
|
+
if _version("mlflow") is None:
|
|
38
|
+
print("缺少MLflow依赖,请在当前Python环境重新安装danwen-eval(不要使用--no-deps)。", file=sys.stderr)
|
|
39
|
+
return 2
|
|
40
|
+
try:
|
|
41
|
+
# No shell, no argument interpolation. Replace the wrapper process rather
|
|
42
|
+
# than orphaning a long-lived server behind an extra subprocess layer.
|
|
43
|
+
# POSIX signal/exit behavior is verified; Windows requires separate QA.
|
|
44
|
+
os.execv(sys.executable, [sys.executable, "-m", "mlflow", *args])
|
|
45
|
+
except OSError as exc:
|
|
46
|
+
print(f"无法启动底层命令:{exc}", file=sys.stderr)
|
|
47
|
+
return 126
|
|
48
|
+
return 0 # Only reachable with an execv test double.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Copyright 2018 Databricks, Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MLflow 3.17.2
|
|
2
|
+
Source: https://github.com/mlflow/mlflow/tree/v3.17.2
|
|
3
|
+
License source: https://raw.githubusercontent.com/mlflow/mlflow/v3.17.2/LICENSE.txt
|
|
4
|
+
License: Apache License 2.0
|
|
5
|
+
Copyright notice is retained in MLflow-LICENSE.txt.
|
|
6
|
+
|
|
7
|
+
This package supplies a separate Danwen installation and CLI wrapper. It does not
|
|
8
|
+
rename or claim authorship of the MLflow engine. MLflow is installed as a separate
|
|
9
|
+
dependency; its installed distribution retains its own license files/notices.
|
|
10
|
+
Other transitive dependencies retain their respective licenses.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: danwen-eval
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Danwen branded installation and CLI wrapper for MLflow
|
|
5
|
+
Author: 但问智能
|
|
6
|
+
Project-URL: Homepage, https://www.huicewang.com
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE_POLICY.md
|
|
10
|
+
Requires-Dist: mlflow==3.17.2
|
|
11
|
+
Provides-Extra: test
|
|
12
|
+
Requires-Dist: pytest<10,>=8; extra == "test"
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# 但问智测 · danwen-eval
|
|
16
|
+
|
|
17
|
+
北京慧测 · 但问智能 | www.huicewang.com | 官方微信 huice666
|
|
18
|
+
|
|
19
|
+
## 本次交付的定位
|
|
20
|
+
|
|
21
|
+
这是安装与启动封装,不是MLflow源码改名或独立评测引擎。产品名但问智测,Python分发名danwen-eval,模块名danwen_eval,命令名danwen。底层依赖固定为mlflow==3.17.2。不会改变上游网页Logo、标题、路由、SDK/API、认证、存储格式或模型配置。
|
|
22
|
+
|
|
23
|
+
当前为本地构建的0.1.0交付包,**未发布PyPI、没有注册包名,也没有创建线上服务**。在公司正式发布之前,不能宣称直接执行`pip install danwen-eval`就能安装本次包。
|
|
24
|
+
|
|
25
|
+
## 1. 安装交付的wheel(当前即可使用)
|
|
26
|
+
|
|
27
|
+
建议Python3.10及以上,优先使用独立虚拟环境。请先检查交付校验文件,再安装。
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python -m venv .venv
|
|
31
|
+
# Linux / macOS
|
|
32
|
+
source .venv/bin/activate
|
|
33
|
+
# Windows PowerShell改用:.\.venv\Scripts\Activate.ps1
|
|
34
|
+
python -m pip install --upgrade pip
|
|
35
|
+
python -m pip install ./packages/danwen_eval-0.1.0-py3-none-any.whl
|
|
36
|
+
danwen --version
|
|
37
|
+
danwen server --help
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
wheel不包含底层MLflow及其传递依赖;安装时需能够从配置的可信包源下载依赖。仅有本wheel不构成离线安装包。
|
|
41
|
+
|
|
42
|
+
## 2. 本地启动
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
danwen server --host 127.0.0.1 --port 5000
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
浏览器访问http://127.0.0.1:5000。服务器运行在前台,使用Ctrl+C停止。默认数据库与Artifact行为继承上游;请在固定工作目录运行,先验证再迁移实际资产。
|
|
49
|
+
|
|
50
|
+
也可以显式设置数据库与文件Artifact根(示例路径需确保可写):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
danwen server --host 127.0.0.1 --port 5000 \
|
|
54
|
+
--backend-store-uri sqlite:///danwen.db \
|
|
55
|
+
--default-artifact-root ./artifacts
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
模块入口等价:`python -m danwen_eval server --help`。除`danwen --help/-h`和`danwen --version`外,参数原样传递给上游CLI,包含未知参数和上游返回码。客户端仍使用真实`mlflow` SDK及`MLFLOW_TRACKING_URI`。
|
|
59
|
+
|
|
60
|
+
## 3. 远程访问与安全边界
|
|
61
|
+
|
|
62
|
+
若要让客户远程连接,需另行配置监听地址、上游allowed-hosts、反向代理TLS、认证与网络访问控制。不要在公网直接暴露未经认证的服务,也不要将allowed-hosts设置为通配符作为生产配置。公司包名不会自动提供登录、RBAC、数据隔离或企业许可校验。
|
|
63
|
+
|
|
64
|
+
## 4. 源码开发与测试
|
|
65
|
+
|
|
66
|
+
在project目录下执行:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
python -m pip install -e '.[test]'
|
|
70
|
+
python -m pytest -q
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 5. 构建与发布
|
|
74
|
+
|
|
75
|
+
详见docs/发布与维护指南.md。公开PyPI、私有仓库和离线分发是不同的交付方式。发布账户、包名所有权、软件许可和生产安全需由公司确认。
|
|
76
|
+
|
|
77
|
+
## 第三方来源
|
|
78
|
+
|
|
79
|
+
底层MLflow:https://github.com/mlflow/mlflow ,Apache License 2.0。上游原名、版权与许可保留;本包不声明上游引擎为自主原创。许可证及说明随wheel中的danwen_eval/third_party交付。公司自有封装代码许可在正式对外发布前另行确认,见LICENSE_POLICY.md。
|
|
80
|
+
|
|
81
|
+
## 本次服务验证与资源提示
|
|
82
|
+
|
|
83
|
+
在Linux/Python3.13独立虚拟环境,wheel安装和14项测试通过。真实服务HTTP验证采用单worker,显式设置`MLFLOW_SERVER_ENABLE_JOB_EXECUTION=false`:首页、/version、/health均200,服务正常关闭。这只验证基础服务,不验证后台评测任务。
|
|
84
|
+
|
|
85
|
+
首次保留默认后台任务的尝试到达启动日志后进程被终止,未完成HTTP验收,终止根因未确定。低资源环境可临时用以下命令排查基础启动;这不是完整功能或生产建议:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# Linux / macOS,仅基础服务排查;禁用后台任务会影响相关异步功能
|
|
89
|
+
MLFLOW_SERVER_ENABLE_JOB_EXECUTION=false danwen server --host 127.0.0.1 --port 5000 --workers 1
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Windows PowerShell需先设置`$env:MLFLOW_SERVER_ENABLE_JOB_EXECUTION="false"`,排查后移除该环境变量;Windows本次未实测。正式使用后台任务前需单独验证资源、依赖、任务执行与停止行为。封装包自身不会默认关闭后台任务,也不会自动降低上游worker数量。
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
LICENSE_POLICY.md
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
docs/发布与维护指南.md
|
|
6
|
+
src/danwen_eval/__init__.py
|
|
7
|
+
src/danwen_eval/__main__.py
|
|
8
|
+
src/danwen_eval/cli.py
|
|
9
|
+
src/danwen_eval.egg-info/PKG-INFO
|
|
10
|
+
src/danwen_eval.egg-info/SOURCES.txt
|
|
11
|
+
src/danwen_eval.egg-info/dependency_links.txt
|
|
12
|
+
src/danwen_eval.egg-info/entry_points.txt
|
|
13
|
+
src/danwen_eval.egg-info/requires.txt
|
|
14
|
+
src/danwen_eval.egg-info/top_level.txt
|
|
15
|
+
src/danwen_eval/third_party/MLflow-LICENSE.txt
|
|
16
|
+
src/danwen_eval/third_party/THIRD_PARTY_NOTICES.txt
|
|
17
|
+
tests/test_cli.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
danwen_eval
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import metadata
|
|
5
|
+
import pytest
|
|
6
|
+
from danwen_eval import cli
|
|
7
|
+
|
|
8
|
+
@pytest.mark.parametrize("args", [[], ["--help"], ["-h"]])
|
|
9
|
+
def test_brand_help(args, monkeypatch, capsys):
|
|
10
|
+
monkeypatch.setattr(os, "execv", lambda *a: pytest.fail("help must not exec"))
|
|
11
|
+
assert cli.main(args) == 0
|
|
12
|
+
out = capsys.readouterr().out
|
|
13
|
+
assert "但问智测" in out and "不修改MLflow网页" in out
|
|
14
|
+
|
|
15
|
+
def test_version(monkeypatch, capsys):
|
|
16
|
+
monkeypatch.setattr(cli, "_version", lambda n: {"danwen-eval":"0.1.0", "mlflow":"3.17.2"}[n])
|
|
17
|
+
assert cli.main(["--version"]) == 0
|
|
18
|
+
out = capsys.readouterr().out
|
|
19
|
+
assert "0.1.0" in out and "3.17.2" in out
|
|
20
|
+
|
|
21
|
+
@pytest.mark.parametrize("args", [
|
|
22
|
+
["server", "--host", "127.0.0.1", "--port", "5000"],
|
|
23
|
+
["server", "--backend-store-uri", "sqlite:///a path/test.db"],
|
|
24
|
+
["server", "--default-artifact-root", "x; echo unsafe"],
|
|
25
|
+
["unknown-command", "--unknown-option"],
|
|
26
|
+
])
|
|
27
|
+
def test_exec_preserves_arguments(args, monkeypatch):
|
|
28
|
+
seen=[]
|
|
29
|
+
monkeypatch.setattr(cli, "_version", lambda n:"3.17.2")
|
|
30
|
+
monkeypatch.setattr(os, "execv", lambda *a:seen.append(a))
|
|
31
|
+
assert cli.main(args)==0
|
|
32
|
+
assert seen==[(sys.executable,[sys.executable,"-m","mlflow",*args])]
|
|
33
|
+
|
|
34
|
+
def test_missing_dependency(monkeypatch, capsys):
|
|
35
|
+
monkeypatch.setattr(cli, "_version", lambda n:None)
|
|
36
|
+
monkeypatch.setattr(os, "execv", lambda *a:pytest.fail("missing dep must not exec"))
|
|
37
|
+
assert cli.main(["server"])==2
|
|
38
|
+
assert "缺少MLflow依赖" in capsys.readouterr().err
|
|
39
|
+
|
|
40
|
+
def test_exec_failure(monkeypatch, capsys):
|
|
41
|
+
monkeypatch.setattr(cli, "_version", lambda n:"3.17.2")
|
|
42
|
+
def fail(*args): raise OSError("test failure")
|
|
43
|
+
monkeypatch.setattr(os, "execv", fail)
|
|
44
|
+
assert cli.main(["server"])==126
|
|
45
|
+
assert "无法启动" in capsys.readouterr().err
|
|
46
|
+
|
|
47
|
+
def test_metadata_missing(monkeypatch):
|
|
48
|
+
def missing(name):raise metadata.PackageNotFoundError(name)
|
|
49
|
+
monkeypatch.setattr(metadata,"version",missing)
|
|
50
|
+
assert cli._version("missing") is None
|
|
51
|
+
|
|
52
|
+
def test_module_entrypoint():
|
|
53
|
+
p=subprocess.run([sys.executable,"-m","danwen_eval","--version"],capture_output=True,text=True,check=True)
|
|
54
|
+
assert "danwen-eval 0.1.0" in p.stdout
|
|
55
|
+
assert "MLflow backend 3.17.2" in p.stdout
|
|
56
|
+
|
|
57
|
+
def test_real_upstream_help():
|
|
58
|
+
p=subprocess.run([sys.executable,"-m","danwen_eval","server","--help"],capture_output=True,text=True,check=True,timeout=60)
|
|
59
|
+
assert "--backend-store-uri" in p.stdout
|
|
60
|
+
|
|
61
|
+
def test_upstream_error_exit_code():
|
|
62
|
+
args=["server","--danwen-invalid-test-option"]
|
|
63
|
+
direct=subprocess.run([sys.executable,"-m","mlflow",*args],capture_output=True,text=True,timeout=60)
|
|
64
|
+
wrapped=subprocess.run([sys.executable,"-m","danwen_eval",*args],capture_output=True,text=True,timeout=60)
|
|
65
|
+
assert direct.returncode==wrapped.returncode==2
|