V0lantis commented on issue #19001:
URL: https://github.com/apache/airflow/issues/19001#issuecomment-1006816889


   There is definitely a mistake from my side, since the following command : 
    ```bash
   cat <<EOF > tmp.py
   import os
   
   os.environ['AIRFLOW__CORE__LOGGING_LEVEL'] = 'ERROR'
   os.environ['AIRFLOW__LOGGING__LOGGING_LEVEL'] = 'ERROR'
   from airflow.jobs.scheduler_job import SchedulerJob
   from airflow.utils.db import create_session
   from airflow.utils.net import get_hostname
   import sys
   
   with create_session() as session:
       job = 
session.query(SchedulerJob).filter_by(hostname=get_hostname()).order_by(
           SchedulerJob.latest_heartbeat.desc()).limit(1).first()
   sys.exit(0 if job.is_alive() else 1)
   EOF
   
   
   /entrypoint python -Wignore tmp.py
   ```
   
   return 
   
   ```bash
   Traceback (most recent call last):
     File "/opt/airflow/tmp.py", line 5, in <module>
       from airflow.jobs.scheduler_job import SchedulerJob
   ModuleNotFoundError: No module named 'airflow'
   ```
   
   I am using a custom image to import private dependancies. Therefore, my 
airflow image is defined by :
   
   <details>
   
   ```Dockerfile
   FROM python:3.9-slim AS compile-image
   RUN apt-get update
   RUN apt-get install -y --no-install-recommends build-essential gcc git ssh 
libpq-dev python3-dev
   
   RUN python -m venv /opt/venv
   # Make sure we use the virtualenv:
   ENV PATH="/opt/venv/bin:$PATH"
   
   RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
   COPY requirements.txt .
   RUN --mount=type=ssh,id=github_ssh_key pip install \
       --no-cache \
       -r requirements.txt
   
   FROM apache/airflow:2.2.1-python3.9
   
   COPY --from=compile-image --chown=airflow /opt/venv /opt/venv
   ENV PATH="/opt/venv/bin:$PATH"
   ENV PYTHONPATH="/opt/venv/lib/python3.9/site-packages/:$PYTHONPATH"
   ```
   
   </details>
   
   I'll try with the normal deployment setup. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to