-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fdc1db
commit 7dbab67
Showing
7 changed files
with
267 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from airflow import DAG | ||
from airflow.operators.python_operator import PythonOperator | ||
from datetime import datetime | ||
import subprocess | ||
|
||
# Define a function to get the list of installed pip packages | ||
def list_installed_packages(): | ||
# Run the pip freeze command to get installed packages | ||
installed_packages = subprocess.check_output(['pip', 'freeze']).decode('utf-8') | ||
|
||
# Log the output to Airflow logs | ||
print("Installed pip packages:") | ||
print(installed_packages) | ||
|
||
# Define the DAG | ||
default_args = { | ||
'owner': 'airflow', | ||
'start_date': datetime(2023, 1, 1), | ||
'retries': 1 | ||
} | ||
|
||
with DAG( | ||
dag_id='list_pip_packages', | ||
default_args=default_args, | ||
schedule_interval=None, | ||
catchup=False | ||
) as dag: | ||
|
||
# Define the task using PythonOperator | ||
check_pip_packages = PythonOperator( | ||
task_id='check_pip_packages', | ||
python_callable=list_installed_packages | ||
) | ||
|
||
# Set task dependencies (if needed) | ||
check_pip_packages |
Oops, something went wrong.