ms-env 0.2.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.
- ms_env-0.2.0/.github/workflows/ci.yml +18 -0
- ms_env-0.2.0/.github/workflows/docs.yml +47 -0
- ms_env-0.2.0/.github/workflows/publish.yml +31 -0
- ms_env-0.2.0/.gitignore +220 -0
- ms_env-0.2.0/LICENSE +21 -0
- ms_env-0.2.0/PKG-INFO +133 -0
- ms_env-0.2.0/README.md +110 -0
- ms_env-0.2.0/docs/api_reference.md +5 -0
- ms_env-0.2.0/docs/guide.md +184 -0
- ms_env-0.2.0/docs/index.md +39 -0
- ms_env-0.2.0/pyproject.toml +51 -0
- ms_env-0.2.0/setup.cfg +4 -0
- ms_env-0.2.0/src/ms_env/__init__.py +50 -0
- ms_env-0.2.0/src/ms_env/app.py +165 -0
- ms_env-0.2.0/src/ms_env/host.py +50 -0
- ms_env-0.2.0/src/ms_env/recipes.py +481 -0
- ms_env-0.2.0/src/ms_env/steps.py +94 -0
- ms_env-0.2.0/src/ms_env.egg-info/PKG-INFO +133 -0
- ms_env-0.2.0/src/ms_env.egg-info/SOURCES.txt +24 -0
- ms_env-0.2.0/src/ms_env.egg-info/dependency_links.txt +1 -0
- ms_env-0.2.0/src/ms_env.egg-info/requires.txt +3 -0
- ms_env-0.2.0/src/ms_env.egg-info/scm_file_list.json +21 -0
- ms_env-0.2.0/src/ms_env.egg-info/scm_version.json +8 -0
- ms_env-0.2.0/src/ms_env.egg-info/top_level.txt +1 -0
- ms_env-0.2.0/tests/test_ms_env.py +253 -0
- ms_env-0.2.0/zensical.toml +75 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
tests:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v7
|
|
13
|
+
- uses: actions/setup-python@v7
|
|
14
|
+
with:
|
|
15
|
+
python-version: "3.12"
|
|
16
|
+
cache: pip
|
|
17
|
+
- run: pip install -e ".[dev]"
|
|
18
|
+
- run: pytest -q
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
tags:
|
|
7
|
+
- "v*"
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: documentation
|
|
12
|
+
cancel-in-progress: false
|
|
13
|
+
|
|
14
|
+
# mike commits every version to the gh-pages branch and GitHub Pages serves that
|
|
15
|
+
# branch (Settings > Pages > Deploy from a branch: gh-pages, / (root)).
|
|
16
|
+
# An Actions Pages deployment is keyed by commit SHA, so a release tag on a
|
|
17
|
+
# commit already deployed from main would be silently ignored.
|
|
18
|
+
permissions:
|
|
19
|
+
contents: write
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
deploy:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v6
|
|
26
|
+
with:
|
|
27
|
+
fetch-depth: 0
|
|
28
|
+
- uses: actions/setup-python@v6
|
|
29
|
+
with:
|
|
30
|
+
python-version: 3.x
|
|
31
|
+
- run: pip install zensical "mkdocstrings[python]" "mike @ git+https://github.com/squidfunk/mike.git"
|
|
32
|
+
- name: Configure Git author
|
|
33
|
+
run: |
|
|
34
|
+
git config user.name "github-actions[bot]"
|
|
35
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
36
|
+
- name: Deploy development documentation
|
|
37
|
+
if: github.ref == 'refs/heads/main'
|
|
38
|
+
run: |
|
|
39
|
+
mike deploy --push dev
|
|
40
|
+
if ! mike list latest >/dev/null 2>&1; then
|
|
41
|
+
mike set-default --push dev
|
|
42
|
+
fi
|
|
43
|
+
- name: Deploy release documentation
|
|
44
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
45
|
+
run: |
|
|
46
|
+
mike deploy --push --update-aliases --alias-type redirect "$GITHUB_REF_NAME" latest
|
|
47
|
+
mike set-default --push latest
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Publish to PyPI on a GitHub release.
|
|
2
|
+
#
|
|
3
|
+
# No secrets: the job authenticates to PyPI over OIDC (Trusted Publishing).
|
|
4
|
+
# It has to be enabled on the PyPI side *before* the first upload -- for a
|
|
5
|
+
# project that does not exist yet, that is a "pending publisher" under
|
|
6
|
+
# Your projects > Publishing, and it must name this repo, `publish.yml`
|
|
7
|
+
# and the `pypi` environment below.
|
|
8
|
+
name: publish
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
release:
|
|
12
|
+
types: [published]
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
pypi:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
environment: pypi
|
|
18
|
+
permissions:
|
|
19
|
+
# A permissions block sets every scope it does not name to none, so
|
|
20
|
+
# checkout needs contents spelled out or it cannot read a private repo.
|
|
21
|
+
contents: read
|
|
22
|
+
id-token: write # mint the OIDC token PyPI checks; no secret involved
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v7
|
|
25
|
+
with:
|
|
26
|
+
fetch-depth: 0 # setuptools-scm reads the version off the tag
|
|
27
|
+
- uses: actions/setup-python@v7
|
|
28
|
+
with:
|
|
29
|
+
python-version: "3.12"
|
|
30
|
+
- run: pipx run build
|
|
31
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
ms_env-0.2.0/.gitignore
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
*.lcov
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
# Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# uv
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
# poetry.lock
|
|
110
|
+
# poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
# pdm.lock
|
|
117
|
+
# pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
# pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi/*
|
|
127
|
+
!.pixi/config.toml
|
|
128
|
+
|
|
129
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
130
|
+
__pypackages__/
|
|
131
|
+
|
|
132
|
+
# Celery stuff
|
|
133
|
+
celerybeat-schedule*
|
|
134
|
+
celerybeat.pid
|
|
135
|
+
|
|
136
|
+
# Redis
|
|
137
|
+
*.rdb
|
|
138
|
+
*.aof
|
|
139
|
+
*.pid
|
|
140
|
+
|
|
141
|
+
# RabbitMQ
|
|
142
|
+
mnesia/
|
|
143
|
+
rabbitmq/
|
|
144
|
+
rabbitmq-data/
|
|
145
|
+
|
|
146
|
+
# ActiveMQ
|
|
147
|
+
activemq-data/
|
|
148
|
+
|
|
149
|
+
# SageMath parsed files
|
|
150
|
+
*.sage.py
|
|
151
|
+
|
|
152
|
+
# Environments
|
|
153
|
+
.env
|
|
154
|
+
.envrc
|
|
155
|
+
.venv
|
|
156
|
+
env/
|
|
157
|
+
venv/
|
|
158
|
+
ENV/
|
|
159
|
+
env.bak/
|
|
160
|
+
venv.bak/
|
|
161
|
+
|
|
162
|
+
# Spyder project settings
|
|
163
|
+
.spyderproject
|
|
164
|
+
.spyproject
|
|
165
|
+
|
|
166
|
+
# Rope project settings
|
|
167
|
+
.ropeproject
|
|
168
|
+
|
|
169
|
+
# mkdocs/Zensical documentation
|
|
170
|
+
/site
|
|
171
|
+
|
|
172
|
+
# mypy
|
|
173
|
+
.mypy_cache/
|
|
174
|
+
.dmypy.json
|
|
175
|
+
dmypy.json
|
|
176
|
+
|
|
177
|
+
# Pyre type checker
|
|
178
|
+
.pyre/
|
|
179
|
+
|
|
180
|
+
# pytype static type analyzer
|
|
181
|
+
.pytype/
|
|
182
|
+
|
|
183
|
+
# Cython debug symbols
|
|
184
|
+
cython_debug/
|
|
185
|
+
|
|
186
|
+
# PyCharm
|
|
187
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
188
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
189
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
190
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
191
|
+
.idea/
|
|
192
|
+
|
|
193
|
+
# Abstra
|
|
194
|
+
# Abstra is an AI-powered process automation framework.
|
|
195
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
196
|
+
# Learn more at https://abstra.io/docs
|
|
197
|
+
.abstra/
|
|
198
|
+
|
|
199
|
+
# Visual Studio Code
|
|
200
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
|
|
201
|
+
# can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
202
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer, you
|
|
203
|
+
# could uncomment the following to ignore the entire vscode folder
|
|
204
|
+
# .vscode/
|
|
205
|
+
# Temporary file for partial code execution
|
|
206
|
+
tempCodeRunnerFile.py
|
|
207
|
+
|
|
208
|
+
# Ruff stuff:
|
|
209
|
+
.ruff_cache/
|
|
210
|
+
|
|
211
|
+
# PyPI configuration file
|
|
212
|
+
.pypirc
|
|
213
|
+
|
|
214
|
+
# Marimo
|
|
215
|
+
marimo/_static/
|
|
216
|
+
marimo/_lsp/
|
|
217
|
+
__marimo__/
|
|
218
|
+
|
|
219
|
+
# Streamlit
|
|
220
|
+
.streamlit/secrets.toml
|
ms_env-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MolSuite
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ms_env-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ms_env
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Environments for MolSuite apps: find or install external tools, on this machine or over ssh.
|
|
5
|
+
Author: Mario S. Valdés-Tresanco, Mario E. Valdés-Tresanco
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/MolSuite/ms_env
|
|
8
|
+
Project-URL: Documentation, https://molsuite.github.io/ms_env/
|
|
9
|
+
Project-URL: Issues, https://github.com/MolSuite/ms_env/issues
|
|
10
|
+
Keywords: environments,conda,micromamba,ssh,molsuite
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering
|
|
17
|
+
Requires-Python: >=3.12
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# ms_env
|
|
25
|
+
|
|
26
|
+
Environments for MolSuite apps: find an external tool that already works, or install
|
|
27
|
+
it, on this machine or on a host reached over `ssh`. Standard library only.
|
|
28
|
+
|
|
29
|
+
A **recipe** says how to tell that a tool works and how to install it. A **host**
|
|
30
|
+
says where. `ms_env` applies one to the other.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from ms_env import READY, Host, ToolSpec, ensure, locate
|
|
34
|
+
|
|
35
|
+
spec = ToolSpec.load("openbabel.toml")
|
|
36
|
+
|
|
37
|
+
recipe = spec.recipe("/home/me/.myapp/tools") # bound to this machine
|
|
38
|
+
state, executable = locate(recipe) # (READY, ".../bin/obabel") or (MISSING, "")
|
|
39
|
+
if state != READY:
|
|
40
|
+
install = ensure(recipe) # returns at once: a daemon thread installs
|
|
41
|
+
install.future.result() # wait; `install.lines` is the live log
|
|
42
|
+
|
|
43
|
+
cluster = Host("me@login.hpc") # as `ssh` knows it
|
|
44
|
+
ensure(spec.recipe("/home/me/.myapp/tools"), cluster).future.result()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## A recipe
|
|
48
|
+
|
|
49
|
+
One TOML file per tool, shipped by the app:
|
|
50
|
+
|
|
51
|
+
```toml
|
|
52
|
+
[tool]
|
|
53
|
+
name = "openbabel"
|
|
54
|
+
label = "OpenBabel"
|
|
55
|
+
version = "3.1.1" # pinned here; never a user option
|
|
56
|
+
prefix = "{tools_home}/{name}/{version}" # the default
|
|
57
|
+
|
|
58
|
+
[locate]
|
|
59
|
+
paths = ["{prefix}/bin/obabel"] # where the install puts it
|
|
60
|
+
commands = ["obabel"] # looked up on PATH
|
|
61
|
+
check = ["{exe}", "-V"] # {exe} = the candidate
|
|
62
|
+
|
|
63
|
+
[env] # a conda prefix at {prefix}
|
|
64
|
+
conda = ["openbabel={version}"]
|
|
65
|
+
pip = []
|
|
66
|
+
|
|
67
|
+
[[install]] # plain steps, after [env]
|
|
68
|
+
name = "download the model"
|
|
69
|
+
argv = ["curl", "-fsSL", "-o", "{prefix}/model.pt", "https://..."]
|
|
70
|
+
timeout = 1800
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Lookup on a host, first candidate whose check exits 0 wins: the paths the user
|
|
74
|
+
registered, the managed install under `tools_home`, then `PATH`. `[env]` is created
|
|
75
|
+
with micromamba: the one on the host's `PATH`, or one downloaded into `tools_home`.
|
|
76
|
+
Another conda-type program is used only when the app names it (`manager=`).
|
|
77
|
+
|
|
78
|
+
## Whose an environment is
|
|
79
|
+
|
|
80
|
+
`ensure` stamps the prefix it installs. The stamp decides what may happen to it:
|
|
81
|
+
|
|
82
|
+
| At the prefix | `ensure` | `remove` |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| Nothing | Creates it | Nothing to delete |
|
|
85
|
+
| A stamp of this recipe | Nothing | Deletes it |
|
|
86
|
+
| A stamp of another recipe (the TOML changed) | Creates it again: the update | Deletes it |
|
|
87
|
+
| Something without a stamp: the user's own environment | Verifies it, never changes it | Leaves it |
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from ms_env import remove, verify
|
|
91
|
+
|
|
92
|
+
mine = spec.recipe("/home/me/.myapp/tools", prefix="/home/me/envs/babel") # an environment I already have
|
|
93
|
+
verify(mine) # [] when it meets the recipe, else what it lacks:
|
|
94
|
+
# ["conda: openbabel=3.1.1 is asked for and is not there"]
|
|
95
|
+
remove(recipe) # True: ms_env had installed it and it is gone
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`verify` looks up every pinned conda package, every pinned pip package and the
|
|
99
|
+
recipe's check, and only reads. An executable registered on its own (`extra_paths=`)
|
|
100
|
+
is not an environment: it only has to pass the check.
|
|
101
|
+
|
|
102
|
+
`ensure(recipe, host, busy=why)` asks `why()` before it changes an install of its own:
|
|
103
|
+
a reason (`"2 jobs are running from it"`) makes the install fail and leaves the prefix
|
|
104
|
+
as it is.
|
|
105
|
+
|
|
106
|
+
## A host
|
|
107
|
+
|
|
108
|
+
`Host()` is this machine. `Host("me@login.hpc")` runs every command through the system's
|
|
109
|
+
`ssh` with `BatchMode=yes`: users, keys and jumps come from `~/.ssh/config`, the key
|
|
110
|
+
logs in or the command fails at once, no credential is handled and nothing is left
|
|
111
|
+
listening on the other side. A host is a POSIX machine; only Linux is supported.
|
|
112
|
+
|
|
113
|
+
## The environment of an app
|
|
114
|
+
|
|
115
|
+
`app_recipe` makes the recipe that gives a host the environment an app runs in here:
|
|
116
|
+
the same Python, the same versions, and the code of a source checkout as it is now.
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from ms_env import app_recipe
|
|
120
|
+
|
|
121
|
+
home = cluster.home()
|
|
122
|
+
recipe = app_recipe("myapp", ["myapp"], ["myapp"], prefix=f"{home}/.myapp/env",
|
|
123
|
+
tools_home=f"{home}/.myapp/tools", cache="/home/me/.myapp/cache/wheels")
|
|
124
|
+
ensure(recipe, cluster).future.result()
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Install
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
pip install ms_env
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Documentation: <https://molsuite.github.io/ms_env/>
|
ms_env-0.2.0/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# ms_env
|
|
2
|
+
|
|
3
|
+
Environments for MolSuite apps: find an external tool that already works, or install
|
|
4
|
+
it, on this machine or on a host reached over `ssh`. Standard library only.
|
|
5
|
+
|
|
6
|
+
A **recipe** says how to tell that a tool works and how to install it. A **host**
|
|
7
|
+
says where. `ms_env` applies one to the other.
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from ms_env import READY, Host, ToolSpec, ensure, locate
|
|
11
|
+
|
|
12
|
+
spec = ToolSpec.load("openbabel.toml")
|
|
13
|
+
|
|
14
|
+
recipe = spec.recipe("/home/me/.myapp/tools") # bound to this machine
|
|
15
|
+
state, executable = locate(recipe) # (READY, ".../bin/obabel") or (MISSING, "")
|
|
16
|
+
if state != READY:
|
|
17
|
+
install = ensure(recipe) # returns at once: a daemon thread installs
|
|
18
|
+
install.future.result() # wait; `install.lines` is the live log
|
|
19
|
+
|
|
20
|
+
cluster = Host("me@login.hpc") # as `ssh` knows it
|
|
21
|
+
ensure(spec.recipe("/home/me/.myapp/tools"), cluster).future.result()
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## A recipe
|
|
25
|
+
|
|
26
|
+
One TOML file per tool, shipped by the app:
|
|
27
|
+
|
|
28
|
+
```toml
|
|
29
|
+
[tool]
|
|
30
|
+
name = "openbabel"
|
|
31
|
+
label = "OpenBabel"
|
|
32
|
+
version = "3.1.1" # pinned here; never a user option
|
|
33
|
+
prefix = "{tools_home}/{name}/{version}" # the default
|
|
34
|
+
|
|
35
|
+
[locate]
|
|
36
|
+
paths = ["{prefix}/bin/obabel"] # where the install puts it
|
|
37
|
+
commands = ["obabel"] # looked up on PATH
|
|
38
|
+
check = ["{exe}", "-V"] # {exe} = the candidate
|
|
39
|
+
|
|
40
|
+
[env] # a conda prefix at {prefix}
|
|
41
|
+
conda = ["openbabel={version}"]
|
|
42
|
+
pip = []
|
|
43
|
+
|
|
44
|
+
[[install]] # plain steps, after [env]
|
|
45
|
+
name = "download the model"
|
|
46
|
+
argv = ["curl", "-fsSL", "-o", "{prefix}/model.pt", "https://..."]
|
|
47
|
+
timeout = 1800
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Lookup on a host, first candidate whose check exits 0 wins: the paths the user
|
|
51
|
+
registered, the managed install under `tools_home`, then `PATH`. `[env]` is created
|
|
52
|
+
with micromamba: the one on the host's `PATH`, or one downloaded into `tools_home`.
|
|
53
|
+
Another conda-type program is used only when the app names it (`manager=`).
|
|
54
|
+
|
|
55
|
+
## Whose an environment is
|
|
56
|
+
|
|
57
|
+
`ensure` stamps the prefix it installs. The stamp decides what may happen to it:
|
|
58
|
+
|
|
59
|
+
| At the prefix | `ensure` | `remove` |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| Nothing | Creates it | Nothing to delete |
|
|
62
|
+
| A stamp of this recipe | Nothing | Deletes it |
|
|
63
|
+
| A stamp of another recipe (the TOML changed) | Creates it again: the update | Deletes it |
|
|
64
|
+
| Something without a stamp: the user's own environment | Verifies it, never changes it | Leaves it |
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from ms_env import remove, verify
|
|
68
|
+
|
|
69
|
+
mine = spec.recipe("/home/me/.myapp/tools", prefix="/home/me/envs/babel") # an environment I already have
|
|
70
|
+
verify(mine) # [] when it meets the recipe, else what it lacks:
|
|
71
|
+
# ["conda: openbabel=3.1.1 is asked for and is not there"]
|
|
72
|
+
remove(recipe) # True: ms_env had installed it and it is gone
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`verify` looks up every pinned conda package, every pinned pip package and the
|
|
76
|
+
recipe's check, and only reads. An executable registered on its own (`extra_paths=`)
|
|
77
|
+
is not an environment: it only has to pass the check.
|
|
78
|
+
|
|
79
|
+
`ensure(recipe, host, busy=why)` asks `why()` before it changes an install of its own:
|
|
80
|
+
a reason (`"2 jobs are running from it"`) makes the install fail and leaves the prefix
|
|
81
|
+
as it is.
|
|
82
|
+
|
|
83
|
+
## A host
|
|
84
|
+
|
|
85
|
+
`Host()` is this machine. `Host("me@login.hpc")` runs every command through the system's
|
|
86
|
+
`ssh` with `BatchMode=yes`: users, keys and jumps come from `~/.ssh/config`, the key
|
|
87
|
+
logs in or the command fails at once, no credential is handled and nothing is left
|
|
88
|
+
listening on the other side. A host is a POSIX machine; only Linux is supported.
|
|
89
|
+
|
|
90
|
+
## The environment of an app
|
|
91
|
+
|
|
92
|
+
`app_recipe` makes the recipe that gives a host the environment an app runs in here:
|
|
93
|
+
the same Python, the same versions, and the code of a source checkout as it is now.
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from ms_env import app_recipe
|
|
97
|
+
|
|
98
|
+
home = cluster.home()
|
|
99
|
+
recipe = app_recipe("myapp", ["myapp"], ["myapp"], prefix=f"{home}/.myapp/env",
|
|
100
|
+
tools_home=f"{home}/.myapp/tools", cache="/home/me/.myapp/cache/wheels")
|
|
101
|
+
ensure(recipe, cluster).future.result()
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Install
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install ms_env
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Documentation: <https://molsuite.github.io/ms_env/>
|