Skip to content

Instantly share code, notes, and snippets.

View CribberSix's full-sized avatar

Cribber CribberSix

  • Germany
View GitHub Profile
{
"componentState": {
"componentId": "...",
"stateDescription": "...",
"clusterState": {},
"localState": {
"scope": "LOCAL",
"totalEntryCount": 1,
"state": [
{
def prepare():
"""Where something happens before the NiFi pipeline is triggered."""
pass
def startup():
# Initialize the following variables according to your setup / needs:
url_nifi_api = "https://our.cluster.address.com:9443/nifi-api/"
processor_id = "" # e.g. hardcoded / pass them via `provide_context`
access_payload = { "username": ""
,"password": ""
} # e.g. retrieve via Airflow's `BaseHook` functionality
token = get_token(url_nifi_api, access_payload)
response = update_processor_status(processor_id, "RUNNING", token, url_nifi_api)
def wait_for_update():
"""DAG task."""
# Initialize the following variables according to your setup / needs:
url_nifi_api = "https://our.cluster.address.com:9443/nifi-api/"
processor_id = "" # e.g. pass them via the DAG's `provide_context` functionality
access_payload = "" # e.g. retrieve the via Airflow's `BaseHook` functionality
timestamp_property= "last_tms" # the processor's attribute name
token = get_token(url_nifi_api, access_payload)
def finalize():
"""Some code to execute after the NiFi pipeline has finished."""
pass
with DAG(
dag_id='my_dag_name',
schedule_interval=None,
start_date=days_ago(2),
catchup=False,
) as dag:
preparation = PythonOperator(
task_id='preparation',
python_callable=prepare,
@CribberSix
CribberSix / 0001.txt
Last active November 1, 2021 17:43
0001
TABLE OF CONTENTS:
1. [My Header](#My-Header)
# My Header
Introduction text.
TABLE OF CONTENTS:
1. [My Header](#firstheader)
# My Header<a name="firstheader"></a>
Introduction text.
with open(file_name, "r", encoding="utf-8") as f:
content = f.read().split("\n")
def remove_code_blocks(content: List[str]) -> List[str]:
content_cleaned = []
code_block = False
for x in content:
# detect code blocks, act accordingly
if x[:3] == '```':
code_block = not code_block
elif not code_block:
content_cleaned.append(x)