Skip to content

Commit bfb12a7

Browse files
committed
refac
1 parent 97e3316 commit bfb12a7

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

backend/.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@ _test
88
Pipfile
99
!/data
1010
/data/*
11-
!/data/litellm
12-
/data/litellm/*
13-
!data/litellm/config.yaml
14-
15-
!data/config.json
11+
/open_webui/data/*
1612
.webui_secret_key

backend/open_webui/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
KEY_FILE = Path.cwd() / ".webui_secret_key"
1212

13+
os.environ["RUNNING_FROM_INIT_PY"] = "true"
14+
1315

1416
@app.command()
1517
def serve(

backend/open_webui/env.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,9 @@
8888

8989
ENV = os.environ.get("ENV", "dev")
9090

91-
PIP_INSTALL = False
92-
try:
93-
importlib.metadata.version("open-webui")
94-
PIP_INSTALL = True
95-
except importlib.metadata.PackageNotFoundError:
96-
pass
97-
98-
99-
PIP_INSTALL = (
100-
os.environ.get("PIP_INSTALL", "False").lower() == "true"
101-
if os.environ.get("PIP_INSTALL")
102-
else PIP_INSTALL
103-
)
91+
FROM_INIT_PY = os.environ.get("FROM_INIT_PY", "False").lower() == "true"
10492

105-
if PIP_INSTALL:
93+
if FROM_INIT_PY:
10694
PACKAGE_DATA = {"version": importlib.metadata.version("open-webui")}
10795
else:
10896
try:
@@ -193,7 +181,7 @@ def parse_section(section):
193181

194182
DATA_DIR = Path(os.getenv("DATA_DIR", BACKEND_DIR / "data")).resolve()
195183

196-
if PIP_INSTALL:
184+
if FROM_INIT_PY:
197185
NEW_DATA_DIR = Path(os.getenv("DATA_DIR", OPEN_WEBUI_DIR / "data")).resolve()
198186
NEW_DATA_DIR.mkdir(parents=True, exist_ok=True)
199187

@@ -212,7 +200,7 @@ def parse_section(section):
212200

213201
FRONTEND_BUILD_DIR = Path(os.getenv("FRONTEND_BUILD_DIR", BASE_DIR / "build")).resolve()
214202

215-
if PIP_INSTALL:
203+
if FROM_INIT_PY:
216204
FRONTEND_BUILD_DIR = Path(
217205
os.getenv("FRONTEND_BUILD_DIR", OPEN_WEBUI_DIR / "frontend")
218206
).resolve()

0 commit comments

Comments
 (0)