Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rebench/rebench.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ def determine_exp_name_and_filters(filters):
f.startswith("t:"))]
return exp_name, exp_filter

def _report_completion(self):
def _report_completion(self) -> bool:
rebench_db = self._config.get_rebench_db_connector()
success, _ = rebench_db.send_completion(get_current_time())
success = rebench_db.send_completion(get_current_time())
return success

@staticmethod
Expand Down
19 changes: 10 additions & 9 deletions rebench/rebenchdb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from time import sleep
from typing import Optional, Tuple

from http.client import HTTPException
from urllib.request import urlopen, Request as HttpRequest
Expand Down Expand Up @@ -60,17 +61,17 @@ def is_api_v2(self):

return self._api_v2

def send_results(self, benchmark_data, num_items):
def send_results(self, benchmark_data, num_items) -> bool:
success, response = self._send_to_rebench_db(benchmark_data, "/results")

if success:
self.ui.verbose_output_info(
"ReBenchDB: Sent {num_i} results to ReBenchDB, response was: {resp}\n",
num_i=num_items, resp=response)

return success, response
return success

def send_completion(self, end_time):
def send_completion(self, end_time) -> bool:
success, response = self._send_to_rebench_db({"endTime": end_time}, "/completion")

if success:
Expand All @@ -82,10 +83,10 @@ def send_completion(self, end_time):
self.ui.error("Reporting completion to ReBenchDB failed.\n" +
"{ind}Error: {response}", response=response)

return success, response
return success

@staticmethod
def _send_payload(payload, url):
def _send_payload(payload, url) -> str:
req = HttpRequest(url, payload,
{'Content-Type': 'application/json'}, method='PUT')
with urlopen(req) as socket:
Expand All @@ -106,7 +107,7 @@ def _get_api_version(self):
def convert_data_to_json(self, data):
return json.dumps(data, separators=(",", ":"), ensure_ascii=True)

def _send_to_rebench_db(self, payload_data, operation):
def _send_to_rebench_db(self, payload_data, operation) -> Tuple[bool, Optional[str]]:
payload_data["projectName"] = self._project_name
payload_data["experimentName"] = self._experiment_name
url = self._server_base_url + operation
Expand All @@ -119,8 +120,8 @@ def _send_to_rebench_db(self, payload_data, operation):

return self._send_with_retries(payload.encode("utf-8"), url)

def _send_with_retries(self, payload_bytes, url):
attempts = 4
def _send_with_retries(self, payload_bytes, url) -> Tuple[bool, Optional[str]]:
attempts = 10
wait_sec = 10
while True:
try:
Expand All @@ -143,7 +144,7 @@ def _send_with_retries(self, payload_bytes, url):
+ "{ind}{ind}" + str(error) + "\n")
attempts -= 1
sleep(wait_sec)
wait_sec *= 2
wait_sec = min(wait_sec * 2, 5 * 60)
else:
self.ui.error("{ind}Error: Reporting to ReBenchDB failed.\n"
+ "{ind}{ind}" + str(error) + "\n")
Expand Down
Loading