Re: [PR] Add pre-commit To Prevent Usage of session.query In Core Airflow [airflow]
Prab-27 commented on PR #45714: URL: https://github.com/apache/airflow/pull/45714#issuecomment-2692753439 Sorry I have to close this PR -- 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]
Re: [PR] Add pre-commit To Prevent Usage of session.query In Core Airflow [airflow]
Prab-27 closed pull request #45714: Add pre-commit To Prevent Usage of session.query In Core Airflow URL: https://github.com/apache/airflow/pull/45714 -- 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]
Re: [PR] Add pre-commit To Prevent Usage of session.query In Core Airflow [airflow]
ephraimbuddy commented on PR #45714: URL: https://github.com/apache/airflow/pull/45714#issuecomment-2665753274 > Could you please clarify it for me? 1 Is it okay to include` providers` in this pre-commit hook ? 2 Do I need to remove `session.query` from the codebases to pass this pre-commit check ? Providers should not be part of this. You have to specify that this should check in airflow/ and task_sdk/ and not providers/. You also need to remove all usage of session.query for this to pass. Sorry for this late reply -- 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]
Re: [PR] Add pre-commit To Prevent Usage of session.query In Core Airflow [airflow]
Prab-27 commented on PR #45714: URL: https://github.com/apache/airflow/pull/45714#issuecomment-2599459949 Could you please clarify it for me? 1 Is it okay to include` providers` in this pre-commit in this hook ? 2 Do I need to remove `session.query` from the codebases to pass this pre-commit check ? -- 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]
Re: [PR] Add pre-commit To Prevent Usage of session.query In Core Airflow [airflow]
Prab-27 commented on code in PR #45714:
URL: https://github.com/apache/airflow/pull/45714#discussion_r1920491423
##
scripts/ci/pre_commit/usage_session_attribute.py:
##
@@ -0,0 +1,55 @@
+# 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 ast
+import sys
+from pathlib import Path
+
+from rich.console import Console
+
+console = Console(color_system="standard", width=200)
+
+
+def check_session_query(mod: ast.Module) -> int:
+errors = 0
+for node in ast.walk(mod):
+if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute):
+if (
+node.func.attr == "query"
+and isinstance(node.func.value, ast.Name)
+and node.func.value.id == "session"
+):
+console.print(f"Remove session.query from line {node.lineno}")
+errors += 1
+return errors
+
+
+def main():
+for file in sys.argv[1:]:
+file_path = Path(file)
+if file_path.name.startswith("test_"):
+continue
Review Comment:
Done!
--
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]
Re: [PR] Add pre-commit To Prevent Usage of session.query In Core Airflow [airflow]
Prab-27 commented on code in PR #45714:
URL: https://github.com/apache/airflow/pull/45714#discussion_r1920491145
##
scripts/ci/pre_commit/usage_session_attribute.py:
##
@@ -0,0 +1,55 @@
+# 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 ast
+import sys
+from pathlib import Path
+
+from rich.console import Console
+
+console = Console(color_system="standard", width=200)
+
+
+def check_session_query(mod: ast.Module) -> int:
+errors = 0
+for node in ast.walk(mod):
+if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute):
+if (
+node.func.attr == "query"
+and isinstance(node.func.value, ast.Name)
+and node.func.value.id == "session"
+):
+console.print(f"Remove session.query from line {node.lineno}")
Review Comment:
Done !
I tried to write msg from
[session.query](https://docs.sqlalchemy.org/en/20/orm/session_api.html#sqlalchemy.orm.Session.query)
IS it okay ?
--
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]
Re: [PR] Add pre-commit To Prevent Usage of session.query In Core Airflow [airflow]
ephraimbuddy commented on code in PR #45714:
URL: https://github.com/apache/airflow/pull/45714#discussion_r1920059493
##
scripts/ci/pre_commit/usage_session_attribute.py:
##
@@ -0,0 +1,55 @@
+# 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 ast
+import sys
+from pathlib import Path
+
+from rich.console import Console
+
+console = Console(color_system="standard", width=200)
+
+
+def check_session_query(mod: ast.Module) -> int:
+errors = 0
+for node in ast.walk(mod):
+if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute):
+if (
+node.func.attr == "query"
+and isinstance(node.func.value, ast.Name)
+and node.func.value.id == "session"
+):
+console.print(f"Remove session.query from line {node.lineno}")
Review Comment:
We are removing the session.query because it is deprecated in SQLAlchemy 2.
The message should reflect this and suggest that the user use the new-style
query constructs.
##
scripts/ci/pre_commit/usage_session_attribute.py:
##
@@ -0,0 +1,55 @@
+# 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 ast
+import sys
+from pathlib import Path
+
+from rich.console import Console
+
+console = Console(color_system="standard", width=200)
+
+
+def check_session_query(mod: ast.Module) -> int:
+errors = 0
+for node in ast.walk(mod):
+if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute):
+if (
+node.func.attr == "query"
+and isinstance(node.func.value, ast.Name)
+and node.func.value.id == "session"
+):
+console.print(f"Remove session.query from line {node.lineno}")
+errors += 1
+return errors
+
+
+def main():
+for file in sys.argv[1:]:
+file_path = Path(file)
+if file_path.name.startswith("test_"):
+continue
Review Comment:
This check for tests file is not necessary because you have the files to
look for at the pre-commit-config.yaml entry
--
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]
Re: [PR] Add pre-commit To Prevent Usage of session.query In Core Airflow [airflow]
potiuk commented on PR #45714: URL: https://github.com/apache/airflow/pull/45714#issuecomment-2596844944 as explained in slack - you can replace the confilcting images / .txt with either versions, rebase and re-run pre-commit. The images wil get regenerated to be "latest" automatically (in fact it should happen automatically when you rebase your PR and resolve the conflicts if you did `pre-commit install` before). -- 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]
Re: [PR] Add pre-commit To Prevent Usage of session.query In Core Airflow [airflow]
Prab-27 commented on PR #45714: URL: https://github.com/apache/airflow/pull/45714#issuecomment-2596354814 a conflict occurred with the images, and I'm not sure how to resolve it. Would you please help me? -- 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]
