dmart 1.4.41.post36__py3-none-any.whl → 1.4.41.post38__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dmart/data_adapters/file/drop_index.py +4 -1
- dmart/dmart.py +6 -1
- dmart/main.py +26 -7
- dmart/utils/settings.py +41 -0
- {dmart-1.4.41.post36.dist-info → dmart-1.4.41.post38.dist-info}/METADATA +1 -1
- {dmart-1.4.41.post36.dist-info → dmart-1.4.41.post38.dist-info}/RECORD +9 -9
- {dmart-1.4.41.post36.dist-info → dmart-1.4.41.post38.dist-info}/WHEEL +0 -0
- {dmart-1.4.41.post36.dist-info → dmart-1.4.41.post38.dist-info}/entry_points.txt +0 -0
- {dmart-1.4.41.post36.dist-info → dmart-1.4.41.post38.dist-info}/top_level.txt +0 -0
|
@@ -27,6 +27,9 @@ async def drop_index(space: str, schema: str) -> None:
|
|
|
27
27
|
print(f"Error: {e}")
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
def main():
|
|
31
|
+
asyncio.run(drop_index(args.space, args.schema))
|
|
32
|
+
|
|
30
33
|
if __name__ == "__main__":
|
|
31
34
|
parser = argparse.ArgumentParser(description="Script to drop index and delete associated documents in Redis.")
|
|
32
35
|
parser.add_argument("space", help="Space name where the index is located.")
|
|
@@ -37,4 +40,4 @@ if __name__ == "__main__":
|
|
|
37
40
|
if args.schema == "meta":
|
|
38
41
|
print("Cannot drop index for schema 'meta'")
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
main()
|
dmart/dmart.py
CHANGED
|
@@ -37,6 +37,7 @@ commands = """
|
|
|
37
37
|
archive
|
|
38
38
|
json_to_db
|
|
39
39
|
db_to_json
|
|
40
|
+
update_query_policies
|
|
40
41
|
help
|
|
41
42
|
version
|
|
42
43
|
info
|
|
@@ -140,7 +141,8 @@ LISTENING_PORT=8282
|
|
|
140
141
|
"default_language": "en",
|
|
141
142
|
"languages": { "ar": "العربية", "en": "English" },
|
|
142
143
|
"backend": "http://localhost:8282",
|
|
143
|
-
"websocket": "ws://0.0.0.0:8484/ws"
|
|
144
|
+
"websocket": "ws://0.0.0.0:8484/ws",
|
|
145
|
+
"cxb_url": "/cxb"
|
|
144
146
|
}
|
|
145
147
|
with open(cxb_config, "w") as f:
|
|
146
148
|
json.dump(default_cxb_config, f, indent=2)
|
|
@@ -443,6 +445,7 @@ def hypercorn_main() -> int:
|
|
|
443
445
|
|
|
444
446
|
if args.cxb_config is not sentinel:
|
|
445
447
|
os.environ["DMART_CXB_CONFIG"] = args.cxb_config
|
|
448
|
+
settings.load_cxb_config()
|
|
446
449
|
|
|
447
450
|
env_file = get_env_file()
|
|
448
451
|
if env_file and os.path.exists(env_file):
|
|
@@ -594,6 +597,8 @@ def main():
|
|
|
594
597
|
os.environ["DMART_CXB_CONFIG"] = sys.argv[idx + 1]
|
|
595
598
|
sys.argv.pop(idx + 1)
|
|
596
599
|
sys.argv.pop(idx)
|
|
600
|
+
|
|
601
|
+
settings.load_cxb_config()
|
|
597
602
|
|
|
598
603
|
if open_cxb:
|
|
599
604
|
host = settings.listening_host
|
dmart/main.py
CHANGED
|
@@ -46,16 +46,35 @@ from pathlib import Path
|
|
|
46
46
|
|
|
47
47
|
class SPAStaticFiles(StaticFiles):
|
|
48
48
|
async def get_response(self, path: str, scope) -> Response:
|
|
49
|
+
if path == "" or path == "index.html":
|
|
50
|
+
return await self.serve_index()
|
|
51
|
+
|
|
49
52
|
try:
|
|
50
53
|
return await super().get_response(path, scope)
|
|
51
54
|
except StarletteHTTPException as ex:
|
|
52
55
|
if ex.status_code == 404 and path != "index.html" and not os.path.splitext(path)[1]:
|
|
53
56
|
try:
|
|
54
|
-
return await
|
|
55
|
-
except
|
|
57
|
+
return await self.serve_index()
|
|
58
|
+
except Exception:
|
|
56
59
|
pass
|
|
57
60
|
raise ex
|
|
58
61
|
|
|
62
|
+
async def serve_index(self):
|
|
63
|
+
index_path = os.path.join(self.directory, "index.html")
|
|
64
|
+
if not os.path.exists(index_path):
|
|
65
|
+
raise StarletteHTTPException(status_code=404)
|
|
66
|
+
|
|
67
|
+
with open(index_path, "r") as f:
|
|
68
|
+
content = f.read()
|
|
69
|
+
|
|
70
|
+
target_url = settings.cxb_url
|
|
71
|
+
if not target_url.endswith("/"):
|
|
72
|
+
target_url += "/"
|
|
73
|
+
|
|
74
|
+
content = content.replace("/cxb/", target_url)
|
|
75
|
+
|
|
76
|
+
return Response(content, media_type="text/html")
|
|
77
|
+
|
|
59
78
|
|
|
60
79
|
@asynccontextmanager
|
|
61
80
|
async def lifespan(app: FastAPI):
|
|
@@ -493,9 +512,8 @@ if not os.path.exists(os.path.join(cxb_path, "index.html")):
|
|
|
493
512
|
if os.path.isdir(cxb_path):
|
|
494
513
|
@app.get(f"{settings.cxb_url}/config.json", include_in_schema=False)
|
|
495
514
|
async def get_cxb_config():
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
return FileResponse(cxb_config)
|
|
515
|
+
if settings.cxb_config_path and os.path.exists(settings.cxb_config_path):
|
|
516
|
+
return FileResponse(settings.cxb_config_path)
|
|
499
517
|
|
|
500
518
|
if os.path.exists("config.json"):
|
|
501
519
|
return FileResponse("config.json")
|
|
@@ -521,7 +539,8 @@ if os.path.isdir(cxb_path):
|
|
|
521
539
|
"default_language": "en",
|
|
522
540
|
"languages": { "ar": "العربية", "en": "English" },
|
|
523
541
|
"backend": f"{settings.app_url}" if settings.app_url else f"http://{settings.listening_host}:{settings.listening_port}",
|
|
524
|
-
"websocket": settings.websocket_url if settings.websocket_url else f"ws://{settings.listening_host}:{settings.websocket_port}/ws"
|
|
542
|
+
"websocket": settings.websocket_url if settings.websocket_url else f"ws://{settings.listening_host}:{settings.websocket_port}/ws",
|
|
543
|
+
"cxb_url": settings.cxb_url
|
|
525
544
|
}
|
|
526
545
|
|
|
527
546
|
app.mount(settings.cxb_url, SPAStaticFiles(directory=cxb_path, html=True), name="cxb")
|
|
@@ -537,7 +556,7 @@ async def myoptions():
|
|
|
537
556
|
@app.patch("/{x:path}", include_in_schema=False)
|
|
538
557
|
@app.delete("/{x:path}", include_in_schema=False)
|
|
539
558
|
async def catchall(x):
|
|
540
|
-
if x.startswith("
|
|
559
|
+
if x.startswith(settings.cxb_url.strip("/")):
|
|
541
560
|
return RedirectResponse(f"{settings.cxb_url}/")
|
|
542
561
|
raise api.Exception(
|
|
543
562
|
status_code=status.HTTP_404_NOT_FOUND,
|
dmart/utils/settings.py
CHANGED
|
@@ -34,6 +34,7 @@ class Settings(BaseSettings):
|
|
|
34
34
|
|
|
35
35
|
app_url: str = ""
|
|
36
36
|
cxb_url: str = "/cxb"
|
|
37
|
+
cxb_config_path: str = ""
|
|
37
38
|
public_app_url: str = ""
|
|
38
39
|
app_name: str = "dmart"
|
|
39
40
|
websocket_url: str = "" #"http://127.0.0.1:8484"
|
|
@@ -150,6 +151,46 @@ class Settings(BaseSettings):
|
|
|
150
151
|
|
|
151
152
|
except Exception as e:
|
|
152
153
|
logger.error(f"Failed to open the channel config file at {channels_config_file}. Error: {e}")
|
|
154
|
+
|
|
155
|
+
self.load_cxb_config()
|
|
156
|
+
|
|
157
|
+
def load_cxb_config(self) -> None:
|
|
158
|
+
backend_dir = Path(__file__).resolve().parent.parent
|
|
159
|
+
cxb_path = backend_dir / "cxb"
|
|
160
|
+
if (cxb_path / "client").is_dir():
|
|
161
|
+
cxb_path = cxb_path / "client"
|
|
162
|
+
|
|
163
|
+
if not (cxb_path / "index.html").exists():
|
|
164
|
+
project_root = backend_dir.parent
|
|
165
|
+
cxb_dist_path = project_root / "cxb" / "dist" / "client"
|
|
166
|
+
if cxb_dist_path.is_dir():
|
|
167
|
+
cxb_path = cxb_dist_path
|
|
168
|
+
|
|
169
|
+
config_path = None
|
|
170
|
+
cxb_config_env = os.getenv("DMART_CXB_CONFIG")
|
|
171
|
+
if cxb_config_env and os.path.exists(cxb_config_env):
|
|
172
|
+
config_path = cxb_config_env
|
|
173
|
+
elif os.path.exists("config.json"):
|
|
174
|
+
config_path = "config.json"
|
|
175
|
+
elif (self.spaces_folder / "config.json").exists():
|
|
176
|
+
config_path = str(self.spaces_folder / "config.json")
|
|
177
|
+
elif (Path.home() / ".dmart" / "config.json").exists():
|
|
178
|
+
config_path = str(Path.home() / ".dmart" / "config.json")
|
|
179
|
+
elif (cxb_path / "config.json").exists():
|
|
180
|
+
config_path = str(cxb_path / "config.json")
|
|
181
|
+
|
|
182
|
+
if config_path:
|
|
183
|
+
self.cxb_config_path = config_path
|
|
184
|
+
try:
|
|
185
|
+
with open(config_path, "r") as f:
|
|
186
|
+
config_data = json.load(f)
|
|
187
|
+
if "cxb_url" in config_data:
|
|
188
|
+
url = config_data["cxb_url"]
|
|
189
|
+
if not url.startswith("/"):
|
|
190
|
+
url = "/" + url
|
|
191
|
+
self.cxb_url = url
|
|
192
|
+
except Exception as e:
|
|
193
|
+
logger.error(f"Failed to read CXB config at {config_path}. Error: {e}")
|
|
153
194
|
|
|
154
195
|
raw_allowed_submit_models: str = Field(default="",alias="allowed_submit_models")
|
|
155
196
|
|
|
@@ -8,13 +8,13 @@ dmart/conftest.py,sha256=0ry_zeCmdBNLbm5q115b-pkOrUFYxdsOUXbIMkr7E5Y,362
|
|
|
8
8
|
dmart/curl.pypi.sh,sha256=KQ-kgV3_d5mwqoLd4XOwz5s2wRQ7LDVX3z-kvjvp9hA,15631
|
|
9
9
|
dmart/curl.sh,sha256=lmHSFVr5ft-lc5Aq9LfvKyWfntrfYbnirhzx1EGjp_A,15743
|
|
10
10
|
dmart/data_generator.py,sha256=CnE-VHEeX7-lAXtqCgbRqR9WHjTuOgeiZcviYrHAmho,2287
|
|
11
|
-
dmart/dmart.py,sha256=
|
|
11
|
+
dmart/dmart.py,sha256=Hf3Ac9qq7xW43xKuZZHZQDDPl-DUiBlhae7nXHaTBQw,34281
|
|
12
12
|
dmart/get_settings.py,sha256=Sbe2WCoiK398E7HY4SNLfDN_GmE8knR4M-YJWF31jcg,153
|
|
13
13
|
dmart/hypercorn_config.toml,sha256=-eryppEG8HBOM_KbFc4dTQePnpyfoW9ZG5aUATU_6yM,50
|
|
14
14
|
dmart/info.json,sha256=1VYb3TIoWeUp8-9IPkNkfqHIb3znxlrd8qa7oBl3_No,123
|
|
15
15
|
dmart/login_creds.sh,sha256=Aht1LwL11uzR13sa8p3BdeUCprIa9tq0vzOoplJjH5U,235
|
|
16
16
|
dmart/login_creds.sh.sample,sha256=Sb43HNNn1g11rrJrtDsPgAxcXu3_wJvdNn--8S62dTE,227
|
|
17
|
-
dmart/main.py,sha256=
|
|
17
|
+
dmart/main.py,sha256=JyU2UEEoo4H_ag81m1zMJi1elAlzNZLLKDEvtmPcPHc,20719
|
|
18
18
|
dmart/manifest.sh,sha256=K3mY5MsUlrTyHa5cARslkShegvXh-UeqJcE2UZobdrE,544
|
|
19
19
|
dmart/migrate.py,sha256=hn1MZoVby_Jjqhc7y3CrLcGD619QmVZv3PONNvO7VKQ,665
|
|
20
20
|
dmart/password_gen.py,sha256=xjx8wi105ZYvhLBBQj7_rugACpxifGXHse6f7YlGXWQ,196
|
|
@@ -204,7 +204,7 @@ dmart/data_adapters/file/archive.py,sha256=B4VV6HNB3Bqd4tlqZ3jUQps8oqht_xOdBNOi9
|
|
|
204
204
|
dmart/data_adapters/file/create_index.py,sha256=lUcUkepo9QUIQDDDgoPAL74_n16cZ_q0NKnITGmbF6I,11888
|
|
205
205
|
dmart/data_adapters/file/create_users_folders.py,sha256=zOBgxMnqgEskYP4pgkmE6VYMca-ADLz8mXKPHJPYpys,1670
|
|
206
206
|
dmart/data_adapters/file/custom_validations.py,sha256=ziOERgTr-eY_zrN0C41B2FYmpEyoKiV4holh8an-p2c,1754
|
|
207
|
-
dmart/data_adapters/file/drop_index.py,sha256=
|
|
207
|
+
dmart/data_adapters/file/drop_index.py,sha256=iczJVaEw22Q_x7u4GqyYCUdaeVUqLB8v5pCiONK24Ko,1441
|
|
208
208
|
dmart/data_adapters/file/health_check.py,sha256=cMvwsXhjEykjrTyB3HtUn8QqKdtB_h5w8mGOEYPepzU,24221
|
|
209
209
|
dmart/data_adapters/file/redis_services.py,sha256=83STcca5fYFaEVLRYAxfUQXeUQZqJOT8XH-GBSbkR-E,39914
|
|
210
210
|
dmart/data_adapters/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -476,15 +476,15 @@ dmart/utils/query_policies_helper.py,sha256=Bf5qriQJ8CpUqPaQg5cdvNrn-92l_jKxHwsv
|
|
|
476
476
|
dmart/utils/regex.py,sha256=cv9b_l_e8tz42mKckeeyDgypKqh2e71E28co2iuEVxA,2286
|
|
477
477
|
dmart/utils/repository.py,sha256=9L-IvQ0Js0SQ5OR-Rh0i2Wdu4H9H06r8eE84hfBIu7Q,18313
|
|
478
478
|
dmart/utils/router_helper.py,sha256=Tgoq3oakejdEeyeVieTNk38JsPZ8x5RuR0kw2THc1mI,604
|
|
479
|
-
dmart/utils/settings.py,sha256=
|
|
479
|
+
dmart/utils/settings.py,sha256=zCqwt3TDensl1xCdHomyog6nZnL4RfNICUA28shhOT0,7785
|
|
480
480
|
dmart/utils/sms_notifier.py,sha256=04D6D_ldk3S9SojI7_381pqLc8v9lligeNHAysohz7w,550
|
|
481
481
|
dmart/utils/social_sso.py,sha256=Dm1W6U9OwKbAeUwM-kwJBHFEoreeoN-s-RHdOZ1-cNg,2216
|
|
482
482
|
dmart/utils/ticket_sys_utils.py,sha256=9QAlW2iiy8KyxQRBDj_WmzS5kKb0aYJmGwd4qzmGVqo,7005
|
|
483
483
|
dmart/utils/web_notifier.py,sha256=QM87VVid2grC5lK3NdS1yzz0z1wXljr4GChJOeK86W4,843
|
|
484
484
|
dmart/utils/templates/activation.html.j2,sha256=XAMKCdoqONoc4ZQucD0yV-Pg5DlHHASZrTVItNS-iBE,640
|
|
485
485
|
dmart/utils/templates/reminder.html.j2,sha256=aoS8bTs56q4hjAZKsb0jV9c-PIURBELuBOpT_qPZNVU,639
|
|
486
|
-
dmart-1.4.41.
|
|
487
|
-
dmart-1.4.41.
|
|
488
|
-
dmart-1.4.41.
|
|
489
|
-
dmart-1.4.41.
|
|
490
|
-
dmart-1.4.41.
|
|
486
|
+
dmart-1.4.41.post38.dist-info/METADATA,sha256=yeMaKBEPAL2egk8-U7R4GgIxQLl4sTt7KQh6MgtWbNA,839
|
|
487
|
+
dmart-1.4.41.post38.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
488
|
+
dmart-1.4.41.post38.dist-info/entry_points.txt,sha256=N832M4wG8d2GDw1xztKRVM3TnxpY2QDzvdFE8XaWaG8,43
|
|
489
|
+
dmart-1.4.41.post38.dist-info/top_level.txt,sha256=zJo4qk9fUW0BGIR9f4DCfpxaXbvQXH9izIOom6JsyAo,6
|
|
490
|
+
dmart-1.4.41.post38.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|