Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synctiles: automatically detect number of available CPUs #98

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: v3.18.0
rev: v3.19.0
hooks:
- id: pyupgrade
name: Modernize Python code
args: ["--py312-plus"]
args: ["--py313-plus"]

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
Expand Down Expand Up @@ -47,7 +47,7 @@ repos:
additional_dependencies: [flake8-bugbear, Flake8-pyproject]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.12.0
rev: v1.13.0
hooks:
- id: mypy
name: Check Python types
Expand Down
7 changes: 5 additions & 2 deletions demo/_synctiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import json
from multiprocessing import Pool
from multiprocessing.pool import Pool as PoolType
import os
from pathlib import Path, PurePath
import re
import sys
Expand Down Expand Up @@ -743,6 +744,8 @@ def finish_retile(ctxfile: TextIO, summarydir: Path) -> None:


if __name__ == '__main__':
cpu_count = os.process_cpu_count() # type: ignore[attr-defined]

parser = ArgumentParser()
subparsers = parser.add_subparsers(metavar='subcommand', required=True)

Expand Down Expand Up @@ -779,8 +782,8 @@ def finish_retile(ctxfile: TextIO, summarydir: Path) -> None:
metavar='COUNT',
dest='workers',
type=int,
default=4,
help='number of worker processes to start [4]',
default=cpu_count,
help=f'number of worker processes to start [{cpu_count}]',
)
parser_tile.set_defaults(cmd='tile')

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.black]
line-length = 79
skip-string-normalization = true
target-version = ["py312"]
target-version = ["py313"]

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

[tool.mypy]
namespace_packages = false
python_version = "3.13"
strict = true