poetry + watchmedo + uwsgi: unrecognized arguments - python

I have a uWSGI application that I want to monitor with watchmedo, and is under a poetry environment.
Unfortunately, the following does not work:
poetry run watchmedo auto-restart --directory=./ --pattern="*.py;*.yml;*.html" --recursive -- uwsgi --ini=uwsgi.ini
This command raises:
watchmedo: error: unrecognized arguments: --ini=uwsgi.ini
it seems that poetry is incapable of understanding that I'm passing parameters to uwsgi, not to watchmedo. I tried multiple permutations of this command and I could not get it to work. What am I missing? Even running this as poetry run bash -c still raises the same error.

Related

Issue in creating a layer for AWS lambda for psycopg2

I am trying to create a layer for aws lambda for psycopg. I am following the answer to the question - psycopg2 folder zipped into python venv lambda function
Screenshot of the process from above link
However I am getting the below error while executing the docker step.
$ docker run "lambci/lambda:build-python3.8" /bin/sh -c "pip install -r requirements.txt -t /python/lib/python3.8/site-packages/; exit"
**docker: Error response from daemon: failed to create shim task: OCI
runtime create failed: runc create failed: unable to start container
process: exec: "C:/Users/aameen/AppData/Local/Programs/Git/usr/bin/sh":
stat C:/Users/aameen/AppData/Local/Programs/Git/usr/bin/sh: no such file
or directory: unknown.**
I am executing this on the git bash on windows. May be the problem lies there.

MLFlow projects; bash: python: command not found

I'm running MLflow Project for a model using following command from my ubuntu 20.04 terminal
mlflow run . --no-conda -P alpha=0.5
My system doesn't have conda or python (It does however have python3). So, I added alias for python using terminal
alias python='python3'
After which I could open python in terminal using python. However, I still got the same error
2021/11/21 08:07:34 INFO mlflow.projects.utils: === Created directory /tmp/tmpp4h595ql for downloading remote URIs passed to arguments of type 'path' ===
2021/11/21 08:07:34 INFO mlflow.projects.backend.local: === Running command 'python tracking.py 0.5 0.1' in run with ID 'e50ca47b3f8848a083906be6220c26fc' ===
bash: python: command not found
2021/11/21 08:07:34 ERROR mlflow.cli: === Run (ID 'e50ca47b3f8848a083906be6220c26fc') failed ===
How to get rid of this error?
Change python to python3 in the MLproject file to the resolve error.
command: "python3 tracking.py {alpha} {l1_ratio}"
Running the command below in the terminal helped me:
$ sudo apt install python-is-python3
After installation, run the ML project and it should work.

"bin/bash: python: command not found" returned when running docker image

Here is the docker run output:
hausey#ubuntu:~/niso2-jxj934$ docker run niso2-jxj934
Test version: 15:59, Mar 24th 2020
Question 1: Evaluation of expression.
Command failed: /bin/bash -c "python /bin/jxj934.py -question 1 -expr \"(ifleq (ifleq -1.11298616747 1.63619642199 (sub -1.11298616747 -1.11298616747) 1.7699684348) (add (exp -0.822479932786) 1.39992604386) (add -1.11298616747 (exp 0.385042309638)) 0.205973267133)\" -n 10 -x \"-0.168958230447 -0.131749160548 0.0971246476126 1.8706205565 -0.464122426299 2.35887369763 -0.375948313434 -0.613901105864 0.411326743135 -0.149276696072\"" Exit status: exited with code 127 stderr: /bin/bash: python: command not found
Here is the Dockerfile:
FROM pklehre/niso2020-lab2-msc
ADD jxj934.py /bin
CMD ["-username","jxj934", "-submission", "python /bin/jxj934.py"]
Here is check for python:
hausey#ubuntu:~/niso2-jxj934$ which python
/usr/bin/python
Is that related to the PATH of python?
Usually, it is related to the value of PATH but, specifically, that image only has python3. In other words, looking through the filesystem with
find / -name -type f "python*"
Look for regular files named "python*" in /
There were only python3 results.
...
/usr/bin/python3.8
/usr/bin/python3.7
...
A quick solution is to specify python3 in your CMD line (python3 /bin/jxj934.py). Another is to add a soft link (ln -s /usr/bin/python /usr/bin/python3.8). The best solution is to solve it using the package manager. Then again, that depends if you're in control of the Dockerfile + image.
When you queried which python, you did so on your local machine. The container runs in a different filesystem namespace than yours and with a completely different terminal. The container will behave differently than your machine and any such investigations will yield relevant results only when run within the container.
A little unrelated to your question but it might serve you.
docker run has a --entrypoint option that allows you to override the image's entrypoint. You can ask for bash and explore the container.
docker run --it --entrypoint=bash pklehre/niso2020-lab2-msc
Note that bash has to be in the $PATH.

