maitri01 commited on
Commit
8b66cc2
·
verified ·
1 Parent(s): 89ce8a0

Update teammate.sh

Browse files
Files changed (1) hide show
  1. teammate.sh +75 -65
teammate.sh CHANGED
@@ -1,67 +1,3 @@
1
- #!/bin/bash
2
- # =============================================================
3
- # HACKATHON SETUP: STEP 2 OF 2 - TEAMMATES RUN AFTER TEAM LEAD
4
- # =============================================================
5
- # EXECUTION ORDER (IMPORTANT):
6
- # 1. The TEAM LEAD must first run hackathon_setup.sh and
7
- # finish creating the shared folders, ACLs, datasets and envs.
8
- # 2. ONLY AFTER THE TEAM LEAD FINISHES, each remaining team
9
- # member runs THIS script from their own JURECA account.
10
- # Run: source teammate.sh
11
- #
12
- # The team lead runs hackathon_setup.sh, not this script.
13
- # Every remaining member runs teammate.sh individually.
14
- #
15
- # Before running, set TEAM_LEAD to the team lead's Juelich
16
- # username and TEAM_FOLDER to the EXACT team name used by
17
- # the team lead in hackathon_setup.sh.
18
- # =============================================================
19
-
20
- # =============================================================
21
- # CONFIGURATION - EACH TEAMMATE EDITS THESE VALUES
22
- # =============================================================
23
- TEAM_LEAD="" # Juelich username of your team lead
24
- TEAM_FOLDER="" # Exact team name from the team lead's setup
25
- # =============================================================
26
-
27
- RED='\033[0;31m'
28
- GREEN='\033[0;32m'
29
- YELLOW='\033[1;33m'
30
- BLUE='\033[0;34m'
31
- NC='\033[0m'
32
-
33
- _log() { echo -e "${BLUE}[INFO]${NC} $1"; }
34
- _ok() { echo -e "${GREEN}[OK]${NC} $1"; }
35
- _warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
36
- _error() { echo -e "${RED}[ERROR]${NC} $1"; }
37
-
38
- if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
39
- _error "This script must be sourced: source teammate.sh"
40
- exit 1
41
- fi
42
-
43
- if [[ -z "$TEAM_LEAD" || -z "$TEAM_FOLDER" || "$TEAM_LEAD" == */* || "$TEAM_FOLDER" == */* || "$TEAM_FOLDER" == "." || "$TEAM_FOLDER" == ".." ]]; then
44
- _error "Set valid TEAM_LEAD and TEAM_FOLDER values before running."
45
- return 1
46
- fi
47
-
48
- PROJECT_NAME="training2666"
49
- WRITE_TO_BASHRC="yes"
50
-
51
- SCRATCH_BASE="/p/scratch/$PROJECT_NAME"
52
- TEAM_DIR="$SCRATCH_BASE/$TEAM_LEAD/$TEAM_FOLDER"
53
- UV_BASE="$TEAM_DIR/.uv"
54
- HF_CACHE="$TEAM_DIR/.cache"
55
-
56
- echo ""
57
- echo "============================================="
58
- echo " Shared Team Setup - Teammates (Step 2/2)"
59
- echo "============================================="
60
- echo ""
61
- echo " Project : $PROJECT_NAME"
62
- echo " Team lead : $TEAM_LEAD"
63
- echo " Team folder : $TEAM_DIR"
64
- echo ""
65
 
66
  _log "Step 1/4 - Checking cluster tools..."
67
 
@@ -93,4 +29,78 @@ fi
93
 
94
  if [[ ! -r "$TEAM_DIR" || ! -w "$TEAM_DIR" || ! -x "$TEAM_DIR" ]]; then
95
  _error "You do not have read/write/traverse access to: $TEAM_DIR"
96
- echo " Ask the team lead to check the shared-folder ACLs."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
  _log "Step 1/4 - Checking cluster tools..."
3
 
 
29
 
30
  if [[ ! -r "$TEAM_DIR" || ! -w "$TEAM_DIR" || ! -x "$TEAM_DIR" ]]; then
31
  _error "You do not have read/write/traverse access to: $TEAM_DIR"
32
+ echo " Ask the team lead to check the shared-folder ACLs."
33
+ return 1
34
+ fi
35
+
36
+ _log "Step 3/4 - Exporting shared cache paths..."
37
+
38
+ export UV_CACHE_DIR="$UV_BASE/cache"
39
+ export UV_TOOL_DIR="$UV_BASE/tools"
40
+ export UV_PYTHON_INSTALL_DIR="$UV_BASE/python"
41
+ export HF_HOME="$HF_CACHE"
42
+ export HUGGINGFACE_HUB_CACHE="$HF_CACHE/hub"
43
+
44
+ _ok "Shared environment variables exported in current shell."
45
+
46
+ if [[ "$WRITE_TO_BASHRC" == "yes" ]]; then
47
+ if grep -Fq "TEAM SHARED UV/HF CONFIG: $TEAM_DIR" "$HOME/.bashrc" 2>/dev/null; then
48
+ _warn "Shared config already present in ~/.bashrc"
49
+ else
50
+ cat <<EOF >> "$HOME/.bashrc"
51
+
52
+ # TEAM SHARED UV/HF CONFIG: $TEAM_DIR
53
+ export PATH="\$HOME/.local/bin:\$PATH"
54
+ export UV_CACHE_DIR="$UV_BASE/cache"
55
+ export UV_TOOL_DIR="$UV_BASE/tools"
56
+ export UV_PYTHON_INSTALL_DIR="$UV_BASE/python"
57
+ export HF_HOME="$HF_CACHE"
58
+ export HUGGINGFACE_HUB_CACHE="$HF_CACHE/hub"
59
+ EOF
60
+ _ok "Shared config written to ~/.bashrc"
61
+ fi
62
+ fi
63
+
64
+ _log "Step 4/4 - Checking shared folder and uv..."
65
+ _ok "You can access the shared team folder."
66
+
67
+ if command -v uv &> /dev/null; then
68
+ _ok "uv found: $(uv --version 2>&1)"
69
+ else
70
+ _warn "uv is not available in your shell. Installing for this user..."
71
+
72
+ if ! curl -LsSf https://astral.sh/uv/install.sh | sh; then
73
+ _error "uv installation failed."
74
+ return 1
75
+ fi
76
+
77
+ if [[ -f "$HOME/.local/bin/env" ]]; then
78
+ source "$HOME/.local/bin/env"
79
+ fi
80
+
81
+ export PATH="$HOME/.local/bin:$PATH"
82
+
83
+ if command -v uv &> /dev/null; then
84
+ _ok "uv installed: $(uv --version 2>&1)"
85
+ else
86
+ _error "uv installation seems to have failed."
87
+ echo "Run these manually:"
88
+ echo "curl -LsSf https://astral.sh/uv/install.sh | sh"
89
+ echo 'source $HOME/.local/bin/env'
90
+ return 1
91
+ fi
92
+ fi
93
+
94
+ echo ""
95
+ echo "============================================="
96
+ echo -e "${GREEN} Teammate shell setup complete!${NC}"
97
+ echo "============================================="
98
+ echo ""
99
+ echo "Use the shared folder with:"
100
+ echo " cd $TEAM_DIR/<dataset-name>"
101
+ echo " source .venv/bin/activate"
102
+ echo ""
103
+ echo "Or run from inside a task directory:"
104
+ echo " cd $TEAM_DIR/<dataset-name>"
105
+ echo " uv run python main.py"
106
+ echo ""