airflow-cli 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: airflow-cli
3
+ Version: 0.1.1
4
+ Summary: CLI para facilitar o setup de Airflow com Docker.
5
+ Author-email: LEMA-UFPB <ufpb.lema@gmail.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.7
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: simple-term-menu>=1.0.0
11
+ Requires-Dist: requests>=2.25.0
12
+ Requires-Dist: flake8>=4.0.0
13
+ Requires-Dist: pyyaml>=5.4.0
14
+ Dynamic: license-file
15
+
16
+ # Airflow Docker Helper
17
+
18
+ A command-line tool to facilitate the setup of Apache Airflow using Docker and enable local DAG development and testing.
19
+
20
+ ## Features
21
+
22
+ - 🚀 Quick Airflow setup with Docker Compose
23
+ - 🔧 Local DAG development and testing
24
+ - 📦 Pre-configured Docker environment
25
+ - 🛠️ CLI interface for common Airflow operations
26
+ - 🧪 Testing utilities for DAG validation
27
+
28
+ ## Prerequisites
29
+
30
+ - Python 3.7+
31
+ - Docker and Docker Compose
32
+ - Git
33
+
34
+ ## Installation
35
+
36
+ ### From PyPI (Recommended)
37
+
38
+ ```bash
39
+ pip install airflow-cli
40
+ ```
41
+
42
+
43
+ ## Quick Start
44
+
45
+ ### 1. Start Airflow Environment
46
+
47
+ ```bash
48
+ airflow-cli up
49
+ ```
50
+
51
+ This command will:
52
+ - Check Docker installation and environment
53
+ - Download the latest docker-compose.yml from LEMA UFPB repository
54
+ - Start Airflow services with Docker Compose
55
+
56
+ ### 2. Access Airflow UI
57
+
58
+ Open your browser and navigate to http://localhost:8080
59
+
60
+ Default credentials:
61
+ - Username: `airflow`
62
+ - Password: `airflow`
63
+
64
+ ### 3. Stop Airflow Environment
65
+
66
+ ```bash
67
+ airflow-cli down
68
+ ```
69
+
70
+ ## Usage
71
+
72
+ ### Available Commands
73
+
74
+ ```bash
75
+ # Start Docker environment
76
+ airflow-cli up
77
+
78
+ # Stop Docker environment
79
+ airflow-cli down
80
+
81
+ # Run Airflow DAG inside Docker
82
+ airflow-cli run-dag
83
+
84
+ # Run flake8 linter on DAGs
85
+ airflow-cli fix-code
86
+
87
+ # Show help
88
+ airflow-cli --help
89
+ ```
90
+
91
+ ### DAG Development
92
+
93
+ 1. Place your DAG files in the `dags/` directory
94
+ 2. The directory is automatically mounted to the Airflow container
95
+ 3. Changes are reflected immediately (no restart required)
96
+
97
+ Expected DAG structure for `run-dag` command:
98
+ ```
99
+ project/
100
+ ├── dags/
101
+ │ └── my_dag/
102
+ │ ├── config.yml
103
+ │ └── dag.py
104
+
105
+ ```
106
+
107
+ Example `config.yml`:
108
+ ```yaml
109
+ args:
110
+ id: "my_dag_id"
111
+ ```
112
+
113
+ ### Testing DAGs
114
+
115
+ #### Run a DAG inside Docker
116
+ ```bash
117
+ airflow-cli run-dag
118
+ ```
119
+
120
+ This command will:
121
+ - Look for DAG configuration files in `dags/*/config.yml`
122
+ - Execute the DAG inside the running Airflow container
123
+
124
+ #### Validate DAG syntax with flake8
125
+ ```bash
126
+ airflow-cli fix-code
127
+ ```
128
+
129
+ This will run flake8 linter on the `dags/` folder to check for Python syntax issues.
130
+
131
+ ### Building from Source
132
+
133
+ ```bash
134
+ # Build wheel
135
+ python -m build
136
+
137
+ # Install built package
138
+ pip install dist/airflow_docker_helper-*.whl
139
+ ```
140
+
141
+ ## Publishing to PyPI
142
+ ```bash
143
+ # Build wheel
144
+ python -m build
145
+ # Publish to PyPI
146
+ twine upload dist/*
147
+ ```
148
+
149
+ ## License
150
+
151
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
152
+
153
+
154
+ ---
155
+
156
+ Made with ❤️ by the LEMA UFPB team
@@ -0,0 +1,141 @@
1
+ # Airflow Docker Helper
2
+
3
+ A command-line tool to facilitate the setup of Apache Airflow using Docker and enable local DAG development and testing.
4
+
5
+ ## Features
6
+
7
+ - 🚀 Quick Airflow setup with Docker Compose
8
+ - 🔧 Local DAG development and testing
9
+ - 📦 Pre-configured Docker environment
10
+ - 🛠️ CLI interface for common Airflow operations
11
+ - 🧪 Testing utilities for DAG validation
12
+
13
+ ## Prerequisites
14
+
15
+ - Python 3.7+
16
+ - Docker and Docker Compose
17
+ - Git
18
+
19
+ ## Installation
20
+
21
+ ### From PyPI (Recommended)
22
+
23
+ ```bash
24
+ pip install airflow-cli
25
+ ```
26
+
27
+
28
+ ## Quick Start
29
+
30
+ ### 1. Start Airflow Environment
31
+
32
+ ```bash
33
+ airflow-cli up
34
+ ```
35
+
36
+ This command will:
37
+ - Check Docker installation and environment
38
+ - Download the latest docker-compose.yml from LEMA UFPB repository
39
+ - Start Airflow services with Docker Compose
40
+
41
+ ### 2. Access Airflow UI
42
+
43
+ Open your browser and navigate to http://localhost:8080
44
+
45
+ Default credentials:
46
+ - Username: `airflow`
47
+ - Password: `airflow`
48
+
49
+ ### 3. Stop Airflow Environment
50
+
51
+ ```bash
52
+ airflow-cli down
53
+ ```
54
+
55
+ ## Usage
56
+
57
+ ### Available Commands
58
+
59
+ ```bash
60
+ # Start Docker environment
61
+ airflow-cli up
62
+
63
+ # Stop Docker environment
64
+ airflow-cli down
65
+
66
+ # Run Airflow DAG inside Docker
67
+ airflow-cli run-dag
68
+
69
+ # Run flake8 linter on DAGs
70
+ airflow-cli fix-code
71
+
72
+ # Show help
73
+ airflow-cli --help
74
+ ```
75
+
76
+ ### DAG Development
77
+
78
+ 1. Place your DAG files in the `dags/` directory
79
+ 2. The directory is automatically mounted to the Airflow container
80
+ 3. Changes are reflected immediately (no restart required)
81
+
82
+ Expected DAG structure for `run-dag` command:
83
+ ```
84
+ project/
85
+ ├── dags/
86
+ │ └── my_dag/
87
+ │ ├── config.yml
88
+ │ └── dag.py
89
+
90
+ ```
91
+
92
+ Example `config.yml`:
93
+ ```yaml
94
+ args:
95
+ id: "my_dag_id"
96
+ ```
97
+
98
+ ### Testing DAGs
99
+
100
+ #### Run a DAG inside Docker
101
+ ```bash
102
+ airflow-cli run-dag
103
+ ```
104
+
105
+ This command will:
106
+ - Look for DAG configuration files in `dags/*/config.yml`
107
+ - Execute the DAG inside the running Airflow container
108
+
109
+ #### Validate DAG syntax with flake8
110
+ ```bash
111
+ airflow-cli fix-code
112
+ ```
113
+
114
+ This will run flake8 linter on the `dags/` folder to check for Python syntax issues.
115
+
116
+ ### Building from Source
117
+
118
+ ```bash
119
+ # Build wheel
120
+ python -m build
121
+
122
+ # Install built package
123
+ pip install dist/airflow_docker_helper-*.whl
124
+ ```
125
+
126
+ ## Publishing to PyPI
127
+ ```bash
128
+ # Build wheel
129
+ python -m build
130
+ # Publish to PyPI
131
+ twine upload dist/*
132
+ ```
133
+
134
+ ## License
135
+
136
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
137
+
138
+
139
+ ---
140
+
141
+ Made with ❤️ by the LEMA UFPB team
@@ -3,12 +3,14 @@ import logging
3
3
  import sys
