Adam Community Tools and Utilities
Project description
Adam Community
Adam Community 是一个 Python 工具包,提供了 CLI 命令行工具和 Python 模块,用于解析和构建 Python 项目包。
安装
pip install -e .
使用方式
CLI 命令行
查看帮助:
adam-cli --help
初始化新项目:
adam-cli init
解析 Python 文件生成 functions.json:
adam-cli parse .
构建项目包:
adam-cli build .
更新 CLI 到最新版本:
adam-cli update
SIF 文件管理
管理 SIF 文件,包括上传到 Docker 镜像仓库等操作:
# 查看帮助
adam-cli sif --help
# 上传 SIF 文件到镜像仓库(自适应切片)
adam-cli sif upload ./xxx.sif registry.example.com/image:1.0.0
# 带认证上传
adam-cli sif upload ./app.sif registry.cn-hangzhou.aliyuncs.com/ns/app:latest \
--username user --password pass
Python 模块导入
from adam_community.cli.parser import parse_directory, parse_python_file
from adam_community.cli.build import build_package
# 解析目录下的 Python 文件
classes = parse_directory(Path("./"))
# 构建项目包
success, errors, zip_name = build_package(Path("./"))
States Management(任务状态管理)
用于在任务执行过程中记录和读取状态,与服务端共享 states.json 文件。
from adam_community.util import setState, getState, trackPath
# 记录文件列表(自动与服务端和其他 Tool 的文件合并)
setState("files", [
{"path": "output/result.json", "is_dir": False, "mtime": 1704100800},
{"path": "cache", "is_dir": True, "mtime": 1704100000}
])
# 获取合并后的文件列表(来自 server + 所有 tools)
files = getState("files")
# 记录自定义状态(支持嵌套 key)
setState("stage", "data_cleaning")
setState("config.threshold", 0.5)
# 获取状态
stage = getState("stage") # -> "data_cleaning"
threshold = getState("config.threshold") # -> 0.5
# 追踪文件/目录(自动检测 is_dir 和 mtime,先进先出,最多 30 条)
trackPath("/path/to/output/result.json")
trackPath("/path/to/cache")
功能特性
- Python 文件解析: 自动解析 Python 类和函数的文档字符串
- JSON Schema 验证: 将 Python 类型转换为 JSON Schema 并验证
- 项目构建: 检查配置文件、文档文件并创建 zip 包
- 类型检查: 支持多种 Python 类型注解格式
- 自动更新: 智能检查和更新到最新版本,支持用户配置
- SIF 镜像构建: 将 SIF 文件切片并构建 Docker 镜像推送到仓库
开发
安装依赖:
make install
运行测试:
make test
构建包:
make build
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
adam_community-1.0.27.tar.gz
(46.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adam_community-1.0.27.tar.gz.
File metadata
- Download URL: adam_community-1.0.27.tar.gz
- Upload date:
- Size: 46.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85e557ac23c44eca4a1c3bb29bc32d31eddabed34ae11bb8ec0d0fe9761fe00e
|
|
| MD5 |
ac7f47597cc986962437819957907875
|
|
| BLAKE2b-256 |
f4410602694962302ccb0dff9e2f81eabc5ec8425993130a7e0f384da9bb155b
|
File details
Details for the file adam_community-1.0.27-py3-none-any.whl.
File metadata
- Download URL: adam_community-1.0.27-py3-none-any.whl
- Upload date:
- Size: 55.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92c65e232ab4d632d519260b4890783a4cd038911a2080a9aa3374ddca594c09
|
|
| MD5 |
e4ded1a10618e58bacc5cd1746075d7c
|
|
| BLAKE2b-256 |
0a53d9acef8f26e98c84134485caa8a28417d816f14209a1cb7413c84f5d0210
|