potiuk commented on a change in pull request #20763: URL: https://github.com/apache/airflow/pull/20763#discussion_r786340660
########## 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: It's for readability. It's much clearer to see that it's 1024 ** 3 (you could also write it this way but multiplication is likely faster than power of). Simple question: Do you know by heart that 1073741824 is (as it should be) 1024 ^ 3 when you look at it? Can you verify it when code reviewing without using calculator? How about 1024*1024*1024. For me - I can immediately see that the second one is 1024 ** 3 as expected. -- 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]
