msdev 0.9.0__tar.gz → 0.10.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.
Files changed (75) hide show
  1. msdev-0.10.0/LICENSE +124 -0
  2. msdev-0.9.0/README.md → msdev-0.10.0/PKG-INFO +28 -24
  3. msdev-0.9.0/src/msdev.egg-info/PKG-INFO → msdev-0.10.0/README.md +4 -33
  4. msdev-0.10.0/pyproject.toml +49 -0
  5. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/__init__.py +1 -1
  6. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/cli.py +0 -32
  7. msdev-0.10.0/src/msdev/core/container_helper.py +244 -0
  8. msdev-0.10.0/src/msdev/core/helper_deploy.py +143 -0
  9. msdev-0.10.0/src/msdev/core/host_files.py +92 -0
  10. msdev-0.10.0/src/msdev/core/host_mutations.py +332 -0
  11. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/inventory.py +6 -1
  12. msdev-0.10.0/src/msdev/core/multiplex.py +143 -0
  13. msdev-0.10.0/src/msdev/core/request_client.py +174 -0
  14. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/resources.py +1 -64
  15. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/services/__init__.py +13 -0
  16. msdev-0.10.0/src/msdev/core/services/capabilities.py +135 -0
  17. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/services/node.py +1 -25
  18. msdev-0.10.0/src/msdev/core/services/results.py +65 -0
  19. msdev-0.10.0/src/msdev/core/stream_limits.py +17 -0
  20. msdev-0.10.0/src/msdev/core/stream_server.py +596 -0
  21. msdev-0.10.0/src/msdev/core/stream_transport.py +353 -0
  22. msdev-0.10.0/src/msdev/core/streamproto.py +129 -0
  23. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/transport.py +23 -31
  24. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/workspace/__init__.py +8 -1
  25. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/workspace/client.py +55 -0
  26. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/workspace/paths.py +21 -1
  27. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/workspace/registry.py +42 -4
  28. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/daemon.py +187 -48
  29. {msdev-0.9.0 → msdev-0.10.0/src/msdev.egg-info}/PKG-INFO +21 -26
  30. {msdev-0.9.0 → msdev-0.10.0}/src/msdev.egg-info/SOURCES.txt +24 -2
  31. {msdev-0.9.0 → msdev-0.10.0}/tests/test_cli.py +16 -37
  32. {msdev-0.9.0 → msdev-0.10.0}/tests/test_cli_only_architecture.py +1 -32
  33. msdev-0.10.0/tests/test_container_helper.py +234 -0
  34. {msdev-0.9.0 → msdev-0.10.0}/tests/test_daemon.py +140 -60
  35. msdev-0.10.0/tests/test_daemon_container_stream.py +83 -0
  36. msdev-0.10.0/tests/test_docker_stream_dispatch.py +232 -0
  37. msdev-0.10.0/tests/test_helper_deploy.py +185 -0
  38. {msdev-0.9.0 → msdev-0.10.0}/tests/test_msdev_cli_skill.py +11 -21
  39. msdev-0.10.0/tests/test_multiplex.py +190 -0
  40. {msdev-0.9.0 → msdev-0.10.0}/tests/test_node_env_config.py +2 -48
  41. msdev-0.10.0/tests/test_request_client.py +235 -0
  42. msdev-0.10.0/tests/test_stream_server.py +503 -0
  43. msdev-0.10.0/tests/test_stream_transport.py +309 -0
  44. msdev-0.10.0/tests/test_streamproto.py +65 -0
  45. msdev-0.9.0/tests/test_resource_guides.py → msdev-0.10.0/tests/test_target_guides.py +0 -18
  46. {msdev-0.9.0 → msdev-0.10.0}/tests/test_transport.py +30 -124
  47. {msdev-0.9.0 → msdev-0.10.0}/tests/test_workspace.py +26 -8
  48. {msdev-0.9.0 → msdev-0.10.0}/tests/test_workspace_client.py +12 -26
  49. msdev-0.9.0/pyproject.toml +0 -28
  50. {msdev-0.9.0 → msdev-0.10.0}/setup.cfg +0 -0
  51. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/__init__.py +0 -0
  52. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/config.py +0 -0
  53. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/guides.py +0 -0
  54. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/limits.py +0 -0
  55. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/services/context.py +0 -0
  56. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/services/environment.py +0 -0
  57. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/services/execution.py +0 -0
  58. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/services/model.py +0 -0
  59. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/services/npu.py +0 -0
  60. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/services/workspace.py +0 -0
  61. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/core/workspace/access.py +0 -0
  62. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/session/__init__.py +0 -0
  63. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/session/export.py +0 -0
  64. {msdev-0.9.0 → msdev-0.10.0}/src/msdev/session/log.py +0 -0
  65. {msdev-0.9.0 → msdev-0.10.0}/src/msdev.egg-info/dependency_links.txt +0 -0
  66. {msdev-0.9.0 → msdev-0.10.0}/src/msdev.egg-info/entry_points.txt +0 -0
  67. {msdev-0.9.0 → msdev-0.10.0}/src/msdev.egg-info/top_level.txt +0 -0
  68. {msdev-0.9.0 → msdev-0.10.0}/tests/test_cli_session.py +0 -0
  69. {msdev-0.9.0 → msdev-0.10.0}/tests/test_config.py +0 -0
  70. {msdev-0.9.0 → msdev-0.10.0}/tests/test_inventory.py +0 -0
  71. {msdev-0.9.0 → msdev-0.10.0}/tests/test_model_cli.py +0 -0
  72. {msdev-0.9.0 → msdev-0.10.0}/tests/test_model_services.py +0 -0
  73. {msdev-0.9.0 → msdev-0.10.0}/tests/test_node_env_services.py +0 -0
  74. /msdev-0.9.0/tests/test_node_execution_services.py → /msdev-0.10.0/tests/test_target_exec_services.py +0 -0
  75. {msdev-0.9.0 → msdev-0.10.0}/tests/test_workspace_services.py +0 -0
