lorax-arg 0.1__py3-none-any.whl → 0.1.1__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.
- lorax/modes.py +6 -7
- lorax/sockets/file_ops.py +31 -19
- {lorax_arg-0.1.dist-info → lorax_arg-0.1.1.dist-info}/METADATA +1 -1
- {lorax_arg-0.1.dist-info → lorax_arg-0.1.1.dist-info}/RECORD +7 -7
- {lorax_arg-0.1.dist-info → lorax_arg-0.1.1.dist-info}/WHEEL +0 -0
- {lorax_arg-0.1.dist-info → lorax_arg-0.1.1.dist-info}/entry_points.txt +0 -0
- {lorax_arg-0.1.dist-info → lorax_arg-0.1.1.dist-info}/top_level.txt +0 -0
lorax/modes.py
CHANGED
|
@@ -79,8 +79,8 @@ def detect_mode() -> str:
|
|
|
79
79
|
|
|
80
80
|
Priority:
|
|
81
81
|
1. Explicit LORAX_MODE environment variable
|
|
82
|
-
2. Auto-detect
|
|
83
|
-
3.
|
|
82
|
+
2. Auto-detect: production only when both Redis and GCS are configured
|
|
83
|
+
3. Otherwise default to 'local' (never implicitly select development)
|
|
84
84
|
"""
|
|
85
85
|
explicit_mode = os.getenv("LORAX_MODE", "").lower()
|
|
86
86
|
if explicit_mode in MODE_CONFIGS:
|
|
@@ -91,10 +91,9 @@ def detect_mode() -> str:
|
|
|
91
91
|
has_gcs = bool(os.getenv("GCS_BUCKET_NAME") or os.getenv("BUCKET_NAME"))
|
|
92
92
|
if has_redis and has_gcs:
|
|
93
93
|
return "production"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return "local"
|
|
94
|
+
|
|
95
|
+
# Fall back to local to avoid accidentally running builds in development mode
|
|
96
|
+
return "local"
|
|
98
97
|
|
|
99
98
|
|
|
100
99
|
def get_mode_config(mode: Optional[str] = None) -> ModeConfig:
|
|
@@ -139,7 +138,7 @@ def get_data_dir(mode_config: Optional[ModeConfig] = None) -> Path:
|
|
|
139
138
|
def get_uploads_dir(mode_config: Optional[ModeConfig] = None) -> Path:
|
|
140
139
|
"""Get the uploads directory for the current mode."""
|
|
141
140
|
data_dir = get_data_dir(mode_config)
|
|
142
|
-
uploads_dir = data_dir / "
|
|
141
|
+
uploads_dir = data_dir / "projects" if mode_config and mode_config.mode == "local" else data_dir
|
|
143
142
|
uploads_dir.mkdir(parents=True, exist_ok=True)
|
|
144
143
|
return uploads_dir
|
|
145
144
|
|
lorax/sockets/file_ops.py
CHANGED
|
@@ -22,6 +22,14 @@ from lorax.sockets.utils import is_csv_session_file
|
|
|
22
22
|
UPLOAD_DIR = Path(UPLOADS_DIR)
|
|
23
23
|
UPLOAD_DIR.mkdir(exist_ok=True)
|
|
24
24
|
|
|
25
|
+
DEV_MODE = CURRENT_MODE == "development"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def dev_print(*args, **kwargs):
|
|
29
|
+
"""Print only when running in development mode."""
|
|
30
|
+
if DEV_MODE:
|
|
31
|
+
print(*args, **kwargs)
|
|
32
|
+
|
|
25
33
|
|
|
26
34
|
def register_file_events(sio):
|
|
27
35
|
"""Register file operation socket events."""
|
|
@@ -32,7 +40,7 @@ def register_file_events(sio):
|
|
|
32
40
|
share_sid = data.get("share_sid")
|
|
33
41
|
|
|
34
42
|
if not lorax_sid:
|
|
35
|
-
|
|
43
|
+
dev_print(f"⚠️ Missing lorax_sid")
|
|
36
44
|
await sio.emit("error", {
|
|
37
45
|
"code": ERROR_MISSING_SESSION,
|
|
38
46
|
"message": "Session ID is missing."
|
|
@@ -41,7 +49,7 @@ def register_file_events(sio):
|
|
|
41
49
|
|
|
42
50
|
session = await session_manager.get_session(lorax_sid)
|
|
43
51
|
if not session:
|
|
44
|
-
|
|
52
|
+
dev_print(f"⚠️ Unknown sid {lorax_sid}")
|
|
45
53
|
await sio.emit("error", {
|
|
46
54
|
"code": ERROR_SESSION_NOT_FOUND,
|
|
47
55
|
"message": "Session expired. Please refresh the page."
|
|
@@ -49,7 +57,7 @@ def register_file_events(sio):
|
|
|
49
57
|
return
|
|
50
58
|
|
|
51
59
|
if share_sid and share_sid != lorax_sid:
|
|
52
|
-
|
|
60
|
+
dev_print(f"⚠️ share_sid denied for sid={lorax_sid} target={share_sid}")
|
|
53
61
|
await sio.emit("error", {
|
|
54
62
|
"code": "share_sid_denied",
|
|
55
63
|
"message": "Access denied for shared upload."
|
|
@@ -62,16 +70,19 @@ def register_file_events(sio):
|
|
|
62
70
|
# Extract genomic coordinates from client if provided
|
|
63
71
|
genomiccoordstart = data.get("genomiccoordstart")
|
|
64
72
|
genomiccoordend = data.get("genomiccoordend")
|
|
65
|
-
|
|
73
|
+
dev_print("lorax_sid", lorax_sid, project, filename)
|
|
66
74
|
if not filename:
|
|
67
|
-
|
|
75
|
+
dev_print("Missing file param")
|
|
68
76
|
return
|
|
69
77
|
|
|
78
|
+
gcs_allowed = True
|
|
70
79
|
if project == 'Uploads':
|
|
71
80
|
target_sid = share_sid if share_sid else lorax_sid
|
|
72
81
|
if CURRENT_MODE == "local":
|
|
82
|
+
# Local mode keeps uploads flat and does not pull uploads from GCS
|
|
73
83
|
file_path = UPLOAD_DIR / project / filename
|
|
74
84
|
blob_path = f"{project}/{filename}"
|
|
85
|
+
gcs_allowed = False
|
|
75
86
|
else:
|
|
76
87
|
file_path = UPLOAD_DIR / project / target_sid / filename
|
|
77
88
|
blob_path = f"{project}/{target_sid}/{filename}"
|
|
@@ -79,17 +90,18 @@ def register_file_events(sio):
|
|
|
79
90
|
file_path = UPLOAD_DIR / project / filename
|
|
80
91
|
blob_path = f"{project}/{filename}"
|
|
81
92
|
|
|
82
|
-
if BUCKET_NAME and
|
|
93
|
+
if BUCKET_NAME and gcs_allowed:
|
|
83
94
|
if file_path.exists():
|
|
84
|
-
|
|
95
|
+
dev_print(f"File {file_path} already exists, skipping download.")
|
|
85
96
|
else:
|
|
86
|
-
|
|
97
|
+
dev_print(f"Downloading file {file_path} from {BUCKET_NAME}")
|
|
98
|
+
print(f"[Lorax] Downloading gs://{BUCKET_NAME}/{blob_path} -> {file_path}")
|
|
87
99
|
await download_gcs_file(BUCKET_NAME, f"{blob_path}", str(file_path))
|
|
88
100
|
else:
|
|
89
|
-
|
|
101
|
+
dev_print("using local files (GCS disabled for this request)")
|
|
90
102
|
|
|
91
103
|
if not file_path.exists():
|
|
92
|
-
|
|
104
|
+
dev_print("File not found")
|
|
93
105
|
return
|
|
94
106
|
|
|
95
107
|
# Clear TreeGraph cache when loading a new file
|
|
@@ -99,7 +111,7 @@ def register_file_events(sio):
|
|
|
99
111
|
session.file_path = str(file_path)
|
|
100
112
|
await session_manager.save_session(session)
|
|
101
113
|
|
|
102
|
-
|
|
114
|
+
dev_print("loading file", file_path, os.getpid())
|
|
103
115
|
ctx = await handle_upload(str(file_path), str(UPLOAD_DIR))
|
|
104
116
|
|
|
105
117
|
await sio.emit("status", {
|
|
@@ -120,9 +132,9 @@ def register_file_events(sio):
|
|
|
120
132
|
if genomiccoordstart is not None and genomiccoordend is not None:
|
|
121
133
|
try:
|
|
122
134
|
config['initial_position'] = [int(genomiccoordstart), int(genomiccoordend)]
|
|
123
|
-
|
|
135
|
+
dev_print(f"Using client-provided coordinates: [{genomiccoordstart}, {genomiccoordend}]")
|
|
124
136
|
except (ValueError, TypeError) as e:
|
|
125
|
-
|
|
137
|
+
dev_print(f"Invalid coordinates, using computed: {e}")
|
|
126
138
|
|
|
127
139
|
owner_sid = share_sid if share_sid else lorax_sid
|
|
128
140
|
await sio.emit("load-file-result", {
|
|
@@ -134,7 +146,7 @@ def register_file_events(sio):
|
|
|
134
146
|
}, to=sid)
|
|
135
147
|
|
|
136
148
|
except Exception as e:
|
|
137
|
-
|
|
149
|
+
dev_print(f"Load file error: {e}")
|
|
138
150
|
await sio.emit("error", {"message": str(e)}, to=sid)
|
|
139
151
|
|
|
140
152
|
@sio.event
|
|
@@ -150,7 +162,7 @@ def register_file_events(sio):
|
|
|
150
162
|
return
|
|
151
163
|
|
|
152
164
|
if not session.file_path:
|
|
153
|
-
|
|
165
|
+
dev_print(f"⚠️ No file loaded for session {lorax_sid}")
|
|
154
166
|
await sio.emit("error", {
|
|
155
167
|
"code": ERROR_NO_FILE_LOADED,
|
|
156
168
|
"message": "No file loaded. Please load a file first."
|
|
@@ -163,12 +175,12 @@ def register_file_events(sio):
|
|
|
163
175
|
}, to=sid)
|
|
164
176
|
return
|
|
165
177
|
|
|
166
|
-
|
|
178
|
+
dev_print("fetch details in ", session.sid, os.getpid())
|
|
167
179
|
|
|
168
180
|
result = await handle_details(session.file_path, data)
|
|
169
181
|
await sio.emit("details-result", {"data": json.loads(result)}, to=sid)
|
|
170
182
|
except Exception as e:
|
|
171
|
-
|
|
183
|
+
dev_print(f"❌ Details error: {e}")
|
|
172
184
|
await sio.emit("details-result", {"error": str(e)}, to=sid)
|
|
173
185
|
|
|
174
186
|
@sio.event
|
|
@@ -181,7 +193,7 @@ def register_file_events(sio):
|
|
|
181
193
|
return
|
|
182
194
|
|
|
183
195
|
if not session.file_path:
|
|
184
|
-
|
|
196
|
+
dev_print(f"⚠️ No file loaded for session {lorax_sid}")
|
|
185
197
|
await sio.emit("error", {
|
|
186
198
|
"code": ERROR_NO_FILE_LOADED,
|
|
187
199
|
"message": "No file loaded. Please load a file first."
|
|
@@ -196,5 +208,5 @@ def register_file_events(sio):
|
|
|
196
208
|
"data": {"value": value, "localTrees": local_trees}
|
|
197
209
|
}, to=sid)
|
|
198
210
|
except Exception as e:
|
|
199
|
-
|
|
211
|
+
dev_print(f"❌ Query error: {e}")
|
|
200
212
|
await sio.emit("query-result", {"error": str(e)}, to=sid)
|
|
@@ -6,7 +6,7 @@ lorax/handlers.py,sha256=PYuw_xq5-SsvSjAGURW0SnadyvjKr6Vct_0rQbtFsEw,32702
|
|
|
6
6
|
lorax/lineage.py,sha256=BJo0vkYReyjT2CPwOzKNTZmKQLvPFDSxbJjRFRjhZzk,12955
|
|
7
7
|
lorax/lorax_app.py,sha256=OabXITlMyPh-vO1qlFl90PRJbSKsw_M7xnlFXnOJVcg,2122
|
|
8
8
|
lorax/manager.py,sha256=ARGZwVOo7dSGUIUeUVMeR0KugVeJdEbPD_torVQLE50,2232
|
|
9
|
-
lorax/modes.py,sha256=
|
|
9
|
+
lorax/modes.py,sha256=Yku8eI2_RCm-BuksmFKDeXf-QNk_tYZYktStqcjWVVY,6040
|
|
10
10
|
lorax/pg.py,sha256=u-KPzmKr990-7euhTR7bENz5KvKD-FBX9zgJQNoMAlg,6500
|
|
11
11
|
lorax/redis_utils.py,sha256=DqP-YwcCDAdmkERO6cDrr5X0PdrgzIK52Wm-ZTlalsU,725
|
|
12
12
|
lorax/routes.py,sha256=zMjQ7XWKlNNRXNTyb7mArBiYYRdG4C9HGEiUw9MCCyM,4681
|
|
@@ -36,7 +36,7 @@ lorax/sockets/__init__.py,sha256=K6X2GyUha8yNhk1S4f4Q6NYhHwlmAprRLVcun1Cs0Ro,179
|
|
|
36
36
|
lorax/sockets/connection.py,sha256=jKSJF5ToF260zbS24JiHVALIsFuv0kDP_R9ovVUc63g,3373
|
|
37
37
|
lorax/sockets/debug.py,sha256=uUgnyAfhe1cwNMaEyPrWKqgtoxtHwy1n92ZEaHs8DRE,1374
|
|
38
38
|
lorax/sockets/decorators.py,sha256=2QtG7VGIGSj38coDs7KbNjHUEqmvtR7sBobRlqntMjk,3785
|
|
39
|
-
lorax/sockets/file_ops.py,sha256=
|
|
39
|
+
lorax/sockets/file_ops.py,sha256=5Ercfsf15l58xsc-MfLb_9wX4L4uXGiB28IIZqaOps8,8195
|
|
40
40
|
lorax/sockets/lineage.py,sha256=zfMal4X7ldG-e1PjQWbodgOfp2t5yiPlQGPVtGkW88A,10111
|
|
41
41
|
lorax/sockets/metadata.py,sha256=3fgF80ez-riF2F7-M6bmBlilX10Lx1wUH__wY9y_Sww,9444
|
|
42
42
|
lorax/sockets/mutations.py,sha256=kHafhth6DgI0Hss8HAIlhI8uqsddVlgkvfcV8RBuaME,5542
|
|
@@ -59,8 +59,8 @@ lorax_app/static/assets/localBackendWorker-BaWwjSV_.js,sha256=YW5js0UirOVb0YQPmK
|
|
|
59
59
|
lorax_app/static/assets/renderDataWorker-BKLdiU7J.js,sha256=sghrouSnLrHUz3Pc7z_D-bc3PT1X0WdCi8_WHI2pHJY,4077
|
|
60
60
|
lorax_app/static/gestures/gesture-flick.ogv,sha256=MVMT2CxgsnRBsR10WTptQe2vw8z2uGXQC7DC_2bqs4w,34638
|
|
61
61
|
lorax_app/static/gestures/gesture-two-finger-scroll.ogv,sha256=E-IyviZeXmrm3FuwfAkEowEN0-IDh8zDikj36D0LVlo,39065
|
|
62
|
-
lorax_arg-0.1.dist-info/METADATA,sha256=
|
|
63
|
-
lorax_arg-0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
64
|
-
lorax_arg-0.1.dist-info/entry_points.txt,sha256=E2tGcqHnfNAyKE7np2CFCpgbJiIm7e-0vPLo1g2RNVA,107
|
|
65
|
-
lorax_arg-0.1.dist-info/top_level.txt,sha256=midqTve5iv_2twMSjDj-HmJ_DePhUhLKtN-qtFaQyH4,16
|
|
66
|
-
lorax_arg-0.1.dist-info/RECORD,,
|
|
62
|
+
lorax_arg-0.1.1.dist-info/METADATA,sha256=JLzX21bF7h0Sm7hk2R84q_3vISUsVhNdtGSOo4KzoWY,3600
|
|
63
|
+
lorax_arg-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
64
|
+
lorax_arg-0.1.1.dist-info/entry_points.txt,sha256=E2tGcqHnfNAyKE7np2CFCpgbJiIm7e-0vPLo1g2RNVA,107
|
|
65
|
+
lorax_arg-0.1.1.dist-info/top_level.txt,sha256=midqTve5iv_2twMSjDj-HmJ_DePhUhLKtN-qtFaQyH4,16
|
|
66
|
+
lorax_arg-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|