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