msdev-0.10.0/LICENSE ADDED
@@ -0,0 +1,124 @@
1
+ 木兰宽松许可证, 第2版
2
+
3
+ 2020年1月 http://license.coscl.org.cn/MulanPSL2
4
+
5
+ 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
6
+
7
+ 0. 定义
8
+
9
+ “软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
10
+
11
+ “贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
12
+
13
+ “贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
14
+
15
+ “法人实体” 是指提交贡献的机构及其“关联实体”。
16
+
17
+ “关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
18
+
19
+ 1. 授予版权许可
20
+
21
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
22
+
23
+ 2. 授予专利许可
24
+
25
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
26
+
27
+ 3. 无商标许可
28
+
29
+ “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
30
+
31
+ 4. 分发限制
32
+
33
+ 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
34
+
35
+ 5. 免责声明与责任限制
36
+
37
+ “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
38
+
39
+ 6. 语言
40
+
41
+ “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
42
+
43
+ 条款结束
44
+
45
+ 如何将木兰宽松许可证,第2版,应用到您的软件
46
+
47
+ 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
48
+
49
+ 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
50
+
51
+ 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
52
+
53
+ 3, 请将如下声明文本放入每个源文件的头部注释中。
54
+
55
+ Copyright (c) [Year] [name of copyright holder]
56
+ [Software Name] is licensed under Mulan PSL v2.
57
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
58
+ You may obtain a copy of Mulan PSL v2 at:
59
+ http://license.coscl.org.cn/MulanPSL2
60
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
61
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
62
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
63
+ See the Mulan PSL v2 for more details.
64
+ Mulan Permissive Software License,Version 2
65
+ Mulan Permissive Software License,Version 2 (Mulan PSL v2)
66
+
67
+ January 2020 http://license.coscl.org.cn/MulanPSL2
68
+
69
+ Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
70
+
71
+ 0. Definition
72
+
73
+ Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
74
+
75
+ Contribution means the copyrightable work licensed by a particular Contributor under this License.
76
+
77
+ Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
78
+
79
+ Legal Entity means the entity making a Contribution and all its Affiliates.
80
+
81
+ Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
82
+
83
+ 1. Grant of Copyright License
84
+
85
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
86
+
87
+ 2. Grant of Patent License
88
+
89
+ Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
90
+
91
+ 3. No Trademark License
92
+
93
+ No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4.
94
+
95
+ 4. Distribution Restriction
96
+
97
+ You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
98
+
99
+ 5. Disclaimer of Warranty and Limitation of Liability
100
+
101
+ THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
102
+
103
+ 6. Language
104
+
105
+ THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
106
+
107
+ END OF THE TERMS AND CONDITIONS
108
+
109
+ How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
110
+
111
+ To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
112
+
113
+ Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
114
+ Create a file named "LICENSE" which contains the whole context of this License in the first directory of your software package;
115
+ Attach the statement to the appropriate annotated syntax at the beginning of each source file.
116
+ Copyright (c) [Year] [name of copyright holder]
117
+ [Software Name] is licensed under Mulan PSL v2.
118
+ You can use this software according to the terms and conditions of the Mulan PSL v2.
119
+ You may obtain a copy of Mulan PSL v2 at:
120
+ http://license.coscl.org.cn/MulanPSL2
121
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
122
+ EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
123
+ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
124
+ See the Mulan PSL v2 for more details.
@@ -1,3 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: msdev
3
+ Version: 0.10.0
4
+ Summary: Portable nodes and execution environments for msModelSlim development
5
+ Author: msModelSlim Agent Contributors
6
+ License-Expression: MulanPSL-2.0
7
+ Project-URL: Homepage, https://gitcode.com/rookie_hongchuan/msdev
8
+ Project-URL: Repository, https://gitcode.com/rookie_hongchuan/msdev
9
+ Keywords: ssh,docker,conda,venv,remote,npu,mlops,devops
10
+ Classifier: Environment :: Console
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Operating System :: MacOS
18
+ Classifier: Operating System :: POSIX :: Linux
19
+ Classifier: Topic :: Software Development :: Build Tools
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
1
25
  # msdev
