Skip to content
Snippets Groups Projects
Commit b1020f13 authored by Jedrzej Rybicki's avatar Jedrzej Rybicki
Browse files

yolo

parent 2190f080
No related branches found
No related tags found
No related merge requests found
from airflow.models.baseoperator import BaseOperator
from airflow.models.connection import Connection
from st import get_objects
class B2ShareOperator(BaseOperator):
def __init__(
self,
name: str,
conn_id: str = 'default_b2share',
**kwargs) -> None:
super().__init__(**kwargs)
self.name = name
self.connection = Connection.get_connection_from_secrets(conn_id)
def execute(self, context):
message = "Hello {}".format(self.name)
print(message)
print(self.connection.host)
print(f"Retrieving info from {self.connection.host}")
lst = get_objects(server=self.connection.schema+self.connection.host)
print(f"GOT: {lst}")
return message
...@@ -6,6 +6,7 @@ from airflow.utils.dates import days_ago ...@@ -6,6 +6,7 @@ from airflow.utils.dates import days_ago
from airflow.operators.bash import BashOperator from airflow.operators.bash import BashOperator
from b2shareoperator import B2ShareOperator
def_args = { def_args = {
'owner': 'airflow', 'owner': 'airflow',
...@@ -21,5 +22,7 @@ with DAG('firsto', default_args=def_args, description='first dag', schedule_inte ...@@ -21,5 +22,7 @@ with DAG('firsto', default_args=def_args, description='first dag', schedule_inte
t1 = BashOperator(task_id='print_date', bash_command='date') t1 = BashOperator(task_id='print_date', bash_command='date')
t2 = BashOperator(task_id='do_noting', bash_command='sleep 5') t2 = BashOperator(task_id='do_noting', bash_command='sleep 5')
t3 = B2ShareOperator(task_id='task_b2sh', dag=dag, name='B2Share')
t1 >> t2 t1 >> t2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment