Skip to content

Commit 87211d5

Browse files
Fix: Hide debug statements behind _DEBUG (#730)
* Fix: Hide debug statements behind _DEBUG * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 695a314 commit 87211d5

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/litdata/streaming/downloader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
from litdata.constants import (
2828
_AZURE_STORAGE_AVAILABLE,
29+
_DEBUG,
2930
_GOOGLE_STORAGE_AVAILABLE,
3031
_HF_HUB_AVAILABLE,
3132
_INDEX_FILENAME,
@@ -258,7 +259,8 @@ def download_file(self, remote_filepath: str, local_filepath: str) -> None:
258259
ExtraArgs=extra_args,
259260
Config=TransferConfig(use_threads=False),
260261
)
261-
print("DOWNLOAD TIME", time() - t0)
262+
if _DEBUG:
263+
print("DOWNLOAD TIME", time() - t0)
262264

263265
def download_bytes(self, remote_filepath: str, offset: int, length: int, local_chunkpath: str) -> bytes:
264266
obj = parse.urlparse(remote_filepath)

src/litdata/streaming/item_loader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def load_item_from_chunk(
222222
if (time() - start_time) > _MAX_WAIT_TIME:
223223
raise FileNotFoundError(f"The {chunk_filepath} hasn't been found.")
224224

225-
if time() - start_time > 5:
225+
if _DEBUG and time() - start_time > 5:
226226
print("WAIT TIME", time() - start_time)
227227

228228
self._chunk_filepath = chunk_filepath
@@ -340,7 +340,8 @@ def delete(self, chunk_index: int, chunk_filepath: str) -> None:
340340
)
341341
)
342342
if os.path.exists(chunk_filepath):
343-
print(f"delete_chunk_{chunk_index}")
343+
if _DEBUG:
344+
print(f"delete_chunk_{chunk_index}")
344345
os.remove(chunk_filepath)
345346
logger.debug(
346347
_get_log_msg(

src/litdata/streaming/reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(
8383
num_bytes_per_nodes = self._config.num_bytes // self._distributed_env.num_nodes
8484
self._delete_chunks_when_processed = num_bytes_per_nodes > max_cache_size if max_cache_size else False
8585

86-
if distributed_env.global_rank == 0 and self._worker_env.rank == 0:
86+
if _DEBUG and distributed_env.global_rank == 0 and self._worker_env.rank == 0:
8787
print(f"Delete chunks when used: {self._delete_chunks_when_processed}")
8888

8989
self._has_exited = False

0 commit comments

Comments
 (0)