Skip to content

Commit aebf3f4

Browse files
authored
fixing various typos (#20893)
* fixing various typos * flaky test_async_checkpoint_plugin * Apply suggestions from code review
1 parent 64b2b6a commit aebf3f4

File tree

34 files changed

+68
-65
lines changed

34 files changed

+68
-65
lines changed

.actions/assistant.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ def load_readme_description(path_dir: str, homepage: str, version: str) -> str:
154154
155155
"""
156156
path_readme = os.path.join(path_dir, "README.md")
157-
with open(path_readme, encoding="utf-8") as fo:
158-
text = fo.read()
157+
with open(path_readme, encoding="utf-8") as fopen:
158+
text = fopen.read()
159159

160160
# drop images from readme
161161
text = text.replace(
@@ -308,17 +308,17 @@ def copy_replace_imports(
308308
if ext in (".pyc",):
309309
continue
310310
# Try to parse everything else
311-
with open(fp, encoding="utf-8") as fo:
311+
with open(fp, encoding="utf-8") as fopen:
312312
try:
313-
lines = fo.readlines()
313+
lines = fopen.readlines()
314314
except UnicodeDecodeError:
315315
# a binary file, skip
316316
print(f"Skipped replacing imports for {fp}")
317317
continue
318318
lines = _replace_imports(lines, list(zip(source_imports, target_imports)), lightning_by=lightning_by)
319319
os.makedirs(os.path.dirname(fp_new), exist_ok=True)
320-
with open(fp_new, "w", encoding="utf-8") as fo:
321-
fo.writelines(lines)
320+
with open(fp_new, "w", encoding="utf-8") as fopen:
321+
fopen.writelines(lines)
322322

323323

324324
def create_mirror_package(source_dir: str, package_mapping: dict[str, str]) -> None:
@@ -370,10 +370,10 @@ def _prune_packages(req_file: str, packages: Sequence[str]) -> None:
370370

371371
@staticmethod
372372
def _replace_min(fname: str) -> None:
373-
with open(fname, encoding="utf-8") as fo:
374-
req = fo.read().replace(">=", "==")
375-
with open(fname, "w", encoding="utf-8") as fw:
376-
fw.write(req)
373+
with open(fname, encoding="utf-8") as fopen:
374+
req = fopen.read().replace(">=", "==")
375+
with open(fname, "w", encoding="utf-8") as fwrite:
376+
fwrite.write(req)
377377

378378
@staticmethod
379379
def replace_oldest_ver(requirement_fnames: Sequence[str] = REQUIREMENT_FILES_ALL) -> None:
@@ -471,15 +471,15 @@ def convert_version2nightly(ver_file: str = "src/version.info") -> None:
471471
"""Load the actual version and convert it to the nightly version."""
472472
from datetime import datetime
473473

474-
with open(ver_file) as fo:
475-
version = fo.read().strip()
474+
with open(ver_file) as fopen:
475+
version = fopen.read().strip()
476476
# parse X.Y.Z version and prune any suffix
477477
vers = re.match(r"(\d+)\.(\d+)\.(\d+).*", version)
478478
# create timestamp YYYYMMDD
479479
timestamp = datetime.now().strftime("%Y%m%d")
480480
version = f"{'.'.join(vers.groups())}.dev{timestamp}"
481-
with open(ver_file, "w") as fo:
482-
fo.write(version + os.linesep)
481+
with open(ver_file, "w") as fopen:
482+
fopen.write(version + os.linesep)
483483

484484
@staticmethod
485485
def generate_docker_tags(

dockers/base-cuda/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ ENV \
3434
MAKEFLAGS="-j2"
3535

3636
RUN \
37-
apt-get update --fix-missing && apt-get install -y wget && \
38-
apt-get update -qq --fix-missing && \
39-
NCCL_VER=$(dpkg -s libnccl2 | grep '^Version:' | awk -F ' ' '{print $2}' | awk -F '-' '{print $1}' | grep -ve '^\s*$') && \
4037
CUDA_VERSION_MM=${CUDA_VERSION%.*} && \
38+
apt-get update -qq --fix-missing && apt-get install -y wget && \
39+
NCCL_VER=$(dpkg -s libnccl2 | grep '^Version:' | awk -F ' ' '{print $2}' | awk -F '-' '{print $1}' | grep -ve '^\s*$') && \
40+
echo "NCCL version found: $NCCL_VER" && \
4141
TO_INSTALL_NCCL=$(echo -e "$MAX_ALLOWED_NCCL\n$NCCL_VER" | sort -V | head -n1)-1+cuda${CUDA_VERSION_MM} && \
42+
echo "NCCL version to install: $TO_INSTALL_NCCL" && \
4243
apt-get install -y --no-install-recommends --allow-downgrades --allow-change-held-packages \
4344
build-essential \
4445
pkg-config \
@@ -96,7 +97,7 @@ RUN \
9697
--extra-index-url="https://download.pytorch.org/whl/test/cu${CUDA_VERSION_MM//'.'/''}/"
9798

9899
RUN \
99-
# Show what we have
100+
# Show what we have \
100101
pip --version && \
101102
pip list && \
102103
python -c "import sys; ver = sys.version_info ; assert f'{ver.major}.{ver.minor}' == '$PYTHON_VERSION', ver" && \

examples/fabric/build_your_own_trainer/trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def load(self, state: Optional[Mapping], path: str) -> None:
418418
"""Loads a checkpoint from a given file into state.
419419
420420
Args:
421-
state: a mapping contaning model, optimizer and lr scheduler
421+
state: a mapping containing model, optimizer and lr scheduler
422422
path: the path to load the checkpoint from
423423
424424
"""

examples/fabric/meta_learning/train_fabric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def accuracy(predictions, targets):
3030
def fast_adapt(batch, learner, loss, adaptation_steps, shots, ways):
3131
data, labels = batch
3232

33-
# Separate data into adaptation/evalutation sets
33+
# Separate data into adaptation/evaluation sets
3434
adaptation_indices = torch.zeros(data.size(0), dtype=bool)
3535
adaptation_indices[torch.arange(shots * ways) * 2] = True
3636
evaluation_indices = ~adaptation_indices

examples/fabric/meta_learning/train_torch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def fast_adapt(batch, learner, loss, adaptation_steps, shots, ways, device):
3434
data, labels = batch
3535
data, labels = data.to(device), labels.to(device)
3636

37-
# Separate data into adaptation/evalutation sets
37+
# Separate data into adaptation/evaluation sets
3838
adaptation_indices = torch.zeros(data.size(0), dtype=bool)
3939
adaptation_indices[torch.arange(shots * ways) * 2] = True
4040
evaluation_indices = ~adaptation_indices

examples/pytorch/domain_templates/reinforce_learn_ppo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def generate_trajectory_samples(self) -> tuple[list[torch.Tensor], list[torch.Te
353353
# logging
354354
self.avg_reward = sum(self.epoch_rewards) / self.steps_per_epoch
355355

356-
# if epoch ended abruptly, exlude last cut-short episode to prevent stats skewness
356+
# if epoch ended abruptly, exclude last cut-short episode to prevent stats skewness
357357
epoch_rewards = self.epoch_rewards
358358
if not done:
359359
epoch_rewards = epoch_rewards[:-1]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ blank = true
3333

3434
[tool.codespell]
3535
# Todo: enable also python files in a next step
36-
skip = '*.py'
36+
#skip = '*.py'
3737
quiet-level = 3
3838
# comma separated list of words; waiting for:
3939
# https://github.com/codespell-project/codespell/issues/2839#issuecomment-1731601603

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
- for `pytorch-lightning` use `export PACKAGE_NAME=pytorch ; pip install .`
2828
- for `lightning-fabric` use `export PACKAGE_NAME=fabric ; pip install .`
2929
30-
3. Building packages as sdist or binary wheel and installing or publish to PyPI afterwords you use command
30+
3. Building packages as sdist or binary wheel and installing or publish to PyPI afterwards you use command
3131
`python setup.py sdist` or `python setup.py bdist_wheel` accordingly.
3232
In case you want to build just a particular package you want to set an environment variable:
3333
`PACKAGE_NAME=lightning|pytorch|fabric python setup.py sdist|bdist_wheel`

src/lightning/__version__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
if not os.path.exists(_VERSION_PATH):
66
# relevant for `bdist_wheel`
77
_VERSION_PATH = os.path.join(_PACKAGE_ROOT, "version.info")
8-
with open(_VERSION_PATH, encoding="utf-8") as fo:
9-
version = fo.readlines()[0].strip()
8+
with open(_VERSION_PATH, encoding="utf-8") as fopen:
9+
version = fopen.readlines()[0].strip()

src/lightning/fabric/connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class _Connector:
8383
1. strategy class
8484
2. strategy str registered with STRATEGY_REGISTRY
8585
3. strategy str in _strategy_type enum which listed in each strategy as
86-
backend (registed these too, and _strategy_type could be deprecated)
86+
backend (registered these too, and _strategy_type could be deprecated)
8787
8888
C. plugins flag could be:
8989
1. precision class (should be removed, and precision flag should allow user pass classes)

0 commit comments

Comments
 (0)