ishaq101 commited on
Commit
19bd037
·
1 Parent(s): 6bff5d9

[NOTICKET] fix: add SKIP_INIT_DB flag and remove pymongo dependency

Browse files

- Add SKIP_INIT_DB env variable to skip database initialization on startup,
useful for local dev when DB is not available
- Remove pymongo dependency (unused, replaced by PostgreSQL-based user storage)
- Comment out unused MongoDB settings in Settings class
- Update .gitignore: add API_CONTRACT_AGENT*.md and migratego/
- Remove .vscode/launch.json (superseded by uv run fastapi dev)

Files changed (6) hide show
  1. .gitignore +3 -0
  2. .vscode/launch.json +0 -25
  3. main.py +6 -2
  4. pyproject.toml +1 -3
  5. src/config/settings.py +4 -4
  6. uv.lock +1 -24
.gitignore CHANGED
@@ -37,6 +37,8 @@ playground_chat.py
37
  playground_flush_cache.py
38
  playground_create_user.py
39
  API_CONTRACT.md
 
 
40
  context_engineering/
41
  sample_file/
42
  test_tesseract.py
@@ -46,3 +48,4 @@ software/
46
 
47
  tests/
48
  .claude/
 
 
37
  playground_flush_cache.py
38
  playground_create_user.py
39
  API_CONTRACT.md
40
+ API_CONTRACT_AGENT.md
41
+ API_CONTRACT_AGENT_ACTIVE.md
42
  context_engineering/
43
  sample_file/
44
  test_tesseract.py
 
48
 
49
  tests/
50
  .claude/
51
+ migratego/
.vscode/launch.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "name": "DataEyond: FastAPI (debug)",
9
- "type": "debugpy",
10
- "request": "launch",
11
- "module": "uvicorn",
12
- "args": [
13
- "main:app",
14
- "--host", "0.0.0.0",
15
- "--port", "7860",
16
- "--reload"
17
- ],
18
- "jinja": true,
19
- "justMyCode": true,
20
- "envFile": "${workspaceFolder}/.env",
21
- "console": "integratedTerminal",
22
- "cwd": "${workspaceFolder}"
23
- }
24
- ]
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
main.py CHANGED
@@ -14,6 +14,7 @@ from src.api.v1.users import router as users_router
14
  from src.api.v1.db_client import router as db_client_router
15
  from src.api.v1.data_catalog import router as data_catalog_router
16
  from src.db.postgres.init_db import init_db
 
17
  import uvicorn
18
 
19
  # Configure logging
@@ -24,8 +25,11 @@ logger = get_logger("main")
24
  @asynccontextmanager
25
  async def lifespan(app: FastAPI):
26
  logger.info("Starting application...")
27
- await init_db()
28
- logger.info("Database initialized")
 
 
 
29
  yield
30
 
31
 
 
14
  from src.api.v1.db_client import router as db_client_router
15
  from src.api.v1.data_catalog import router as data_catalog_router
16
  from src.db.postgres.init_db import init_db
17
+ import os
18
  import uvicorn
19
 
20
  # Configure logging
 
25
  @asynccontextmanager
26
  async def lifespan(app: FastAPI):
27
  logger.info("Starting application...")
28
+ if os.getenv("SKIP_INIT_DB", "false").lower() != "true":
29
+ await init_db()
30
+ logger.info("Database initialized")
31
+ else:
32
+ logger.info("Skipping database initialization (SKIP_INIT_DB=true)")
33
  yield
34
 
35
 
pyproject.toml CHANGED
@@ -77,7 +77,6 @@ dependencies = [
77
  "cachetools==5.5.0",
78
  "apscheduler==3.10.4",
79
  "jsonpatch>=1.33",
80
- "pymongo>=4.14.0",
81
  "psycopg2>=2.9.11",
82
  # --- SQL parsing / guardrails ---
83
  "sqlglot>=25.0.0",
@@ -121,8 +120,7 @@ ignore = [
121
  ]
122
 
123
  [tool.ruff.lint.per-file-ignores]
124
- # S608 in tests is a false positive — tests assert literal SQL strings as fixtures.
125
- "tests/**" = ["S101", "S105", "S106", "S608"]
126
 
127
  [tool.mypy]
128
  python_version = "3.12"
 
77
  "cachetools==5.5.0",
78
  "apscheduler==3.10.4",
79
  "jsonpatch>=1.33",
 
80
  "psycopg2>=2.9.11",
81
  # --- SQL parsing / guardrails ---
82
  "sqlglot>=25.0.0",
 
120
  ]