4
4
 
5
5
  from .env_utils import ensure_venv, is_in_venv
6
- from .os_utils import check_docker, check_os, update_docker_compose
6
+ from .os_utils import check_docker, check_os
7
7
  from .docker_utils import docker_up, docker_down, run_dag, fix_python_code
8
8
 
9
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
9
+ logging.basicConfig(level=logging.INFO,
10
+ format='%(asctime)s - %(levelname)s - %(message)s')
10
11
  log = logging.getLogger(__name__)
11
12
 
13
+
12
14
  def main():
13
15
  parser = argparse.ArgumentParser(description="Airflow Docker Helper CLI")
14
16
  subparsers = parser.add_subparsers(dest="command")
@@ -30,16 +32,14 @@ def main():
30
32
  # Pré-checks antes de qualquer comando
31
33
  ensure_venv()
32
34
  if not is_in_venv():
33
- log.warning("⚠️ Not running inside virtual environment. Interpreter: %s", sys.executable)
34
-
35
-
35
+ log.warning(
36
+ "⚠️ Not running inside virtual environment. Interpreter: %s", sys.executable)
36
37
 
37
38
  if not check_docker():
38
39
  log.error("❌ Docker not ready.")
39
40
  sys.exit(1)
40
41
 
41
42
  check_os()
