New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python web app #8873
base: master
Are you sure you want to change the base?
Python web app #8873
Conversation
@@ -0,0 +1,8 @@ | |||
FROM debian:bookworm-slim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using Python images instead of Debian. These get updated faster and contain less programs, so smaller size (especially Alpine-based) and less possibilities to exploit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yeah, this was copy-pasted for now from the other Python-related dockerfile, but that's a good steer. Personally I'd build ultra-minimal docker images with Nix, but probably won't do so here.
|
||
HTML_DIR="../../html" | ||
|
||
BuildStatus = namedtuple("BuildStatus", ['started_at', 'completed_at', 'next_at', 'duration']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using @dataclass
if there's not a significant performance increase by having namedtuple()
, it's more readable and allows specifying types and better static checking with mypy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just aiming for the most lightweight and concise object-instead-of-a-dict wrapper tbh, but I might consider dataclasses.
|
||
package_data = None | ||
def load_package_data(): | ||
global package_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using @lru_cache()
instead of a global
variable. That way the cache will be stored in the function's object instead of in the app.py
's namespace and there would be no need for the conditions. Cleaning then is as simple as load_package_data.cache_clear()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay, thanks, this is a great tip. I've been mostly out of the Python ecosystem for a long time since the early days when I wrote unittest.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try mentioning it whenever I see singleton-like approach in Python which isn't heavy for performance. Less testing and bugs. If it were a possible bottleneck, maybe try it with timeit beforehands, though I believe the difference with the recent Python might be optimized away anyway. 😊
Will this change effect the availability of https://melpa.org/archive.json? |
@purcell wanted to ping and see if you saw @progfolio 's question. I haven't had time to dig through this and understand the end state. |
The changes here will hopefully replace the Javascript single-page application version of the MELPA and MELPA Stable websites with a server-side rendered equivalent, using a small web app written in Python, which reads its data from the JSON files produced during package builds instead of maintaining any sort of database.
This will fulfill #3728, and the implementation is an alternative and (for me) preferred approach to #8584 and #8585. It should also fix #6205.
Remaining work:
/
,/package/*
and/getting-started
behindnginx