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/10/10 20:23:55 UTC

[GitHub] [airflow] ephraimbuddy opened a new pull request #11408: Fix incorrect typing, remove hardcoded argument values and improve code in AzureContainerInstancesOperator

ephraimbuddy opened a new pull request #11408:
URL: https://github.com/apache/airflow/pull/11408


   This PR addresses a few things.
   1) Incorrect type for command argument: The correct type is List[str] and is now updated
   2) I added os_type and restart_policy arguments so that it's not hardcoded.
   3) I also added ip_address and ports argument so that these values can be configured on the container at the start. Without these, there's no way of getting a generated IP and FQDN from azure when you run containers such as the [microsoft/aci-helloworld](https://hub.docker.com/_/microsoft-azuredocs-aci-helloworld)
   
   
   ---
   **^ 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] turbaszek commented on a change in pull request #11408: Fix incorrect typing, remove hardcoded argument values and improve code in AzureContainerInstancesOperator

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



##########
File path: airflow/providers/microsoft/azure/operators/azure_container_instances.py
##########
@@ -167,11 +180,28 @@ def __init__(
         self.fail_if_exists = fail_if_exists
         self._ci_hook: Any = None
         self.tags = tags
+        self.os_type = os_type
+        self.restart_policy = restart_policy
+        self.ip_address = ip_address
+        self.ports = ports
 
     def execute(self, context: dict) -> int:
         # Check name again in case it was templated.
         self._check_name(self.name)
 
+        if self.os_type not in ['Linux', 'Windows']:
+            raise AirflowException(
+                "Invalid value for the os_type argument. "
+                "Please set 'Linux' or 'Windows' as the os_type. "
+                f"Found `{self.os_type}`."
+            )
+        if self.restart_policy not in ['Always', 'OnFailure', 'Never']:
+            raise AirflowException(
+                "Invalid value for the restart_policy argument. "
+                "Please set one of 'Always', 'OnFailure','Never' as the restart_policy. "
+                f"Found `{self.restart_policy}`"
+            )
+

Review comment:
       Let's move it to constructor to fail as soon as possible




----------------------------------------------------------------
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] turbaszek commented on a change in pull request #11408: Fix incorrect typing, remove hardcoded argument values and improve code in AzureContainerInstancesOperator

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



##########
File path: airflow/providers/microsoft/azure/operators/azure_container_instances.py
##########
@@ -88,37 +90,44 @@ class AzureContainerInstancesOperator(BaseOperator):
     :param gpu: GPU Resource for the container.
     :type gpu: azure.mgmt.containerinstance.models.GpuResource
     :param command: the command to run inside the container
-    :type command: Optional[str]
+    :type command: Optional[List[str]]
     :param container_timeout: max time allowed for the execution of
         the container instance.
     :type container_timeout: datetime.timedelta
     :param tags: azure tags as dict of str:str
     :type tags: Optional[dict[str, str]]
+    :param os_type: he operating system type required by the containers

Review comment:
       ```suggestion
       :param os_type: the operating system type required by the containers
   ```




----------------------------------------------------------------
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] turbaszek merged pull request #11408: Fix incorrect typing, remove hardcoded argument values and improve code in AzureContainerInstancesOperator

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


   


----------------------------------------------------------------
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] ephraimbuddy commented on pull request #11408: Fix incorrect typing, remove hardcoded argument values and improve code in AzureContainerInstancesOperator

Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on pull request #11408:
URL: https://github.com/apache/airflow/pull/11408#issuecomment-706683136


   Hi, @mik-laj @turbaszek @feluelle, please your reviews will be highly appreciated. Thanks


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