forked from weaigc/bingo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/endpoint.txt | ||
/.env |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from huggingface_hub import HfApi, list_models | ||
import os | ||
|
||
hf_api = HfApi( | ||
endpoint="https://huggingface.co", # Can be a Private Hub endpoint. | ||
token=os.environ.get('HF_TOKEN'), # Token is not persisted on the machine. | ||
) | ||
ENDPOINTS = os.environ.get('ENDPOINTS') | ||
file = 'endpoint.txt' | ||
endpoints = ENDPOINTS.split('\n') | ||
endpoint = endpoints[0].strip() | ||
try: | ||
with open(file,"r") as f: | ||
content=f.read().strip() | ||
endpoint = endpoints[1] if content == endpoints[0] else endpoints[0] | ||
f.close() | ||
except IOError: | ||
print("File not accessible") | ||
with open(file, "w") as wf: | ||
wf.write(endpoint) | ||
wf.close() | ||
|
||
print('new endpoint', endpoint) | ||
hf_api.add_space_secret('hf4all/bingo2', 'ENDPOINT', endpoint.strip()) | ||
|