Skip to content
Snippets Groups Projects
Unverified Commit eadd2e3e authored by Henri Menke's avatar Henri Menke
Browse files

Run `ruff check . --fix --unsafe-fixes`

parent 17fae376
No related branches found
No related tags found
1 merge request!136Add additional checks to ruff
......@@ -127,22 +127,21 @@ def get_release_info(mpsd_release: str, root_dir: Path) -> Tuple[str, str, List[
f"{folders.release_base_dir} does not exist.\n"
f"Hint: `prepare {mpsd_release}` may fix this."
)
with os_chdir(folders.release_base_dir):
with os_chdir("spack-environments"):
# Get the branch and commit hash of the spack-environments repo
spe_commit_hash = (
run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=True)
.stdout.decode()
.strip()
)
spe_branch = (
run(
["git", "rev-parse", "--abbrev-ref", "HEAD"],
stdout=subprocess.PIPE,
check=True,
)
.stdout.decode()
.strip()
with os_chdir(folders.release_base_dir), os_chdir("spack-environments"):
# Get the branch and commit hash of the spack-environments repo
spe_commit_hash = (
run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=True)
.stdout.decode()
.strip()
)
spe_branch = (
run(
["git", "rev-parse", "--abbrev-ref", "HEAD"],
stdout=subprocess.PIPE,
check=True,
)
available_package_sets = os.listdir("toolchains")
.stdout.decode()
.strip()
)
available_package_sets = os.listdir("toolchains")
return spe_branch, spe_commit_hash, available_package_sets
......@@ -27,15 +27,14 @@ def pretty_print_spec(spec: str) -> None:
prev_colour = ""
for flag in colour_map.keys():
for flag in colour_map:
# If the flag is in the spec string,
# replace it with: previous closing colour, new colour, flag
if flag in spec:
if (
colour_map[flag] not in prev_colour
): # avoid duplicates for eg when having both ~ and +
spec = spec.replace(flag, f"{prev_colour}[{colour_map[flag]}]{flag}", 1)
prev_colour = f"[/{colour_map[flag]}]" # for next iter
if flag in spec and (
colour_map[flag] not in prev_colour
): # avoid duplicates for eg when having both ~ and +
spec = spec.replace(flag, f"{prev_colour}[{colour_map[flag]}]{flag}", 1)
prev_colour = f"[/{colour_map[flag]}]" # for next iter
# Add the final closing tag to the spec string
spec += prev_colour
......
......@@ -5,7 +5,7 @@ import subprocess
import time
def run(*args, counter=[0], **kwargs):
def run(*args, counter=None, **kwargs):
"""
Run a subprocess and log the call.
......@@ -53,6 +53,8 @@ def run(*args, counter=[0], **kwargs):
"""
# token is printed in front of every meta-data line - useful for
# searching the logs. Starts with "##-00", then "##-01", ...
if counter is None:
counter = [0]
token = f"##-{counter[0]:02d}"
counter[0] += 1 # increase counter
......
......@@ -85,7 +85,7 @@ def create_fake_environment():
spe_folder = tmp_path / mpsd_release / "spack-environments"
spe_folder.mkdir(parents=True, exist_ok=True)
for microarch in expected_toolchain_map.keys():
for microarch in expected_toolchain_map:
toolchain_lmod_folder = (
tmp_path / mpsd_release / microarch / "lmod" / "Core" / "toolchains"
)
......
......@@ -33,7 +33,7 @@ def test_environment_status(
# check that the environment status is is correct
toolchain_map = status.environment_status(mpsd_release, tmp_path)
# convert each list to a set to ensure that the order doesn't matter
for microarch in expected_toolchain_map.keys():
for microarch in expected_toolchain_map:
assert set(toolchain_map[microarch]) == set(expected_toolchain_map[microarch])
# 3) If mpsd_release and toolchain, list available packages
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment