Splitting app throws error

Separating out plot function into a separate .py file (had some st.markdown code too) throws

**StreamlitAPIException** : set_page_config() can only be called once per app, and must be called as the first Streamlit command in your script.

The file is being imported at the top of app.py file. Have tried placing set_page_config inside plotting file as well but still the error doesn’t go away.