Weeknotes 2022-07-18
,Fought with strange bugs last week, also some work and much outdoor stuff.
For example when using Jupyter Notebooks in a Django environment, the PYTHONPATH was always set to some old project and therefore imports from my current project didn't work. And it was simply not possible to get the PYTHONPATH right. I could not find the old projects name in any config or virtualenv. Weird. But then I had a closer look at the kernels using jupyter kernelspec list:
$ jupyter kernelspec list Available kernels: django_extensions /Users/jochen/Library/Jupyter/kernels/django_extensions python3 /Users/jochen/.virtualenvs/foo/share/jupyter/kernels/python3
Ok ~/Library/Jupyter/kernels is weird. And there the name of the different project appeared in the kernel.json. Whoa. Somehow this old django_extensions kernel has overwritten my django_extensions kernel from the virtualenv. After deleting the old one, my kernelspec looked like this:
$ jupyter kernelspec list Available kernels: django_extensions /Users/jochen/.virtualenvs/foo/share/jupyter/kernels/django_extensions python3 /Users/jochen/.virtualenvs/foo/share/jupyter/kernels/python3
This was pretty hard to debug.
And then there was this strange fastdeploy bug forcing me to have a closer look at SQLAlchemy. I still don't know what the root cause of the problem is. I switched to using SQLAlchemy in combination with asyncpg a frew months ago and there were this "The garbage collector is trying to clean up connection <asyncpg connection>" in the logs right from the beginning. I didn't pay attention, because it all seemed to work fine. But during my deployment tests with cast_registry I finally saw some real errors. The tests caused a lot (well, not really) of read queries to the database while the deployment process is posting steps to fastdeploy causing writes. And now I saw 401 responses to some requests from cast_registry, because the access token could not be verified or 404 because some object was not found. Looking at the logs I found some messages from asyncpg like "asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress". Hmm, seems like two coroutines are trying to use the same database connection which should not happen. After some debugging I found out the reason for this was me using "uow=SqlAlchemyUnitOfWork()" holding the database connection as a default argument in a bootstrap function, which causes uow to be instanciated at import time and never be replaced by a new uow, ouch. But after fixing that, fastdeploy is now ending up in a deadlock after some time. But only on Linux.
And while I'm sure it's all my fault and I'm just holding SQLAlchemy wrong and being and early adopter using it in combination with asyncpg doesn't help - I just cannot wrap my head around the SQLAlchemy interface. Why are there engines, connections and sessions? When do I have to instanciate/open/close them? Why do I have to close a connection, but dispose an engine? I often close a session, then a connection and then dispose the engine. If you should always use this combination, why isn't there a highlevel function doing just that? If you don't, why is there no documentation showing why and how? 😤
Progress on having a landing page where people can create podcasts/blogs:
And then I started an experiment trying to help someone getting started with Django and writing a series of blogposts about it.
- Merged the old work in progress on the "Deployed Services Configuration"-issue to be able to work on this database bug without conflicts getting out of hand 🫣
Out of Context Images
Articles
Videos
- The Amplituhedron - Nima Arkani-Hamed | Hmm, didn't know about this one..
- With the newest version of Git 2.37.0, you can run just "git push" to push new branches. No more "--set-upstream origin".
- ChainMap is in collections in the #Python stdlib: it's a list of dictionaries, searched in order for items. Handy for nested contexts like programming language scopes. Or pizza specials! 🍕🥤😎🍕
- I was recently looking for materials to learn causal inference. These lectures given by @david_sontag are really amazing.
- A Python pattern that I like to use is attaching exceptions to callables that use them. To me this is syntactical sugar on larger projects. #twitter4devs
- This is probably well-known in some circles but not everywhere. The most important skill for Research Scientists in AI (at least at @OpenAI ) is software engineering. Background in ML research is sometimes useful, but you can usually get away with a few landmark paper. | Software engenieering is the most useful skill in a lot of fields right now..
Software
- Community: Component Libraries | List of web component libraries for date pickers etc..
- htmx 1.8.0 Release
- Typer Release 0.6.1 | Integration with rich
Podcasts
- #799 (Fünfphasig) (Bits und so)
- #293 – Donald Hoffman: Reality is an Illusion – How Evolution Hid the Truth (Lex Fridman Podcast)
- WR1384 Zeitenwende (Zum Thema) | Great episode, would like to hear a lot more stuff like this
- Kommunismus - Ein schillerndes Gespenst (Sein und Streit) | Interesting topic, but the episode was rather boring (at least for me)
- Chip Kidd—award-winning designer, musician, author, and all around rock star—joins for his fifth time to talk about his recent projects and so much more (Design Matters)