Skip to content

Commit

Permalink
Add template
Browse files Browse the repository at this point in the history
  • Loading branch information
you-n-g committed Nov 15, 2024
1 parent 18370d4 commit 21a99d2
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/exp/ablation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Introduction

| name | .env | desc |
| -- | -- | -- |
| full | full.env | enable all features |
1 change: 1 addition & 0 deletions scripts/exp/ablation/env/full.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions scripts/exp/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The tools in the directory contains following generalfeatures
- collecting envs and run each
- collect results and generate summary
Empty file added scripts/exp/tools/collect.py
Empty file.
46 changes: 46 additions & 0 deletions scripts/exp/tools/run_envs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
cat << "EOF" > /dev/null
Given a directory with *.env files. Run each one.
usage for example:
1) directly run command without extra shared envs
./run_envs.sh -d <dir_to_*.envfiles> -j <number of parallel process> -- <command>
2) load shared envs `.env` before running command with different envs.
dotenv run -- ./run_envs.sh -d <dir_to_*.envfiles> -j <number of parallel process> -- <command>
EOF

# Function to display usage
usage() {
echo "Usage: $0 -d <dir_to_*.envfiles> -j <number of parallel process> -- <command>"
exit 1
}

# Parse command line arguments
while getopts "d:j:" opt; do
case $opt in
d) DIR=$OPTARG ;;
j) JOBS=$OPTARG ;;
*) usage ;;
esac
done

# Shift to get the command
shift $((OPTIND -1))

# Check if directory and jobs are set
if [ -z "$DIR" ] || [ -z "$OBS" ] || [ $# -eq 0 ]; then
usage
fi

COMMAND="$@"

# Export and run each .env file in parallel
find "$DIR" -name "*.env" | xargs -n 1 -P "$JOBS" -I {} sh -c "
set -a
. {}
set +a
$COMMAND
"

0 comments on commit 21a99d2

Please sign in to comment.