How to setup and run Celery on windows? - django

Hello and thank your for your time
i have a big Django project and i'm developing it in PyCharm on Windows. Right now i need to use smart queries, so i want to add Celery on it. The main problem, that celery dropped support for Windows since v4.0. So my questions is:
1) How can i use rabbit/celery on windows?
2) I have some old answer, that suggest to use old version, that has support for windows, but maybe it has some way with virtual box or other staff to lanch it on windows?

You can use Docker to run your Celery, there is an official image in Docker Hub: https://hub.docker.com/_/celery/
It will take some time to learn how to use Docker though. But it's definitely worth it.
You could use Vagrant, but in this case you will have to spend some time to configure your Celery environment, at least I didn't find existing Celery Vagrant Box you could use in your project.

Related

Should I move windows project folder into WSL?

I'm trying to set up a work environment on a new machine and I am a bit confused how best to procede.
I've set up a new windows machine and have WSL2 set-up; I plan on using that with VS Code for my development environment.
I have a previous django project that I want to continue working on stored in a folder in a thumb drive.
Do I move the [windows] project folder into the linux folder system and everything is magically ready to go?
Will my previous virtual environment in the existing folder still work or do I need to start a new one?
Is it better to just start a new folder via linux terminal and pull the project from github?
I haven't installed pip, python, or django on the windows OR linux side just yet either.
Any other things to look out for while setting this up would be really appreciated. I'm trying to avoid headaches later by getting it all set-up correctly now!
I would pull it from github, and make sure you have the correct settings for line endings, since they are different between windows and linux. Just let git manage these though:
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
Some other suggestions:
Use a version manager in linux to manage your python versions - something like pyenv or asdf. It will make life easier.
Make sure to always create a virtual environment for everything and don't pip install anything in your main python. (I use direnv for virtual env management)
The single exception to the previous suggestion is pipx, which I do install in the main python and then use to install things like cli tools, black, isort, pip-tools etc.
Configure VScode to use the pipx installed versions of black, flake8 etc. for linting purposes.
If you're using Docker, enable the WSL integration for your WSL flavour (probably Ubuntu). Note that docker desktop needs starting before your WSL session.

Tensorflow Serving using Docker

I have created a Neural Network Regression Model and I wish to deploy it using AWS.
I am using tensorflow serving, and have gone so far as to save the model.
Now I am trying to use Docker to deploy it in the container using Docker on Windows 10 home
As an example, I tried to use multiple tutorials but when it comes to this command, no matter what I do, it just doesn't work for me:
docker run -t --rm -p 8501:8501 -v "$TESTDATA/saved_model_half_plus_two_cpu:/models/half_plus_two" -e MODEL_NAME=half_plus_two tensorflow/serving
Every time I change something, I get a different error. I am totally at loss. Please direct me to some tutorials for this that are simple but complete for novices like me. I have already read the TensorFlow documentation but the errors persist.
Any help would REALLY oblige me greatly since I have been stuck for about a month now.
The easiest tutorial I found was https://www.tensorflow.org/tfx/serving/docker#serving_example
Also
Docker toolkit
has trouble with the mounts as you have to manually specify the path, so if you can afford it, upgrade to Windows Pro which will simplify dockerization. That way you will get Docker Desktop which is much simpler.

What is the benefit to use Docker for Django and Channels?

I'm developing a Django web app with Channels. While I'm following this tutorial , it is required to install Docker.
I'm working on WSL on windows 10 HOME, and so, it is really painful to install Docker.
I just discover Docker, I'm a little confuse about it, I understand it is a tool which facilitates the deployment of a web app on a web hosting later. But I'm not sure.
Could you give me your advice ? Could you tell me if it is really important to use Docker for my project ?
Would Have I less pain if I would develop on a Ubuntu OS ?
Thank you,
The following are my own considerations, not pretending to be exhaustive Docker review.
Moving to Docker would give you following advantages:
Easy deploy - you don't need to supply manuals on how to install your app, dependencies and link them together. Only How to install Docker (btw for Windows it hurts:)
Isolation - your services get isolated network and do not bother the host
Easy upgrade - just push new image and that's it
Decomposition - with docker-compose and other tools you will be able to split your application into services and maintain them separately
Scaling - with proper design, tools like k8s will allow you to easily scale app by adding replicas of your services
From the other hand, on Windows Docker create additional overhead, unlike Linux where it is implemented on top of Linux kernel, also you need Win10 Professional to enjoy Docker and not docker toolbox.
Also Windows is not so good in automated package management and installing software for Windows in many cases cannot be done as simple as apt-get install whatever, thus you loose another Docker benefit - easy system preparation via Dockerfile.
If you plan to stay only on Windows, based on my own exp I would probably not recommend moving to Docker, because I personally found it difficult to use without VirtualBox/Ubuntu.

Debug Django code in Docker

I want to debug my Django code running through docker container. Is it possible with PDB, PYCHARM debugger or with another technique?
It was made possible in pycharm pro 2017.1 and up.
https://www.jetbrains.com/help/pycharm/docker.html
Good luck!
Ofcourse its possible, with any remote debugger (quick Google search - https://pypi.python.org/pypi/remote-pdb) you just need to take care of networking and connect to the debugger's port (e.g. docker run -p ...)

Producing a WAR file from a django project with SQLite

I have a django project (a django module/app some other modules that are used from the django one) that uses SQLite. This project is for a University course and now I am asked to supply it in such a way so that it may be installed on some server in our faculty. I'm not the one who's going to install it, and I will not be contacted in case of failure, so I am looking for the easiest, simplest way to supply the project for installation.
I have come across django-jython which supposedly allows one to create WAR files from django projects. However, in the Database Backends section, it says:
SQLite3
Experimental. By now, use it only if you are working on improving it. Or if you are really adventurous.
My overall goal is to deliver this project and I would appreciate any helpful advice. In particular:
Is there another way to pack a django project into a WAR file that supports SQLite?
Is it safe to use SQLite with django-jython in spite of this warning? If so, then how?
Is there any other simple way to pack a django project so that it'll be a piece of cake to install?
If the above answers are "no", then what does it take to change the configuration of the project to use MySQL instead?
You should look into Fabric for easy deployment. I haven't used it myself, but I've heard good things.
I've also had good success quickly and easily setting up servers using Gunicorn with Nginx as a reverse-proxy.
As others have said, using virtualenv, with pip, can quickly
get all your dependencies installed via requirements.txt (from virtualenv).
Some of these blog posts may help:
Tools of the modern Python hacker - virtualenv, pip, fabric
Basic Django Deployment - virtualenv, pip, fabric, rsync
Easy Django Deployment - very quick nginx and gunicorn setup
Edit:
As I reread your post I saw your last bullet point/question. Django is designed to be loosely coupled, meaning that there shouldn't (in most cases) be reasons that one app is dependant on sqlite vs mysql. If you don't need to save the data in the db, changing to MySQL is as easy as starting a mysql server on your machine, and changing the settings.py of your django project. This SO question may help