Airflow DAG: create dag with bash operator!

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ก.ค. 2024
  • Airflow DAG: create dag with bash operator!
    #Airflow #AirflowTutorial #Coder2j
    ========== VIDEO CONTENT 📚 ==========
    Today I am going to show you how to create our first dag using the bash operator! By watching this video, you will know:
    👉 How to create a dag and set parameters as your need
    👉 Define tasks using BashOperator
    👉 How to build the task dependencies
    Video Request: forms.gle/UMp4GA3krcSMMWzy9
    You don't have a running Airflow in your local setup? Check out the Apache Airflow 2.0 Installation Tutorials.
    Run Airflow locally 👉 • Airflow introduction a...
    Run Airflow in Docker 👉 • Airflow Docker: run Ai...
    ========== L I N K S 🔗 ==========
    GitHub Repo 👉 bit.ly/3HD5oTX
    Airflow Documentation 👉 bit.ly/3wbTqv4
    ========== T I M E S T A M P ⏰ ==========
    00:00 - Launch airflow using docker
    01:08 - Remove all the airflow example dags
    02:16 - Create our first dag and set the parameters
    05:00 - Create dag tasks using bash operator
    07:26 - Trigger our first dag run
    08:05 - Define multiple tasks for the dag
    10:15 - Three different ways to build tasks dependencies
    ========== Connect with me 👏 ==========
    Twitter 👉 / coder2j
    Website 👉 coder2j.com
    GitHub 👉 github.com/coder2j

