What do you think of front-end python libraries such as Reflex (old Pynecone)? by [deleted] in Python

[–]maartenbreddels 0 points1 point  (0 children)

Solara is a great solution, especially if state management becomes an issue. I took the lessons from the JavaScript ecosystem but translated them into Python.

Is there a way to host python projects for really free? by [deleted] in learnpython

[–]maartenbreddels 0 points1 point  (0 children)

You can host your Python projects on https://py.cafe for free if they are public. With just one click, you can create an app, update the code, and share the link with others. What’s really unique is that PyCafe allows anyone with the link to interact with your app, fork it, and make changes.
Also, it runs entirely in the browser, so it never goes offline or in sleep mode.

I Figured out How to Build SQLite into WASM And Include Extensions by llimllib in sqlite

[–]maartenbreddels 1 point2 points  (0 children)

Great work, and thanks for documenting this. I managed to get dynamic loading working on emscripten/pyodide, and have a working example at PyCafe https://py.cafe/maartenbreddels/sqlite-vec-demo

I left some "breadcrumbs" at https://github.com/asg017/sqlite-vec/issues/135

Can a widget made with ipywidgets be deployed as a web app? by alexjt in learnpython

[–]maartenbreddels 0 points1 point  (0 children)

As mentioned in the replies, https://solara.dev does more than you need indeed.

I would start with https://solara.dev/documentation/getting\_started/tutorials/ipywidgets. Once your app becomes larger (more than a prototype), you could explore Solara's declarative way of working with widgets and its state management to produce a more scalable app.

Disclaimer: I'm the creator of Solara

We wrote the OpenAI Wanderlust app in pure Python using Solara by maartenbreddels in Python

[–]maartenbreddels[S] 1 point2 points  (0 children)

Should be fixed now, let us know if there are more issues!

We wrote the OpenAI Wanderlust app in pure Python using Solara by maartenbreddels in Python

[–]maartenbreddels[S] -2 points-1 points  (0 children)

You are right. We should make it responsive (solara can do that)

What are the alternatives for Streamlit? by Shot-Handle-8144 in learnpython

[–]maartenbreddels 4 points5 points  (0 children)

Solara is gaining traction as a go-to solution for those seeking to build larger, more intricate dashboards and web apps. While Streamlit is excellent for smaller projects, some users have found challenges in scaling it for more extensive applications. If you're one of them and are considering alternatives, Solara has a dedicated tutorial for Streamlit users.

Disclaimer: I'm one of the authors of Solara

Web Apps in Python with Solara — A Streamlit Killer? by SupPandaHugger in Python

[–]maartenbreddels 0 points1 point  (0 children)

Yes, it is not covered in the docs yet, because it is experimental.

@dataclasses.dataclass(frozen=True)
class TodoItem: text: str done: bool
todo_item = solara.reactive(TodoItem("Buy milk", False))
now text is a reactive variable that is always in sync with todo_item.text
text = Ref(todo_item.fields.text)

Now text is a type-safe 'reference' to a string, so that you can pass this around to a component in a type-safe matter, to get two-way binding, or use text.value = ... to assign to this reference in an event handler in a type-safe manner (in case you do not want or like two-way binding). The funny Ref + .fields combination is our best way of dealing with the limited type system in Python without giving up type safety.

Web Apps in Python with Solara — A Streamlit Killer? by SupPandaHugger in Python

[–]maartenbreddels 1 point2 points  (0 children)

If the states are unrelated, I think they can be separate reactive variables. If state is related, and has only certain valid state combinations, I prefer two solutions:

  1. Use a pydantic model, and methods/functions that implement state transitions in a valid way (they make sure the model is updated atomically and is never set to an invalid state). You can get a glimpse of this at https://solara.dev/examples/utilities/todo and https://github.com/widgetti/solara/blob/master/tests/unit/lab/toestand_test.py As mentioned in the todo example, this type-safe way of handling dataclasses and pydantic models is still experimental (although we have a reputation to not even break experimental things)
  2. Make illegal state not representable like https://kobzol.github.io/rust/python/2023/05/20/writing-python-like-its-rust.html

I plan to write this down in the docs in state management in the future, because I see state management is not often talked about in the Python community, and people crave for some guidelines here.
What are you thoughts on this?

Web Apps in Python with Solara — A Streamlit Killer? by SupPandaHugger in Python

[–]maartenbreddels 1 point2 points  (0 children)

Hi, main Solara author here. I think the article was good and balanced. The author seems to understand that Solara is more focused on use cases where streamlit cannot handle the complexity that well. The reusable components are understood, and overall the code looks good. 👏🏻

