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/01/08 15:35:30 UTC

[GitHub] [airflow] potiuk commented on a change in pull request #20763: [WIP] Verify enough resources for breeze

potiuk commented on a change in pull request #20763:
URL: https://github.com/apache/airflow/pull/20763#discussion_r780678128



##########
File path: dev/breeze/doc/BREEZE.md
##########
@@ -93,8 +95,16 @@ Breeze, is not globally accessible until your PATH is updated. Add <USER FOLDER>
 pipx ensurepath
 ```
 
+<<<<<<< HEAD

Review comment:
       Some merge artifacts 

##########
File path: scripts/in_container/run_resource_check.py
##########
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+
+
+# 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.
+
+import os
+
+import psutil
+
+os.system("sh _in_container_script_init.sh")

Review comment:
       I  think we do not really need to source it - it was mainly needed for the bash script to source some common functions but we can simply drop it.

##########
File path: scripts/in_container/run_resource_check.py
##########
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+
+
+# 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.
+
+import os
+
+import psutil
+
+os.system("sh _in_container_script_init.sh")
+
+
+def get_size(kilobytes):
+    """
+    Convert kilobytes into gigabytes
+    1 Gigabytes = 1,048,576 Kb
+    """
+    factor = 1000000000
+    value_gb = kilobytes // factor
+    return value_gb
+
+
+def resoure_check():
+    """
+    use gsutil to get resources in kylobytes: memory, cpus and disk
+    """
+    resources = {}
+    print("Checking resources.")
+
+    # Memory available
+    svmem = psutil.virtual_memory()
+    mem_available = get_size(svmem.total)
+    resources.setdefault('memory', []).append(mem_available)
+
+    # Cpus available
+    cpus_available = psutil.cpu_count(logical=True)
+    resources.setdefault('cpus', []).append(cpus_available)
+
+    # Disk: Get all disk partitions /
+    partitions = psutil.disk_partitions()
+    partition_usage = psutil.disk_usage(partitions[0].mountpoint)
+    disk_available = get_size(partition_usage.free)
+    resources.setdefault('disk', []).append(disk_available)
+
+    return resources
+
+
+def resoure_validate():
+
+    resources = resoure_check()
+
+    resources.setdefault("memory", []).append(4)
+    resources.setdefault("cpus", []).append(2)
+    resources.setdefault("disk", []).append(20)
+
+    for resource, available in resources.items():
+
+        if (
+            resource == "memory"
+            and available[0] < 4
+            or resource == "cpus"
+            and available[0] < 2
+            or resource == "disk"
+            and available[0] < 20
+        ):
+            print(f"== {resource} ==")
+            print(f"WARNING!!!: Not enough {resource} available for Docker.")
+            print(f"At least {available[1]}GB of {resource} required. You have {available[0]}\n")

Review comment:
       We need to add colors/rich to that :)

##########
File path: dev/breeze/doc/BREEZE.md
##########
@@ -32,6 +32,8 @@
         alt="Airflow Breeze - Development and Test Environment for Apache Airflow">
 </div>
 
+<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Review comment:
       Copy * Paste mistake :) ? 




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