Streamlit with juliacall

Has anyone tried using JuliaCall with Streamlit?

JuliaCall works on the first iteration of Streamlit, but on the second run (reloading/button click etc) it hangs when referencing a passed variable. It stays hanging so there is no error message or further information.

The error can be reproduced with the code below. I’m using streamlit==1.30.0 and juliacall==0.9.15

##############################

app.py

##############################
import os
import streamlit as st
from juliacall import Main as jl

current_directory = os.path.dirname(os.path.abspath(file))
julia_module_path = os.path.join(current_directory, “test_bug_module.jl”)
jl.include(julia_module_path)
jl.test_bug_module.test_bug_function(1)
st.subheader(“StreamLit App”)

##############################

test_bug_module.jl

##############################
module test_bug_module
function test_bug_function(input_variable)
println(“This prints”)
x = input_variable * 2
println(“This doesn’t print on the second iteration of the app”)
end
end
##############################

This issue might be related to

Unfortunately my only solution is switching to shiny for python which does not have the same issue with juliacall.

1 Like

This might help Calling Julia functions from Streamlit applications - Speaker Deck.

The GitHub project for this is at GitHub - mrkn/streamlit-julia-call: An extension for Streamlit that makes it available to call Julia from Streamlit applications.

There is also https://genieframework.com/ though not sure how close that is to what you want.

Looks like the issue already has a ticket on the streamlit repository. Calling Julia from Streamlit App using PyJulia · Issue #4585 · streamlit/streamlit · GitHub.