42
- update_docker_compose()
43
43
 
44
44
  # Execução dos comandos
45
45
  if args.command == "up":
@@ -52,4 +52,3 @@ def main():
52
52
  fix_python_code()
53
53
  else:
54
54
  parser.print_help()
55
-
@@ -2,17 +2,23 @@ import subprocess
2
2
  import logging
3
3
  from glob import glob
4
4
  import yaml
5
+ import os
5
6
 
6
7
  log = logging.getLogger(__name__)
7
8
 
8
9
  def docker_up():
9
10
  log.info("🐳 Starting Docker environment...")
10
- subprocess.run(["docker", "compose", "up", "-d"], check=True)
11
- log.info(" Docker environment is ready.")
11
+ env = os.environ.copy()
12
+ env["AIRFLOW_UID"] = "50000"
13
+
14
+ compose_file = os.path.join(os.path.dirname(__file__), "docker-compose.yml")
15
+ subprocess.run(["docker", "compose", "-f", compose_file, "up", "-d"], env=env, check=True)
16
+ log.info("✅ Docker environment is ready: http://localhost:8080")
12
17
 
13
18
  def docker_down():
14
19
  log.info("🐳 Stopping Docker environment...")
15
- subprocess.run(["docker", "compose", "down"], check=False)
20
+ compose_file = os.path.join(os.path.dirname(__file__), "docker-compose.yml")
21
+ subprocess.run(["docker", "compose", "-f", compose_file, "down"], check=False)
16
22
 
17
23
  def run_dag():
18
24
  log.info("🚀 Running DAG in Docker...")
@@ -7,6 +7,7 @@ from .os_utils import check_os, update_docker_compose, check_docker
7
7
 
8
8
  log = logging.getLogger(__name__)
9
9
 
10
+
10
11
  def show_menu():
