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



##########
File path: scripts/in_container/run_resource_check.py
##########
@@ -0,0 +1,116 @@
+#!/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.
+
+
+from dataclasses import dataclass
+from typing import Dict
+
+import psutil
+from rich.console import Console
+
+
+@dataclass
+class Resource:
+    current: int
+    minimumAllowed: int
+
+
+console = Console(force_terminal=True, color_system="standard", width=180)
+
+
+def get_size(kilobytes):
+    """
+    Convert kilobytes into gigabytes
+    1 Gigabytes = 1,048,576 Kb
+    """
+    factor = 1000000000

Review comment:
       Yes, this is definitely more understandable.
   
   @potiuk some points I checked here:
   
   **Point 01**: gsutil returns the size of resources in bytes of 
memory(available) and disk(free), and the function get_size takes bytes and 
returns Gb.
   ` 1 Gigabytes = 1024*1024*1024 = 1073741824 bytes`. Here is where I am 
taking just the integer value:
   `value_gb = bytes // factor` if this is 4.605457306 I will take 4 because 
rounding to 5 is not convenient, it would be to complete the missing memory, 
which is wrong.
   
   **Point 02**: One of the things I realized in the previous code 
**run_resource_check.sh** is that in "human_readable_memory" we were storing 
the total memory in our system instead of Total Memory Available. Now I am 
using:  `mem_available = get_size(svmem.available)`
   
   
   ![Screenshot from 2022-01-17 
21-47-54](https://user-images.githubusercontent.com/58795858/149863493-cf0e704f-c26f-4285-adac-cdd1fec654e3.png)
   
   
   **This is to my own understanding** :)
   MemFree != MemAvailable. We are using MemAvailable which is the case.
   - MemFree: The amount of physical RAM, in kilobytes, left unused by the 
system.
   - MemAvailable: An estimate of how much memory is available for starting new 
applications, without swapping
   
   
   




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


Reply via email to