pyscript: Examples should NOT point to /latest/
Currently, some of our examples are broken “out of the box”. For example, look at issue #654; to reproduce:
git clone git@github.com:pyscript/pyscript.git(at the time of writing, the latest commit is 2a59ff8)- open
pyscript/example/simple_bioinformatics_tool.htmldirectly in the browser, without doingmake examples - observe that the buttons don’t respond.
This specific reproducer was broken by ee9b0960, which changed pys-onClick into py-onClick. After that commit, the examples work if you do make examples and run them using the locally built pyscript, but they don’t work with either pyscript.net/alpha or pyscript.net/latest.
The underlying fundamental problem is that we are trying to use examples/ in two contradictory ways:
- as a tool to check that our code works. In this sense, for a given checkout we want examples to work with the pyscript version living in that checkout. This is what
make examplesand our CI is currently testing. - as an entry point for beginners to start playing with pyscript: in this sense, we would like that if you
git clonepyscript and open a random HTML file, it will work out of the box; but to work out of the box, it must point to a globablly available pyscript version, which is what we have been trying to do by pointing them topyscript.net/alpha/,/latest/and/or/unstable/.
The two statements are contradictory because (1) points to a very precise and fixed-in-stone version of pyscript (the one corresponding to the given checkout) while (2) points to a variable version: for a given checkout, if I point the examples to /latest/ or /unstable/, maybe they will work today, but eventually they will break for sure.
This is basically the equivalent of cloning the repository of a random python project and hope that the tests in the master branch pass against the latest released version on PyPI: sometimes they will, sometimes they won’t.
I think we already discussed IRL with @fpliger and we have two different opinions:
- @fpliger would like people to be able to
git clonethe repo, open the examples in the browser, and play with them (Fabio, please correct me in case I am reporting your thoughts wrongly); - I think that keeping the dual nature of the examples is fundamentally impossible and will lead to inevitable confusion. So I would like to add some logic which actively prevents examples to be opened from a git checkout
If we really want to try to keep them working, the best we can do is to point the examples to /unstable/, which points to the latest published git commit. This ensures that if I do a git clone and immediately open the examples, they will work. However, this is a very partial solution, because it might happen the following:
- I clone pyscript at commit N
- at this point in time,
pyscript/examplespoint to/unstable/which is version N, and they work - a certain time
Tpasses - someone merges a PR with an incompatible change, commit N+1
- I open the examples: now
/unstable/points to version N+1, and my examples no longer work unless Igit pull.
Of course, the more time passes in point (2), the higher is the possibility that someone merges a backwards-incompatible commit. If you are unlucky, it might happen only a few minutes, which makes it very confusing for beginners.
This is related to #624, which attempted to fix the problem, but now the examples point to /latest/ which is already incompatible with the current main.
/cc @marimeireles and @pww217
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (22 by maintainers)
Aaaaaah, gotcha! I think we already had something like that because of cors but, if not, sounds like a plan!
Cheers!! 🍻🍻
Overall agree with both @antocuni and @pww217 above. Only think we need to shave some edges on these parts of the proposal:
That’s a great proposal and we actually talked about this (or something very close) before. I think this should be an extension or something and not too custom to examples. This, actually, doesn’t need to be a part of “fixing” the current state and could be an enhancement issue on its own.
I think there is still value to keep the custom logic the walks the user through what’s going on in the example even when deployed on pyscript.net. That said, we can discuss that in a separate issue related to my comment above.
This is a good discussion, I think we are converging towards a better structure 😃
I agree with all of the above. The point which IMHO causes troubles is this:
I agree it would be nice, but it causes more troubles than it solves. To start with, only the very simple examples work out of the box: all the examples which reference external files don’t work, so the hypotetical user will be very confused because half of them work and half don’t.
Moreover, as I explained above, there is a fundamental tension between the need of being “self consistent in the repo” (i.e., I expect the examples to work with the pyscript in the same checkout) and “work out of the box with an external URL which changes over time”.
Moreover, cloning the git repo is for developers, not casual users. I agree that we want some nice tutorial/getting started for people to start playing with pyscript, but it does not belong to the main pyscript repo, in the same way that python courses are not in the main CPython repo.
I propose the following:
examplesshould point to a local url, likebuild/pyscript.js.make dev, which builds the local copy and starts a local webserverThis way, we are still friendly to the casual user which just open the HTML file, we ensure that examples pushed to pyscrpt.net always work, and we save a lot of headaches.
as @marimeireles says, some of the examples like Mario don’t really belong to the main repo but I don’t have any strong opinion.
Yes I agree, but we can modify the URL when we publish to
pyscript.net, there is no need to hardcode it in the git files.I think I agree with everything here. Just reiterating that some tests should be moved e.g the Mario one has too many dependencies and things we don’t really care about, it’s just hard to maintain (cause we’ll be maintaining other work that’s not relevant to pyscript).
Yeah, I’m slowly making progress on it! I hope to post something today by the end of the day.