diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 280fb2fc..9d0fff1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: export DEBIAN_FRONTEND=noninteractive sudo apt-add-repository -y ppa:deadsnakes/ppa sudo apt-get -y install python3.7 python3.7-dev python3-pip python3-setuptools - sudo python3.7 -m pip install pylint mypy typing-extensions + sudo python3.7 -m pip install pylint mypy typing-extensions pytz - name: Run checks run: make checkfull diff --git a/tools/efrotools/__init__.py b/tools/efrotools/__init__.py index d4010289..78aa7d4e 100644 --- a/tools/efrotools/__init__.py +++ b/tools/efrotools/__init__.py @@ -12,14 +12,6 @@ if TYPE_CHECKING: from typing import Dict, Union, Sequence, Optional, Any -def get_proc_count() -> int: - """Return the number of logical processors available.""" - - # Note: this is mac specific currently. - return int( - subprocess.check_output(['sysctl', '-n', 'hw.ncpu']).decode().strip()) - - def explicit_bool(value: bool) -> bool: """Simply return input value; can avoid unreachable-code type warnings.""" return value diff --git a/tools/efrotools/code.py b/tools/efrotools/code.py index f5ee3e91..4c9dce08 100644 --- a/tools/efrotools/code.py +++ b/tools/efrotools/code.py @@ -18,7 +18,8 @@ def formatcode(projroot: Path, full: bool) -> None: """Run clang-format on all of our source code (multithreaded).""" import time import concurrent.futures - from efrotools import get_files_hash, get_proc_count + from efrotools import get_files_hash + from multiprocessing import cpu_count os.chdir(projroot) cachepath = Path(projroot, 'config/.cache-formatcode') if full and cachepath.exists(): @@ -50,7 +51,7 @@ def formatcode(projroot: Path, full: bool) -> None: # so it actually helps to lighten the load around them. # may want to revisit later when we have everything chopped up # better - with concurrent.futures.ThreadPoolExecutor(max_workers=get_proc_count() // + with concurrent.futures.ThreadPoolExecutor(max_workers=cpu_count() // 2) as executor: # Converting this to a list will propagate any errors. list(executor.map(format_file, dirtyfiles)) @@ -66,7 +67,8 @@ def formatcode(projroot: Path, full: bool) -> None: def cpplintcode(projroot: Path, full: bool) -> None: """Run lint-checking on all code deemed lint-able.""" from concurrent.futures import ThreadPoolExecutor - from efrotools import get_config, get_proc_count + from efrotools import get_config + from multiprocessing import cpu_count os.chdir(projroot) filenames = get_code_filenames(projroot) if any(' ' in name for name in filenames): @@ -98,7 +100,7 @@ def cpplintcode(projroot: Path, full: bool) -> None: if result != 0: raise Exception(f'Linting failed for {filename}') - with ThreadPoolExecutor(max_workers=get_proc_count() // 2) as executor: + with ThreadPoolExecutor(max_workers=cpu_count() // 2) as executor: # Converting this to a list will propagate any errors. list(executor.map(lint_file, dirtyfiles)) @@ -129,7 +131,8 @@ def formatscripts(projroot: Path, full: bool) -> None: """Runs yapf on all our scripts (multithreaded).""" import time from concurrent.futures import ThreadPoolExecutor - from efrotools import get_proc_count, get_files_hash + from efrotools import get_files_hash + from multiprocessing import cpu_count os.chdir(projroot) cachepath = Path(projroot, 'config/.cache-formatscripts') if full and cachepath.exists(): @@ -158,7 +161,7 @@ def formatscripts(projroot: Path, full: bool) -> None: # so it actually helps to lighten the load around them. # may want to revisit later when we have everything chopped up # better - with ThreadPoolExecutor(max_workers=get_proc_count() // 2) as executor: + with ThreadPoolExecutor(max_workers=cpu_count() // 2) as executor: # Converting this to a list will propagate any errors list(executor.map(format_file, dirtyfiles))