Skip to content

Commit 413cce0

Browse files
committed
[RZP-260009]: refactor: update optional dependencies for MongoDB and improve database connection handling
1 parent bdb5db9 commit 413cce0

5 files changed

Lines changed: 31 additions & 12 deletions

File tree

poetry.lock

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ dependencies = [
1616
"streamlit>=1.49.0",
1717
"python-box (>=7.3.2,<8.0.0)",
1818
"uvicorn (>=0.40.0,<0.41.0)",
19-
"pymongo (>=4.15.5,<5.0.0)",
2019
"bs4 (>=0.0.2,<0.0.3)",
2120
"dotenv (>=0.9.9,<0.10.0)",
2221
"pydantic (>=2.12.5,<3.0.0)",
2322
"click (>=8.3.1,<9.0.0)",
2423
]
24+
[project.optional-dependencies]
25+
mongo = ["pymongo (>=4.15.5,<5.0.0)"]
2526

2627

2728
[tool.poetry]
@@ -30,6 +31,7 @@ packages = [
3031
{ include = "assets/images/logo.png", from = "src" },
3132
]
3233

34+
include = [{ path = "templates/**/*", format = ["sdist", "wheel"] }]
3335

3436
[project.scripts]
3537
sample = "sample.cli:cli"

src/sample/api/fast_api.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ class GreetResponse(BaseModel):
3737
message: str
3838

3939

40-
@app.get("/version",tags=["Meta"])
40+
@app.get("/version", tags=["Meta"])
4141
def version():
4242
return {"version": app.version}
4343

4444

45-
@app.get("/", response_class=HTMLResponse,tags=["Meta"])
45+
@app.get("/", response_class=HTMLResponse, tags=["Meta"])
4646
async def read_root(request: Request):
4747
return """
4848
<html>
@@ -84,7 +84,7 @@ async def read_root(request: Request):
8484
"""
8585

8686

87-
@app.get("/health",tags=["Meta"])
87+
@app.get("/health", tags=["Meta"])
8888
def health_check():
8989
return {"status": "ok"}
9090

@@ -106,7 +106,12 @@ def start():
106106
import uvicorn
107107

108108
print(f"🧵 {__version__}\n")
109-
connect_db()
109+
try:
110+
connect_db()
111+
except Exception:
112+
print(
113+
"⚠️ Could not connect to the database.Please check database configuration."
114+
)
110115
uvicorn.run("sample.api.fast_api:app", host="127.0.0.1", port=5000, reload=True)
111116

112117

src/sample/features/greeting.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ def greet():
88
st.header(APP_TITLE)
99

1010
name = st.text_input("Enter your name")
11-
connect_db()
11+
12+
# Try connecting, but don't crash if it fails
13+
try:
14+
connect_db()
15+
except Exception:
16+
st.warning(
17+
"⚠️ Could not connect to the database. Please check database configuration."
18+
)
1219

1320
clean_name = normalize_name(name)
1421

templates/faq.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
--bg: #2a2a2a;
1616
--border: #3a3a3a;
1717
--border-hover: #4a4a4a;
18-
--summary-color: #e1e4e8;
18+
--summary-color: #4b72a6;
1919
--text-color: #764ba2;
2020
}
2121
}
2222

2323
.faq-container {
24-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
24+
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
2525
max-width: 900px;
2626
margin: 20px auto;
2727
padding: 20px;
@@ -88,4 +88,4 @@
8888
font-size: 0.9375rem;
8989
}
9090
}
91-
}
91+
}

0 commit comments

Comments
 (0)