potiuk commented on code in PR #47026:
URL: https://github.com/apache/airflow/pull/47026#discussion_r1968203898


##########
task_sdk/dev/generate_models.py:
##########
@@ -0,0 +1,86 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import json
+import os
+from pathlib import Path
+from typing import TYPE_CHECKING
+
+from datamodel_code_generator import (
+    DataModelType,
+    DatetimeClassType,
+    InputFileType,
+    LiteralType,
+    PythonVersion,
+    generate as generate_models,
+)
+
+from airflow.api_fastapi.execution_api.app import create_task_execution_api_app

Review Comment:
   I don't think you have guarantee - when you run dev script that the right 
PYTHONPATH will be used, it really depends on how pre-commit it is run.
   
   One of the ways I was able to fix it in the past - in 
`check_provider_docs.py` is to add
   
   ```python
   sys.path.insert(0, str(Path(__file__).parent.resolve()))  # make sure common 
utils are importable
   
   from common_precommit_utils import (
       AIRFLOW_PROVIDERS_ROOT_PATH,
       AIRFLOW_SOURCES_ROOT_PATH,
       get_all_provider_info_dicts,
   )
   
   sys.path.insert(0, str(AIRFLOW_SOURCES_ROOT_PATH)) 
   ```
   



##########
task_sdk/dev/generate_models.py:
##########
@@ -0,0 +1,86 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import json
+import os
+from pathlib import Path
+from typing import TYPE_CHECKING
+
+from datamodel_code_generator import (
+    DataModelType,
+    DatetimeClassType,
+    InputFileType,
+    LiteralType,
+    PythonVersion,
+    generate as generate_models,
+)
+
+from airflow.api_fastapi.execution_api.app import create_task_execution_api_app

Review Comment:
   I don't think you have guarantee - when you run dev script that the right 
PYTHONPATH will be used, it really depends on how pre-commit it is run.
   
   One of the ways I was able to fix it in the past - in 
`check_provider_docs.py` is to add
   
   ```python
   sys.path.insert(0, str(Path(__file__).parent.resolve()))  # make sure common 
utils are importable
   
   from common_precommit_utils import (
       AIRFLOW_SOURCES_ROOT_PATH,
   )
   
   sys.path.insert(0, str(AIRFLOW_SOURCES_ROOT_PATH)) 
   ```
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to