MediaFileManager: Missing file on Google App Engine
See original GitHub issueHi All 🙂,
I have been going through the process of deploying a Streamlit application to https://radiotherapy.ai using Google App Engine. Once it was deployed it presented an interesting bug that I hadn’t seen before. The matplotlib
plots were intermittently not showing up within the interface and the following error message was presented within the App Engine logs:
2021-05-26 05:10:15 default[20210526t145605] 2021-05-26 05:10:15.441 MediaFileManager: Missing file 5c5c1707408633221e9aab6c4c4f9437cdab6da0ed660ef129103e79.png
Here is what I saw
Here is what was able to make the app able to see if I dragged the slider to other values and then came back a few times:
I had a suspicion that this might be due to the new garbage collection process being undergone in 0.82.0
:
So I downgraded to version 0.81.1
, but unfortunately the issue was still present.
Then, wondering if maybe I wasn’t provisioning sufficient RAM I increased the instance from 5 GB up to 16 GB. However unfortunately this still didn’t rectify the issue.
I haven’t yet pointed my domain to the app engine version, so if you’d like to see this issue in action go to https://rtai-autocontouring.ts.r.appspot.com/.
I’d be more than happy to go through further debugging if you so desire.
I have copied in the code I am using to produce this below, of particular note, I am directly passing the fig
object through to st.pyplot
, so hopefully shouldn’t be running into the issue of using the global plt.figure()
object.
# main.py
fig = _utilities.comparison_display(
x, y, ct_image, gold_standard_masks, predicted_masks, zoom, windowing
)
st.pyplot(fig)
# _utilities.py
def comparison_display(
x,
y,
ct_image,
ground_truth_masks,
predicted_masks=None,
zoom=1,
windowing=(None, None),
figsize=(8, 6),
):
fig, axs = plt.subplots(nrows=1, ncols=2, figsize=figsize)
c = _individual_plots(
axs[0], x, y, ct_image, ground_truth_masks, zoom=zoom, windowing=windowing
)
axs[0].set_title("Ground Truth")
if not predicted_masks is None:
_individual_plots(
axs[1], x, y, ct_image, predicted_masks, zoom=zoom, windowing=windowing
)
axs[1].set_title("Model")
label_to_handle_map = {}
for ax in axs:
handles, labels = ax.get_legend_handles_labels()
for handle, label in zip(handles, labels):
if not label in label_to_handle_map.keys():
label_to_handle_map[label] = handle
fig.colorbar(c, ax=axs[:], shrink=0.8, location="bottom")
labels = list(label_to_handle_map.keys())
handles = [label_to_handle_map[label] for label in labels]
if len(labels) != 0:
fig.legend(
handles=handles,
labels=labels,
loc="upper center",
bbox_to_anchor=(0.5, 1.05),
ncol=len(labels),
)
return fig
Cheers 🙂, Simon
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I was having the same problem but for visualizing videos in a streamlit app but deployed to Google Cloud Run. I manage to get it working by setting
Maximum requests per container
to a high value (100) and #CPU=1Thanks @SimonBiggs! Really appreciate your help here!