121
 
122
  [tool.ruff.lint.per-file-ignores]
123
+ "tests/**" = ["S101", "S105", "S106"]
 
124
 
125
  [tool.mypy]
126
  python_version = "3.12"
src/config/settings.py CHANGED
@@ -1,7 +1,7 @@
1
  """Centralized configuration management using pydantic-settings."""
2
 
3
- import os
4
- from typing import Optional
5
  from pydantic import Field
6
  from pydantic_settings import BaseSettings, SettingsConfigDict
7
 
@@ -51,8 +51,8 @@ class Settings(BaseSettings):
51
  LANGFUSE_HOST: str
52
 
53
  # MongoDB (for users - existing)
54
- emarcal_mongo_endpoint_url: str = Field(alias="emarcal__mongo__endpoint__url", default="")
55
- emarcal_buma_mongo_dbname: str = Field(alias="emarcal__buma__mongo__dbname", default="")
56
 
57
  # JWT (for users - existing)
58
  emarcal_jwt_secret_key: str = Field(alias="emarcal__jwt__secret_key", default="")
 
1
  """Centralized configuration management using pydantic-settings."""
2
 
3
+ # import os
4
+ # from typing import Optional
5
  from pydantic import Field
6
  from pydantic_settings import BaseSettings, SettingsConfigDict
7
 
 
51
  LANGFUSE_HOST: str
52
 
53
  # MongoDB (for users - existing)
54
+ # emarcal_mongo_endpoint_url: str = Field(alias="emarcal__mongo__endpoint__url", default="")
55
+ # emarcal_buma_mongo_dbname: str = Field(alias="emarcal__buma__mongo__dbname", default="")
56
 
57
  # JWT (for users - existing)
58
  emarcal_jwt_secret_key: str = Field(alias="emarcal__jwt__secret_key", default="")
uv.lock CHANGED
@@ -1,5 +1,5 @@
1
  version = 1
2
- revision = 3
3
  requires-python = "==3.12.*"
