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 2020/11/17 21:24:46 UTC

[GitHub] [airflow] mik-laj opened a new pull request #12420: Optiimize json schema validation in providers_manager

mik-laj opened a new pull request #12420:
URL: https://github.com/apache/airflow/pull/12420


   ```
       :func:`validate` will first verify that the provided schema is
       itself valid, since not doing so can lead to less obvious error
       messages and fail in less obvious or consistent ways.
   
       If you know you have a valid schema already, especially if you
       intend to validate multiple instances with the same schema, you
       likely would prefer using the `IValidator.validate` method directly
       on a specific validator (e.g. ``Draft7Validator.validate``).
   ```
   <!--
   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 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/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+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 [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


----------------------------------------------------------------
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.

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



[GitHub] [airflow] mik-laj commented on a change in pull request #12420: Optiimize json schema validation in providers_manager

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #12420:
URL: https://github.com/apache/airflow/pull/12420#discussion_r525613849



##########
File path: airflow/providers_manager.py
##########
@@ -36,8 +35,12 @@
 log = logging.getLogger(__name__)
 
 
-def _load_schema() -> Dict:
-    return json.loads(importlib_resources.read_text('airflow', 'provider.yaml.schema.json'))
+def _create_validator():
+    schema = json.loads(importlib_resources.read_text('airflow', 'provider.yaml.schema.json'))
+    cls = jsonschema.validators.validator_for(schema)
+    cls.check_schema(schema)

Review comment:
       Removed. We validate this file in the pre-commit check, so we don't need any additional tests.




----------------------------------------------------------------
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.

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



[GitHub] [airflow] ashb commented on a change in pull request #12420: Optiimize json schema validation in providers_manager

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #12420:
URL: https://github.com/apache/airflow/pull/12420#discussion_r525561367



##########
File path: airflow/providers_manager.py
##########
@@ -36,8 +35,12 @@
 log = logging.getLogger(__name__)
 
 
-def _load_schema() -> Dict:
-    return json.loads(importlib_resources.read_text('airflow', 'provider.yaml.schema.json'))
+def _create_validator():
+    schema = json.loads(importlib_resources.read_text('airflow', 'provider.yaml.schema.json'))
+    cls = jsonschema.validators.validator_for(schema)
+    cls.check_schema(schema)

Review comment:
       This should probably be at test-time only, not run time.




----------------------------------------------------------------
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.

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



[GitHub] [airflow] mik-laj commented on a change in pull request #12420: Optiimize json schema validation in providers_manager

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #12420:
URL: https://github.com/apache/airflow/pull/12420#discussion_r525613505



##########
File path: airflow/providers_manager.py
##########
@@ -36,8 +35,12 @@
 log = logging.getLogger(__name__)
 
 
-def _load_schema() -> Dict:
-    return json.loads(importlib_resources.read_text('airflow', 'provider.yaml.schema.json'))
+def _create_validator():
+    schema = json.loads(importlib_resources.read_text('airflow', 'provider.yaml.schema.json'))
+    cls = jsonschema.validators.validator_for(schema)
+    cls.check_schema(schema)

Review comment:
       ```suggestion
   ```




----------------------------------------------------------------
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.

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



[GitHub] [airflow] github-actions[bot] commented on pull request #12420: Optiimize json schema validation in providers_manager

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #12420:
URL: https://github.com/apache/airflow/pull/12420#issuecomment-729225226


   The PR should be OK to be merged with just subset of tests as it does not modify Core of Airflow. The committers might merge it or can add a label 'full tests needed' and re-run it to run all tests if they see it is needed!


----------------------------------------------------------------
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.

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



[GitHub] [airflow] potiuk merged pull request #12420: Optimize json schema validation in providers_manager

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #12420:
URL: https://github.com/apache/airflow/pull/12420


   


----------------------------------------------------------------
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.

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