maitri01 commited on
Commit
f6989d0
·
verified ·
1 Parent(s): 195496c

Update teammate.sh

Browse files
Files changed (1) hide show
  1. teammate.sh +36 -90
teammate.sh CHANGED
@@ -1,19 +1,27 @@
1
  #!/bin/bash
2
  # =============================================================
3
- # Hackathon Setup each for teammates
4
- # Make changes in CONFIGURATION section below before running this script:
5
- # 1) for property OWNER: add your team lead user name from Juelich
6
- # 2) for property TEAM_FOLDER: add your team name (exactly same what the team_leader added in hackathon_setup.sh)
7
- # Run with: source teammate.sh
 
 
 
 
 
 
 
 
 
 
8
  # =============================================================
9
 
10
  # =============================================================
11
- # CONFIGURATION — edit before running
12
  # =============================================================
13
-
14
- OWNER="" # <-- replace with your team_lead username from Juelich
15
- TEAM_FOLDER="" # <-- replace with your team_name as done by team_lead
16
-
17
  # =============================================================
18
 
19
  RED='\033[0;31m'
@@ -32,23 +40,26 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
32
  exit 1
33
  fi
34
 
 
 
 
 
 
35
  PROJECT_NAME="training2625"
36
  WRITE_TO_BASHRC="yes"
37
 
38
- # =============================================================
39
-
40
  SCRATCH_BASE="/p/scratch/$PROJECT_NAME"
41
- TEAM_DIR="$SCRATCH_BASE/$OWNER/$TEAM_FOLDER"
42
-
43
  UV_BASE="$TEAM_DIR/.uv"
44
  HF_CACHE="$TEAM_DIR/.cache"
45
 
46
  echo ""
47
  echo "============================================="
48
- echo " Shared Team Environment Setup"
49
  echo "============================================="
50
  echo ""
51
  echo " Project : $PROJECT_NAME"
 
52
  echo " Team folder : $TEAM_DIR"
53
  echo ""
54
 
@@ -62,89 +73,24 @@ _ok "jutil found."
62
 
63
  _log "Step 2/4 - Activating project $PROJECT_NAME..."
64
 
65
- jutil env activate -p "$PROJECT_NAME"
 
 
 
66
 
67
  if [[ -z "$PROJECT" ]]; then
68
- _error "\$PROJECT is empty after activation."
69
  return 1
70
  fi
71
  _ok "Project activated. \$PROJECT = $PROJECT"
72
 
73
- _log "Step 3/4 - Exporting shared cache paths..."
74
-
75
- export UV_CACHE_DIR="$UV_BASE/cache"
76
- export UV_TOOL_DIR="$UV_BASE/tools"
77
- export UV_PYTHON_INSTALL_DIR="$UV_BASE/python"
78
- export HF_HOME="$HF_CACHE"
79
- export HUGGINGFACE_HUB_CACHE="$HF_CACHE/hub"
80
-
81
- _ok "Shared environment variables exported in current shell."
82
-
83
- if [[ "$WRITE_TO_BASHRC" == "yes" ]]; then
84
- if grep -q "TEAM SHARED UV/HF CONFIG: $TEAM_DIR" ~/.bashrc 2>/dev/null; then
85
- _warn "Shared config already present in ~/.bashrc"
86
- else
87
- cat << EOF >> ~/.bashrc
88
-
89
- # TEAM SHARED UV/HF CONFIG: $TEAM_DIR
90
- export PATH="\$HOME/.local/bin:\$PATH"
91
- export UV_CACHE_DIR=$UV_BASE/cache
92
- export UV_TOOL_DIR=$UV_BASE/tools
93
- export UV_PYTHON_INSTALL_DIR=$UV_BASE/python
94
- export HF_HOME=$HF_CACHE
95
- export HUGGINGFACE_HUB_CACHE=$HF_CACHE/hub
96
- EOF
97
- _ok "Shared config written to ~/.bashrc"
98
- fi
99
- fi
100
-
101
- _log "Step 4/4 - Checking access to shared folder and uv..."
102
-
103
  if [[ ! -d "$TEAM_DIR" ]]; then
104
  _error "Shared team folder does not exist: $TEAM_DIR"
 
105
  return 1
106
  fi
107
 
108
- if [[ ! -r "$TEAM_DIR" || ! -x "$TEAM_DIR" ]]; then
109
- _error "You do not have proper access to: $TEAM_DIR"
110
- return 1
111
- fi
112
-
113
- _ok "You can access the shared team folder."
114
-
115
- if command -v uv &> /dev/null; then
116
- _ok "uv found: $(uv --version 2>&1)"
117
- else
118
- _warn "uv is not available in your shell. Installing for this user..."
119
-
120
- curl -LsSf https://astral.sh/uv/install.sh | sh
121
-
122
- if [[ -f "$HOME/.local/bin/env" ]]; then
123
- source "$HOME/.local/bin/env"
124
- fi
125
-
126
- export PATH="$HOME/.local/bin:$PATH"
127
-
128
- if command -v uv &> /dev/null; then
129
- _ok "uv installed: $(uv --version 2>&1)"
130
- else
131
- _error "uv installation seems to have failed."
132
- echo "Run these manually:"
133
- echo "curl -LsSf https://astral.sh/uv/install.sh | sh"
134
- echo "source \$HOME/.local/bin/env"
135
- return 1
136
- fi
137
- fi
138
-
139
- echo ""
140
- echo "============================================="
141
- echo -e "${GREEN} Teammate shell setup complete!${NC}"
142
- echo "============================================="
143
- echo ""
144
- echo "Use the shared folder with:"
145
- echo " cd $TEAM_DIR/<dataset-name>"
146
- echo " source .venv/bin/activate"
147
- echo ""
148
- echo "Or run directly:"
149
- echo " uv run $TEAM_DIR/<dataset-name>/main.py"
150
- echo ""
 
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'
 
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="training2625"
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
 
 
73
 
74
  _log "Step 2/4 - Activating project $PROJECT_NAME..."
75
 
76
+ if ! jutil env activate -p "$PROJECT_NAME"; then
77
+ _error "Could not activate project $PROJECT_NAME."
78
+ return 1
79
+ fi
80
 
81
  if [[ -z "$PROJECT" ]]; then
82
+ _error '\$PROJECT is empty after activation.'
83
  return 1
84
  fi
85
  _ok "Project activated. \$PROJECT = $PROJECT"
86
 
87
+ # Verify the team lead has finished the shared setup before writing config.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  if [[ ! -d "$TEAM_DIR" ]]; then
89
  _error "Shared team folder does not exist: $TEAM_DIR"
90
+ echo " Ask the team lead to finish hackathon_setup.sh first."
91
  return 1
92
  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."