Skip to content

Commit 75b6312

Browse files
committed
register expression namespace so /expression/ePlant_expression route is active
1 parent 1c1d133 commit 75b6312

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

api/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,25 @@ def create_app():
128128
else:
129129
bind_names.update(p.stem for p in db_dir.glob("*.sql") if p.stem)
130130

131+
# SQL files larger than this are production-sized MySQL dumps and
132+
# cannot be mirrored to SQLite — they are only usable via MySQL.
133+
_SQLITE_MIRROR_MAX_BYTES = 50 * 1024 * 1024 # 50 MB
134+
135+
db_host = os.environ.get("DB_HOST", "localhost")
136+
cfg_binds = bar_app.config.get("SQLALCHEMY_BINDS") or {}
137+
131138
sqlite_binds = {}
132139
for name in sorted(bind_names):
133140
sql_path = db_dir / f"{name}.sql"
134141
if not sql_path.exists():
135142
continue
143+
if sql_path.stat().st_size > _SQLITE_MIRROR_MAX_BYTES:
144+
# Too large to mirror — fall back to MySQL bind if configured,
145+
# substituting DB_HOST so Docker containers resolve correctly.
146+
mysql_bind = cfg_binds.get(name)
147+
if mysql_bind:
148+
sqlite_binds[name] = mysql_bind.replace("localhost", db_host)
149+
continue
136150
db_path = tmp_root / f"{name}.db"
137151
if (
138152
os.environ.get("BAR_API_AUTO_SQLITE_MIRRORS") == "1"
@@ -187,6 +201,7 @@ def create_app():
187201
from api.resources.llama3 import llama3
188202
from api.resources.gene_expression import gene_expression
189203
from api.resources.gene_density import gene_density
204+
from api.resources.expression import expression
190205

191206
bar_api.add_namespace(gene_information)
192207
bar_api.add_namespace(gaia)
@@ -204,6 +219,7 @@ def create_app():
204219
bar_api.add_namespace(llama3)
205220
bar_api.add_namespace(gene_expression)
206221
bar_api.add_namespace(gene_density)
222+
bar_api.add_namespace(expression)
207223
bar_api.init_app(bar_app)
208224
return bar_app
209225

0 commit comments

Comments
 (0)