Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging bug in dragon_install #761

Merged
merged 7 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Jump to:

Description

- Fix dragon build logging bug
- Merge core refactor into MLI feature branch
- Implement asynchronous notifications for shared data
- Quick bug fix in _validate
Expand Down
11 changes: 9 additions & 2 deletions smartsim/_core/_cli/scripts/dragon_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,15 @@ def filter_assets(
asset = next((asset for asset in assets if _platform_filter(asset.name)), None)

if not asset:
# there is a mismatch between the platform and the asset
asset = assets[0]
logger.warning(f"Platform-specific package not found. Using {asset.name}")
if "crayex" in asset.name.lower():
# non-Cray platform, Cray EX asset
logger.warning(f"Platform does not support Cray EX assets")
asset = None
else:
# Cray platform, non Cray EX asset
logger.warning(f"Platform-specific package not found. Using {asset.name}")

return asset

Expand All @@ -267,9 +274,9 @@ def retrieve_asset_info(request: DragonInstallRequest) -> GitReleaseAsset:

platform_result = check_platform()
if not platform_result.is_cray:
logger.warning("Installing Dragon without HSTA support")
for msg in platform_result.failures:
logger.warning(msg)
logger.warning("Installing Dragon without HSTA support")

if asset is None:
raise SmartSimCLIActionCancelled("No dragon runtime asset available to install")
Expand Down
56 changes: 56 additions & 0 deletions tests/_legacy/test_dragon_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import tarfile
import typing as t
from collections import namedtuple
from unittest.mock import MagicMock

import pytest
from github.GitRelease import GitRelease
Expand All @@ -44,6 +45,7 @@
DragonInstallRequest,
cleanup,
create_dotenv,
filter_assets,
install_dragon,
install_package,
retrieve_asset,
Expand Down Expand Up @@ -577,3 +579,57 @@ def test_create_dotenv_format(monkeypatch: pytest.MonkeyPatch, test_dir: str):
for line in lines:
line_split = line.split("=")
assert len(line_split) == 2


@pytest.mark.parametrize(
"_platform_filter_return,asset_name,returned_asset_bool",
[
pytest.param(
True,
"dragon-0.10-py3.9.4.1-CRAYEX.tar.gz",
True,
id="cray platform, crayex in name",
),
pytest.param(
False,
"dragon-0.10-py3.9.4.1-CRAYEX.tar.gz",
False,
id="non cray platform, crayex in name",
),
pytest.param(
False,
"dragon-0.10-py3.9.4.1-.tar.gz",
True,
id="cray platform, crayex not in name",
),
pytest.param(
True,
"dragon-0.10-py3.9.4.1-.tar.gz",
True,
id="non cray platform, crayex not in name",
),
],
)
def test_filter_assets(
monkeypatch, test_dir, _platform_filter_return, asset_name, returned_asset_bool
):
request = DragonInstallRequest(test_dir, version="0.10")
monkeypatch.setattr(
"smartsim._core._cli.scripts.dragon_install._platform_filter",
MagicMock(return_value=_platform_filter_return),
)
monkeypatch.setattr(
"smartsim._core._cli.scripts.dragon_install._version_filter",
MagicMock(return_value=True),
)
monkeypatch.setattr(
"smartsim._core._cli.scripts.dragon_install._pin_filter",
MagicMock(return_value=True),
)
mocked_asset = MagicMock()
mocked_asset.name = asset_name
asset = filter_assets(request, [mocked_asset])
if returned_asset_bool:
assert asset is not None
else:
assert asset is None
Loading