Skip to content

Commit

Permalink
Docker-python fix for get_ubuntu_version() (ultralytics#4430)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored Aug 17, 2023
1 parent 9d27e7a commit 162e403
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
docker push ultralytics/ultralytics:${{ matrix.tags }}
- name: Notify on failure
if: github.event_name == 'push' && (cancelled() || failure())
if: github.event_name == 'push' && failure() # do not notify on cancelled() as cancelling is performed by hand
uses: slackapi/[email protected]
with:
payload: |
Expand Down
4 changes: 1 addition & 3 deletions tests/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,8 @@ def test_events():


def test_utils_init():
from ultralytics.utils import (get_git_branch, get_git_origin_url, get_ubuntu_version, is_github_actions_ci,
is_ubuntu)
from ultralytics.utils import get_git_branch, get_git_origin_url, get_ubuntu_version, is_github_actions_ci

is_ubuntu()
get_ubuntu_version()
is_github_actions_ci()
get_git_origin_url()
Expand Down
4 changes: 3 additions & 1 deletion ultralytics/engine/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ def export_ncnn(self, prefix=colorstr('ncnn:')):
'https://github.com/pnnx/pnnx/.\nNote PNNX Binary file must be placed in current working directory '
f'or in {ROOT}. See PNNX repo for full installation instructions.')
_, assets = get_github_assets(repo='pnnx/pnnx', retry=True)
asset = [x for x in assets if ('macos' if MACOS else 'ubuntu' if LINUX else 'windows') in x][0]
system = 'macos' if MACOS else 'ubuntu' if LINUX else 'windows' # operating system
asset = [x for x in assets if system in x][0] if assets else \
f'https://github.com/pnnx/pnnx/releases/download/20230816/pnnx-20230816-{system}.zip' # fallback
attempt_download_asset(asset, repo='pnnx/pnnx', release='latest')
unzip_dir = Path(asset).with_suffix('')
pnnx = ROOT / pnnx_filename # new location
Expand Down
7 changes: 4 additions & 3 deletions ultralytics/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,10 @@ def get_ubuntu_version():
Returns:
(str): Ubuntu version or None if not an Ubuntu OS.
"""
with contextlib.suppress(FileNotFoundError, AttributeError):
with open('/etc/os-release') as f:
return re.search(r'VERSION_ID="(\d+\.\d+)"', f.read())[1]
if is_ubuntu():
with contextlib.suppress(FileNotFoundError, AttributeError):
with open('/etc/os-release') as f:
return re.search(r'VERSION_ID="(\d+\.\d+)"', f.read())[1]


def get_user_config_dir(sub_dir='Ultralytics'):
Expand Down

0 comments on commit 162e403

Please sign in to comment.