-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_pipeline.sh
executable file
·48 lines (34 loc) · 1.47 KB
/
run_pipeline.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Script name: run_pipeline.sh
# Set session name
SESSION_NAME="pipeline_experiment"
# Set your conda environment name here
CONDA_ENV="mip" # Replace with your environment name
# Create log directory if it doesn't exist
mkdir -p tmux_logs
# Get current timestamp
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
# Check if the session exists
tmux has-session -t $SESSION_NAME 2>/dev/null
if [ $? != 0 ]; then
# Create a new session
tmux new-session -d -s $SESSION_NAME
# Set up window
tmux rename-window -t $SESSION_NAME:0 'pipeline'
# Configure logging
tmux pipe-pane -t $SESSION_NAME:0 "cat >> tmux_logs/pipeline_${TIMESTAMP}.log"
# Initialize conda for bash shell
tmux send-keys -t $SESSION_NAME:0 'eval "$(conda shell.bash hook)"' C-m
# Activate conda environment
tmux send-keys -t $SESSION_NAME:0 "conda activate $CONDA_ENV" C-m
# Navigate to the correct directory (modify path as needed)
tmux send-keys -t $SESSION_NAME:0 "cd $(pwd)" C-m
# Run the pipeline with nohup to ensure it continues running
tmux send-keys -t $SESSION_NAME:0 "python pipeline.py > pipeline_output_${TIMESTAMP}.log 2>&1" C-m
echo "Started pipeline in tmux session: $SESSION_NAME"
echo "Logging to: tmux_logs/pipeline_${TIMESTAMP}.log"
echo "Additional output in: pipeline_output_${TIMESTAMP}.log"
else
echo "Session $SESSION_NAME already exists"
echo "Use 'tmux attach -t $SESSION_NAME' to connect to it"
fi