Skip to content

Commit 6cfa508

Browse files
authored
Merge pull request #98 from bgilbert/cpus
synctiles: automatically detect number of available CPUs
2 parents fe9a386 + 5cc26fe commit 6cfa508

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ repos:
1515
- id: trailing-whitespace
1616

1717
- repo: https://github.com/asottile/pyupgrade
18-
rev: v3.18.0
18+
rev: v3.19.0
1919
hooks:
2020
- id: pyupgrade
2121
name: Modernize Python code
22-
args: ["--py312-plus"]
22+
args: ["--py313-plus"]
2323

2424
- repo: https://github.com/PyCQA/isort
2525
rev: 5.13.2
@@ -47,7 +47,7 @@ repos:
4747
additional_dependencies: [flake8-bugbear, Flake8-pyproject]
4848

4949
- repo: https://github.com/pre-commit/mirrors-mypy
50-
rev: v1.12.0
50+
rev: v1.13.0
5151
hooks:
5252
- id: mypy
5353
name: Check Python types

demo/_synctiles.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import json
3131
from multiprocessing import Pool
3232
from multiprocessing.pool import Pool as PoolType
33+
import os
3334
from pathlib import Path, PurePath
3435
import re
3536
import sys
@@ -743,6 +744,8 @@ def finish_retile(ctxfile: TextIO, summarydir: Path) -> None:
743744

744745

745746
if __name__ == '__main__':
747+
cpu_count = os.process_cpu_count() # type: ignore[attr-defined]
748+
746749
parser = ArgumentParser()
747750
subparsers = parser.add_subparsers(metavar='subcommand', required=True)
748751

@@ -779,8 +782,8 @@ def finish_retile(ctxfile: TextIO, summarydir: Path) -> None:
779782
metavar='COUNT',
780783
dest='workers',
781784
type=int,
782-
default=4,
783-
help='number of worker processes to start [4]',
785+
default=cpu_count,
786+
help=f'number of worker processes to start [{cpu_count}]',
784787
)
785788
parser_tile.set_defaults(cmd='tile')
786789

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.black]
22
line-length = 79
33
skip-string-normalization = true
4-
target-version = ["py312"]
4+
target-version = ["py313"]
55

66
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
77
# requires Flake8-pyproject
@@ -14,4 +14,5 @@ force_sort_within_sections = true
1414

1515
[tool.mypy]
1616
namespace_packages = false
17+
python_version = "3.13"
1718
strict = true

0 commit comments

Comments
 (0)