From e8d0084c289127e41aa6a688c66d5d0c28f5e742 Mon Sep 17 00:00:00 2001 From: Satya Ortiz-Gagne Date: Mon, 15 Apr 2024 15:54:46 -0400 Subject: [PATCH] Fix cloud instance name conflict This would prevent the CI or multiple contributors to run tests with the same config --- docs/usage.rst | 4 ++++ milabench/cli/cloud.py | 8 ++++++-- milabench/common.py | 6 +++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index 76aed5934..b2a25d85d 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -140,6 +140,10 @@ supported cloud profiles. username: ubuntu size: Standard_B2ats_v2 location: eastus2 + # state_prefix and state_id can be set to force a specific cloud + # instance id + # state_prefix: cloud-ci + # state_id: 849897_bivunaku Run milabench on the cloud diff --git a/milabench/cli/cloud.py b/milabench/cli/cloud.py index 150e37749..8d95a47d1 100644 --- a/milabench/cli/cloud.py +++ b/milabench/cli/cloud.py @@ -1,5 +1,6 @@ from copy import deepcopy import os +import socket import subprocess import sys @@ -8,6 +9,7 @@ import yaml from milabench.fs import XPath +from milabench.utils import blabla from ..common import get_multipack @@ -42,6 +44,8 @@ def manage_cloud(pack, run_on, action="setup"): plan_params = deepcopy(pack.config["system"]["cloud_profiles"][run_on]) run_on, *profile = run_on.split("__") profile = profile[0] if profile else "" + default_state_prefix = profile or run_on + default_state_id = "_".join((pack.config["hash"][:6], blabla())) remote_base = XPath("/data") / pack.dirs.base.name local_base = pack.dirs.base.absolute().parent @@ -51,8 +55,8 @@ def manage_cloud(pack, run_on, action="setup"): if n["ip"] != "1.1.1.1": continue - plan_params["state_prefix"] = plan_params.get("state_prefix", None) or profile or run_on - plan_params["state_id"] = plan_params.get("state_id", None) or pack.config["hash"] + plan_params["state_prefix"] = plan_params.get("state_prefix", default_state_prefix) + plan_params["state_id"] = plan_params.get("state_id", default_state_id) plan_params["cluster_size"] = max(len(pack.config["system"]["nodes"]), i + 1) import milabench.cli.covalent as cv diff --git a/milabench/common.py b/milabench/common.py index ff0388df2..1f22463b6 100644 --- a/milabench/common.py +++ b/milabench/common.py @@ -338,9 +338,9 @@ def _push_reports(reports_repo, runs): reports_repo = git.repo.base.Repo.clone_from(repo_url, str(reports_repo), branch="reports") reports_url = ([ - _r.url for _r in _repo.remotes if "mila-iqia" in _r.url + url for _r in _repo.remotes for url in _r.urls if "mila-iqia" in url ] or [ - _r.url for _r in _repo.remotes if _r.name == "origin" + url for _r in _repo.remotes for url in _r.urls if _r.name == "origin" ])[0] reports_url = XPath("github.com".join(reports_url.split("github.com")[1:])[1:]) reports_url = XPath("https://github.com") / f"{reports_url.with_suffix('')}/tree/{reports_repo.active_branch.name}" @@ -363,7 +363,7 @@ def _push_reports(reports_repo, runs): device = _meta["cpu"]["brand"].replace(" ", "_") break - build = "-".join([_repo.active_branch.name.replace(os.path.sep, "_"), next(_repo.iter_commits()).hexsha]) + build = meta[0]["milabench"]["tag"] reports_dir = XPath(reports_repo.working_tree_dir) / build run = XPath(run)