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

Handle indentation for callable and context #5

Open
zhongjiajie opened this issue Dec 1, 2021 · 0 comments
Open

Handle indentation for callable and context #5

zhongjiajie opened this issue Dec 1, 2021 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@zhongjiajie
Copy link
Contributor

After #2 merged, we keep all comment but not keep indentation as old file. For now context manager and callable would have different indentation between old file. Here is the result we run command python ./example/transfer_tutorial.py, and we could see each BashOperator end close parenthesis would be add four blank, so as DAG contenxt. And DAG contenxt would also have leading newline in this example.

@@ -27,10 +27,10 @@
 from textwrap import dedent
 
 # The DAG object; we'll need this to instantiate a DAG
-from airflow import DAG
+from pydolphinscheduler.core.process_definition import ProcessDefinition
 
 # Operators; we need this to operate!
-from airflow.operators.bash import BashOperator
+from pydolphinscheduler.tasks.shell import Shell
 
 # [END import_module]
 
@@ -62,30 +62,24 @@
 # [END default_args]
 
 # [START instantiate_dag]
-with DAG(
-    'tutorial',
-    default_args=default_args,
+with ProcessDefinition('tutorial',
     description='A simple tutorial DAG',
-    schedule_interval=timedelta(days=1),
-    start_date=datetime(2021, 1, 1),
-    catchup=False,
-    tags=['example'],
-) as dag:
+    schedule=timedelta(days=1),
+    start_time=datetime(2021, 1, 1),
+    ) as dag:
     # [END instantiate_dag]
 
     # t1, t2 and t3 are examples of tasks created by instantiating operators
     # [START basic_task]
-    t1 = BashOperator(
-        task_id='print_date',
-        bash_command='date',
+    t1 = Shell(
+        name='print_date',
+        command='date',
     )
 
-    t2 = BashOperator(
-        task_id='sleep',
-        depends_on_past=False,
-        bash_command='sleep 5',
-        retries=3,
-    )
+    t2 = Shell(
+        name='sleep',
+        command='sleep 5',
+        )
     # [END basic_task]
 
     # [START documentation]
@@ -116,13 +110,11 @@
     """
     )
 
-    t3 = BashOperator(
-        task_id='templated',
-        depends_on_past=False,
-        bash_command=templated_command,
-        params={'my_param': 'Parameter I passed in'},
-    )
+    t3 = Shell(
+        name='templated',
+        command=templated_command,
+        )
     # [END jinja_template]
 
     t1 >> [t2, t3]
\ No newline at end of file
@zhongjiajie zhongjiajie added enhancement New feature or request good first issue Good for newcomers labels Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant