Streamlit APP deployment : error not recognizing my own functions

Hello,

I’m trying to deploy my streamlit app and learning how to do it at the same thime. In the local way, the streamlit app works.

Here how it works : I have “donnees.py” which is my script with all the function I need for the preprocessing and the modelisation. And I have “streamlit_appw.py” which is the script for the streamlit app. When I run “streamlit_appw.py” it seems that all the error are related to the first script “donnees.py”. After several try, It seems that Streamlit doesn’t take in count my script “donnees.py” because all the errors refers to the functions declare in “donnees.py”.

Here the error message:

My repo is here : linkhttps://github.com/m-moriss/Data_challenge_RAKUTEN

Does anyone know how to fix that ? I need to deploy it for an application but it work only in local on my laptop.

Thank you

Ahd here what i am expected to see (in the local way it works):

Hi @Mrss,

It looks like there’s an error with one of the underlying files in your dataset. The two things that I did to help debug this were:

  1. Look at the logs in the sidebar (that way you can see the actual error message). I deployed a fork of the repo in order to do this on my own, and I saw
AttributeError: 'DataFrame' object has no attribute 'imageid'

Ah, so it has something to do with the dataframe object itself and perhaps a missing column.
2. Use st.write for debugging. print() also works, but I like to use st.write especially for dataframes, so that I can see and explore them.
You can see the write statement I added here Data_challenge_RAKUTEN/donnees.py at main · blackary/Data_challenge_RAKUTEN · GitHub
And the output here: https://blackary-data-challenge-rakuten-streamlit-appw-t3yqsr.streamlit.app/

Note that there is a column called imageid;;;;;;;;;;....
My guess is that you are using semicolons to separate the columns in your csv, and pandas is expecting commas, so you need to pass an extra argument when reading the csv to tell it to use semicolons.

However, the main thing is that you can use these techniques to do your own digging in and debugging. Hope that’s helpful!

(P.S. For a large dataset, you might consider using parquet rather than csv, as it will be more compressed, and tends to have fewer problems than csv. It’s not human-readable as a file, but with files that are large, that doesn’t tend to matter too much).

1 Like

Hi @blackary ,

Thanks a lot.
Now i found others mistakes but your explanations and example helps me a lot. Really hopeful!

It’s very strange because in my local it works.