All jobs

Fix "AttributeError: module 'streamlit' has no attribute 'beta_columns'" and the beta_expander Rename

Yes. An agent renames the beta_ calls, drops the removed config option that fails first, and proves the app renders with Streamlit's AppTest.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads the app and its requirements before reproducing anything. In an app like rjtavares/BirdsPyView, requirements.txt lists streamlit, streamlit-drawable-canvas, opencv-python-headless, pandas, shapely, scipy and mplsoccer with no versions, and birdspyview.py is 161 lines: line 21 calls st.set_option('deprecation.showfileUploaderEncoding', False), line 38 opens st.beta_expander(...), and lines 41, 83, 131 and 156 call st.beta_columns(...) with width lists such as [2,1,0.5,1] and (3,1,3). The readme's run command is streamlit run birdspyview.py, and the only test, test_bpv.py, checks the homography math in helpers.py.

A clean install resolves Streamlit 1.67.0, streamlit-drawable-canvas 0.13.0 and opencv-python-headless 5.0.0.93, and on that Streamlit hasattr(st, 'beta_columns') and hasattr(st, 'beta_expander') are both false while st.columns and st.expander exist. Running the script under streamlit.testing.v1.AppTest shows that the search-box error is not the first one: the run stops at line 21 with StreamlitAPIException: Unrecognized config option: deprecation.showfileUploaderEncoding, raised from config.set_user_option, before any title is rendered. Only once that line is gone would the beta_expander call on line 38 raise, and then each beta_columns call after it.

The fix is the three renames and one deletion, nothing else: line 21 is removed, st.beta_expander( becomes st.expander( and every st.beta_columns( becomes st.columns(, keeping the width arguments and the expanded=True keyword. The agent leaves helpers.py, pitch.py and the canvas code alone, since none of them call a removed Streamlit API.

Proof comes from the same AppTest, which runs the script headlessly without a browser. On the branch it completes with no exception, renders the title Upload Image or Video and one file uploader, which is everything the app shows before a file is chosen. pytest test_bpv.py passes its one test. The drawing canvas and the column layout only appear after an upload, so the agent would also start streamlit run in the sandbox and load the page in its browser, choosing the repository's own pitch.png to reach the expander and the four column rows, and reports whatever that shows.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Our Streamlit app fails with \"AttributeError: module 'streamlit' has no attribute 'beta_columns'\" on a fresh deploy. Read requirements.txt and the app, say which Streamlit a clean install resolves, and run the script under streamlit.testing.v1.AppTest to find the first exception, which may not be the one in the title. Rename every beta_ call to its current name with the same arguments, remove any config option Streamlit no longer recognises, and run the AppTest and the repository's tests again. If the app needs an upload to show its layout, start it headless and load it in the browser with a file from the repository. Open a pull request quoting the exceptions before and the rendered elements after.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

A pull request that edits only birdspyview.py: one deleted set_option line, one expander rename and four columns renames. The description quotes the Unrecognized config option exception from the original, the attribute errors the renamed calls would have raised, and the AppTest result on the branch with the title and uploader it rendered.

A reviewer checks that each columns call keeps its width list, that expanded=True survived on the expander, and that requirements.txt did not gain a pin. If the agent reached the post-upload layout in the browser, the description includes what it saw there; if not, it says the AppTest covered the pre-upload page only.

The pull request also notes that the unpinned streamlit line is why an app last edited in 2021 broke on its next deploy, and leaves a pin as a separate decision.

Run it on every failed Streamlit deploy

The error shows up in the deploy log of the hosting service, so a handler on your server that receives that service's failure notification starts this run with POST /o/{org}/sessions, sending a UUID v5 of the deploy id as request_id so a repeated notification returns the run already started.

A repository with a frozen requirements.txt is still exposed the next time Streamlit removes an alias, so a schedule trigger with a monthly cron in your timezone can run the AppTest against a clean install and open a pull request only when it finds an exception.

The use case this job follows, with its automation and trigger: Fix a bug from an alert.

Why run it on Rush?

The error in the search box is rarely the first error the app raises, and only running the script shows the order. In a Rush sandbox the agent installs the app's dependencies as a deploy would, runs it under AppTest, reads the first exception, and keeps the output of every attempt, so the pull request lists the failures in the order a deploy would hit them.

Streamlit apps are checked by looking at them, which is hard to do from a CI job. The sandbox has a browser, so the agent can start the app headless, upload the repository's own image and reach the layout the renamed calls build, with screenshots and the server log kept with the run.

Frequently asked questions

Why does the app fail on set_option before it reaches beta_columns?

Because line 21 runs first and Streamlit 1.67 no longer knows the deprecation.showfileUploaderEncoding option, so set_option raises StreamlitAPIException: Unrecognized config option. The agent removes that line, after which the beta_ calls are the next failure.

Are st.columns and st.expander the same as the beta_ versions?

They take the same arguments in this app: a list or tuple of relative widths for columns, and a label plus expanded=True for expander. The agent renames the calls and keeps every argument, then shows the script running under AppTest.

Can the agent test the drawing canvas?

Not from AppTest alone, since the canvas appears only after a file is uploaded. The agent starts the app with streamlit run in the sandbox and uses its browser to upload pitch.png from the repository, and reports what rendered.

Should streamlit be pinned in requirements.txt?

That is a separate decision. The unpinned line is why the deploy broke years after the last commit, and the pull request says so, but adding a pin changes how the app tracks Streamlit and is left to the team.

More Streamlit jobs

More jobs like this: Fix a bug from an alert

Keep reading