用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/arm2arm/AstroAgentAssistant --skill dtwin-setup命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
S3/MinIO operations: connectivity, transfers, read benchmarks, and matplotlib visualization templates.
Complete guide to the REANA reproducible analytics platform: Dockerized client setup, multi-backend profiles, workflow authoring patterns, S3 dataset workflows, and best practices. Covers dev/prod backends, serial workflows, REANA_WORKSPACE usage, and self-learning from finished workflows.
Complete guide to working with Arepo simulation HDF5 files: structure inspection, unit conversion, radial profiles, slice projections, and dimensionality reduction (UMAP/t-SNE) for clustering analysis.
基于 SOC 职业分类
正在显示 SKILL.md
| name | dtwin-setup |
| category | science |
| description | Build and run the dt4acc Digital Twin for particle accelerators using Apptainer |
Build and run the dt4acc Digital Twin for particle accelerators using Apptainer
This skill contains a reusable operational workflow. Follow the existing task-specific steps and examples in the sections below.
Build and run the dt4acc Digital Twin (BESSY II accelerator simulation) using Apptainer containers on ARM64 Ubuntu systems.
dt4acc, dtwin, BESSY II, or accelerator twinhttps://codebase.helmholtz.cloud/digital-twins-for-accelerators/containers/pyat-softioc-digital-twin# Check if already installed
apptainer --version
# Install if needed
sudo apt update
sudo apt install -y apptainer
cd /tmp
git clone https://codebase.helmholtz.cloud/digital-twins-for-accelerators/containers/pyat-softioc-digital-twin.git dtwin-build
cd dtwin-build
git submodule update --init --recursive
Note: May see warning
fatal: No url found for submodule path...forlat2db/scripts/bessy2reflat— this is expected and harmless.
Important: Do NOT try to pull the pre-built image from
registry.hzdr.de— the pre-builtpyat-softioc-digital-twinimage is AMD64 only and will fail on ARM64. You must build from source.
If recipies/pyat-as-twin-softioc.sdef doesn't exist (e.g., the git repo's .git directory was lost, or repo was cloned but not initialized), create it from the self-contained template:
bash\ncd /tmp/dtwin-build\nmkdir -p recipies\ncp ~/.hermes/skills/science/dtwin-setup/references/sdef-self-contained.sdef recipies/pyat-as-twin-softioc.sdef\n\n\nImportant: The SDEF must include:\n- pip install softioc>=4.1 p4p (PyPI dependencies, not just local packages)\n- uuid.py Python 2 syntax fix (copies /usr/lib/python3.11/uuid.py to override broken package versions)\n- A startup wrapper script that bypasses the interactive Python console (</dev/null)
%startscript with exec /start_ioc.sh (not just exec /start.sh — the script must be created in %post first)bash\ncd /tmp/dtwin-build\napptainer build --fakeroot pyat-as-twin-softioc.sif recipies/pyat-as-twin-softioc.sdef 2>&1 | tail -50\n\n\n> Expected output: INFO: Build complete: pyat-as-twin-softioc.sif\n> File size: ~342 MB\n> Architecture: arm64 (native)\n> Build time: ~3-5 minutes\n\n> Note: The --fakeroot flag is required for building as a non-root user.\n\n### 5. Handle Missing Repositories
If the git repo is unavailable (e.g., codebase.helmholtz.cloud unreachable), all source repos must exist locally in /tmp/dtwin-build/:
dt4acc/bact-twin-architecture/dt4acc-lib/\n- lat2db/\n\nThese are copied into the container via the %files section of the SDEF.
find /twin/python/venv/lib/python3.12/site-packages -name 'uuid.py' -exec cp /usr/lib/python3.12/uuid.py {} ; 2>/dev/null || true
The existing code should look like:
python3 -m pip install -v /build/lat2db/ /build/bact-twin-architecture/ /build/dt4acc/
# ---------------------------------------------------------
# Fix broken uuid.py in p4p/softioc packages (Python 2 syntax)
find /twin/python/venv/lib/python3.12/site-packages -name 'uuid.py' -exec cp /usr/lib/python3.12/uuid.py {} \; 2>/dev/null || true
# ---------------------------------------------------------
# add /twin/lib so that it will be used by ldconfig
### 4. Build the Apptainer Image
```bash
cd /tmp/dtwin-build
apptainer build pyat-as-twin-softioc.sif recipies/pyat-as-twin-softioc.sdef 2>&1 | tail -50
Expected output:
INFO: Build complete: pyat-as-twin-softioc.sifFile size: ~246 MB Architecture: arm64 (native) Build time: ~3-5 minutes
cd /tmp/dtwin-build
nohup apptainer run --cleanenv pyat-as-twin-softioc.sif </dev/null > /tmp/dtwin-ioc.log 2>&1 &
echo "IOC started with PID $!"
Wait for startup (typically 10-15 seconds):
sleep 10
tail -20 /tmp/dtwin-ioc.log
Look for these lines in the log:
✓ softioc initialized
✓ All PVs set up
✓ Starting iocInit
✓ iocRun: All initialization complete
✓ PVXS QSRV2 is loaded, permitted, and ENABLED
✓ EPICS 7.0.10.1-DEV
Run this test script inside the container:
cd /tmp/dtwin-build
apptainer exec --cleanenv pyat-as-twin-softioc.sif /twin/python/venv/bin/python3 -c "
from p4p import listRefs
import time
time.sleep(2)
refs = listRefs()
print(f'Found {len(refs)} PVs')
for ref in sorted(refs)[:10]:
print(f' {ref}')
"
Or run the full integration test:
apptainer exec --cleanenv \
--bind /tmp/dtwin_simple_test.py:/dtwin_simple_test.py \
pyat-as-twin-softioc.sif \
/twin/python/venv/bin/python3 /dtwin_simple_test.py
SyntaxError: invalid decimal literal in uuid.pyuuid.py has Python 2 syntaxFATAL: container creation failed: network requires root--network host without root--network host (EPICS CA broadcasts still work inside container). To expose PVs to host, use --network host with sudo or add user to required groups.softioc.interactive_ioc(globals()) opens a blocking >>> Python prompt. Even with </dev/null, the script may exit silently before iocInit completes.%startscript section — it must exec a wrapper that patches interactive_ioc to call ioc_init() instead, or use exec to bypass the prompt. If logs are truly empty, the IOC may be failing during import (e.g., missing function).initialize_bpm_pvs not found in pv_setup module). Check for NameError in imports by running the script interactively inside the container: apptainer exec --cleanenv pyat-as-twin-softioc.sif /twin/python/venv/bin/python3 -c "from dt4acc.custom_epics.ioc.server import *".fuser -km /tmp/apptainer/mnt/*/mount 2>/dev/null; pkill -9 -f squashfuse 2>/dev/null; fuser -km /tmp/dtwin* 2>/dev/null. Then retry startup.apptainer run fails silently or IOC exits immediately with no log output, stale mounts are likely the culprit.kill $(pgrep -f pyat-as-twin-softioc) 2>/dev/null; sleep 2; fuser -km /tmp/apptainer/mnt/*/mount 2>/dev/nullModuleNotFoundError: No module named 'p4p.ca' or from p4p.client import Client failsfrom p4p import listRefs to query PVs from inside the container. For read/write operations, use EPICS client tools on the host (pvget, pvput) or install p4p with client support on the host and connect to the IOC's EPICS endpoints| Category | Example PVs |
|---|---|
| Cavity | CAVH4T8R:Cm:set, CAVH3T8R:Cm:set |
| BPM | MDIZ2T5G |
| Master Clock | MCLKHX251C |
| Orbit | Various orbit corrector PVs |
| Twiss | Alpha/Beta parameter PVs |
| Tune | Horizontal/Vertical tune PVs |
# Check SIF file
ls -lh pyat-as-twin-softioc.sif
# View running IOC log
tail -f /tmp/dtwin-ioc.log
# Exec into container (interactive shell)
apptainer exec --cleanenv pyat-as-twin-softioc.sif /bin/bash
# Query specific PV from host (requires p4p installed on host)
python3 -c "
from p4p import listRefs
import time
time.sleep(2)
refs = listRefs()
print([r for r in refs if 'CAVH' in r])
"
recipies/pyat-as-twin-softioc.sdef — Apptainer build recipescripts/bessyii/dt4acc_softioc.py — host-side EPICS startup script in the current GitHub dt4acc reposrc/dt4acc/custom_epics/ioc/server.py — EPICS IOC server code/tmp/dtwin_simple_test.py — Integration test scriptFor quick validation of the current GitHub dt4acc/dt4acc-lib codebase, you can skip MongoDB and container startup entirely and smoke-test the core stack on the host by:
dt4acc-lib, dt4acc, lat2db, softioc, p4p, accelerator-toolbox, and transitions into a venv,src/dt4acc/custom_facility/bessyii/resources/storage_ring/input/bessy2_storage_ring_reflat.json,lat2db.tools.factories.pyat.factory,SimulatorBackend + CommandRewriter, andThis is a good first check before debugging container-specific issues.
A developer-maintained README update currently lives on branch:
dt4acc/dt4acc:dev/feature/updated-readmeREADME_details.rstThe developer indicates the new installation flow is not yet fully merged into dev/main because two pull requests are still pending. Once those land, the preferred git-based install is expected to be:
python3 -m venv venv
source venv/bin/activate
python3 -m pip install \
"dt4acc-lib @ git+https://github.com/dt4acc/dt4acc-lib.git" \
"dt4acc[epics,bessyii] @ git+https://github.com/dt4acc/dt4acc.git"
dt4acc_bessyii
Treat this as upstream guidance / near-future workflow, not yet guaranteed for dev/main until the pending PRs are merged.
lat2db/scripts/bessy2reflat fails to recurse but doesn't affect functionality%post section--network hostmongodb://localhost:27017/bessyii but can run without itdt4acc_softioc.py opens a Python >>> prompt; run with </dev/null to bypassapptainer --version returns 1.4+)dtwin-host-smoke-test — first-pass host-side validation of the current dt4acc stack without MongoDB, TANGO, or Apptainerreana-workflow-best-practices — for running dtwin on REANA clustersapptainer — general Apptainer usage patterns