Skip to content

Commit

Permalink
Fix cloud instance name conflict
Browse files Browse the repository at this point in the history
This would prevent the CI or multiple contributors to run tests with the same config
  • Loading branch information
satyaog committed Apr 15, 2024
1 parent 4ccea23 commit e8d0084
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions milabench/cli/cloud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from copy import deepcopy
import os
import socket
import subprocess
import sys

Expand All @@ -8,6 +9,7 @@
import yaml

from milabench.fs import XPath
from milabench.utils import blabla

from ..common import get_multipack

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions milabench/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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)
Expand Down

0 comments on commit e8d0084

Please sign in to comment.