File size: 1,514 Bytes
d721bf1
 
 
 
 
2a2521b
 
 
 
 
 
 
d721bf1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2a2521b
 
 
 
 
 
 
 
 
 
d721bf1
2a2521b
 
 
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
#!/bin/bash

# Fail on error
set -e

# Ensure DVC is initialized (in case .dvc folder was not copied)
if [ ! -d ".dvc" ]; then
    echo "Initializing DVC..."
    dvc init --no-scm
    dvc remote add -d origin https://dagshub.com/se4ai2526-uniba/Hopcroft.dvc
fi

# Determine credentials
# Prefer specific DAGSHUB vars, fallback to MLFLOW vars (often the same for DagsHub)
USER=${DAGSHUB_USERNAME:-$MLFLOW_TRACKING_USERNAME}
PASS=${DAGSHUB_TOKEN:-$MLFLOW_TRACKING_PASSWORD}

if [ -n "$USER" ] && [ -n "$PASS" ]; then
    echo "Configuring DVC authentication for DagsHub..."
    # Configure local config (not committed)
    dvc remote modify origin --local auth basic
    dvc remote modify origin --local user "$USER"
    dvc remote modify origin --local password "$PASS"
else
    echo "WARNING: No DagsHub credentials found. DVC pull might fail if the remote is private."
fi

echo "Pulling models from DVC..."
# Pull only the necessary files for inference
dvc pull models/random_forest_tfidf_gridsearch.pkl.dvc \
         models/tfidf_vectorizer.pkl.dvc \
         models/label_names.pkl.dvc

echo "Starting FastAPI application in background..."
uvicorn hopcroft_skill_classification_tool_competition.main:app --host 0.0.0.0 --port 8000 &

# Wait for API to start
echo "Waiting for API to start..."
sleep 10

echo "Starting Streamlit application..."
export API_BASE_URL="http://localhost:8000"
streamlit run hopcroft_skill_classification_tool_competition/streamlit_app.py --server.port 7860 --server.address 0.0.0.0