Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "beam-client"
version = "0.2.204"
version = "0.2.206"
description = ""
authors = ["beam.cloud <[email protected]>"]
packages = [
Expand All @@ -10,9 +10,10 @@ packages = [

[tool.poetry.dependencies]
python = "^3.8"
packaging = ">=24.0"
requests = "^2.31.0"
websockets = ">=13,<16"
beta9 = "^0.1.262"
beta9 = "^0.1.264"

[tool.poetry.group.dev.dependencies]
pytest = "^8.1.1"
Expand Down
17 changes: 12 additions & 5 deletions python/src/beam/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@ def check_version():
if current_version >= minimum_version:
return

# Use the interpreter that is running the Beam CLI. A bare `pip` executable
# may belong to a different Python installation, leaving this CLI unchanged.
upgrade_command = f'"{sys.executable}" -m pip install --upgrade beam-client'

click.echo(
(
f"{click.style('Update Required', fg='yellow', bold=True)}\n\n"
f"Your current version: {click.style(str(current_version), bold=True)}\n"
f"Minimum required version: {click.style(str(minimum_version), fg='yellow', bold=True)}\n"
"\nPlease upgrade to the latest version.\n"
f" {click.style('pip install --upgrade beam-client', bold=True)}\n"
f"{click.style('Beam CLI update required', fg='yellow', bold=True)}\n\n"
f"Installed: {click.style(str(current_version), bold=True)}\n"
f"Minimum: {click.style(str(minimum_version), fg='yellow', bold=True)}\n"
f"Python: {sys.executable}\n"
"\nUpgrade this installation (not a different `pip` on your PATH):\n"
f" {click.style(upgrade_command, bold=True)}\n"
"\nThen verify:\n"
f" {click.style('beam --version', bold=True)}\n"
)
)

Expand Down
31 changes: 31 additions & 0 deletions python/tests/cli/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys

import pytest

from beam.cli import utils


class FakeResponse:
def raise_for_status(self):
pass

def json(self):
return {"version": "0.2.202"}


def test_check_version_upgrades_the_python_environment_running_beam(monkeypatch, capsys):
monkeypatch.setattr(utils.requests, "get", lambda *args, **kwargs: FakeResponse())
monkeypatch.setattr(utils.metadata, "version", lambda package: "0.2.191")
monkeypatch.setattr(sys, "executable", "/opt/Beam Client/bin/python")

with pytest.raises(SystemExit) as exc_info:
utils.check_version()

assert exc_info.value.code == 1
output = capsys.readouterr().out
assert "Beam CLI update required" in output
assert "Installed: 0.2.191" in output
assert "Minimum: 0.2.202" in output
assert "Python: /opt/Beam Client/bin/python" in output
assert '"/opt/Beam Client/bin/python" -m pip install --upgrade beam-client' in output
assert "beam --version" in output
Loading