Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
airflow-dags
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Team DB
airflow-dags
Commits
0173220e
Commit
0173220e
authored
4 months ago
by
lcd22
Browse files
Options
Downloads
Patches
Plain Diff
add clean buckets
parent
ff5f08f3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dags.py
+28
-1
28 additions, 1 deletion
dags.py
with
28 additions
and
1 deletion
dags.py
+
28
−
1
View file @
0173220e
...
...
@@ -10,6 +10,28 @@ from airflow.providers.apache.spark.operators.spark_submit import SparkSubmitOpe
repo_home
=
'
/opt/airflow/dags/repo
'
# Função para limpar o buckets do Minio
def
clean_buckets
():
# Configurar cliente do Minio
minio_client
=
Minio
(
"
http://minio.minio-cluster.svc.cluster.local:9000
"
,
access_key
=
"
minioadmin
"
,
secret_key
=
"
minioadmin
"
,
secure
=
True
)
bucket_names
=
[
"
bronze
"
,
"
silver
"
,
"
gold
"
]
for
bucket_name
in
bucket_names
:
try
:
# Listar objetos no bucket e remover
for
obj
in
minio_client
.
list_objects
(
bucket_name
):
minio_client
.
remove_object
(
bucket_name
,
obj
.
object_name
)
print
(
f
"
Objeto
{
obj
.
object_name
}
removido com sucesso!
"
)
except
ResponseError
as
err
:
print
(
f
"
Erro ao limpar o bucket:
{
err
}
"
)
@dag
()
def
process_records
():
"""
...
...
@@ -33,7 +55,12 @@ def process_records():
bash_command
=
"
dbt deps && dbt build
"
,
)
task_1
>>
task_2
>>
task_3
task_4
=
PythonOperator
(
task_id
=
"
clean_buckets
"
,
python_callable
=
clean_buckets
)
task_1
>>
task_2
>>
task_3
>>
task_4
dag
=
process_records
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment