Skip to content

Commit

Permalink
Refactor assertions that use walrus (#18496)
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli authored and lantiga committed Sep 14, 2023
1 parent ce5e490 commit 023a18c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lightning/pytorch/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fixed the display of `v_num` in the progress bar when running with `Trainer(fast_dev_run=True)` ([#18491](https://github.com/Lightning-AI/lightning/pull/18491))


- Fixed `UnboundLocalError` when running with `python -O` ([#18496](https://github.com/Lightning-AI/lightning/pull/18496))


- Fixed visual glitch with the TQDM progress bar leaving the validation bar incomplete before switching back to the training display ([#18503](https://github.com/Lightning-AI/lightning/pull/18503))

Expand Down
4 changes: 2 additions & 2 deletions src/lightning/pytorch/loops/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def __iter__(self) -> "_DataFetcher":
return self

def __next__(self) -> Any:
assert (iterator := self.iterator) is not None
assert self.iterator is not None
self._start_profiler()
try:
batch = next(iterator)
batch = next(self.iterator)
except StopIteration:
self.done = True
raise
Expand Down
4 changes: 4 additions & 0 deletions tests/tests_pytorch/run_standalone_tasks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=0 python strategies/scripts/
# test that ddp can launched as a module (-m option)
echo "Running ddp example as module"
python -m strategies.scripts.cli_script ${args}

# test that `python -O` (optimized mode) works
echo "Running bug report model with 'python -O'"
python -O ../../examples/pytorch/bug_report/bug_report_model.py

0 comments on commit 023a18c

Please sign in to comment.