2
26
 
3
27
  `msdev` manages connection Nodes and execution Envs. A Node owns SSH and its
@@ -15,7 +39,9 @@ The CLI is intentionally stateless:
15
39
  ## Install
16
40
 
17
41
  ```bash
18
- python3 -m pip install -e tools/msdev
42
+ git clone https://gitcode.com/rookie_hongchuan/msdev.git
43
+ cd msdev
44
+ python3 -m pip install -e .
19
45
  msdev --help
20
46
  ```
21
47
 
@@ -38,20 +64,6 @@ the remote user daemon:
38
64
  msdev node bootstrap dev-122
39
65
  ```
40
66
 
41
- Configure persistent variables inherited by host-side child processes,
42
- including `exec`, `env shell`, NPU queries, and workspace Git commands:
43
-
44
- ```bash
45
- msdev node env dev-122 --set LD_LIBRARY_PATH=/opt/driver/lib
46
- msdev node env dev-122
47
- msdev node env dev-122 --unset LD_LIBRARY_PATH
48
- ```
49
-
50
- Node variables apply only to the host runtime; Docker Envs do not inherit host
51
- paths. Per-command `exec --env-var` values take precedence. Variable names and
52
- values are stored in the private local resource registry, so use a dedicated
53
- secret mechanism rather than this feature for credentials.
54
-
55
67
  Persistent OpenSSH masters are optional:
56
68
 
57
69
  ```bash
@@ -59,13 +71,6 @@ msdev node connect dev-122
59
71
  msdev node disconnect dev-122
60
72
  ```
61
73
 
62
- For a server available only through a browser terminal, see
63
- [Rootless web terminal access](docs/rootless-web-terminal-access.md). It covers
64
- a rootless SSH daemon, a domestic reverse tunnel, WSL Fake-IP routing, host-key
65
- verification, and the errors found during a real setup. Direct SSH in that
66
- guide is a human connectivity bootstrap step; agent operations must still use
67
- explicit `msdev` resources and must not bypass the CLI with SSH or SCP.
68
-
69
74
  Nodes and Envs have separate private Markdown guides:
70
75
 
71
76
  ```bash
