Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: airflow and kv pair #173

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions .grit/patterns/python/airflow_decorator_syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pattern function_returning_DAG(
$ref <: and { !within assignment(left=$dag_varname), $dag_varname, !within keyword_argument() },
$dag_var_refs += $ref
},
// if there is no reference outside of a kwarg, remove the declaration
// if there is no reference outside of a kwarg, remove the declaration
if ($dag_var_refs <: .) {
$dag_decl => .
}
Expand Down Expand Up @@ -108,7 +108,7 @@ pattern replace_task_refs() {
},
$decl => .
}
}
}
}


Expand All @@ -134,10 +134,10 @@ pattern is_task_ref() {
`SmoothOperator`,
`BranchDayOfWeekOperator`
},
$ref <: $taskname
$ref <: $taskname
}
}

}
}
}
Expand All @@ -153,7 +153,7 @@ pattern rewrite_chaining() {
if ($op <: "<<") {
$out = `chain($b, $a)`
}
} => `$out`
} => `$out`
}


Expand Down Expand Up @@ -187,15 +187,15 @@ def do_my_thing() -> DAG:
```python
@dag(description="My cool DAG")
def do_my_thing():

@task(task_id='do_db_thing', provide_context=True)
def do_thing(**context: T.Any) -> bool:
return not aws_rds.db_exists(region=get_variable(EnvVarKeys.TARGET))
@task()
def do_thing_two(**context: T.Any) -> bool:
pass


chain(do_thing, do_thing_two)
```

Expand All @@ -207,12 +207,6 @@ def not_a_dag():
return dag
```

```python
def not_a_dag():
dag = notDAG()
return dag
```

## Removes any references to the `dag` variable.

Removing the `dag` reference from kwargs will still retain the intended behavior,
Expand All @@ -229,7 +223,7 @@ def my_dag():
```python
@dag()
def my_dag():

o1 = EmptyOperator()
o2 = EmptyOperator(foo=bar)
return chain(o1, o2)
Expand All @@ -249,7 +243,7 @@ def some_dag():
```python
@dag()
def some_dag():

first = BashOperator(bash_command="echo hello")
second = EmptyOperator()
# second is upstream of first
Expand Down Expand Up @@ -278,8 +272,8 @@ def some_dag():
@task()
def print_dag():
print(dag)


chain(print_dag, print_dag)
```

Expand All @@ -291,7 +285,7 @@ def some_dag():
def print_dag():
print(dag)
t1 = PythonOperator(dag=dag,python_callable=print_dag)
t2 = BashOperator(dag=dag,bash_command="echo 1")
t2 = BashOperator(dag=dag,bash_command="echo 1")
t1 >> t2
```

Expand All @@ -302,7 +296,7 @@ def some_dag():
@task()
def print_dag():
print(dag)
t2 = BashOperator(bash_command="echo 1")

t2 = BashOperator(bash_command="echo 1")
chain(print_dag, t2)
```
19 changes: 19 additions & 0 deletions .grit/patterns/terraform/kv_pair.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,22 @@ incident_rules {
}
}
```

```hcl
default_address = "127.0.0.1"
default_message = upper("Incident: ${incident}")
default_options = {
priority: "High",
color: "Red"
}

incident_rules {
# Rule number 1
rule "down_server" "infrastructure" {
incident = 100
options = var.override_options ? var.override_options : var.default_options
server = default_address
message = default_message
}
}
```
Loading