Dockerized web-service does not run in background even with detached flag

I'm trying to Dockerize a web service using Tangelo and python.
My project structure is as follows:
test.py
requirements.txt
Dockerfile
test.py
import ...
def run(query):
...
return response
requirements.txt
... # other packages, numpy, open-cv, etc
tangelo
Dockerfile
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y python python-pip git
EXPOSE 9220
ADD . /test
WORKDIR /test
RUN pip install -r requirements.txt
CMD "tangelo --port 9220"
I build this using
docker build -t "test" .
And run in detached mode using
docker run -p 9220:9220 -d "test"
But docker ps shows me that the docker stops almost as soon as it has started. I don't know what the problem is since I cannot inspect the logs.
I have tried a lot of things but I still can't figure this thing out.
Any ideas? If needed, I can provide more info.
EDIT:
When I build, step 8 says
Step 8/8 : ENTRYPOINT tangelo --port 9220
---> Running in 8b54841853ab
Removing intermediate container 8b54841853ab
So it means these are run in an intermediate container. Why is that and how can I prevent it?
TL;DR: Use:
CMD tangelo -np --port 9220
Instead of:
CMD "tangelo --port 9220"
Explanation:
You have two ways to debug the problem:
Inspect the logs of the container:
$ docker run -d test
28684015e519c0c8d644fccf98240d1465acabab6d16c19fd59c5f465b7f18af
$ sudo docker logs 28684015e519c
/bin/sh: 1: tangelo --port 9220: not found
Instead of running in detached mode, run in foreground with -i/--interactive (and optionally also -t/--tty):
$ docker run -ti test
/bin/sh: 1: tangelo --port 9220: not found
As you can see from above, the problem is that tangelo --port 9220 is being interpreted as a single argument. Split it by removing quotes:
CMD tangelo --port 9220 # this will use a shell
or use the "exec" form (preferred, given that you don't need any shell features):
CMD ["tangelo", "--port", "9220"] # this will execute tangelo directly
or even better use ENTRYPOINT + CMD:
ENTRYPOINT ["tangelo"]
CMD ["--port", "9220"] # this will execute tangelo directly
After this change, you'll still have a problem:
$ sudo docker run -ti test
...
[29/Apr/2018:02:43:39] TANGELO no such group 'nobody' to drop privileges to
Tangelo is complaining about the fact that there is no user and group named nobody inside the container. Again, there are two things you can do: add a RUN to create the nobody user and group, or run Tangelo with the -np/--no-drop-privileges option:
ENTRYPOINT ["tangelo"]
CMD ["--no-drop-privileges", "--port", "9220"]
It's fine if during the build you see intermediate containers: Docker creates them for each build step. The commands you specify in ENTRYPOINT or CMD are not executed during build, they're just recorded into the final image.

Starting qsub in parent folder with Python fails

I'm creating a Python script to setup a series of calculations on a remote calculation cluster. However I have run into a problem.
The calculation on the remote server is started with the command:
qsub Run.sh
Run.sh is located in the folder ./sol/
If I enter ./sol/ and run:
python25 -c "import os;os.system(\"qsub Run.sh\")"
Every thing works like it should.
However, If I am located in ./ and run this command:
python25 -c "import os;os.chdir(\"sol\");os.system(\"qsub Run.sh\")"
qsub failes with this error message:
*** error from copy
Host key verification failed.
lost connection
*** end error output
Does anyone know why this is? I use python version 2.5.1 and unix 2.6.18

Categories