Adi12345 commited on
Commit
73a267e
·
verified ·
1 Parent(s): 57025b0

Create dvnc_patch_loader_example.py

Browse files
Files changed (1) hide show
  1. dvnc_patch_loader_example.py +27 -0
dvnc_patch_loader_example.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Example launcher that keeps the original code untouched.
3
+
4
+ Place this file alongside the existing app module and adjust the import path if needed.
5
+ Run this launcher instead of the original entry point.
6
+ """
7
+
8
+ import importlib.util
9
+ import sys
10
+ from pathlib import Path
11
+
12
+ ORIGINAL_APP_PATH = Path("dvnc_ai_v2_hf/app.py")
13
+ PATCH_PATH = Path("dvnc_flip_insight_patch.py")
14
+
15
+ spec = importlib.util.spec_from_file_location("dvnc_original_app", ORIGINAL_APP_PATH)
16
+ mod = importlib.util.module_from_spec(spec)
17
+ sys.modules["dvnc_original_app"] = mod
18
+ spec.loader.exec_module(mod)
19
+
20
+ patch_spec = importlib.util.spec_from_file_location("dvnc_flip_insight_patch", PATCH_PATH)
21
+ patch = importlib.util.module_from_spec(patch_spec)
22
+ sys.modules["dvnc_flip_insight_patch"] = patch
23
+ patch_spec.loader.exec_module(patch)
24
+ patch.apply_patch(mod)
25
+
26
+ # If the original app exposes demo/launch objects, they remain on mod.
27
+ # Example: mod.demo.launch()