ความคิดเห็น • 71

  • @leamonlee8809
    @leamonlee8809 2 ปีที่แล้ว +4

    Thanks man, you're the best instructor in Airflow on TH-cam ever.
    Looking forward to the next one!

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      Thanks. Stay tuned! 🙌

  • @helovesdata8483
    @helovesdata8483 2 ปีที่แล้ว +1

    I really enjoyed this video. I learned more today than the past two weeks with another youtube video. Also I reinstalled Airflow with your instructions from another video and it has never been this stable. Thank you!

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      Glad it was helpful!

  • @brunodupont8494
    @brunodupont8494 ปีที่แล้ว

    Amazing videos, very simply explained

  • @SudhirKumar-rl4wt
    @SudhirKumar-rl4wt ปีที่แล้ว

    Thankyou for this this tutorial.

  • @JoyantoGhoshJG
    @JoyantoGhoshJG 2 ปีที่แล้ว +8

    I am following your instructions and have been able to understand Airflow at an intermediate level.
    I would love to see your writing DAGs for PythonOperator with Xcoms. Eagerly waiting for it!

    • @coder2j
      @coder2j  2 ปีที่แล้ว +3

      Nice to hear that. Python operator is already planned. Stay tuned! 😉

    • @Akashkumar-ei5tm
      @Akashkumar-ei5tm 2 ปีที่แล้ว +1

      Same here 😊

  • @manimaran.v3099
    @manimaran.v3099 2 ปีที่แล้ว

    Nice AirFlow video ever in you Tube, heartfelt Thanks

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      You are welcome!

  • @caiofelixreis8970
    @caiofelixreis8970 2 ปีที่แล้ว

    Awsomee!!! Thank you for all this broo, its really helpful

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      Thanks. Have fun learning.

  • @khalidsultani1896
    @khalidsultani1896 2 ปีที่แล้ว

    Thanks for posting far easy and clearly explained then paid material . Please keep postings if possible on airflow integeration with aws services such as red shift and databricks .

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      Thanks for the feedback ☺️

  • @francosterrantino5208
    @francosterrantino5208 7 หลายเดือนก่อน

    Thanks man.

  • @looklook6075
    @looklook6075 6 หลายเดือนก่อน

    OMG, you are my hero!

    • @coder2j
      @coder2j  6 หลายเดือนก่อน

      🤗🤗

  • @user-zc7hl4db7g
    @user-zc7hl4db7g 2 ปีที่แล้ว

    this is the best video ever.

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      Thanks for your nice comment.

  • @thomasripoll3438
    @thomasripoll3438 2 ปีที่แล้ว

    Thx

  • @fiannafailgalway8446
    @fiannafailgalway8446 2 ปีที่แล้ว

    More please

  • @follygee4667
    @follygee4667 2 ปีที่แล้ว

    how do i import a json config file that is dependent on another python script in airflow

  • @simre5476
    @simre5476 2 ปีที่แล้ว

    Good stuff! Thanks for the tuto! I am running the dag which is status success but the task 1, 2, and 3 are blanks and if I select one task to run it independently, it tells me ''Only works with the Celery or Kubernetes executors, sorry'' any clues how to fix this? I should add some settings in the .yaml file?

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      If you want to rerun the dag or one of the task, you need to click the dag or task run, then click the clear button. Wait a second, the scheduler will schedule it and run it again. Check out the airflow tutorial part6, in which I also dodi the same.

  • @Akashkumar-ei5tm
    @Akashkumar-ei5tm 2 ปีที่แล้ว +3

    Nicee .. please create one for passing one variable from 1st function to another function using these python operators

    • @coder2j
      @coder2j  2 ปีที่แล้ว +2

      Thanks for the feedback. Will include that in the coming episode. Subscribe and Stay tuned! 😉

    • @Akashkumar-ei5tm
      @Akashkumar-ei5tm 2 ปีที่แล้ว +2

      Always man 🙂.. would like to see you covering more stuff's like kafta flume spark and all

  • @afolakebaiyewu476
    @afolakebaiyewu476 ปีที่แล้ว

    Please include branchpyhtonoperator

  • @VitaliyZlobin
    @VitaliyZlobin 6 หลายเดือนก่อน

    Hello) Cool videos! Thank you!
    Why is the old version of DAG not rebooting, but a new one is created?
    And how to remove old versions, leaving only the latter?

    • @coder2j
      @coder2j  6 หลายเดือนก่อน +1

      Because a new dag ID is created. You can simply delete the old dag on the UI.

  • @universe2dimension
    @universe2dimension 2 ปีที่แล้ว

    大哥,用visual studio编辑DAG,然后在airflow portal refresh,我这里创建不了新的DAG,而且,也删除不了原有的31个DAG。怎么解决呢?我用的mac

  • @hayathbasha4519
    @hayathbasha4519 2 ปีที่แล้ว

    Hi is it possible to get task/dag duration from airflow context

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      Yes, you can use the on_success_callback in operators. Check the documentation here: bit.ly/3uxpxER

  • @bimerap5735
    @bimerap5735 2 ปีที่แล้ว +3

    Please include how we can install more python package?

    • @coder2j
      @coder2j  2 ปีที่แล้ว +2

      Thanks for your great feedback. We, as data engineers/scientists need a lot of python packages. It definitely deserves an episode! Stay tuned! 😉

    • @leamon9024
      @leamon9024 2 ปีที่แล้ว

      @@coder2j Also interested in this topic. XD Maybe dockerizing an application with all its dependencies, then run it using docker operator?

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      @@leamon9024 Will cover it in the future episode! Stay tuned! 😉

  • @Akshay-dn7ni
    @Akshay-dn7ni 2 ปีที่แล้ว +1

    i am getting error as- Import "airflow" could not be resolved. possible solutions plz

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      Did you get this error from the airflow webserver or from local python lint? And are you running airflow locally or in docker?

    • @Akshay-dn7ni
      @Akshay-dn7ni 2 ปีที่แล้ว

      @@coder2j I get this error in vscode whenever I write " from airflow import DAG". I am running using docker. I think it is not able to find airflow module which is installed in docker.

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      @Akshay That's normal. Because the airflow package is installed in the docker container. The vs code will complain it since there is no airflow package installed. One tip to bypass this error is to create a local python environment, install airflow in that and tell the vs code the path of the python environment you created. But you can ignore this as long as you can launch airflow webserver successfully!

  • @akmalhafiz7830
    @akmalhafiz7830 9 หลายเดือนก่อน

    when I try to import airflow, it says that "Import "airflow" could not be resolved". I looked up over the internet and it seems like the problem is my local python interpreter doesnt have airflow installed. How can I use python interpretor from the container instead in visual studio code so that I wont get this error?

    • @coder2j
      @coder2j  9 หลายเดือนก่อน

      You can install vscode remote Container Plugin and select python interpreter within the container.

  • @Uxdkkkhcddvbh
    @Uxdkkkhcddvbh 2 ปีที่แล้ว

    Hi this has been really helpful. However the error in the logfiles I get when I run my dag is that says it doesn't have access to my python file - INFO - python: can't open file '. I am using the Bash Operator and the bash command is 'python fulldirectorypath/myscript.py' how can I fix this. I have tried all version of the writing the full path. How do I give airflow permission?

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      If you want to execute python functions, it is recommended to use PythonOperator. I covered that in the Airflow Tutorial Part6.

  • @pythonmathui3057
    @pythonmathui3057 ปีที่แล้ว

    Sir the airflow webserver has already running but when i tried to import DAG from airflow it says no module named airflow, should i just pip install it? or did i miss something that make the airflow module not automatically installed?

    • @coder2j
      @coder2j  ปีที่แล้ว

      Is the error coming from the IDE lint or runtime?

    • @pythonmathui3057
      @pythonmathui3057 ปีที่แล้ว

      @@coder2j ide, but i alreadY just pip install apache-airflow in the terminal

  • @dhanasekar7068
    @dhanasekar7068 2 ปีที่แล้ว

    Hi, really good videos. Shall I know how to dm you. I want to ask a doubt regarding sql sensor and hive operator

    • @coder2j
      @coder2j  2 ปีที่แล้ว

      Please leave it directly in the comment section. So that we can share the info in case others may also have the same question.

  • @vilw4739
    @vilw4739 ปีที่แล้ว

    Hi, am using bash operator and passing multiple commands inside bash_command.Its a mixture of if else loops and commands.I don't know how to correctly incorporate it.l am using" to separate it. Could you guide me here if you have worked with something similar please thanks in advance

    • @coder2j
      @coder2j  ปีที่แล้ว

      Can you try wrapping the multiple lines command into 3 double quotes? Like """
      """

    • @vilw4739
      @vilw4739 ปีที่แล้ว

      @@coder2j yes but I have nested if loops and inside one loop I'm executing a s3a command.So my qn is do I put all of these ifs and else's in one ''' ''' or after each if else?also do I need to use + with '''? Like- ''' echo''' + '''if else'''

    • @coder2j
      @coder2j  ปีที่แล้ว +1

      Hi, you can save your bash commands in a .sh file under the dags folder, then just put the relative path of .sh file as the value of the bash_command parameter.

    • @vilw4739
      @vilw4739 ปีที่แล้ว

      @@coder2j if I have to pass arguments which has macro values can I do so by-
      Date=some macros #global variable
      Bash_command='''
      "File.sh Date "
      '''

    • @coder2j
      @coder2j  ปีที่แล้ว +1

      You can use Jinja template to insert parameters. airflow.apache.org/docs/apache-airflow/stable/howto/operator/bash.html
      bash_task = BashOperator(
      task_id="bash_task",
      bash_command="echo \"here is the message: '$message'\"",
      env={"message": '{{ dag_run.conf["message"] if dag_run else "" }}'},
      )

  • @trantheluc3580
    @trantheluc3580 ปีที่แล้ว

    i use BashOperator run bash_command='date > ./date.txt' but when i run task i cannot find 'date.txt' in folder. so where is it?

    • @coder2j
      @coder2j  ปีที่แล้ว +1

      You can save it under dags folder: date > dags/date.txt

    • @trantheluc3580
      @trantheluc3580 ปีที่แล้ว

      how can i find where it's saved when i run task in webserver?

    • @coder2j
      @coder2j  ปีที่แล้ว

      It should be under your dags folder.

    • @trantheluc3580
      @trantheluc3580 ปีที่แล้ว

      @@coder2j i tried to run task, it was successfull but i can find this file under dags folder