You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/08/23 10:04:45 UTC

[GitHub] [airflow] clellmann opened a new pull request, #25900: Add conf parameter to CLI for airflow dags test

clellmann opened a new pull request, #25900:
URL: https://github.com/apache/airflow/pull/25900

   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   This PR adds a feature so that it's possible to pass a DAG run conf via the CLI for debugging DAGs wit "airflow dags test". This closes the gap, that templated operator fields using this DAG run config can also be debugged.
   
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] uranusjr commented on a diff in pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #25900:
URL: https://github.com/apache/airflow/pull/25900#discussion_r956985216


##########
airflow/cli/commands/dag_command.py:
##########
@@ -453,7 +453,10 @@ def dag_test(args, session=None):
     """Execute one single DagRun for a given DAG and execution date, using the DebugExecutor."""
     run_conf = None
     if args.conf:
-        run_conf = json.loads(args.conf)
+        try:
+            run_conf = json.loads(args.conf)
+        except ValueError as e:
+            raise SystemExit(f"Configuration '{args.conf}' is not valid JSON. Error: {e}")

Review Comment:
   ```suggestion
               raise SystemExit(f"Configuration {args.conf!r} is not valid JSON. Error: {e}")
   ```
   
   This provides better escaping.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] clellmann commented on pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
clellmann commented on PR #25900:
URL: https://github.com/apache/airflow/pull/25900#issuecomment-1226868882

   I need a review here please as everything is green now :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk commented on pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25900:
URL: https://github.com/apache/airflow/pull/25900#issuecomment-1224050517

   restarted. Transient issue. In the futute - you can simply commit --amend and --force push to re-trigger the build


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] clellmann commented on a diff in pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
clellmann commented on code in PR #25900:
URL: https://github.com/apache/airflow/pull/25900#discussion_r956973098


##########
airflow/cli/commands/dag_command.py:
##########
@@ -451,13 +451,18 @@ def dag_list_dag_runs(args, dag=None, session=NEW_SESSION):
 @cli_utils.action_cli
 def dag_test(args, session=None):
     """Execute one single DagRun for a given DAG and execution date, using the DebugExecutor."""
+    run_conf = None
+    if args.conf:
+        run_conf = json.loads(args.conf)

Review Comment:
   @uranusjr I implemented the improvement as suggested. Could you have a look again if this fits your expectation?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] uranusjr commented on a diff in pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #25900:
URL: https://github.com/apache/airflow/pull/25900#discussion_r954606621


##########
airflow/cli/commands/dag_command.py:
##########
@@ -451,13 +451,18 @@ def dag_list_dag_runs(args, dag=None, session=NEW_SESSION):
 @cli_utils.action_cli
 def dag_test(args, session=None):
     """Execute one single DagRun for a given DAG and execution date, using the DebugExecutor."""
+    run_conf = None
+    if args.conf:
+        run_conf = json.loads(args.conf)

Review Comment:
   We should add a try-catch here so invalid input doesn’t crash the command.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] clellmann commented on pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
clellmann commented on PR #25900:
URL: https://github.com/apache/airflow/pull/25900#issuecomment-1223973610

   Hi, I need help regarding the failing git checkout in the pipeline. Can you restart the pipeline or what is the issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] boring-cyborg[bot] commented on pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on PR #25900:
URL: https://github.com/apache/airflow/pull/25900#issuecomment-1229971673

   Awesome work, congrats on your first merged pull request!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] uranusjr commented on a diff in pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #25900:
URL: https://github.com/apache/airflow/pull/25900#discussion_r956951204


##########
airflow/cli/commands/dag_command.py:
##########
@@ -451,13 +451,18 @@ def dag_list_dag_runs(args, dag=None, session=NEW_SESSION):
 @cli_utils.action_cli
 def dag_test(args, session=None):
     """Execute one single DagRun for a given DAG and execution date, using the DebugExecutor."""
+    run_conf = None
+    if args.conf:
+        run_conf = json.loads(args.conf)

Review Comment:
   It should break the command, but we should not show a traceback. A succinct error message is better. See the `users_import` command for an example.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] potiuk commented on pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25900:
URL: https://github.com/apache/airflow/pull/25900#issuecomment-1223861030

   You likely need to add a case in cli unit tests as well.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] clellmann commented on pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
clellmann commented on PR #25900:
URL: https://github.com/apache/airflow/pull/25900#issuecomment-1223919897

   > You likely need to add a case in cli unit tests as well.
   
   Thanks for the hint. Will provide this too.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] clellmann commented on a diff in pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
clellmann commented on code in PR #25900:
URL: https://github.com/apache/airflow/pull/25900#discussion_r955700445


##########
airflow/cli/commands/dag_command.py:
##########
@@ -451,13 +451,18 @@ def dag_list_dag_runs(args, dag=None, session=NEW_SESSION):
 @cli_utils.action_cli
 def dag_test(args, session=None):
     """Execute one single DagRun for a given DAG and execution date, using the DebugExecutor."""
+    run_conf = None
+    if args.conf:
+        run_conf = json.loads(args.conf)

Review Comment:
   What do you think @uranusjr ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] boring-cyborg[bot] commented on pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on PR #25900:
URL: https://github.com/apache/airflow/pull/25900#issuecomment-1223848749

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (flake8, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/BREEZE.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#coding-style-and-best-practices).
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] clellmann commented on a diff in pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
clellmann commented on code in PR #25900:
URL: https://github.com/apache/airflow/pull/25900#discussion_r954612326


##########
airflow/cli/commands/dag_command.py:
##########
@@ -451,13 +451,18 @@ def dag_list_dag_runs(args, dag=None, session=NEW_SESSION):
 @cli_utils.action_cli
 def dag_test(args, session=None):
     """Execute one single DagRun for a given DAG and execution date, using the DebugExecutor."""
+    run_conf = None
+    if args.conf:
+        run_conf = json.loads(args.conf)

Review Comment:
   Actually, I would say it makes sense to break the command when a wrong input is given so that the user is informed. Also it doesn't make sense to execute the command otherwise with a wrong input since this won't give the result the user expects, I think.
   This implementation is also used already in the dag_backfill command in line 82.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] uranusjr merged pull request #25900: Add conf parameter to CLI for airflow dags test

Posted by GitBox <gi...@apache.org>.
uranusjr merged PR #25900:
URL: https://github.com/apache/airflow/pull/25900


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org