You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
The save_dir property in the MLFlowLogger class currently uses str.lstrip() to remove the LOCAL_FILE_URI_PREFIX ("file:") from the tracking URI. This method can unintentionally strip additional characters that match those in the prefix. For example, "file:logs" would be incorrectly modified to "ogs" because lstrip() removes all individual characters that appear in the prefix string, not just the prefix itself.
Minimal Example:
from pytorch_lightning.loggers import MLFlowLogger
logger0 = MLFlowLogger(
save_dir='logs'
)
logger1 = MLFlowLogger(
save_dir='experiments'
)
logger2 = MLFlowLogger(
save_dir='runs' # this should work, as mlflow.LOCAL_FILE_URI_PREFIX ('file:') does not contain r
)
print(logger0.save_dir) # ogs
print(logger1.save_dir) # xperiments
print(logger2.save_dir) # runs
Proposed Solutions:
For Python 3.9 and later: Utilize str.removeprefix(), which is designed to remove a specified prefix only if the string starts with it:
if self._tracking_uri.startswith(LOCAL_FILE_URI_PREFIX):
return self._tracking_uri.removeprefix(LOCAL_FILE_URI_PREFIX)
return None
For Python 3.8 and earlier: Unfortunately, str.removeprefix() was introduced with Python 3.9.0, so another approach would have to be used. One possible solution would be to simply slice off the length of the prefix.
if self._tracking_uri.startswith(LOCAL_FILE_URI_PREFIX):
return self._tracking_uri[len(LOCAL_FILE_URI_PREFIX):]
return None
What version are you seeing the problem on?
v2.4
How to reproduce the bug
No response
Error messages and logs
# Error messages and logs here please
Environment
Current environment
#- PyTorch Lightning Version (e.g., 2.4.0):
#- PyTorch Version (e.g., 2.4):
#- Python version (e.g., 3.12):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
More info
No response
The text was updated successfully, but these errors were encountered:
Bug description
Problem:
The save_dir property in the MLFlowLogger class currently uses str.lstrip() to remove the LOCAL_FILE_URI_PREFIX ("file:") from the tracking URI. This method can unintentionally strip additional characters that match those in the prefix. For example, "file:logs" would be incorrectly modified to "ogs" because lstrip() removes all individual characters that appear in the prefix string, not just the prefix itself.
Minimal Example:
Proposed Solutions:
For Python 3.9 and later: Utilize str.removeprefix(), which is designed to remove a specified prefix only if the string starts with it:
For Python 3.8 and earlier: Unfortunately, str.removeprefix() was introduced with Python 3.9.0, so another approach would have to be used. One possible solution would be to simply slice off the length of the prefix.
What version are you seeing the problem on?
v2.4
How to reproduce the bug
No response
Error messages and logs
Environment
Current environment
More info
No response
The text was updated successfully, but these errors were encountered: