Skip to content

Commit

Permalink
fix: Retry OnnxHub call to improve test reliability (#1889)
Browse files Browse the repository at this point in the history
  • Loading branch information
svotaw authored Mar 24, 2023
1 parent 979c629 commit 52919ce
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ class ONNXHub(val modelCacheDir: Path,
}

private def toStream(url: URL) = {
val urlCon = url.openConnection()
urlCon.setConnectTimeout(connectTimeout)
urlCon.setReadTimeout(readTimeout)
new BufferedInputStream(urlCon.getInputStream)
FaultToleranceUtils.retryWithTimeout(retryCount, Duration.apply(retryTimeoutInSeconds, "sec")) {
val urlCon = url.openConnection()
urlCon.setConnectTimeout(connectTimeout)
urlCon.setReadTimeout(readTimeout)
new BufferedInputStream(urlCon.getInputStream)
}
}

def listModels(repo: String = ONNXHub.DefaultRepo,
Expand Down

0 comments on commit 52919ce

Please sign in to comment.