Upload from GitHub Actions: import flexibility on backend
Browse files- evals/backend.py +10 -4
evals/backend.py
CHANGED
@@ -4,12 +4,18 @@ import os
|
|
4 |
import numpy as np
|
5 |
import pandas as pd
|
6 |
import uvicorn
|
|
|
|
|
7 |
try:
|
8 |
-
# When executed as a package module (uvicorn evals.backend:app
|
9 |
from .countries import make_country_table
|
10 |
-
except
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
from fastapi import FastAPI, Request
|
14 |
from fastapi.middleware.cors import CORSMiddleware
|
15 |
from fastapi.middleware.gzip import GZipMiddleware
|
|
|
4 |
import numpy as np
|
5 |
import pandas as pd
|
6 |
import uvicorn
|
7 |
+
|
8 |
+
# Robust import so this file works both as a package module and as a script
|
9 |
try:
|
10 |
+
# When executed as a package module (recommended): `python -m uvicorn evals.backend:app`
|
11 |
from .countries import make_country_table
|
12 |
+
except Exception:
|
13 |
+
try:
|
14 |
+
# When executed from project root with package path available
|
15 |
+
from evals.countries import make_country_table
|
16 |
+
except Exception:
|
17 |
+
# When executed directly from evals/ directory
|
18 |
+
from countries import make_country_table
|
19 |
from fastapi import FastAPI, Request
|
20 |
from fastapi.middleware.cors import CORSMiddleware
|
21 |
from fastapi.middleware.gzip import GZipMiddleware
|