From df77e3bc601f57372b4c26cf6a96fb2af6f51a38 Mon Sep 17 00:00:00 2001 From: Sergey Mezentsev Date: Fri, 1 Mar 2024 19:50:46 +0300 Subject: [PATCH 1/2] Failed test_non_zero_cost shows filename --- .github/workflows/catalogs.yml | 5 +++++ src/integrity_tests/test_all.py | 23 +++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/catalogs.yml b/.github/workflows/catalogs.yml index d4c3e8a..731dd0c 100644 --- a/.github/workflows/catalogs.yml +++ b/.github/workflows/catalogs.yml @@ -9,6 +9,11 @@ on: schedule: - cron: '0 1 * * *' # 01:00 UTC every day +env: + PIP_DISABLE_PIP_VERSION_CHECK: on + PIP_DEFAULT_TIMEOUT: 10 + PIP_PROGRESS_BAR: off + jobs: catalog-aws: name: Collect AWS catalog diff --git a/src/integrity_tests/test_all.py b/src/integrity_tests/test_all.py index 02b3ac6..5c6f5b4 100644 --- a/src/integrity_tests/test_all.py +++ b/src/integrity_tests/test_all.py @@ -1,19 +1,22 @@ import csv +import os from pathlib import Path -from typing import List import pytest +files = sorted(Path(os.environ["CATALOG_DIR"]).glob("*.csv")) -@pytest.fixture -def catalog_files(catalog_dir: Path) -> List[Path]: - return list(catalog_dir.glob("*.csv")) + +def catalog_name(catalog) -> str: + return catalog.name class TestAllCatalogs: - def test_non_zero_cost(self, catalog_files: List[Path]): - for file in catalog_files: - with open(file, "r") as f: - reader = csv.DictReader(f) - prices = [float(row["price"]) for row in reader] - assert 0 not in prices + @pytest.fixture(params=files, ids=catalog_name) + def catalog(self, request): + yield request.param + + def test_non_zero_cost(self, catalog): + reader = csv.DictReader(catalog.open()) + for row in reader: + assert float(row["price"]) != pytest.approx(0), str(row) From 97c1e9919ee8d5af0a825eb1eeb04a0c6f17b45d Mon Sep 17 00:00:00 2001 From: Sergey Mezentsev Date: Fri, 1 Mar 2024 19:52:00 +0300 Subject: [PATCH 2/2] Skip instances with 0 price in azure --- src/gpuhunt/providers/azure.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gpuhunt/providers/azure.py b/src/gpuhunt/providers/azure.py index bd7fae4..e9c167d 100644 --- a/src/gpuhunt/providers/azure.py +++ b/src/gpuhunt/providers/azure.py @@ -1,5 +1,6 @@ import json import logging +import math import os import re import time @@ -146,10 +147,13 @@ def get( continue if not item["armSkuName"]: continue + price = float(item["retailPrice"]) + if math.isclose(price, 0): + continue offer = RawCatalogItem( instance_name=item["armSkuName"], location=item["armRegionName"], - price=item["retailPrice"], + price=price, spot="Spot" in item["meterName"], cpu=None, memory=None,