@@ -190,7 +195,7 @@ msdev workspace delete project docs/obsolete.md
190
195
 
191
196
  ```bash
192
197
  msdev workspace git-status project --result-json
193
- msdev workspace git-diff --result-json project -- --stat
198
+ msdev workspace git-diff project --result-json -- --stat
194
199
  ```
195
200
 
196
201
  Git diff rejects options that can write files or invoke external diff helpers.
@@ -281,6 +286,5 @@ compare-and-swap. Node/Env and workspace registries use locked atomic updates.
281
286
  ## Testing
282
287
 
283
288
  ```bash
284
- cd tools/msdev
285
289
  python3 -m unittest discover -s tests -v
286
290
  ```
@@ -1,12 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: msdev
3
- Version: 0.9.0
4
- Summary: Portable nodes and execution environments for msModelSlim development
5
- Author: msModelSlim Agent Contributors
6
- License: MulanPSL-2.0
7
- Requires-Python: >=3.10
8
- Description-Content-Type: text/markdown
9
-
10
1
  # msdev
11
2
 
12
3
  `msdev` manages connection Nodes and execution Envs. A Node owns SSH and its
@@ -24,7 +15,9 @@ The CLI is intentionally stateless:
24
15
  ## Install
25
16
 
26
17
  ```bash
27
- python3 -m pip install -e tools/msdev
18
+ git clone https://gitcode.com/rookie_hongchuan/msdev.git
19
+ cd msdev
20
+ python3 -m pip install -e .
28
21
  msdev --help
29
22
  ```
30
23
 
@@ -47,20 +40,6 @@ the remote user daemon:
47
40
  msdev node bootstrap dev-122
48
41
  ```
49
42
 
50
- Configure persistent variables inherited by host-side child processes,
51
- including `exec`, `env shell`, NPU queries, and workspace Git commands:
52
-
53
- ```bash
54
- msdev node env dev-122 --set LD_LIBRARY_PATH=/opt/driver/lib
55
- msdev node env dev-122
56
- msdev node env dev-122 --unset LD_LIBRARY_PATH
57
- ```
58
-
59
- Node variables apply only to the host runtime; Docker Envs do not inherit host
60
- paths. Per-command `exec --env-var` values take precedence. Variable names and
61
- values are stored in the private local resource registry, so use a dedicated
62
- secret mechanism rather than this feature for credentials.
63
-
64
43
  Persistent OpenSSH masters are optional:
65
44
 
66
45
  ```bash
@@ -68,13 +47,6 @@ msdev node connect dev-122
68
47
  msdev node disconnect dev-122
69
48
  ```
70
49
 
71
- For a server available only through a browser terminal, see
72
- [Rootless web terminal access](docs/rootless-web-terminal-access.md). It covers
73
- a rootless SSH daemon, a domestic reverse tunnel, WSL Fake-IP routing, host-key
74
- verification, and the errors found during a real setup. Direct SSH in that
75
- guide is a human connectivity bootstrap step; agent operations must still use
76
- explicit `msdev` resources and must not bypass the CLI with SSH or SCP.
77
-
78
50
  Nodes and Envs have separate private Markdown guides:
79
51
 
80
52
  ```bash
@@ -199,7 +171,7 @@ msdev workspace delete project docs/obsolete.md
199
171
 
200
172
  ```bash
201
173
  msdev workspace git-status project --result-json
202
- msdev workspace git-diff --result-json project -- --stat
174
+ msdev workspace git-diff project --result-json -- --stat
203
175
  ```
204
176
 
205
177
  Git diff rejects options that can write files or invoke external diff helpers.
@@ -290,6 +262,5 @@ compare-and-swap. Node/Env and workspace registries use locked atomic updates.
290
262
  ## Testing
291
263
 
