Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

Honestly, this would have been a great prompt in 1950.


What's the benefit of doing this instead of just using the watchmedo command from watchdog directly ?

    watchmedo shell-command --patterns="*.py" --ignore-directories --recursive . -c "pytest"
As a bonus, watchmedo works for your server, your bundler, you task queue process, etc.

It seems that there is no need to create one tool per command you wish to run. Or am I missing something? Do you only reload tests that are related to the code change?


First, I think for many users typing:

  ptw .
is a lot simpler than typing:

  watchmedo shell-command --patterns="\*.py" --ignore-directories --recursive . -c "pytest"
Second, I personally faced problems with suggested approach. I use neovim with ale plugin that automatically formats my code with black every time I save python file. That's two saves instead of one. In that case watchmedo will trigger pytest to run twice, which is usually not the desired behavior. Sometimes you also just save your file multiple times quickly and you want pytest to run only once with latest changes in mind.

In my tool, there is a 0.5 seconds delay (configurable --delay). pytest-watcher will wait this time for other changes before starting pytest.

Regarding running tests for changed code only, there is a pytest-testmon plugin which does exactly that. It can be used together with pytest-watcher. Here is the link:

https://testmon.org/


> that case watchmedo will trigger pytest to run twice,

That's what the --drop options is for. It's better than delay, since it drops any event while the command is running, no matter the time it took.

> First, I think for many users typing: ... is a lot simpler than typing:...

I think somebody using pytest is perfectly capable of doing:

alias ptw='watchmedo shell-command --patterns="*.py" --ignore-directories --recursive . -c "pytest" --drop'

Or putting that in a makefile, a dodo.py file or what have you.


I don’t think that —drop is better than delay in case of tests. Quite contrary, one usually wants them to run after latest save not the first one.


Sensible decision, although hardly a surprise or a killer feature for something that is a major version bump.

I assume the async story is going to be more fun.

By the way, if you are looking for a good key/value store with expiration without the need to setup redis, have a look at the excellent diskcache:

https://pypi.org/project/diskcache/

It is based on sharded sqlite files, and it's surprisingly capable, even in multiprocessing based env like a django site.

Sqlite is really showing up in all sort of use cases these days, like huey, a task queue that doesn't need any broker to be installed to be useful: https://pypi.org/project/diskcache/

Now things can get fun...

With supervisord (supervisord.org) you can manage multiple processes, and with fastapi + starlette, you can serve your WSGI site without a proxy pass, including static sites: https://fastapi.tiangolo.com/advanced/wsgi/

Then with shiv you can bunddle all that in a pyz file: shiv.readthedocs.io/

Meaning you can now just upload a pyz file to your server, run python on it, and that's it, you have a full stack deployed, with a web framework, db, caching, task queues, static file serving, which can handle around 100k visitor each day without a sweat.

No more infra needed. Just Python code, all bundle in one file.

That's really neat.


But then how do I do microservices in a monorepo based SPA server rendered running on kubernetes?


Also, pair it with Unpoly, tailwind and slippers and you get a pretty amazing frontend setup as well.

https://unpoly.com/

https://mitchel.me/slippers/


Last year I tried Huey for a project where usage was very lightweight. Performance was more than enough with SQLite. Unfortunately Huey with SQLite was not great at handling unexpected crashes like server and docker restarts.

Switching to Redis solved all of these issues.

Maybe it's better now.


>you can serve your WSGI site without a proxy pass, including static sites

What about HTTPS?


Totally agree on hoping there is at least some movement forward on async--particularly async ORM. I love Django and DRF. It is my go-to for a lot of things, but the lack of async support is increasingly a problem for more organizations. Honestly, it would not surprise me that if a solid, kitchen sink web framework emerges in golang, Django will be abandoned rather quickly.

2 cents.


I've been writing web applications using python and django for close to 15 years now. Smooth, concise and stable. Doing the same using a verbose and boilerplate heavy language like golang doesn't sound attractive to me, at all.

Not sure I understand the fuss about upgrades either, at my current job I've gone from python 2 to 3 and from Django 1.8 all the way to 3.2 LTS without too many headaches. The release notes provide detailed instructions on what is deprecated and what you should do to fix it.


Yes, maybe in 10 years when this Go framework catches up with all the features and becomes as battle proven, well documented, maintained and funded as Django and somehow we know is not yet another thing that will be abandoned next year.


The Go hype is as bad as the frontend hype in my opinion.

If you're replacing Django with Go then either you never needed Django, or you have no idea what you're getting into.

