airflow-cli 0.1.0__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.
- airflow_cli-0.1.0/LICENSE +21 -0
- airflow_cli-0.1.0/PKG-INFO +381 -0
- airflow_cli-0.1.0/README.md +366 -0
- airflow_cli-0.1.0/airflow_cli/__init__.py +1 -0
- airflow_cli-0.1.0/airflow_cli/cli.py +55 -0
- airflow_cli-0.1.0/airflow_cli/docker-compose.yml +251 -0
- airflow_cli-0.1.0/airflow_cli/docker_utils.py +39 -0
- airflow_cli-0.1.0/airflow_cli/env_utils.py +33 -0
- airflow_cli-0.1.0/airflow_cli/menu.py +51 -0
- airflow_cli-0.1.0/airflow_cli/os_utils.py +47 -0
- airflow_cli-0.1.0/airflow_cli.egg-info/PKG-INFO +381 -0
- airflow_cli-0.1.0/airflow_cli.egg-info/SOURCES.txt +16 -0
- airflow_cli-0.1.0/airflow_cli.egg-info/dependency_links.txt +1 -0
- airflow_cli-0.1.0/airflow_cli.egg-info/entry_points.txt +2 -0
- airflow_cli-0.1.0/airflow_cli.egg-info/requires.txt +4 -0
- airflow_cli-0.1.0/airflow_cli.egg-info/top_level.txt +1 -0
- airflow_cli-0.1.0/pyproject.toml +27 -0
- airflow_cli-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 LEMA-UFPB
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,381 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: airflow-cli
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: CLI para facilitar o setup de Airflow com Docker.
|
5
|
+
Author-email: LEMA-UFPB <ufpb.lema@gmail.com>
|
6
|
+
License: 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
|
+
### From Source
|
43
|
+
|
44
|
+
```bash
|
45
|
+
git clone https://gitlab.lema.ufpb.br/back-end/lema-ufpb/airflow-docker-helper.git
|
46
|
+
cd airflow-docker-helper
|
47
|
+
pip install -e .
|
48
|
+
```
|
49
|
+
|
50
|
+
### Development Installation
|
51
|
+
|
52
|
+
```bash
|
53
|
+
git clone https://gitlab.lema.ufpb.br/back-end/lema-ufpb/airflow-docker-helper.git
|
54
|
+
cd airflow-docker-helper
|
55
|
+
pip install -e ".[dev]"
|
56
|
+
```
|
57
|
+
|
58
|
+
## Quick Start
|
59
|
+
|
60
|
+
### 1. Start Airflow Environment
|
61
|
+
|
62
|
+
```bash
|
63
|
+
airflow-cli up
|
64
|
+
```
|
65
|
+
|
66
|
+
This command will:
|
67
|
+
- Check Docker installation and environment
|
68
|
+
- Download the latest docker-compose.yml from LEMA UFPB repository
|
69
|
+
- Start Airflow services with Docker Compose
|
70
|
+
|
71
|
+
### 2. Access Airflow UI
|
72
|
+
|
73
|
+
Open your browser and navigate to http://localhost:8080
|
74
|
+
|
75
|
+
Default credentials:
|
76
|
+
- Username: `airflow`
|
77
|
+
- Password: `airflow`
|
78
|
+
|
79
|
+
### 3. Stop Airflow Environment
|
80
|
+
|
81
|
+
```bash
|
82
|
+
airflow-cli down
|
83
|
+
```
|
84
|
+
|
85
|
+
## Usage
|
86
|
+
|
87
|
+
### Available Commands
|
88
|
+
|
89
|
+
```bash
|
90
|
+
# Start Docker environment
|
91
|
+
airflow-cli up
|
92
|
+
|
93
|
+
# Stop Docker environment
|
94
|
+
airflow-cli down
|
95
|
+
|
96
|
+
# Run Airflow DAG inside Docker
|
97
|
+
airflow-cli run-dag
|
98
|
+
|
99
|
+
# Run flake8 linter on DAGs
|
100
|
+
airflow-cli fix-code
|
101
|
+
|
102
|
+
# Show help
|
103
|
+
airflow-cli --help
|
104
|
+
```
|
105
|
+
|
106
|
+
### DAG Development
|
107
|
+
|
108
|
+
1. Place your DAG files in the `dags/` directory
|
109
|
+
2. The directory is automatically mounted to the Airflow container
|
110
|
+
3. Changes are reflected immediately (no restart required)
|
111
|
+
|
112
|
+
Expected DAG structure for `run-dag` command:
|
113
|
+
```
|
114
|
+
project/
|
115
|
+
โโโ dags/
|
116
|
+
โ โโโ my_dag/
|
117
|
+
โ โโโ config.yml
|
118
|
+
โ โโโ dag.py
|
119
|
+
โโโ docker-compose.yml
|
120
|
+
```
|
121
|
+
|
122
|
+
Example `config.yml`:
|
123
|
+
```yaml
|
124
|
+
args:
|
125
|
+
id: "my_dag_id"
|
126
|
+
```
|
127
|
+
|
128
|
+
### Testing DAGs
|
129
|
+
|
130
|
+
#### Run a DAG inside Docker
|
131
|
+
```bash
|
132
|
+
airflow-cli run-dag
|
133
|
+
```
|
134
|
+
|
135
|
+
This command will:
|
136
|
+
- Look for DAG configuration files in `dags/*/config.yml`
|
137
|
+
- Execute the DAG inside the running Airflow container
|
138
|
+
|
139
|
+
#### Validate DAG syntax with flake8
|
140
|
+
```bash
|
141
|
+
airflow-cli fix-code
|
142
|
+
```
|
143
|
+
|
144
|
+
This will run flake8 linter on the `dags/` folder to check for Python syntax issues.
|
145
|
+
|
146
|
+
## Configuration
|
147
|
+
|
148
|
+
### Environment Variables
|
149
|
+
|
150
|
+
Create a `.env` file in your project root:
|
151
|
+
|
152
|
+
```env
|
153
|
+
# Airflow Configuration
|
154
|
+
AIRFLOW_VERSION=2.7.0
|
155
|
+
AIRFLOW_UID=50000
|
156
|
+
AIRFLOW_GID=0
|
157
|
+
|
158
|
+
# Database
|
159
|
+
POSTGRES_USER=airflow
|
160
|
+
POSTGRES_PASSWORD=airflow
|
161
|
+
POSTGRES_DB=airflow
|
162
|
+
|
163
|
+
# Airflow Core
|
164
|
+
AIRFLOW__CORE__EXECUTOR=CeleryExecutor
|
165
|
+
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION=true
|
166
|
+
AIRFLOW__CORE__LOAD_EXAMPLES=false
|
167
|
+
|
168
|
+
# Webserver
|
169
|
+
AIRFLOW__WEBSERVER__EXPOSE_CONFIG=true
|
170
|
+
```
|
171
|
+
|
172
|
+
### Docker Compose Source
|
173
|
+
|
174
|
+
The tool automatically downloads the `docker-compose.yml` from:
|
175
|
+
```
|
176
|
+
https://gitlab.lema.ufpb.br/hub/airflow/-/raw/main/docker-compose.yml
|
177
|
+
```
|
178
|
+
|
179
|
+
This ensures you're always using the latest configuration from the LEMA UFPB Airflow repository.
|
180
|
+
|
181
|
+
## Development
|
182
|
+
|
183
|
+
### Setting up Development Environment
|
184
|
+
|
185
|
+
```bash
|
186
|
+
# Clone the repository
|
187
|
+
git clone https://gitlab.lema.ufpb.br/back-end/lema-ufpb/airflow-docker-helper.git
|
188
|
+
cd airflow-docker-helper
|
189
|
+
|
190
|
+
# Create virtual environment
|
191
|
+
python -m venv venv
|
192
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
193
|
+
|
194
|
+
# Install in development mode
|
195
|
+
pip install -e ".[dev]"
|
196
|
+
|
197
|
+
# Install pre-commit hooks
|
198
|
+
pre-commit install
|
199
|
+
```
|
200
|
+
|
201
|
+
### Building from Source
|
202
|
+
|
203
|
+
```bash
|
204
|
+
# Build wheel
|
205
|
+
python -m build
|
206
|
+
|
207
|
+
# Install built package
|
208
|
+
pip install dist/airflow_docker_helper-*.whl
|
209
|
+
```
|
210
|
+
|
211
|
+
### Running Tests
|
212
|
+
|
213
|
+
```bash
|
214
|
+
# Run all tests
|
215
|
+
pytest
|
216
|
+
|
217
|
+
# Run with coverage
|
218
|
+
pytest --cov=airflow_docker_helper
|
219
|
+
|
220
|
+
# Run specific test file
|
221
|
+
pytest tests/test_cli.py
|
222
|
+
|
223
|
+
# Run with verbose output
|
224
|
+
pytest -v
|
225
|
+
```
|
226
|
+
|
227
|
+
### Code Quality
|
228
|
+
|
229
|
+
```bash
|
230
|
+
# Format code
|
231
|
+
black airflow_docker_helper/
|
232
|
+
|
233
|
+
# Sort imports
|
234
|
+
isort airflow_docker_helper/
|
235
|
+
|
236
|
+
# Lint code
|
237
|
+
flake8 airflow_docker_helper/
|
238
|
+
|
239
|
+
# Type checking
|
240
|
+
mypy airflow_docker_helper/
|
241
|
+
```
|
242
|
+
|
243
|
+
## Troubleshooting
|
244
|
+
|
245
|
+
### Common Issues
|
246
|
+
|
247
|
+
#### Permission Errors
|
248
|
+
```bash
|
249
|
+
# Fix permissions for Airflow directories
|
250
|
+
sudo chown -R $(id -u):$(id -g) dags/ logs/ plugins/
|
251
|
+
```
|
252
|
+
|
253
|
+
#### Port Already in Use
|
254
|
+
```bash
|
255
|
+
# Check what's using port 8080
|
256
|
+
lsof -i :8080
|
257
|
+
|
258
|
+
# Use different port
|
259
|
+
AIRFLOW_WEBSERVER_PORT=8081 airflow-helper start
|
260
|
+
```
|
261
|
+
|
262
|
+
#### Database Connection Issues
|
263
|
+
```bash
|
264
|
+
# Reset database
|
265
|
+
airflow-helper clean
|
266
|
+
airflow-helper init
|
267
|
+
```
|
268
|
+
|
269
|
+
#### DAG Import Errors
|
270
|
+
```bash
|
271
|
+
# Check DAG syntax
|
272
|
+
airflow-helper validate-dags
|
273
|
+
|
274
|
+
# View detailed logs
|
275
|
+
airflow-helper logs scheduler
|
276
|
+
```
|
277
|
+
|
278
|
+
### Getting Help
|
279
|
+
|
280
|
+
```bash
|
281
|
+
# Show help for main command
|
282
|
+
airflow-helper --help
|
283
|
+
|
284
|
+
# Show help for specific command
|
285
|
+
airflow-helper init --help
|
286
|
+
```
|
287
|
+
|
288
|
+
## Examples
|
289
|
+
|
290
|
+
### Example DAG
|
291
|
+
|
292
|
+
```python
|
293
|
+
from datetime import datetime, timedelta
|
294
|
+
from airflow import DAG
|
295
|
+
from airflow.operators.python import PythonOperator
|
296
|
+
|
297
|
+
default_args = {
|
298
|
+
'owner': 'data-team',
|
299
|
+
'depends_on_past': False,
|
300
|
+
'start_date': datetime(2023, 1, 1),
|
301
|
+
'email_on_failure': False,
|
302
|
+
'email_on_retry': False,
|
303
|
+
'retries': 1,
|
304
|
+
'retry_delay': timedelta(minutes=5),
|
305
|
+
}
|
306
|
+
|
307
|
+
dag = DAG(
|
308
|
+
'example_pipeline',
|
309
|
+
default_args=default_args,
|
310
|
+
description='An example data pipeline',
|
311
|
+
schedule_interval=timedelta(days=1),
|
312
|
+
catchup=False,
|
313
|
+
tags=['example', 'tutorial'],
|
314
|
+
)
|
315
|
+
|
316
|
+
def extract_data():
|
317
|
+
print("Extracting data...")
|
318
|
+
return "data_extracted"
|
319
|
+
|
320
|
+
def transform_data():
|
321
|
+
print("Transforming data...")
|
322
|
+
return "data_transformed"
|
323
|
+
|
324
|
+
def load_data():
|
325
|
+
print("Loading data...")
|
326
|
+
return "data_loaded"
|
327
|
+
|
328
|
+
extract_task = PythonOperator(
|
329
|
+
task_id='extract',
|
330
|
+
python_callable=extract_data,
|
331
|
+
dag=dag,
|
332
|
+
)
|
333
|
+
|
334
|
+
transform_task = PythonOperator(
|
335
|
+
task_id='transform',
|
336
|
+
python_callable=transform_data,
|
337
|
+
dag=dag,
|
338
|
+
)
|
339
|
+
|
340
|
+
load_task = PythonOperator(
|
341
|
+
task_id='load',
|
342
|
+
python_callable=load_data,
|
343
|
+
dag=dag,
|
344
|
+
)
|
345
|
+
|
346
|
+
extract_task >> transform_task >> load_task
|
347
|
+
```
|
348
|
+
|
349
|
+
## Contributing
|
350
|
+
|
351
|
+
1. Fork the repository
|
352
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
353
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
354
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
355
|
+
5. Open a Merge Request
|
356
|
+
|
357
|
+
### Development Guidelines
|
358
|
+
|
359
|
+
- Follow PEP 8 style guide
|
360
|
+
- Add tests for new features
|
361
|
+
- Update documentation
|
362
|
+
- Ensure all tests pass
|
363
|
+
- Use meaningful commit messages
|
364
|
+
|
365
|
+
## License
|
366
|
+
|
367
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
368
|
+
|
369
|
+
## Support
|
370
|
+
|
371
|
+
- ๐ง Email: [your-email@ufpb.br]
|
372
|
+
- ๐ Issues: [GitLab Issues](https://gitlab.lema.ufpb.br/back-end/lema-ufpb/airflow-docker-helper/-/issues)
|
373
|
+
- ๐ Documentation: [Wiki](https://gitlab.lema.ufpb.br/back-end/lema-ufpb/airflow-docker-helper/-/wikis/home)
|
374
|
+
|
375
|
+
## Changelog
|
376
|
+
|
377
|
+
See [CHANGELOG.md](CHANGELOG.md) for a list of changes and version history.
|
378
|
+
|
379
|
+
---
|
380
|
+
|
381
|
+
Made with โค๏ธ by the LEMA UFPB team
|