292
264
  ```bash
293
- cd tools/msdev
294
265
  python3 -m unittest discover -s tests -v
295
266
  ```
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "msdev"
7
+ version = "0.10.0"
8
+ description = "Portable nodes and execution environments for msModelSlim development"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MulanPSL-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "msModelSlim Agent Contributors" },
15
+ ]
16
+ keywords = ["ssh", "docker", "conda", "venv", "remote", "npu", "mlops", "devops"]
17
+ classifiers = [
18
+ "Environment :: Console",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Operating System :: MacOS",
26
+ "Operating System :: POSIX :: Linux",
27
+ "Topic :: Software Development :: Build Tools",
28
+ ]
29
+ dependencies = []
30
+
31
+ [project.urls]
32
+ Homepage = "https://gitcode.com/rookie_hongchuan/msdev"
33
+ Repository = "https://gitcode.com/rookie_hongchuan/msdev"
34
+
35
+ [project.scripts]
36
+ msdev = "msdev.cli:main"
37
+ msdevd = "msdev.daemon:main"
38
+
39
+ [tool.setuptools]
40
+ package-dir = { "" = "src" }
41
+
42
+ [tool.setuptools.packages.find]
43
+ where = ["src"]
44
+
45
+ [tool.setuptools.package-data]
46
+ msdev = ["helpers/msdev-file-helper-*"]
47
+
48
+ [tool.pytest.ini_options]
49
+ testpaths = ["tests"]
@@ -1,3 +1,3 @@
1
1
  """Portable node and execution-environment tooling for msModelSlim."""
2
2
 
