VashuTheGreat2 commited on
Commit
70d4931
Β·
verified Β·
1 Parent(s): 1f1b226

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. jenkins +105 -0
  2. main.py +8 -8
jenkins ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pipeline {
2
+ agent any
3
+
4
+ environment {
5
+ REPO_URL = "https://github.com/VashuTheGreat/Multi-Rag.git"
6
+ PROJECT_NAME = "Multi-Rag"
7
+ SPACE_NAME="Multi-Rag"
8
+ HF_USERNAME="VashuTheGreat2"
9
+ HF_TOKEN = credentials('HF_TOKEN')
10
+
11
+ }
12
+
13
+ stages {
14
+
15
+ stage('Clone Repository') {
16
+ steps {
17
+ echo "πŸ“₯ Cloning repository..."
18
+ git branch: 'main', url: "${REPO_URL}"
19
+ }
20
+ }
21
+
22
+ stage('Setup Dependencies') {
23
+ steps {
24
+ echo "πŸ”§ Setting git identity and installing HF CLI..."
25
+ sh '''#!/bin/bash
26
+ set -e
27
+ git config --global user.name "jenkins"
28
+ git config --global user.email "jenkins@local"
29
+ export PATH=$HOME/.local/bin:$PATH
30
+ if ! command -v hf &> /dev/null; then
31
+ pip3 install --user -U huggingface_hub
32
+ fi
33
+ '''
34
+ }
35
+ }
36
+
37
+ stage('Authenticate Hugging Face') {
38
+ steps {
39
+ echo "πŸ” Logging into Hugging Face..."
40
+ sh '''#!/bin/bash
41
+ set -e
42
+ export PATH=$HOME/.local/bin:$PATH
43
+ hf auth login --token "$HF_TOKEN"
44
+ '''
45
+ }
46
+ }
47
+
48
+ stage('Configure Space Meta') {
49
+ steps {
50
+ echo "πŸ“ Injecting HF Spaces configuration into README.md..."
51
+ sh '''#!/bin/bash
52
+ set -e
53
+ TEMP_README=$(mktemp)
54
+ cat << EOF > "$TEMP_README"
55
+ ---
56
+ title: $PROJECT_NAME
57
+ emoji: πŸ€–
58
+ colorFrom: blue
59
+ colorTo: green
60
+ sdk: docker
61
+ app_file: main.py
62
+ pinned: false
63
+ short_description: This is the Multi-Rag Agent
64
+ ---
65
+
66
+ EOF
67
+ cat README.md >> "$TEMP_README"
68
+ mv "$TEMP_README" README.md
69
+ '''
70
+ }
71
+ }
72
+
73
+ stage('Create App Space') {
74
+ steps {
75
+ echo "πŸš€ Creating HF Space if it doesn't exist..."
76
+ sh '''#!/bin/bash
77
+ set -e
78
+ export PATH=$HOME/.local/bin:$PATH
79
+ hf repos create "$HF_USERNAME/$SPACE_NAME" --type space --space-sdk docker || true
80
+ '''
81
+ }
82
+ }
83
+
84
+ stage('Upload to HF Space') {
85
+ steps {
86
+ echo "πŸ“€ Uploading project files..."
87
+ sh '''#!/bin/bash
88
+ set -e
89
+ export PATH=$HOME/.local/bin:$PATH
90
+ hf upload "$HF_USERNAME/$SPACE_NAME" . --repo-type=space
91
+ '''
92
+ }
93
+ }
94
+
95
+ }
96
+
97
+ post {
98
+ success {
99
+ echo "βœ… Pipeline executed successfully!"
100
+ }
101
+ failure {
102
+ echo "❌ Pipeline failed!"
103
+ }
104
+ }
105
+ }
main.py CHANGED
@@ -15,11 +15,11 @@ app.mount("/blog/images", StaticFiles(directory="images"), name="blog_images")
15
  os.makedirs(DATA_FOLDER_PATH, exist_ok=True)
16
  os.makedirs(DB_FOLDER_PATH, exist_ok=True)
17
 
18
- if __name__ == "__main__":
19
- uv.run(
20
- "main:app",
21
- host="0.0.0.0",
22
- port=7860,
23
- reload=True,
24
- reload_excludes=["db/*", "data/*", "logs/*", "vector_db/*", ".venv/*"],
25
- )
 
15
  os.makedirs(DATA_FOLDER_PATH, exist_ok=True)
16
  os.makedirs(DB_FOLDER_PATH, exist_ok=True)
17
 
18
+ # if __name__ == "__main__":
19
+ # uv.run(
20
+ # "main:app",
21
+ # host="0.0.0.0",
22
+ # port=7860,
23
+ # reload=False,
24
+ # reload_excludes=["db/*", "data/*", "logs/*", "vector_db/*", ".venv/*"],
25
+ # )