Spaces:
Sleeping
Sleeping
File size: 1,127 Bytes
094a5f6 db8339d 094a5f6 db8339d 094a5f6 db8339d 094a5f6 db8339d 094a5f6 db8339d 094a5f6 db8339d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | """
warmup_bridge.py
Pre-warms the juliacall Python<->Julia bridge at build time.
Non-fatal: always exits 0 so Docker build never fails here.
"""
import os, sys
# Tell juliapkg to use the pre-installed Julia and NEVER download anything
os.environ["JULIA_DEPOT_PATH"] = "/app/.julia"
os.environ["JULIA_BINDIR"] = "/usr/local/julia/bin"
os.environ["PYTHON_JULIAPKG_OFFLINE"] = "yes" # critical: no downloads
print("Pre-warming juliacall bridge...")
try:
from juliacall import Main as jl
jl.seval('push!(LOAD_PATH, "/app/src")')
jl.seval('include("/app/src/QuantEngine.jl")')
jl.seval("using .QuantEngine")
# Sanity check via the bridge
import numpy as np
c = (100.0 * np.exp(np.cumsum(np.random.randn(100) * 0.005))).tolist()
result = jl.QuantEngine.sma(jl.convert(jl.Vector[jl.Float64], c), 20)
assert len(list(result)) == 100
print("juliacall bridge warmed up ✓")
except Exception as e:
print(f"WARNING: juliacall warmup skipped: {e}")
print("Julia will initialise on first user request instead.")
sys.exit(0) # always succeed — this is optional warmup
|