4
  resolution-markers = [
5
  "python_full_version >= '3.12.4'",
@@ -50,7 +50,6 @@ dependencies = [
50
  { name = "pyarrow" },
51
  { name = "pydantic" },
52
  { name = "pydantic-settings" },
53
- { name = "pymongo" },
54
  { name = "pymssql" },
55
  { name = "pymysql" },
56
  { name = "pypdf" },
@@ -138,7 +137,6 @@ requires-dist = [
138
  { name = "pyarrow", specifier = ">=24.0.0" },
139
  { name = "pydantic", specifier = "==2.10.3" },
140
  { name = "pydantic-settings", specifier = "==2.7.0" },
141
- { name = "pymongo", specifier = ">=4.14.0" },
142
  { name = "pymssql", specifier = ">=2.3.0" },
143
  { name = "pymysql", specifier = ">=1.1.1" },
144
  { name = "pypdf", specifier = "==5.1.0" },
@@ -2560,27 +2558,6 @@ crypto = [
2560
  { name = "cryptography" },
2561
  ]
2562
 
2563
- [[package]]
2564
- name = "pymongo"
2565
- version = "4.16.0"
2566
- source = { registry = "https://pypi.org/simple" }
2567
- dependencies = [
2568
- { name = "dnspython" },
2569
- ]
2570
- sdist = { url = "https://files.pythonhosted.org/packages/65/9c/a4895c4b785fc9865a84a56e14b5bd21ca75aadc3dab79c14187cdca189b/pymongo-4.16.0.tar.gz", hash = "sha256:8ba8405065f6e258a6f872fe62d797a28f383a12178c7153c01ed04e845c600c", size = 2495323, upload-time = "2026-01-07T18:05:48.107Z" }
2571
- wheels = [
2572
- { url = "https://files.pythonhosted.org/packages/6a/03/6dd7c53cbde98de469a3e6fb893af896dca644c476beb0f0c6342bcc368b/pymongo-4.16.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:bd4911c40a43a821dfd93038ac824b756b6e703e26e951718522d29f6eb166a8", size = 917619, upload-time = "2026-01-07T18:04:19.173Z" },
2573
- { url = "https://files.pythonhosted.org/packages/73/e1/328915f2734ea1f355dc9b0e98505ff670f5fab8be5e951d6ed70971c6aa/pymongo-4.16.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:25a6b03a68f9907ea6ec8bc7cf4c58a1b51a18e23394f962a6402f8e46d41211", size = 917364, upload-time = "2026-01-07T18:04:20.861Z" },
2574
- { url = "https://files.pythonhosted.org/packages/41/fe/4769874dd9812a1bc2880a9785e61eba5340da966af888dd430392790ae0/pymongo-4.16.0-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:91ac0cb0fe2bf17616c2039dac88d7c9a5088f5cb5829b27c9d250e053664d31", size = 1686901, upload-time = "2026-01-07T18:04:22.219Z" },
2575
- { url = "https://files.pythonhosted.org/packages/fa/8d/15707b9669fdc517bbc552ac60da7124dafe7ac1552819b51e97ed4038b4/pymongo-4.16.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:cf0ec79e8ca7077f455d14d915d629385153b6a11abc0b93283ed73a8013e376", size = 1723034, upload-time = "2026-01-07T18:04:24.055Z" },
2576
- { url = "https://files.pythonhosted.org/packages/5b/af/3d5d16ff11d447d40c1472da1b366a31c7380d7ea2922a449c7f7f495567/pymongo-4.16.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2d0082631a7510318befc2b4fdab140481eb4b9dd62d9245e042157085da2a70", size = 1797161, upload-time = "2026-01-07T18:04:25.964Z" },
2577
- { url = "https://files.pythonhosted.org/packages/fb/04/725ab8664eeec73ec125b5a873448d80f5d8cf2750aaaf804cbc538a50a5/pymongo-4.16.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:85dc2f3444c346ea019a371e321ac868a4fab513b7a55fe368f0cc78de8177cc", size = 1780938, upload-time = "2026-01-07T18:04:28.745Z" },
2578
- { url = "https://files.pythonhosted.org/packages/22/50/dd7e9095e1ca35f93c3c844c92eb6eb0bc491caeb2c9bff3b32fe3c9b18f/pymongo-4.16.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:dabbf3c14de75a20cc3c30bf0c6527157224a93dfb605838eabb1a2ee3be008d", size = 1714342, upload-time = "2026-01-07T18:04:30.331Z" },
2579
- { url = "https://files.pythonhosted.org/packages/03/c9/542776987d5c31ae8e93e92680ea2b6e5a2295f398b25756234cabf38a39/pymongo-4.16.0-cp312-cp312-win32.whl", hash = "sha256:60307bb91e0ab44e560fe3a211087748b2b5f3e31f403baf41f5b7b0a70bd104", size = 887868, upload-time = "2026-01-07T18:04:32.124Z" },
2580
- { url = "https://files.pythonhosted.org/packages/2e/d4/b4045a7ccc5680fb496d01edf749c7a9367cc8762fbdf7516cf807ef679b/pymongo-4.16.0-cp312-cp312-win_amd64.whl", hash = "sha256:f513b2c6c0d5c491f478422f6b5b5c27ac1af06a54c93ef8631806f7231bd92e", size = 907554, upload-time = "2026-01-07T18:04:33.685Z" },
2581
- { url = "https://files.pythonhosted.org/packages/60/4c/33f75713d50d5247f2258405142c0318ff32c6f8976171c4fcae87a9dbdf/pymongo-4.16.0-cp312-cp312-win_arm64.whl", hash = "sha256:dfc320f08ea9a7ec5b2403dc4e8150636f0d6150f4b9792faaae539c88e7db3b", size = 892971, upload-time = "2026-01-07T18:04:35.594Z" },
2582
- ]
2583
-
2584
  [[package]]
2585
  name = "pymssql"
2586
  version = "2.3.13"
 
1
  version = 1
2
+ revision = 2
3
  requires-python = "==3.12.*"
4
  resolution-markers = [
5
  "python_full_version >= '3.12.4'",
 
50
  { name = "pyarrow" },
51
  { name = "pydantic" },
52
  { name = "pydantic-settings" },
 
53
  { name = "pymssql" },
54
  { name = "pymysql" },
55
  { name = "pypdf" },
 
137
  { name = "pyarrow", specifier = ">=24.0.0" },
138
  { name = "pydantic", specifier = "==2.10.3" },
139
  { name = "pydantic-settings", specifier = "==2.7.0" },
 
140
  { name = "pymssql", specifier = ">=2.3.0" },
141
  { name = "pymysql", specifier = ">=1.1.1" },
142
  { name = "pypdf", specifier = "==5.1.0" },
 
2558
  { name = "cryptography" },
2559
  ]
2560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2561
  [[package]]
2562
  name = "pymssql"
2563
  version = "2.3.13"