Using the PythonOperator
You've implemented several Airflow tasks using the BashOperator but realize that a couple of specific tasks would be better implemented using Python. You'll implement a task to download and save a file to the system within Airflow.
The requests library is imported for you, and the DAG process_sales_dag is already defined.
Deze oefening maakt deel uit van de cursus
Introduction to Apache Airflow in Python
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Define the method
def ____(____, ____):
r = requests.get(URL)
with open(savepath, 'wb') as f:
f.write(r.content)
# Use the print method for logging
print(f"File pulled from {____} and saved to {____}")