1
- name : Run Python script
1
+ name : Deploy to Hugging Face Spaces
2
2
3
3
on :
4
4
push :
5
5
branches :
6
6
- main
7
7
8
8
jobs :
9
- build :
9
+ deploy :
10
10
runs-on : ubuntu-latest
11
+ timeout-minutes : 30 # Adjust this value as needed
11
12
12
13
steps :
13
14
- name : Checkout
14
- uses : actions/checkout@v2
15
+ uses : actions/checkout@v3
15
16
16
- - name : Set up Python
17
- uses : actions /setup-python @v2
17
+ - name : Set up Conda
18
+ uses : conda-incubator /setup-miniconda @v2
18
19
with :
19
- python-version : ' 3.9'
20
+ activate-environment : kg4s
21
+ environment-file : environment.yml
22
+ auto-activate-base : false
23
+ use-mamba : true
20
24
21
- - name : Install Gradio
22
- run : python -m pip install gradio
25
+ - name : Verify Conda installation
26
+ shell : bash -l {0}
27
+ run : |
28
+ conda info
29
+ conda list
23
30
24
- - name : Log in to Hugging Face
25
- run : python -c 'import huggingface_hub; huggingface_hub.login(token="${{ secrets.hf_token }}")'
31
+ - name : Install huggingface_hub
32
+ shell : bash -l {0}
33
+ run : |
34
+ pip install huggingface_hub
35
+ pip list
26
36
27
- - name : Deploy to Spaces
28
- run : gradio deploy
37
+ - name : Deploy to Hugging Face Spaces
38
+ env :
39
+ HF_TOKEN : ${{ secrets.HF_TOKEN }}
40
+ shell : bash -l {0}
41
+ run : |
42
+ python - <<EOF
43
+ import os
44
+ import sys
45
+ from huggingface_hub import HfApi
46
+
47
+ print("Python script started")
48
+ print(f"Python version: {sys.version}")
49
+ print(f"Current working directory: {os.getcwd()}")
50
+ print(f"Contents of current directory: {os.listdir('.')}")
51
+
52
+ sys.path.append('scripts')
53
+ print(f"Updated sys.path: {sys.path}")
54
+ print(f"Contents of scripts directory: {os.listdir('scripts')}")
55
+
56
+ print("Importing demo from run_db_interface")
57
+ from run_db_interface import demo
58
+ print("Demo imported successfully")
59
+
60
+ api = HfApi()
61
+ print("HfApi initialized")
62
+
63
+ print("Creating/verifying repository")
64
+ api.create_repo(
65
+ repo_id="abby101/xurveyor-0",
66
+ repo_type="space",
67
+ space_sdk="gradio",
68
+ token="$HF_TOKEN"
69
+ )
70
+ print("Repository created or verified")
71
+
72
+ print("Starting deployment")
73
+ demo.deploy(
74
+ repo_id="abby101/xurveyor-0",
75
+ hf_token="$HF_TOKEN",
76
+ )
77
+ print("Deployment completed")
78
+ EOF
79
+
80
+ - name : Check Hugging Face Space
81
+ run : |
82
+ echo "Deployment process completed. Please check your Hugging Face Space at https://huggingface.co/spaces/abby101/xurveyor-0"
83
+ echo "If the space is not updated, please check the logs above for any errors."
0 commit comments