Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

setup.sh 1.4 KB

You have to be logged in to leave a comment. Sign In
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
  1. #!/bin/bash
  2. # MLflow Model Serving Setup Script
  3. # This script sets up everything needed to run the model serving API
  4. echo "๐Ÿš€ MLflow Model Serving Setup"
  5. echo "================================"
  6. # Step 1: Install Python dependencies
  7. echo "๐Ÿ“ฆ Installing Python dependencies..."
  8. pip install -r requirements.txt
  9. # Step 2: Train a model if one doesn't exist
  10. if [ ! -f "models/iris_model.pkl" ]; then
  11. echo "๐Ÿค– Training model (no existing model found)..."
  12. python simple_train.py
  13. else
  14. echo "โœ… Model already exists at models/iris_model.pkl"
  15. fi
  16. # Step 3: Test the API locally
  17. echo "๐Ÿงช Testing API locally..."
  18. echo "Starting FastAPI server in background..."
  19. python app.py &
  20. SERVER_PID=$!
  21. # Wait for server to start
  22. sleep 5
  23. # Test the API
  24. echo "Testing root endpoint..."
  25. curl -s http://localhost:8000/ | python -m json.tool
  26. echo -e "\nTesting prediction endpoint..."
  27. curl -s -X POST "http://localhost:8000/predict" \
  28. -H "Content-Type: application/json" \
  29. -d '{"features": [5.1, 3.5, 1.4, 0.2]}' | python -m json.tool
  30. # Stop the server
  31. kill $SERVER_PID
  32. echo -e "\nโœ… Setup complete!"
  33. echo -e "\n๐Ÿ“‹ Next steps:"
  34. echo "1. To run locally: python app.py"
  35. echo "2. To build Docker image: docker build -t iris-model-api ."
  36. echo "3. To run Docker container: docker run -p 8000:8000 iris-model-api"
  37. echo "4. API will be available at: http://localhost:8000"
  38. echo "5. Interactive docs at: http://localhost:8000/docs"
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...