Artenv
artenv は Artemis の version と解析環境を管理するためのツールです.
pyenv や rbenv のように, コマンド一つで Artemis 環境と解析ディレクトリを切り替えられます.
v2 では native installation に加えて Apptainer container image も Artemis version として扱えるようになりました. Apptainer image を使うと, ROOT, yaml-cpp, Artemis を利用先の計算機ごとに用意する手間を減らせます. 解析環境をほかの計算機や共同研究者とそろえやすくなる点も利点です.
Concepts
artenv では, Artemis の実行環境と解析ディレクトリを分けて管理します.
- version: Artemis の実行環境. native installation または Apptainer image.
- environment: 実験・解析ごとの作業環境. 使用する version, working directory, git repository, artlogin の設定などを持つ.
- template: 新しい解析ディレクトリを作るためのひな形. 外部 git repository から取得して使う.
まず artenv version install や artenv version register で Artemis version を登録し,
次に artenv register で解析 environment を登録します.
登録後は次のように切り替えられます.
artenv shell h424
artenv default h424
artenv shell <env> は現在の shell だけを切り替えます.
artenv default <env> は新しく開く shell で使うデフォルト environment を設定します.
Requirements
bash- GNU coreutils (
readlink -f,realpath) git- mikefarah/yq v4 以降 (TOML の読み込みに使用.
artenv bootstrapで導入可能) curlまたはwget(yq の取得や version の install に使用)- Apptainer version を使う場合は
apptainer
shell integration は bash と zsh で使えます.
Installation
git clone で artenv 本体を配置します.
git clone https://github.com/yano404/artenv.git ~/.artenv
.bashrc や .zshrc に次を追加します.
export ARTENV_ROOT="$HOME/.artenv"
export PATH="$ARTENV_ROOT/bin:$PATH"
eval "$(artenv init -)"
shell を再起動します.
exec $SHELL
yq の導入
設定ファイルの読み込みに使う yq は, 次のコマンドで管理者権限なしで導入できます.
artenv bootstrap
省略した場合は, 既存の mikefarah/yq v4 以降を使い, 見つからなければ必要時に自動取得します.
Shell Completion
artenv は bash と zsh の補完を提供しています.
bash の場合は .bashrc などで補完スクリプトを読み込みます.
source "${ARTENV_ROOT}/completions/artenv.bash"
zsh の場合は fpath に補完ディレクトリを追加し, compinit を初期化します.
fpath=("${ARTENV_ROOT}/completions" $fpath)
autoload -Uz compinit
compinit
Quick Start
1. Artemis version を用意する
Apptainer を使える環境では, container image を pull して version として登録するのが簡単です.
artenv version install latest
tag を指定すると, URI, version name, SIF 保存先の入力は省略されます.
この例では artemis_apptainer-latest という version が登録され,
image は $ARTENV_ROOT/images/artemis_apptainer-latest.sif に保存されます.
利用可能な tag は次で確認できます.
artenv version install --list
対話的に Apptainer image を登録することもできます.
$ artenv version install --apptainer
Enter the pull URI [oras://ghcr.io/yano404/artemis_apptainer:latest]>
Enter the version name> artemis-latest
Enter the path to save SIF [/home/yano/.artenv/images/artemis-latest.sif]>
Configuration:
URI oras://ghcr.io/yano404/artemis_apptainer:latest
VERSION artemis-latest
SIF /home/yano/.artenv/images/artemis-latest.sif
OK? (y/N)> y
すでに .sif image を持っている場合は, それを version として登録できます.
$ artenv version register artemis-apptainer
Select version type
1) native
2) apptainer
#? 2
Enter the path to Apptainer image (.sif)> /path/to/artemis.sif
artemis-apptainer was registered
native installation を使う場合は, Artemis, ROOT, yaml-cpp の path を登録します.
$ artenv version register artemis-native
Select version type
1) native
2) apptainer
#? 1
Enter the path to artemis> /path/to/artemis
Enter the path to root> /path/to/root
Enter the path to yaml-cpp> /path/to/yaml-cpp
artemis-native was registered
source から Artemis を build して登録したい場合は --native を使います.
$ artenv version install --native
Enter the path to root> /home/yano/local/root/v6.32.04
Enter the path to yaml-cpp> /home/yano/local/yaml-cpp/v0.8.0
Enter the path to the source of artemis> /home/yano/src/artemis/develop
Enter the path to build directory> /home/yano/build/artemis/artdev
Enter the install prefix> /home/yano/local/artemis/artdev
Configuration:
ROOTSYS /home/yano/local/root/v6.32.04
YAML_CPP_LIB /home/yano/local/yaml-cpp/v0.8.0/lib
YAML_CPP_CMAKE /home/yano/local/yaml-cpp/v0.8.0/lib/cmake
ARTEMIS_SOURCE /home/yano/src/artemis/develop
BUILD_DIR /home/yano/build/artemis/artdev
INSTALL_PREFIX /home/yano/local/artemis/artdev
OK? (y/N)> y
Will you register this version to artenv? (y/N)> y
Enter the version name> artemis-native
artemis-native was registered
2. 解析ディレクトリを登録する・作成する
version を用意したら, 解析ディレクトリを artenv で扱えるようにします.
既存の解析ディレクトリを使う場合は artenv register で登録します.
新しく解析ディレクトリを作る場合は, artenv new で template から working directory を作ってから登録します.
既存の解析ディレクトリを登録する
すでに解析ディレクトリがある場合は, それを environment として登録します.
$ artenv register h424
Select the artemis version
1) artemis-native
2) artemis_apptainer-latest
#? 2
artemis_apptainer-latest was selected
Enter the path to working directory> /path/to/analysis_directory
Use artlogin? (y/n)> n
Enter the path to git repos (optional)> /path/to/git_repos or URL of git repos
h424 was registered
artlogin を使う場合は git repository の指定が必須です.
Use artlogin? (y/n)> y
Enter the path to git repos (required)> /path/to/git_repos or URL of git repos
登録した environment は次で有効化できます.
artenv shell h424
batch job や HPC のセットアップスクリプトでは, 対話せずに登録することもできます.
artenv register h424 \
--version artemis_apptainer-latest \
--work /path/to/analysis_directory \
--singleuser
複数人で共有する artlogin environment の場合は --multiuser と --repos を使います.
artenv register h424 \
--version artemis_apptainer-latest \
--work /path/to/shared_directory \
--repos /path/to/upstream.git \
--multiuser
Template から解析ディレクトリを作る
新しい解析ディレクトリを作る場合は artenv new を使います.
artenv new は template をもとに基本的なディレクトリ構造を作るためのコマンドです.
作成されるのは解析のひな形なので, detector 構成, steering file, parameter file などを実験に合わせて編集する必要があります.
artenv new で解析ディレクトリを作る場合は, 最初に template repository を取得します.
artenv templates update
標準では artemis-templates が default repository として使われます. 取得済みの template は次で確認できます.
artenv templates ls
template を指定して working directory を作ります.
artenv new /path/to/work -t default/standard
template 名が一意に決まる場合は repository 名を省略できます.
artenv new /path/to/work -t standard
-t を省略して対話的に選ぶこともできます.
$ artenv new art
Select the template
1) default/standard
#? 1
created /path/to/art from template default/standard
Next: register an environment for this directory:
artenv register <env> --version <version> --work /path/to/art
作成した directory は, 必要な設定を編集したあとで environment として登録します.
artenv register h424 \
--version artemis_apptainer-latest \
--work /path/to/art \
--singleuser
Configuration Files
設定は $ARTENV_ROOT 以下の TOML ファイルとして保存されます.
Version Configuration
native version の例です.
[version]
type = "native"
artsys = "/path/to/artemis"
rootsys = "/path/to/root"
yamllib = "/path/to/yaml-cpp/lib"
yamlcmake = "/path/to/yaml-cpp/cmake"
Apptainer version の例です.
[version]
type = "apptainer"
uri = "oras://ghcr.io/yano404/artemis_apptainer:latest"
image = "/path/to/artemis.sif"
digest = "sha256:..."
uri と digest は artenv version install で登録した場合に保存されます.
既存の .sif を artenv version register で登録した場合は image のみです.
Environment Configuration
[env]
version = "artemis-latest"
work = "/path/to/work"
git_repos = "/path/to/git_repos"
use_artlogin = false
binds = ["/extra/path"]