{"id":28219016,"url":"https://github.com/attarmau/airflow-dag-trigger","last_synced_at":"2026-04-27T11:31:21.943Z","repository":{"id":290367063,"uuid":"974198729","full_name":"attarmau/Airflow-DAG-Trigger","owner":"attarmau","description":"Manually trigger an Airflow DAG that logs the execution time, using a Docker-based setup with Airflow 2.x.","archived":false,"fork":false,"pushed_at":"2026-01-20T14:08:16.000Z","size":96,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-20T22:17:40.072Z","etag":null,"topics":["apache-airflow","dag","docker","etl-pipeline","trigger-events"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/attarmau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-28T12:05:57.000Z","updated_at":"2026-01-20T14:08:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"a32f6985-3605-4254-9719-6bad46c5ea5f","html_url":"https://github.com/attarmau/Airflow-DAG-Trigger","commit_stats":null,"previous_names":["attarmau/airflow-dag-trigger"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/attarmau/Airflow-DAG-Trigger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attarmau%2FAirflow-DAG-Trigger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attarmau%2FAirflow-DAG-Trigger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attarmau%2FAirflow-DAG-Trigger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attarmau%2FAirflow-DAG-Trigger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/attarmau","download_url":"https://codeload.github.com/attarmau/Airflow-DAG-Trigger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/attarmau%2FAirflow-DAG-Trigger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32335295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-airflow","dag","docker","etl-pipeline","trigger-events"],"created_at":"2025-05-18T02:10:57.114Z","updated_at":"2026-04-27T11:31:21.929Z","avatar_url":"https://github.com/attarmau.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Airflow-DAG-Trigger\n\n## Objective\n\nThis repository demonstrates how to add manual triggering functionality in Airflow, where the trigger prints the time when the DAG is manually triggered. It is designed to run within a Docker-based environment using Airflow 2.x. \n\n⚠️ Note on Airflow 3.0.0 Compatibility\n\nAs of now, Apache Airflow has released version 3.0.0, but it is not yet fully stable or widely supported in Docker-based environments. Some plugins, operators, or Docker images may still have compatibility issues. Therefore, this project uses Airflow 2.6.0, which is a more stable and tested version for Docker deployment. If you're planning to run Airflow in Docker, sticking with 2.6.0 is currently the safer and more reliable choice.\n\nTo achieve this, I have designed the ’test_manual_trigger_dag.py', which is a simple sample DAG created to test the manual triggering functionality in Airflow. \n\nFor further details, follow the specific steps outlined below.\n\n##  📃 Needed File 1: test_manual_trigger.py (The DAG)\nThis is the DAG definition file that defines how the DAG behaves when triggered. This DAG will not run on its own; it only runs when manually triggered. The task in the DAG prints the time when it was manually triggered.\n\nPlace this DAG file in the dags/ folder.\n## Step 1: Start Airflow 2.6.0 on Docker \n```\ncd airflow\n```\n```\ndocker-compose run airflow-webserver airflow db init\n```\nCreate an Airflow admin user via the CLI, which is required the first time you're setting up Airflow\n```\ndocker-compose run airflow-webserver airflow users create --username admin --password admin --firstname Admin --lastname User --role Admin --email admin@example.com\n```\n![Screenshot 2025-04-30 161450](https://github.com/user-attachments/assets/aa1dc9ab-5a59-435d-a455-1a3211e43798)\n\nGenerate a Fernet key, which is required by Apache Airflow for encrypting and decrypting sensitive data in its metadata database\n```\npython -c \"from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())\"\n```\nThen add your generated key in the .env file~\n```\n docker compose up -d\n```\n![Screenshot 2025-04-30 160918](https://github.com/user-attachments/assets/857db5c4-15a7-43a2-a038-574f7b88dc4a)\n\n## Step 2: Log in Airflow Webserver: http://localhost:8080/home\n![Screenshot 2025-04-30 162322](https://github.com/user-attachments/assets/01c2edba-84d3-4fd9-881c-1c6c980cd4f5)\n\n## Step 3: Test the Trigger\n\n![Screenshot 2025-04-30 161619](https://github.com/user-attachments/assets/f593fb6c-1a85-4b1c-936a-53187911ee61)\n\n# If manually trigger...\n## 📃 Needed file 2: trigger.py (Manually Trigger the DAG)\nThis is the script that triggers the DAG. When you run trigger.py, it will use Airflow's API to manually trigger the test_manual_trigger_dag\n\n## 💡 How to Use the Trigger in Your Own DAG\n### Step 1: Keep the trigger.py file as it is to manually trigger any DAG\nChange the dag_id in trigger.py to match the dag_id of the ur own DAG (e.g., \"my_custom_dag\")\n\n### Step 2: Add this function in the ur own DAG file (for example, my_custom_dag.py):\n- Define the DAG with tasks that u want\n- The dag_id in their DAG file must match the dag_id used in trigger.py\n\n## ➡️ How to Trigger your Own DAG\n- Place the DAG file (e.g., my_custom_dag.py) in the dags/ folder\n- Use the existing trigger.py script to manually trigger it\n```\ndag_id = \"my_custom_dag\"  # Replace with your own DAG id\n```\nAfter that, running `trigger.py` will manually trigger the DAG.\n\n### Step 3: Run the Manual Trigger\n\nTo manually trigger the DAG:\n\n1. Navigate to the directory containing `trigger.py`.\n2. Run the command:\n\n   ```bash\n   python trigger.py\n   ```\n\nThis will trigger the `test_manual_trigger_dag` (or their custom DAG) and print the time when it was triggered.\n\n---\n\n### Summary\n\n1. **Place the DAG file** in the `dags/` folder.\n2. **Update `trigger.py`** to reference the correct `dag_id`.\n3. **Run `trigger.py`** to manually trigger the DAG and check the printed message in the logs.\n\n\n\n\n\n# Self-testing steps\nFirst, make sure that the Airflow services are up and running. This can be done using the following commands:\n\n```\nairflow webserver --port 8080\n```\n\nStart the Airflow scheduler\n```\nairflow scheduler\n```\n\n## Step 2: Check if the DAG is listed\n```\nairflow dags list\n```\nThis command will show all the available DAGs in Airflow. Look for the dag_id of your DAG, which should match the ID you have defined in your DAG file. In this demo, the DAG file is named 'test_manual_trigger_dag'. !Ignore this file if u r using ur own DAG file!\n\n## Step 3: Trigger the DAG\n```\nairflow dags trigger test_manual_trigger_dag\n```\nNote: Make sure to replace 'test_manual_trigger_dag' with the correct 'dag_id' if it's different from ur original setting\n\n\u003cimg width=\"423\" alt=\"Screenshot 2025-04-28 at 10 28 19 PM\" src=\"https://github.com/user-attachments/assets/35841f7e-b6fc-41b1-9a9c-2996939d3185\" /\u003e\n\n## Verify: Check the DAG Run\n```\nairflow dags show test_manual_trigger_dag\n```\nThis will display the execution history and status of the DAG runs. You can check if there are any failures or if the DAG completed successfully.\n\n## Expected Output \n\nIf the time the DAG was triggered is printed to the logs, which would look something like this:\n```\n🫡 DAG manually triggered at 2025-04-28 10:35:00\n```\n➡️ In the Airflow web interface, you will see the DAG execution has been triggered, and you can check the logs for the task to confirm the printed time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattarmau%2Fairflow-dag-trigger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fattarmau%2Fairflow-dag-trigger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fattarmau%2Fairflow-dag-trigger/lists"}