Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
from fastapi import FastAPI, Request, Form
|
| 3 |
from fastapi.templating import Jinja2Templates
|
| 4 |
from fastapi.responses import HTMLResponse
|
| 5 |
-
from fastapi.staticfiles import StaticFiles
|
| 6 |
import wandb
|
|
|
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
templates = Jinja2Templates(directory="./")
|
|
@@ -21,7 +21,11 @@ async def process_form(
|
|
| 21 |
run_id: str = Form(...)
|
| 22 |
):
|
| 23 |
try:
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
api = wandb.Api()
|
| 26 |
run_path = f"{entity}/{project}/runs/{run_id}"
|
| 27 |
run = api.run(run_path)
|
|
@@ -29,7 +33,11 @@ async def process_form(
|
|
| 29 |
return templates.TemplateResponse(
|
| 30 |
"index.html",
|
| 31 |
{
|
| 32 |
-
"request": request,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
"iframe_html": iframe_html
|
| 34 |
}
|
| 35 |
)
|
|
@@ -37,7 +45,11 @@ async def process_form(
|
|
| 37 |
return templates.TemplateResponse(
|
| 38 |
"index.html",
|
| 39 |
{
|
| 40 |
-
"request": request,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
"error": str(e)
|
| 42 |
}
|
| 43 |
)
|
|
|
|
| 2 |
from fastapi import FastAPI, Request, Form
|
| 3 |
from fastapi.templating import Jinja2Templates
|
| 4 |
from fastapi.responses import HTMLResponse
|
|
|
|
| 5 |
import wandb
|
| 6 |
+
import os
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
templates = Jinja2Templates(directory="./")
|
|
|
|
| 21 |
run_id: str = Form(...)
|
| 22 |
):
|
| 23 |
try:
|
| 24 |
+
# Set the token as an environment variable
|
| 25 |
+
os.environ["WANDB_API_KEY"] = token
|
| 26 |
+
# Login with the anonymous parameter set
|
| 27 |
+
wandb.login(key=token)
|
| 28 |
+
|
| 29 |
api = wandb.Api()
|
| 30 |
run_path = f"{entity}/{project}/runs/{run_id}"
|
| 31 |
run = api.run(run_path)
|
|
|
|
| 33 |
return templates.TemplateResponse(
|
| 34 |
"index.html",
|
| 35 |
{
|
| 36 |
+
"request": request,
|
| 37 |
+
"token": token,
|
| 38 |
+
"entity": entity,
|
| 39 |
+
"project": project,
|
| 40 |
+
"run_id": run_id,
|
| 41 |
"iframe_html": iframe_html
|
| 42 |
}
|
| 43 |
)
|
|
|
|
| 45 |
return templates.TemplateResponse(
|
| 46 |
"index.html",
|
| 47 |
{
|
| 48 |
+
"request": request,
|
| 49 |
+
"token": token,
|
| 50 |
+
"entity": entity,
|
| 51 |
+
"project": project,
|
| 52 |
+
"run_id": run_id,
|
| 53 |
"error": str(e)
|
| 54 |
}
|
| 55 |
)
|