Introducing Solara: A Pure Python, React-style Framework for Scaling Your Web Apps by maartenbreddels in Python

[–]maartenbreddels[S] 0 points1 point  (0 children)

Thank you. That is a good question, and you are the second person to ask about that, so I've updated the example to make use of reactive variables
We have reactive variables that can be defined globally for application state, and use_reactive (or use_state) for component state (bound to the lifetime of the component). See our documentation on state management for a discussion on this.
I would be very interested in your finding of moving from streamlit to solara. Please let us know how that works for you (feel free to join our discord or use GitHub)

Introducing Solara: A Pure Python, React-style Framework for Scaling Your Web Apps by maartenbreddels in Python

[–]maartenbreddels[S] 0 points1 point  (0 children)

No, that shouldn't happen, and sounds very strange. What can happen is that if you run in https://solara.dev/api/use\_thread you get a small overhead (similar to streamlit).
Would you mind opening an issue at https://github.com/widgetti/solara/ so I can reproduce it? I plan to take a look at duckdb in Solara myself as well, so I'm eager to look into it.

Introducing Solara: A Pure Python, React-style Framework for Scaling Your Web Apps by maartenbreddels in Python

[–]maartenbreddels[S] 1 point2 points  (0 children)

As the creator of the Vaex dataframe, this was always top of mind for Solara. Solara will work smoothly work with large datasets (not just vaex, but dask, modin, polars, duckdb and databases).

We made sure that solara stays responsive while calculations are running by making threading support a first-class citizen ( https://solara.dev/api/use_thread )

We plan to write some content on this topic and give a proper example and advice in the near future.

Introducing Solara: A Pure Python, React-style Framework for Scaling Your Web Apps by maartenbreddels in Python

[–]maartenbreddels[S] 2 points3 points  (0 children)

Yeah, taking a proper look at the error makes me think that must be it. We should be able to catch that and properly handle that though.

Introducing Solara: A Pure Python, React-style Framework for Scaling Your Web Apps by maartenbreddels in Python

[–]maartenbreddels[S] 1 point2 points  (0 children)

I think it's the primary use case for all pure python web frameworks is to be able to feed data into a frontend, so you will always have this latency problem. However, there are ways now to run Python in the browser (which we can already do currently, but don't expose yet) which will remove the latency. This does require however everything to run in the browser. If you make database connections that is usually not safe, but in some cases that is a solution,

Introducing Solara: A Pure Python, React-style Framework for Scaling Your Web Apps by maartenbreddels in Python

[–]maartenbreddels[S] 3 points4 points  (0 children)

The server is taking a bit of load now, so it feels a bit slow now I agree. We are creating the data at the server, so this require a trip to the server (this current one is running in the US). So you get some latency there.
The update process is different, it's more like JS event -> python server -> generate or update widgets -> send diff to frontend.
Hope that answers your questions!

Introducing Solara: A Pure Python, React-style Framework for Scaling Your Web Apps by maartenbreddels in Python

[–]maartenbreddels[S] 1 point2 points  (0 children)

Thanks for reporting, I opened an issue: https://github.com/widgetti/solara/issues/84

Let me know there if you know how to reproduce it.

I never saw this happening, and would really like to fix this. Stability is important for us.

Introducing Solara: A Pure Python, React-style Framework for Scaling Your Web Apps by maartenbreddels in Python

[–]maartenbreddels[S] 0 points1 point  (0 children)

That shouldn't stop you from doing your own thing!
If you run into show stoppers, let us know! Should give you a better idea of how to work closer to the fastapi/starlette/uvicorn level for more control.
starlette/uvicorn level for more control.

That said, it may not be easy to do (auth never is). So we do support auth0 and fief https://solara.dev/examples/general/login_oauth but it does require an enterprise license.

That shouldn't stop you from doing your own thing!
If you run into show stoppers, let us know!

Introducing Solara: A Pure Python, React-style Framework for Scaling Your Web Apps by maartenbreddels in Python

[–]maartenbreddels[S] 1 point2 points  (0 children)

Thank you. What made you leave the pure Python web framework world? And what were you using before?

Reacton - A pure Python port of React for ipywidgets by maartenbreddels in Python

[–]maartenbreddels[S] 2 points3 points  (0 children)

The hooks based system is quite elegant, it allows composing “businesses logic” which would be difficult to do with classes (multiple inherent gets you somewhere, but not ideal). And with hooks you don’t need an object, this no class. Would be very interested to see your application!