11
12
  options = [
12
13
  "🐳 Docker Environment Up",
@@ -20,21 +21,17 @@ def show_menu():
20
21
  return options[choice] if choice is not None else None
21
22
 
22
23
 
23
-
24
24
  def run():
25
25
  ensure_venv()
26
26
  if not is_in_venv():
27
27
  log.warning("⚠️ Not running inside the virtual environment.")
28
28
  log.warning(f"Interpreter: {sys.executable}")
29
29
 
30
-
31
-
32
30
  if not check_docker():
33
31
  log.error("❌ Docker is not ready.")
34
32
  return
35
33
 
36
34
  check_os()
37
- update_docker_compose()
38
35
 
39
36
  while True:
40
37
  option = show_menu()
@@ -33,15 +33,3 @@ def check_docker():
33
33
  log.error(f"❌ Docker check failed: {e}")
34
34
  return False
35
35
 
36
- def update_docker_compose():
37
- """Copy docker-compose.yml from package to current directory if it doesn't exist"""
38
- if not os.path.exists("docker-compose.yml"):
39
- try:
40
- # Get the docker-compose.yml from the package
41
- source = pkg_resources.resource_filename('airflow_docker', 'docker-compose.yml')
42
- shutil.copy2(source, "docker-compose.yml")
43
- log.info("✅ docker-compose.yml copied to current directory.")
44
- except Exception as e:
45
- log.error(f"❌ Failed to copy docker-compose.yml: {e}")
46
- else:
47
- log.info("✅ docker-compose.yml already exists.")
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: airflow-cli
3
+ Version: 0.1.1
4
+ Summary: CLI para facilitar o setup de Airflow com Docker.
5
+ Author-email: LEMA-UFPB <ufpb.lema@gmail.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.7
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: simple-term-menu>=1.0.0
11
+ Requires-Dist: requests>=2.25.0
12
+ Requires-Dist: flake8>=4.0.0
13
+ Requires-Dist: pyyaml>=5.4.0
14
+ Dynamic: license-file
15
+
16
+ # Airflow Docker Helper
17
+
18
+ A command-line tool to facilitate the setup of Apache Airflow using Docker and enable local DAG development and testing.
19
+
20
+ ## Features
21
+
22
+ - 🚀 Quick Airflow setup with Docker Compose
23
+ - 🔧 Local DAG development and testing
24
+ - 📦 Pre-configured Docker environment
25
+ - 🛠️ CLI interface for common Airflow operations
26
+ - 🧪 Testing utilities for DAG validation
27
+
28
+ ## Prerequisites
29
+
30
+ - Python 3.7+
31
+ - Docker and Docker Compose
32
+ - Git
33
+
34
+ ## Installation
35
+
36
+ ### From PyPI (Recommended)
37
+
38
+ ```bash
39
+ pip install airflow-cli
40
+ ```
41
+
42
+
43
+ ## Quick Start
44
+
45
+ ### 1. Start Airflow Environment
46
+
47
+ ```bash
48
+ airflow-cli up
49
+ ```
50
+
51
+ This command will:
52
+ - Check Docker installation and environment
53
+ - Download the latest docker-compose.yml from LEMA UFPB repository
54
+ - Start Airflow services with Docker Compose
55
+
56
+ ### 2. Access Airflow UI
57
+
58
+ Open your browser and navigate to http://localhost:8080
59
+
60
+ Default credentials:
61
+ - Username: `airflow`
62
+ - Password: `airflow`
63
+
64
+ ### 3. Stop Airflow Environment
65
+
66
+ ```bash
67
+ airflow-cli down
68
+ ```
69
+
70
+ ## Usage
71
+
72
+ ### Available Commands
73
+
74
+ ```bash
75
+ # Start Docker environment
76
+ airflow-cli up
77
+
78
+ # Stop Docker environment
79
+ airflow-cli down
80
+
81
+ # Run Airflow DAG inside Docker
82
+ airflow-cli run-dag
83
+
84
+ # Run flake8 linter on DAGs
85
+ airflow-cli fix-code
86
+
87
+ # Show help
88
+ airflow-cli --help
89
+ ```
90
+
91
+ ### DAG Development
92
+
93
+ 1. Place your DAG files in the `dags/` directory
94
+ 2. The directory is automatically mounted to the Airflow container
95
+ 3. Changes are reflected immediately (no restart required)
96
+
97
+ Expected DAG structure for `run-dag` command:
98
+ ```
99
+ project/
100
+ ├── dags/
101
+ │ └── my_dag/
102
+ │ ├── config.yml
103
+ │ └── dag.py
104
+
105
+ ```
106
+
107
+ Example `config.yml`:
108
+ ```yaml
109
+ args:
110
+ id: "my_dag_id"
111
+ ```
112
+
113
+ ### Testing DAGs
114
+
115
+ #### Run a DAG inside Docker
116
+ ```bash
117
+ airflow-cli run-dag
118
+ ```
119
+
120
+ This command will:
121
+ - Look for DAG configuration files in `dags/*/config.yml`
122
+ - Execute the DAG inside the running Airflow container
123
+
124
+ #### Validate DAG syntax with flake8
125
+ ```bash
126
+ airflow-cli fix-code
127
+ ```
128
+
129
+ This will run flake8 linter on the `dags/` folder to check for Python syntax issues.
130
+
131
+ ### Building from Source
132
+
133
+ ```bash
134
+ # Build wheel
135
+ python -m build
136
+
137
+ # Install built package
138
+ pip install dist/airflow_docker_helper-*.whl
139
+ ```
140
+
141
+ ## Publishing to PyPI
142
+ ```bash
143
+ # Build wheel
144
+ python -m build
145
+ # Publish to PyPI
146
+ twine upload dist/*
147
+ ```
148
+
149
+ ## License
150
+
151
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
152
+
153
+
154
+ ---
155
+
156
+ Made with ❤️ by the LEMA UFPB team
@@ -3,7 +3,6 @@ README.md
3
3
  pyproject.toml
4
4
  airflow_cli/__init__.py
5
5
  airflow_cli/cli.py
6
- airflow_cli/docker-compose.yml
7
6
  airflow_cli/docker_utils.py
8
7
  airflow_cli/env_utils.py
9
8
  airflow_cli/menu.py
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "airflow-cli"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "CLI para facilitar o setup de Airflow com Docker."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.7"
7
- license = {text = "MIT"}
7
+ license = "MIT"
8
8
  authors = [{ name="LEMA-UFPB", email="ufpb.lema@gmail.com" }]
9
9
  dependencies = [
10
10
  "simple-term-menu>=1.0.0",
@@ -19,9 +19,6 @@ airflow-cli = "airflow_cli.cli:main"
19
19
  [tool.setuptools]
20
20
  packages = ["airflow_cli"]
21
21
 
22
- [tool.setuptools.package-data]
23
- airflow_cli = ["docker-compose.yml"]
24
-
25
22
  [build-system]
26
23
  requires = ["setuptools", "wheel"]
27
24
  build-backend = "setuptools.build_meta"