Skip to content

Commit 4826d66

Browse files
fix: disable persistent_workers when num_workers is 0 (mllam#235)
Co-authored-by: Simon Adamov <kode@mailbox.org>
1 parent 3ed60f2 commit 4826d66

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Fix README image paths to use absolute GitHub URLs so images display correctly on PyPI [\#188](https://github.com/mllam/neural-lam/pull/188) @bk-simon
1313

14+
- Changed the hardcoded True to a conditional check "persistent_workers=self.num_workers > 0" [\#235](https://github.com/mllam/neural-lam/pull/235) @santhil-cyber
15+
1416
### Maintenance
1517

1618
- Update PR template to clarify milestone/roadmap requirement and maintenance changes [\#186](https://github.com/mllam/neural-lam/pull/186) @joeloskarsson

neural_lam/weather_dataset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def train_dataloader(self):
672672
num_workers=self.num_workers,
673673
shuffle=True,
674674
multiprocessing_context=self.multiprocessing_context,
675-
persistent_workers=True,
675+
persistent_workers=self.num_workers > 0,
676676
)
677677

678678
def val_dataloader(self):
@@ -683,7 +683,7 @@ def val_dataloader(self):
683683
num_workers=self.num_workers,
684684
shuffle=False,
685685
multiprocessing_context=self.multiprocessing_context,
686-
persistent_workers=True,
686+
persistent_workers=self.num_workers > 0,
687687
)
688688

689689
def test_dataloader(self):
@@ -694,5 +694,5 @@ def test_dataloader(self):
694694
num_workers=self.num_workers,
695695
shuffle=False,
696696
multiprocessing_context=self.multiprocessing_context,
697-
persistent_workers=True,
697+
persistent_workers=self.num_workers > 0,
698698
)

0 commit comments

Comments
 (0)