3
- __version__ = "0.9.0"
3
+ __version__ = "0.10.0"
@@ -165,19 +165,6 @@ def command_node(
165
165
  if args.name != "local":
166
166
  node_store.get(args.name)
167
167
  return _command_guide(args, NodeGuideStore(), "node")
168
- if action == "env":
169
- node = (
170
- service.update_variables(
171
- args.name,
172
- set_values=tuple(args.set_values),
173
- unset_keys=tuple(args.unset_keys),
174
- )
175
- if args.set_values or args.unset_keys
176
- else node_store.get(args.name)
177
- )
178
- for assignment in node.variables:
179
- print(assignment)
180
- return 0
181
168
  if action == "add":
182
169
  node = service.add(
183
170
  NodeAddRequest(
@@ -902,25 +889,6 @@ def build_parser() -> argparse.ArgumentParser:
902
889
  help="do not install/start msdevd automatically on first use",
903
890
  )
904
891
  node_sub.add_parser("list")
905
- node_env = node_sub.add_parser(
906
- "env",
907
- help="read or update persistent host environment variables",
908
- )
909
- node_env.add_argument("name")
910
- node_env.add_argument(
911
- "--set",
912
- dest="set_values",
913
- action="append",
914
- default=[],
915
- metavar="KEY=VALUE",
916
- )
917
- node_env.add_argument(
918
- "--unset",
919
- dest="unset_keys",
920
- action="append",
921
- default=[],
922
- metavar="KEY",
923
- )
924
892
  node_guide = node_sub.add_parser(
925
893
  "guide",
926
894
  help="read or maintain the local Markdown guide for a node",
@@ -0,0 +1,244 @@
1
+ """Persistent Docker file-helper connections, one per immutable container ID."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import subprocess
6
+ import threading
7
+ import time
8
+ from typing import Any, Callable
9
+
10
+ from . import streamproto as proto
11
+ from .request_client import RemoteError, RequestClient
12
+ from .stream_limits import (
13
+ HELPER_IDLE_SCAN_INTERVAL_SECONDS,
14
+ HELPER_IDLE_TIMEOUT_SECONDS,
15
+ )
16
+ from .stream_transport import _BoundedStderrDrain
17
+
18
+
19
+ class _HelperConnection:
20
+ def __init__(self, process: subprocess.Popen[bytes]) -> None:
21
+ if process.stdin is None or process.stdout is None:
22
+ raise ValueError("helper process requires stdin and stdout pipes")
23
+ self.process = process
24
+ self.stderr = (
25
+ _BoundedStderrDrain(process.stderr)
26
+ if process.stderr is not None
27
+ else None
28
+ )
29
+ self._last_used = time.monotonic()
30
+ self._last_used_lock = threading.Lock()
31
+ self.client = RequestClient(
32
+ process.stdout,
33
+ process.stdin,
34
+ abort_transport=self._abort,
35
+ )
36
+ try:
37
+ self.client.hello(
38
+ max_in_flight=proto.DEFAULT_MAX_IN_FLIGHT,
39
+ max_frame_bytes=proto.MAX_FRAME_PAYLOAD_BYTES,
40
+ )
41
+ except BaseException:
42
+ self.client.close()
43
+ raise
44
+
45
+ def _abort(self) -> None:
46
+ if self.process.poll() is None:
47
+ self.process.terminate()
48
+ try:
49
+ self.process.wait(timeout=2)
50
+ except subprocess.TimeoutExpired:
51
+ self.process.kill()
52
+ self.process.wait(timeout=2)
53
+ for stream in (self.process.stdin, self.process.stdout, self.process.stderr):
54
+ if stream is not None:
55
+ try:
56
+ stream.close()
57
+ except (OSError, ValueError):
58
+ pass
59
+
60
+ def touch(self) -> None:
61
+ with self._last_used_lock:
62
+ self._last_used = time.monotonic()
63
+
64
+ def idle_for(self) -> float:
65
+ with self._last_used_lock:
66
+ return time.monotonic() - self._last_used
67
+
68
+ def alive(self) -> bool:
69
+ return self.process.poll() is None and not self.client._connection.closed
70
+
71
+ def close(self) -> None:
72
+ self.client.close()
73
+
74
+ def recent_stderr(self) -> bytes:
75
+ return self.stderr.recent() if self.stderr is not None else b""
76
+
77
+
78
+ class ContainerHelperBroker:
79
+ """Own helper deployment, connection reuse, eviction, and shutdown."""
80
+
81
+ def __init__(
82
+ self,
83
+ *,
84
+ node_name: str,
85
+ spawn_helper: Callable[[str, str], subprocess.Popen[bytes]],
86
+ resolve_container_id: Callable[[str], str],
87
+ deploy: Callable[[str], str],
88
+ idle_timeout_seconds: float = HELPER_IDLE_TIMEOUT_SECONDS,
89
+ idle_scan_interval_seconds: float = HELPER_IDLE_SCAN_INTERVAL_SECONDS,
90
+ ) -> None:
91
+ if not isinstance(node_name, str) or not node_name:
92
+ raise ValueError("node_name must be a non-empty string")
93
+ self._node_name = node_name
94
+ self._spawn_helper = spawn_helper
95
+ self._resolve_container_id = resolve_container_id
96
+ self._deploy = deploy
97
+ self._idle_timeout = idle_timeout_seconds
98
+ self._idle_scan_interval = idle_scan_interval_seconds
99
+ self._connections: dict[str, _HelperConnection] = {}
100
+ self._lock = threading.Lock()
101
+ self._closed = threading.Event()
102
+ self._scanner = threading.Thread(target=self._scan_idle_loop, daemon=True)
103
+ self._scanner.start()
104
+
105
+ def _validate_route(
106
+ self,
107
+ container: str,
108
+ value: dict[str, Any],
109
+ ) -> None:
110
+ if not isinstance(value, dict):
111
+ raise ValueError("helper request must be an object")
112
+ node = value.get("node")
113
+ environment = value.get("environment")
114
+ if node != self._node_name:
115
+ raise ValueError(
116
+ f"helper request node {node!r} does not match {self._node_name!r}",
117
+ )
118
+ if not isinstance(environment, str) or not environment:
119
+ raise ValueError("helper request requires an explicit environment")
120
+ if value.get("target") != "docker":
121
+ raise ValueError("container helper accepts only target='docker'")
122
+ if value.get("container") != container:
123
+ raise ValueError("helper request container does not match broker route")
124
+
125
+ def _connection_for(self, container: str) -> tuple[str, _HelperConnection]:
126
+ if self._closed.is_set():
127
+ raise RuntimeError("container helper broker is shut down")
128
+ container_id = self._resolve_container_id(container)
129
+ if not isinstance(container_id, str) or not container_id:
130
+ raise RuntimeError("docker inspect returned an empty container ID")
131
+ stale: _HelperConnection | None = None
132
+ with self._lock:
133
+ existing = self._connections.get(container_id)
134
+ if existing is not None and existing.alive():
135
+ existing.touch()
136
+ return container_id, existing
137
+ if existing is not None:
138
+ stale = self._connections.pop(container_id)
139
+ path = self._deploy(container)
140
+ process = self._spawn_helper(container, path)
141
+ try:
142
+ created = _HelperConnection(process)
143
+ except BaseException:
144
+ if process.poll() is None:
145
+ process.terminate()
146
+ process.wait(timeout=2)
147
+ raise
148
+ self._connections[container_id] = created
149
+ if stale is not None:
150
+ stale.close()
151
+ return container_id, created
152
+
153
+ def _discard_if_dead(
154
+ self,
155
+ container_id: str,
156
+ connection: _HelperConnection,
157
+ ) -> None:
158
+ if connection.alive():
159
+ return
160
+ with self._lock:
161
+ if self._connections.get(container_id) is connection:
162
+ self._connections.pop(container_id, None)
163
+ connection.close()
164
+
165
+ def call(
166
+ self,
167
+ container: str,
168
+ opcode: int,
169
+ value: dict[str, Any],
170
+ ) -> dict[str, Any]:
171
+ self._validate_route(container, value)
172
+ container_id, connection = self._connection_for(container)
173
+ try:
174
+ result = connection.client.call(opcode, value)
175
+ connection.touch()
176
+ return result
177
+ except RemoteError:
178
+ self._discard_if_dead(container_id, connection)
179
+ raise
180
+
181
+ def call_read(
182
+ self,
183
+ container: str,
184
+ *,
185
+ node: str,
186
+ environment: str,
187
+ handle: int,
188
+ offset: int,
189
+ length: int,
190
+ ) -> tuple[bytes, bool]:
191
+ value = {
192
+ "node": node,
193
+ "environment": environment,
194
+ "target": "docker",
195
+ "container": container,
196
+ }
197
+ self._validate_route(container, value)
198
+ container_id, connection = self._connection_for(container)
199
+ try:
200
+ result = connection.client.call_read(
201
+ handle,
202
+ offset,
203
+ length,
204
+ context=value,
205
+ )
206
+ connection.touch()
207
+ return result
208
+ except RemoteError:
209
+ self._discard_if_dead(container_id, connection)
210
+ raise
211
+
212
+ def active_helper_count(self) -> int:
213
+ with self._lock:
214
+ return len(self._connections)
215
+
216
+ def recent_stderr(self, container: str) -> bytes:
217
+ container_id = self._resolve_container_id(container)
218
+ with self._lock:
219
+ connection = self._connections.get(container_id)
220
+ return connection.recent_stderr() if connection is not None else b""
221
+
222
+ def _scan_idle_loop(self) -> None:
223
+ while not self._closed.wait(self._idle_scan_interval):
224
+ stale: list[_HelperConnection] = []
225
+ with self._lock:
226
+ for key, connection in list(self._connections.items()):
227
+ if (
228
+ not connection.alive()
229
+ or connection.idle_for() >= self._idle_timeout
230
+ ):
231
+ stale.append(self._connections.pop(key))
232
+ for connection in stale:
233
+ connection.close()
234
+
235
+ def shutdown(self) -> None:
236
+ if self._closed.is_set():
237
+ return
238
+ self._closed.set()
239
+ self._scanner.join(timeout=max(1.0, self._idle_scan_interval * 2))
240
+ with self._lock:
241
+ connections = list(self._connections.values())
242
+ self._connections.clear()
243
+ for connection in connections:
244
+ connection.close()