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
Harbor 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
9a5c4f43
Commit
9a5c4f43
authored
3 months ago
by
edvs19
Browse files
Options
Downloads
Patches
Plain Diff
teste
parent
4d9f0814
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
teste_dag.py
+35
-23
35 additions, 23 deletions
teste_dag.py
with
35 additions
and
23 deletions
teste_dag.py
+
35
−
23
View file @
9a5c4f43
...
@@ -51,28 +51,40 @@ from airflow import DAG
...
@@ -51,28 +51,40 @@ from airflow import DAG
from
airflow.decorators
import
task
from
airflow.decorators
import
task
from
airflow.models.param
import
Param
from
airflow.models.param
import
Param
with
DAG
(
@dag
(
"
the_dag
"
,
dag_id
=
"
process_records_teste
"
,
params
=
{
params
=
{
"
x
"
:
Param
(
5
,
type
=
"
integer
"
,
minimum
=
3
),
"
input_file
"
:
Param
(
type
=
"
string
"
),
"
my_int_param
"
:
6
},
},
)
as
dag
:
)
def
process_records
():
@task
def
task_spark
(
params
:
dict
):
return
SparkSubmitOperator
(
task_id
=
f
"
landing_to_bronze
"
,
application
=
f
"
{
repo_home
}
/gen_bronze.py
"
,
application_args
=
[
params
[
"
input_file
"
]
],
packages
=
"
org.apache.hadoop:hadoop-aws:3.3.4
"
)
@task.python
@task
def
example_task
(
params
:
dict
):
def
task_dbt_setup
(
params
:
dict
):
# This will print the default value, 6:
return
BashOperator
(
dag
.
log
.
info
(
dag
.
params
[
'
my_int_param
'
])
task_id
=
f
"
dbt_setup
"
,
bash_command
=
f
"
rm -rf /tmp/proj_teste && cp -r
{
repo_home
}
/proj_teste /tmp/proj_teste
"
,
)
# This will print the manually-provided value, 42:
@task
dag
.
log
.
info
(
params
[
'
my_int_param
'
])
def
task_bronze_to_gold
(
params
:
dict
):
return
BashOperator
(
task_id
=
f
"
bronze_to_silver_to_gold
"
,
cwd
=
"
/tmp/proj_teste
"
,
bash_command
=
"
dbt deps && dbt build
"
,
)
# This will print the default value, 5, since it wasn't provided manually:
task_spark
()
>>
task_dbt_setup
()
>>
task_bronze_to_gold
()
dag
.
log
.
info
(
params
[
'
x
'
])
example_task
()
if
__name__
==
"
__main__
"
:
dag
=
process_records
()
dag
.
test
(
run_conf
=
{
"
my_int_param
"
:
42
}
)
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