Skip to content

Commit 2a33b1e

Browse files
authored
Ianmacleod/pypi version nudge (#290)
* adding pypi version bump nudge * version bump * changing naming conventions for env variable to be consistent * .
1 parent 71bf9c2 commit 2a33b1e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

clients/python/llmengine/__init__.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.0.0.beta13"
15+
__version__ = "0.0.0.b14"
1616

17+
import os
1718
from typing import Sequence
1819

20+
import requests
1921
from llmengine.completion import Completion
2022
from llmengine.data_types import (
2123
CancelFineTuneResponse,
@@ -67,3 +69,30 @@
6769
"Model",
6870
"UploadFileResponse",
6971
)
72+
73+
74+
def check_version():
75+
try:
76+
current_version = __version__
77+
response = requests.get("https://pypi.org/pypi/scale-llm-engine/json")
78+
latest_version = response.json()["info"]["version"]
79+
80+
if current_version != latest_version:
81+
print(
82+
f"A newer version ({latest_version}) of 'scale-llm-engine' is available. Please upgrade!"
83+
)
84+
print("To upgrade, run: pip install --upgrade scale-llm-engine")
85+
print(
86+
"Don't want to see this message? Set the environment variable 'LLM_ENGINE_DISABLE_VERSION_CHECK' to 'true'."
87+
)
88+
except requests.RequestException:
89+
# Handle exceptions related to the request (like timeouts, connection errors, etc.)
90+
print(
91+
"Failed to check for the most recent llm-engine package version. Please check your internet connection."
92+
)
93+
except Exception:
94+
print("Something went wrong with checking for the most recent llm-engine package version.")
95+
96+
97+
if not os.environ.get("LLM_ENGINE_DISABLE_VERSION_CHECK"):
98+
check_version()

0 commit comments

Comments
 (0)