Skip to content

Commit

Permalink
fix: allow LANCE_LOG to be set to trace (#3246)
Browse files Browse the repository at this point in the history
Since we are now sharing `LANCE_LOG` with python logging and rust
logging it was erroring out when the log level was set to `trace` since
`trace` is not a valid python logging level.

In addition, I fix up the wording for the batch size, recognizing the
fact that `CoalesceBatchesExec` (which we use in some filtering
situations) could lead to batches larger than `batch_size`.
  • Loading branch information
westonpace authored Dec 16, 2024
1 parent 1a12c21 commit 7fe14ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion python/python/lance/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ def scanner(
}
batch_size: int, default None
The max size of batches returned.
The target size of batches returned. In some cases batches can be up to
twice this size (but never larger than this). In some cases batches can
be smaller than this size.
io_buffer_size: int, default None
The size of the IO buffer. See ``ScannerBuilder.io_buffer_size``
for more information.
Expand Down
9 changes: 8 additions & 1 deletion python/python/lance/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
ENV_NAME_PYLANCE_LOGGING_LEVEL = "LANCE_LOG"


# Rust has 'trace' and Python does not so we map it to 'debug'
def get_python_log_level(rust_log_level: str) -> str:
if rust_log_level.lower() == "trace":
return "DEBUG"
return rust_log_level


def get_log_level():
lance_log_level = os.environ.get(ENV_NAME_PYLANCE_LOGGING_LEVEL, "INFO").upper()
if lance_log_level == "":
Expand All @@ -17,7 +24,7 @@ def get_log_level():
entry for entry in lance_log_level.split(",") if "=" not in entry
]
if len(lance_log_level) > 0:
return lance_log_level[0]
return get_python_log_level(lance_log_level[0])
else:
return "INFO"

Expand Down

0 comments on commit 7fe14ea

Please sign in to comment.