Spaces:
Paused
Paused
File size: 730 Bytes
13c6f75 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import os
from fastapi import FastAPI
from huggingface_hub import HfApi
TOKEN = os.environ.get("BULK_ENERGY_TOKEN")
API = HfApi(token=TOKEN)
REPO_ID = "AIEnergyScore/BulkCalcSpace"
app = FastAPI()
@app.get("/")
def start_train():
space_variables = API.get_space_variables(repo_id=REPO_ID)
if 'STATUS' in space_variables and space_variables['STATUS'] != 'COMPUTING':
print("Beginning processing.")
API.add_space_variable(repo_id=REPO_ID, key='STATUS', value='COMPUTING')
os.system(f"./entrypoint.sh {REPO_ID}")
API.add_space_variable(repo_id=REPO_ID, key='STATUS', value='NOT_COMPUTING')
print("Pausing space")
API.pause_space(REPO_ID)
return {"Status": space_variables['STATUS']} |