from airflow import DAG
from airflow.sensors.local_to_remote import FileSensor
from airflow.operators.python import PythonOperator
from datetime import datetime, timedelta
import csv # for CSV operations
python isn’t able to understand the ‘airflow.sensors.local_to_remote’ and hence could not import FileSensor operator.
But its not showing an error on base class lib airflow and line3,4 as well.Only at line 2 it shows error in pylance.
Environment details:
-
Windows 11
-
Airflow on docker
-
using Remote Container on VScode, that opens in a new instance to work with Docker containers.
-
Windows Airflow directories mapped to docker directory.
-
.devcontainer folder also added in Airflow directory, contains two files within:
requirements.txt
devcontainer.json -
Python interpreter used is 3.8.18 64 bit at usr/local/bin/python which is same as that in the .devcontainer.json file:
{
"name": "Airflow",
"dockerComposeFile": ["../docker-compose.yml"],
"service": "airflow-webserver",
"workspaceFolder": "/opt/airflow",
"extensions": [
"ms-python.python",
"ms-azuretools.vscode-docker"
],
"settings": {
"python.pythonPath": "/usr/local/bin/python"
}
}
7.Airflow web server home screen shows it is not able to import the DAG.
Initially my .devcontainer.json python path was : /usr/local/bin/python3.
I changed it to /usr/local/bin/python because in Vscode, it didn’t had any path as ‘/usr/local/bin/python3.
Some of the python paths it shows are: