From 35a96ab3f0a48bc2766def0acaee483cba3434ef Mon Sep 17 00:00:00 2001 From: Bart Broere Date: Fri, 24 May 2024 08:25:04 +0200 Subject: [PATCH] Fix missing method str.removeprefix in Python 3.8 (#695) --- eland/ml/pytorch/transformers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eland/ml/pytorch/transformers.py b/eland/ml/pytorch/transformers.py index bad24d8..770e4f7 100644 --- a/eland/ml/pytorch/transformers.py +++ b/eland/ml/pytorch/transformers.py @@ -1059,5 +1059,8 @@ def elasticsearch_model_id(model_id: str) -> str: id = re.sub(r"[\s\\/]", "__", model_id).lower()[-64:] if id.startswith("__"): - id = id.removeprefix("__") + # This check is only needed as long as Eland supports Python 3.8 + # str.removeprefix was introduced in Python 3.9 and can be used + # once 3.8 support is dropped + id = id[2:] return id