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/11/15 14:40:13 UTC

[GitHub] [airflow] malthe opened a new pull request, #27689: Add option to add arguments to PSRP hook and operator

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

   <!--
   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 adds an optional `arguments` parameter which allows invoking cmdlets with arguments (rather than parameters which are named arguments).
   
   There's a slight downside (or backwards compatibility if you will) which is that this makes it impossible to add a parameter called `arguments`.
   
   ---
   
   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] malthe commented on a diff in pull request #27689: Add option to add arguments to PSRP hook and operator

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


##########
airflow/providers/microsoft/psrp/hooks/psrp.py:
##########
@@ -215,11 +216,33 @@ def invoke(self) -> Generator[PowerShell, None, None]:
             if local_context:
                 self.__exit__(None, None, None)
 
-    def invoke_cmdlet(self, name: str, use_local_scope=None, **parameters: dict[str, str]) -> PowerShell:
+    def invoke_cmdlet(
+        self,
+        name: str,
+        use_local_scope=None,
+        arguments: list[str] | None = None,
+        parameters: dict[str, str] | None = None,
+        **kwargs: str,
+    ) -> PowerShell:
         """Invoke a PowerShell cmdlet and return session."""
+        if kwargs:
+            if parameters:
+                raise ValueError("**kwargs not allowed when 'parameters' is used at the same time.")
+            warn(
+                "Passing **kwargs to 'invoke_cmdlet' is deprecated "
+                "and will be removed in a future release. Please use 'parameters' "
+                "instead.",
+                DeprecationWarning,
+                stacklevel=2,
+            )

Review Comment:
   I guess it's nice enough to have a deprecation; doesn't cost much.



-- 
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] malthe commented on a diff in pull request #27689: Add option to add arguments to PSRP hook and operator

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


##########
airflow/providers/microsoft/psrp/operators/psrp.py:
##########
@@ -56,8 +56,11 @@ class PsrpOperator(BaseOperator):
     :param cmdlet:
         cmdlet to execute on remote host (templated). Also used as the default
         value for `task_id`.
+    :param arguments:
+        When using the `cmdlet` or `powershell` option, use `arguments` to
+        provide arguments (templated).
     :param parameters:
-        When using the `cmdlet` or `powershell` arguments, use this parameter to
+        When using the `cmdlet` or `powershell` option, use `parameters` to
         provide parameters (templated). Note that a parameter with a value of `None`
         becomes an *argument* (i.e., switch).

Review Comment:
   There's a link in the provider documentation to https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-psrp/.
   
   Most Windows superusers will be familiar with the [Invoke-Command](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command) cmdlet which has the same interface.



-- 
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] malthe merged pull request #27689: Add option to add arguments to PSRP hook and operator

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


-- 
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 #27689: Add option to add arguments to PSRP hook and operator

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


##########
airflow/providers/microsoft/psrp/operators/psrp.py:
##########
@@ -56,8 +56,11 @@ class PsrpOperator(BaseOperator):
     :param cmdlet:
         cmdlet to execute on remote host (templated). Also used as the default
         value for `task_id`.
+    :param arguments:
+        When using the `cmdlet` or `powershell` option, use `arguments` to
+        provide arguments (templated).
     :param parameters:
-        When using the `cmdlet` or `powershell` arguments, use this parameter to
+        When using the `cmdlet` or `powershell` option, use `parameters` to
         provide parameters (templated). Note that a parameter with a value of `None`
         becomes an *argument* (i.e., switch).

Review Comment:
   I’m assuming users fluent with Powershell would understand the difference between these? I wonder if we should add a link to some documentation about this.



-- 
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] malthe commented on pull request #27689: Add option to add arguments to PSRP hook and operator

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

   @uranusjr should we consider merging this one? I rebased 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] uranusjr commented on a diff in pull request #27689: Add option to add arguments to PSRP hook and operator

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


##########
airflow/providers/microsoft/psrp/hooks/psrp.py:
##########
@@ -215,11 +216,33 @@ def invoke(self) -> Generator[PowerShell, None, None]:
             if local_context:
                 self.__exit__(None, None, None)
 
-    def invoke_cmdlet(self, name: str, use_local_scope=None, **parameters: dict[str, str]) -> PowerShell:
+    def invoke_cmdlet(
+        self,
+        name: str,
+        use_local_scope=None,
+        arguments: list[str] | None = None,
+        parameters: dict[str, str] | None = None,
+        **kwargs: str,
+    ) -> PowerShell:
         """Invoke a PowerShell cmdlet and return session."""
+        if kwargs:
+            if parameters:
+                raise ValueError("**kwargs not allowed when 'parameters' is used at the same time.")
+            warn(
+                "Passing **kwargs to 'invoke_cmdlet' is deprecated "
+                "and will be removed in a future release. Please use 'parameters' "
+                "instead.",
+                DeprecationWarning,
+                stacklevel=2,
+            )

Review Comment:
   I wonder if it is worthwhile to do this rather than just bump the major version and break compatibility.



-- 
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] github-actions[bot] commented on pull request #27689: Add option to add arguments to PSRP hook and operator

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

   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.


-- 
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 #27689: Add option to add arguments to PSRP hook and operator

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


##########
airflow/providers/microsoft/psrp/hooks/psrp.py:
##########
@@ -215,11 +216,33 @@ def invoke(self) -> Generator[PowerShell, None, None]:
             if local_context:
                 self.__exit__(None, None, None)
 
-    def invoke_cmdlet(self, name: str, use_local_scope=None, **parameters: dict[str, str]) -> PowerShell:
+    def invoke_cmdlet(
+        self,
+        name: str,
+        use_local_scope=None,

Review Comment:
   ```suggestion
           use_local_scope: bool | None = None,
   ```
   
   (I think)



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