You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "s0neq (via GitHub)" <gi...@apache.org> on 2023/02/20 11:15:57 UTC

[GitHub] [airflow] s0neq opened a new pull request, #29635: support setting endpoint in yandex airflow provider

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

   Sometimes people use API endpoints different from "api.cloud.yandex.net". Yandex.Cloud Python SDK already supports setting custom API endpoint, this PR makes it possible to set endpoint in Yandex Airflow Provider's Yandex.Cloud Connection. 
   
   Functionality is tested on local AirFlow installation.
   


-- 
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] s0neq commented on a diff in pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "s0neq (via GitHub)" <gi...@apache.org>.
s0neq commented on code in PR #29635:
URL: https://github.com/apache/airflow/pull/29635#discussion_r1112407914


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -122,7 +127,8 @@ def __init__(
         self.connection = self.get_connection(self.connection_id)
         self.extras = self.connection.extra_dejson
         credentials = self._get_credentials()
-        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), **credentials)
+        endpoint = self._get_field("endpoint", "api.cloud.yandex.net")
+        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), endpoint=endpoint, **credentials)

Review Comment:
   some documentation on authorization is in README https://github.com/yandex-cloud/python-sdk :)



-- 
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] Taragolis commented on pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on PR #29635:
URL: https://github.com/apache/airflow/pull/29635#issuecomment-1438406620

   Looks nice, there are two things left
   1. Static Checks failed, I would recommend configure locally pre-commit hooks, see [Static code checks](https://github.com/apache/airflow/blob/main/STATIC_CODE_CHECKS.rst#id4)
   2. Write unit tests for this new functional. If I were you i would have a look first in current [Yandex Cloud Hook Tests](https://github.com/apache/airflow/blob/bfcae349b88fd959e32bfacd027a5be976fe2132/tests/providers/yandex/hooks/test_yandex.py#L31). If for some reason you completely lost how to write tests cases feel free to join to [Airflow Slack](https://s.apache.org/airflow-slack) and ask around here, you could even try to ping me in DM, ifI have a time I would help you.


-- 
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] Taragolis commented on a diff in pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #29635:
URL: https://github.com/apache/airflow/pull/29635#discussion_r1112150631


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -122,7 +127,8 @@ def __init__(
         self.connection = self.get_connection(self.connection_id)
         self.extras = self.connection.extra_dejson
         credentials = self._get_credentials()
-        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), **credentials)
+        endpoint = self._get_field("endpoint", False)
+        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), endpoint=endpoint, **credentials)

Review Comment:
   But it not missing in our case, we would provide `False` in this case and it would evaluate to this wrong value
   
   ```python
   kwargs_no_endpoint = {"foo": "bar"}
   print(kwargs_no_endpoint.get("endpoint", "api.cloud.yandex.net"))
   
   kwargs_none_endpoint = {"foo": "bar", "endpoint": None}
   print(kwargs_none_endpoint.get("endpoint", "api.cloud.yandex.net"))
   
   kwargs_false_endpoint = {"foo": "bar", "endpoint": False}
   print(kwargs_false_endpoint.get("endpoint", "api.cloud.yandex.net"))
   ```
   



-- 
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 #29635: support setting endpoint in yandex airflow provider

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #29635:
URL: https://github.com/apache/airflow/pull/29635#issuecomment-1436775002

   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 (ruff, 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] Taragolis commented on a diff in pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #29635:
URL: https://github.com/apache/airflow/pull/29635#discussion_r1112151762


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -122,7 +127,8 @@ def __init__(
         self.connection = self.get_connection(self.connection_id)
         self.extras = self.connection.extra_dejson
         credentials = self._get_credentials()
-        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), **credentials)
+        endpoint = self._get_field("endpoint", False)
+        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), endpoint=endpoint, **credentials)

Review Comment:
   I guess potentially in other places `self._get_field("foo-bar", False)`produced incorrect behaviour of Yandex Cloud SDK



-- 
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] Taragolis commented on a diff in pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #29635:
URL: https://github.com/apache/airflow/pull/29635#discussion_r1112404383


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -122,7 +127,8 @@ def __init__(
         self.connection = self.get_connection(self.connection_id)
         self.extras = self.connection.extra_dejson
         credentials = self._get_credentials()
-        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), **credentials)
+        endpoint = self._get_field("endpoint", "api.cloud.yandex.net")
+        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), endpoint=endpoint, **credentials)

