From a59e2604035d89c36822d209fbdc8dd37046e519 Mon Sep 17 00:00:00 2001 From: jrybicki-jsc <j.rybicki@fz-juelich.de> Date: Tue, 5 Apr 2022 13:45:07 +0200 Subject: [PATCH] reg with md retrieval --- dags/just_reg.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/dags/just_reg.py b/dags/just_reg.py index 7a9bf5c..7abda31 100644 --- a/dags/just_reg.py +++ b/dags/just_reg.py @@ -1,4 +1,4 @@ -from urllib.parse import urljoin + from airflow.decorators import dag, task from airflow.models.connection import Connection from airflow.operators.bash import BashOperator @@ -47,19 +47,31 @@ def datacat_registration_example(): ) try: r = hook.create_entry(datacat_type='dataset', entry=entry) - print("Hook registration returned: ", r, urljoin(hook.connection.url, r)) + print("Hook registration returned: ", r) return r except ConnectionError as e: print('Registration failed', e) return -1 + @task + def get_template(): + hook = DataCatalogHook() + print("Connected to datacat via hook", hook.list_type('dataset')) + + mid = '71e863ac-aee6-4680-a57c-de318530b71e' + entry = hook.get_entry(datacat_type='storage_target', oid=mid) + print(entry) + print(entry['metadata']) + + step1 = BashOperator(bash_command='ls', task_id='nothing') step2 = register( object_url='https://b2share-testing.fz-juelich.de/records/7a12fda26b2a4d248f96d012d54769b7') - step1 >> step2 + step3 = get_template() + step1 >> step2 >> step3 dag = datacat_registration_example() -- GitLab