Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 765cfaf

Browse files
authored
Merge pull request #644 from datafold/LAB-105
poll more frequently when using --cloud
2 parents eb22d3e + 124a6e0 commit 765cfaf

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

data_diff/cloud/datafold_api.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pydantic
88
import requests
99

10-
from data_diff.errors import DataDiffDatasourceIdNotFoundError
10+
from data_diff.errors import DataDiffCloudDiffFailed, DataDiffCloudDiffTimedOut, DataDiffDatasourceIdNotFoundError
1111

1212
from ..utils import getLogger
1313

@@ -248,8 +248,8 @@ def create_data_diff(self, payload: TCloudApiDataDiff) -> int:
248248
def poll_data_diff_results(self, diff_id: int) -> TCloudApiDataDiffSummaryResult:
249249
summary_results = None
250250
start_time = time.monotonic()
251-
sleep_interval = 5 # starts at 5 sec
252-
max_sleep_interval = 30
251+
sleep_interval = 3
252+
max_sleep_interval = 20
253253
max_wait_time = 300
254254

255255
diff_url = f"{self.host}/datadiffs/{diff_id}/overview"
@@ -260,13 +260,15 @@ def poll_data_diff_results(self, diff_id: int) -> TCloudApiDataDiffSummaryResult
260260
if response_json["status"] == "success":
261261
summary_results = response_json
262262
elif response_json["status"] == "failed":
263-
raise Exception(f"Diff failed: {str(response_json)}")
263+
raise DataDiffCloudDiffFailed(f"Diff failed: {str(response_json)}")
264264

265265
if time.monotonic() - start_time > max_wait_time:
266-
raise Exception(f"Timed out waiting for diff results. Please, go to the UI for details: {diff_url}")
266+
raise DataDiffCloudDiffTimedOut(
267+
f"Timed out waiting for diff results. Please, go to the UI for details: {diff_url}"
268+
)
267269

268270
time.sleep(sleep_interval)
269-
sleep_interval = min(sleep_interval * 2, max_sleep_interval)
271+
sleep_interval = min(sleep_interval + 1, max_sleep_interval)
270272

271273
return TCloudApiDataDiffSummaryResult.from_orm(summary_results)
272274

data_diff/errors.py

+8
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ class DataDiffNoDatasourceIdError(Exception):
6060

6161
class DataDiffDatasourceIdNotFoundError(Exception):
6262
"Raised when using --cloud but the datasource_id is not found for a particular org."
63+
64+
65+
class DataDiffCloudDiffFailed(Exception):
66+
"Raised when using --cloud and the remote diff fails."
67+
68+
69+
class DataDiffCloudDiffTimedOut(Exception):
70+
"Raised when using --cloud and the diff did not return finish before the timeout value."

0 commit comments

Comments
 (0)