Review Comment:
   ```suggestion
           sdk_config = {}
           endpoint = self._get_field("endpoint", None)
           if endpoint:
               sdk_config["endpoint"] = endpoint
           self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), **sdk_config, **credentials)
   ```
   
   I would avoid specify default value in Airflow Provider, if it changed in Yandex Cloud SDK it would break in the future. 
   
   BTW, is that all their [documentation](https://cloud.yandex.com/en/docs/functions/lang/python/sdk) for Python SDK? 🙄 



-- 
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 #29635: support Yandex SDK feature "endpoint"

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #29635:
URL: https://github.com/apache/airflow/pull/29635#issuecomment-1440343090

   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] eladkal merged pull request #29635: support Yandex SDK feature "endpoint"

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal merged PR #29635:
URL: https://github.com/apache/airflow/pull/29635


-- 
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] s0neq commented on a diff in pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "s0neq (via GitHub)" <gi...@apache.org>.
s0neq commented on code in PR #29635:
URL: https://github.com/apache/airflow/pull/29635#discussion_r1113895749


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -78,6 +78,11 @@ def get_connection_form_widgets() -> dict[str, Any]:
                 description="Optional. This key will be placed to all created Compute nodes"
                 "to let you have a root shell there",
             ),
+            "endpoint": StringField(
+                lazy_gettext("API endpoint"),
+                widget=BS3TextFieldWidget(),
+                description="Optional.",

Review Comment:
   hi! i fixed the description, if everything's ok lets merge? it seems only people with write access can do it



-- 
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] Taragolis commented on a diff in pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #29635:
URL: https://github.com/apache/airflow/pull/29635#discussion_r1112016187


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -122,7 +127,8 @@ def __init__(
         self.connection = self.get_connection(self.connection_id)
         self.extras = self.connection.extra_dejson
         credentials = self._get_credentials()
-        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), **credentials)
+        endpoint = self._get_field("endpoint", False)
+        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), endpoint=endpoint, **credentials)

Review Comment:
   We need to tests this.
   I guess in case of missing endpoint `self._get_field("endpoint", False)` will return `False`



-- 
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] s0neq commented on a diff in pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "s0neq (via GitHub)" <gi...@apache.org>.
s0neq commented on code in PR #29635:
URL: https://github.com/apache/airflow/pull/29635#discussion_r1112105457


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -122,7 +127,8 @@ def __init__(
         self.connection = self.get_connection(self.connection_id)
         self.extras = self.connection.extra_dejson
         credentials = self._get_credentials()
-        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), **credentials)
+        endpoint = self._get_field("endpoint", False)
+        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), endpoint=endpoint, **credentials)

Review Comment:
   thanks for the comment! 
   False is OK because here we initialize yandexcloud.SDK that sets default API endpoint in case it's missing:
   https://github.com/yandex-cloud/python-sdk/blob/master/yandexcloud/_channels.py#L24
   
   we didn't set endpoint until now, so in these tests no endpoint is passed into hooks  https://github.com/apache/airflow/blob/main/tests/system/providers/yandex/example_yandexcloud.py
   



-- 
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] s0neq commented on a diff in pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "s0neq (via GitHub)" <gi...@apache.org>.
s0neq commented on code in PR #29635:
URL: https://github.com/apache/airflow/pull/29635#discussion_r1112403729


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -122,7 +127,8 @@ def __init__(
         self.connection = self.get_connection(self.connection_id)
         self.extras = self.connection.extra_dejson
         credentials = self._get_credentials()
-        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), **credentials)
+        endpoint = self._get_field("endpoint", False)
+        self.sdk = yandexcloud.SDK(user_agent=self.provider_user_agent(), endpoint=endpoint, **credentials)

Review Comment:
   > But it not missing in our case, we would provide `False` in this case and it would evaluate to this wrong value
   > 
   > ```python
   > kwargs_no_endpoint = {"foo": "bar"}
   > print(kwargs_no_endpoint.get("endpoint", "api.cloud.yandex.net"))
   > 
   > kwargs_none_endpoint = {"foo": "bar", "endpoint": None}
   > print(kwargs_none_endpoint.get("endpoint", "api.cloud.yandex.net"))
   > 
   > kwargs_false_endpoint = {"foo": "bar", "endpoint": False}
   > print(kwargs_false_endpoint.get("endpoint", "api.cloud.yandex.net"))
   > ```
   
   very tru, thanks, force pushed the change, now default endpoint is set in provider
   



-- 
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] eladkal commented on a diff in pull request #29635: YandexCloud provider: support Yandex SDK feature "endpoint"

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #29635:
URL: https://github.com/apache/airflow/pull/29635#discussion_r1113600318


##########
airflow/providers/yandex/hooks/yandex.py:
##########
@@ -78,6 +78,11 @@ def get_connection_form_widgets() -> dict[str, Any]:
                 description="Optional. This key will be placed to all created Compute nodes"
                 "to let you have a root shell there",
             ),
+            "endpoint": StringField(
+                lazy_gettext("API endpoint"),
+                widget=BS3TextFieldWidget(),
+                description="Optional.",

Review Comment:
   I think it's better to have here some more meaningful description



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