At a previous job backend team decided to replace rails "because monolith slow ruby not fun anymore" with Go. Three years later they were still reimplementing things rails gives you since day 1. I've seen abominations as doing migrations as SQL scripts ran by cobbled together bash scripts because "as we don't have orms then orms are bad".

No need to say now they're about 4 years in and the one still running the business and making all the money is the monolith, not all the Go microservices around it.

Go is a replacement for c/c++, maybe java and for building infrastructure probably.

If you're using it for doing CRUD forms, you're using it wrong.


GP (BiteCode_dev) made a valuable comment for how we can build a easily deployable python application with

>web framework, db, caching, task queues, static file serving, which can handle around 100k visitor each day without a sweat.

i.e. with 4-5 large dependencies of frameworks, libraries, software etc.

In Go you can off the bat reduce those dependencies to 1 or 2, even completely eliminate them, you get deployable package and async for free with faster development cycle and lesser headaches of managing dependencies in the long run.


Out of curiosity: what features from Ruby are they reimplenting? I have no experience in Ruby but in a few other languages and framworks. And having encountered something missing yet when writing Go web services.


I've not even mentioned Ruby.

Rails. Features of rails.This is exactly the problem...people focus so much on the language they forget the ecosystem they're in, and the ecosystems matters a lot more than the syntax or the performance.


> And having encountered something missing yet when writing Go web services

How do you do form validations, translations, database access, migrations, email sending, background jobs that don't die on a deployment, user authentication, file uploads, caching, etc?

Of course all of this can be done, you just need to take 100 decisions and tie together 256 libraries many of them probably abandoned in a few years from now.

If you don't need any of that, then just what I said before: ok, you never needed rails from the get go.


I love Django but it seems like such a limitation for certain workloads. You can often work around some of these issues with Celery but still…

.Net already offers a kitchensink with async, it’s growing a lot and is much more attractive than a decade ago.


Interesting. I'll look into some of those projects.

I think you put the wrong link for Huey, btw.



First, there are people that don't want to use a CDN (don't trust them with censorship), or can't (local network).

But you can cache other things that are not the entire page itself:

- database queries

- user sessions

- api calls

- page fragment

- function memoization

What's more, cache backends have the ability to expire things, which can be helpful for all sort of stuff.


Honestly progress doesn't seems slower at all. I hear news of scientific discovery every week. Science is large, and it's not just physics.


Also what people consider science is a bit of a continuum. There is what is universally objective scientific breakthrough (like discovery of quarks) on the one end, and universally objective non-breakthrough (like the construction of a simple bridge) on the other but where does the progress of iPhone 1 to iPhone 13 fit?

So much advancement is going on in or around computing right now I think that in the future we'll sorta look back and consider that closer to science than mere engineering.


No, I disagree. Science is something that's well established and has been around for centuries. Engineering is also well established and has been around for centuries. The iPhone is an engineering advancement and will always be viewed that way; it'll always be in the same category as building the aqueducts. There was nothing scientifically groundbreaking about it, unlike discovering gravity or radiation.


We know.

But geek profiles and marketing profiles have often huge differences in life styles, ethics, rhythm, objectives, etc.

It was visible at university, it's still is in social life and work life.

Diversity enrich your life up to a point, after which cost/ratio plummet. I rarely see those profiles going along and having fun sharing time together. It's not impossible, but it's not common, so you won't get a lot of co-founders that will match, or that did, but will last.

It's not that geek are completely oblivious to their shortcoming.


> Diversity enrich your life up to a point, after which cost/ratio plummet.

This is a really important point that lots of people seem to forget when talking about the strength of diversity.


Optimise for picking a marketer that believes in the vision and uses the product themselves instead of someone who has a proven record of making sales and you'll get along just fine.

Don't trade money for values.


There are some of us out there... I've learned to write code for basic apps (web scrapers in Python, Slack integration in PHP) but I spend most of my days as a product marketer. I love working with software engineers but won't ever be one myself. I know what I'm good at but I can appreciate those other skills.


> I rarely see those profiles going along and having fun sharing time together.

I (resident of North America) rarely see kangaroos.


So, create my start up in australia? Got it!


Sometimes slow is a feature. For once it's a quality filter. Chats are 1% signal, 99% noise.

Zulip is a better than most chat for that, because you commit to a topic, which adds order and caring.

But it's still fast, so it's tempting to writz anything you thinl about.

When I'm on my phone I stop commenting on HN midway quite often because the effort is not worth it. On a computer, it's too easy to type.


> Zulip is a better than most chat for that, because you commit to a topic, which adds order and caring.

I've never used Zulip, but realistically, how does it differ from Slack's thread system?


