Reformat Python code with ruff
This commit is contained in:
@@ -19,6 +19,7 @@ $ python3 upload-build-metrics.py <path-to-CPU-usage-CSV>
|
||||
|
||||
`path-to-CPU-usage-CSV` is a path to a CSV generated by the `src/ci/cpu-usage-over-time.py` script.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import csv
|
||||
import os
|
||||
@@ -31,7 +32,7 @@ from typing import List
|
||||
def load_cpu_usage(path: Path) -> List[float]:
|
||||
usage = []
|
||||
with open(path) as f:
|
||||
reader = csv.reader(f, delimiter=',')
|
||||
reader = csv.reader(f, delimiter=",")
|
||||
for row in reader:
|
||||
# The log might contain incomplete rows or some Python exception
|
||||
if len(row) == 2:
|
||||
@@ -50,25 +51,21 @@ def upload_datadog_measure(name: str, value: float):
|
||||
print(f"Metric {name}: {value:.4f}")
|
||||
|
||||
datadog_cmd = "datadog-ci"
|
||||
if os.getenv("GITHUB_ACTIONS") is not None and sys.platform.lower().startswith("win"):
|
||||
if os.getenv("GITHUB_ACTIONS") is not None and sys.platform.lower().startswith(
|
||||
"win"
|
||||
):
|
||||
# Due to weird interaction of MSYS2 and Python, we need to use an absolute path,
|
||||
# and also specify the ".cmd" at the end. See https://github.com/rust-lang/rust/pull/125771.
|
||||
datadog_cmd = "C:\\npm\\prefix\\datadog-ci.cmd"
|
||||
|
||||
subprocess.run([
|
||||
datadog_cmd,
|
||||
"measure",
|
||||
"--level", "job",
|
||||
"--measures", f"{name}:{value}"
|
||||
],
|
||||
check=False
|
||||
subprocess.run(
|
||||
[datadog_cmd, "measure", "--level", "job", "--measures", f"{name}:{value}"],
|
||||
check=False,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="DataDog metric uploader"
|
||||
)
|
||||
parser = argparse.ArgumentParser(prog="DataDog metric uploader")
|
||||
parser.add_argument("cpu-usage-history-csv")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user