Two things: In Zulip, you can't not have threads. Threads in Slack are an afterthought and the UI actively tries to prevent you from using them (they're a narrow column on the sidebar and you can't see everything), whereas in Zulip they're a first-class citizen.

The second thing is that Zulip's UX is fantastic. You can zoom in and out of conversations with a single keystroke, and the UI is responsive and does exactly what you want. Slack is so slow on my new Ryzen that I frequently out-type it, and half my keystrokes end up interpreted as channel-switching keystrokes, so I end up having typed something random in a random channel instead. Fuck Slack, sincerely.


Slack's thread UI is simply atrocious. Zulip's UI makes it harder to not be part of an existing thread. In slack, anyone can just wander into room and start typing things that should be in a thread, outside of any thread, even (especially) if the thread they want is right there. That's not impossible with Zulip, just harder enough to do that it's not an issue in the same way.


If I understand Zulip's threading correctly (I can't log in right now to check), it imposes a strict two-level threading system. Quill (https://quill.chat) has nested channels but unlike Zulip, clicking on the "outer" channels doesn't show you all the content of all the "innner" channels.


> When I'm on my phone I stop commenting on HN midway quite often because the effort is not worth it. On a computer, it's too easy to type.

With longer comments I usually quit because the editing required to sound like a halfway intelligent person is way harder on a phone. I imagine some other people can nail their first draft, and others just don’t care how they come across.


There are monks that would say that with some practice, you would realize it's not. And they call that direct experience too.

Something you can't measure objectively cannot be so easily hand waved.


> There are monks that would say that with some practice, you would realize it's not. And they call that direct experience too.

I am aware, and I do happen to maintain a practice of that nature. My question to these monks: who is this "you" that realizes it is not? (I don't fear so much offending the monks, my understanding is that many actually enjoy this sort of question :)

> Something you can't measure objectively cannot be so easily hand waved.

Everything that I can measure objectively, including the act of measuring and the concepts of "measure" and "objectivity" happen within the theater of my consciousness (the only thing I have direct experience of is my consciousness, everything else is relative to it).

So I say: Something you experience directly cannot be so easily hand waved.


> Everything that I can measure objectively, including the act of measuring and the concepts of "measure" and "objectivity" happen within the theater of my consciousness

Correction: they happen in what you believe to be a theatre of consciousness. Belief without evidence is religion.

You can demonstrate that such a theatre might exist by demonstrating some phenomenon which cannot be accounted for via mechanistic processes. All attempts have failed so far, as the intuition pumps are typically fallacious.


> Correction: they happen in what you believe to be a theatre of consciousness. Belief without evidence is religion.

I have the highest possible level of evidence: direct experience. It just happens to not be communicable. Not everything is.

> You can demonstrate that such a theatre might exist by demonstrating some phenomenon which cannot be accounted for via mechanistic processes.

All the mechanistic processes that you can account for where observed within the theater of your consciousness. So was everything you ever learned about science, and also this present discussion with me.

What I am pointing at is just Plato's Cave. Not a new argument, nor a settled one.


> I have the highest possible level of evidence: direct experience.

That's not evidence, that's a perception. Perceptions must be interpreted within a body of knowledge. Direct perception is never direct evidence because perceptions are necessarily flawed.


>Something you experience directly cannot be so easily hand waved.

How does this become reconciled with the fact that I cannot directly experience your subjective experience? Does that imply I should be able to hand-wave your subjective away as if it doesn't exist?

I think what part of the discussion is getting at is that a definition of consciousness would (at least partly) solve this problem.


I recall Google, Microsoft, Apple and Amazon to have lied a ton.


Only tangential, but it's a very little know fact that python can import and even run code from a zip archive. There is actually a module for that in the stdlib: zipapp.

This means that you can zip your entire project, including deps, into a pyz file, and ship that to your serveur as one big archive and run it like you would a .py file. It makes deployments very easy.

It also means you don't have to worry about using dependancies in quick scripts: use as many as you want and bundle them!

A tool exists to create the bundle easily and make it extract itself on first run for better perfs:

https://shiv.readthedocs.io

Is that instead of the zipapp module.


Does zipapp automatically bundle dependencies, or do you need to specify that somehow? Also, how does this handle native extensions?

Edit: Answered by first question: https://docs.python.org/3/library/zipapp.html#creating-stand...


for bundled deps, see shiv or pex.

https://shiv.readthedocs.io/en/latest/

https://pex.readthedocs.io/en/v2.1.49/

You still need the host to have a base python interpreter.


Carefull though, pex doesn't work on windows


pip install --target to download your deps then use shiv


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: