Skip to content

Commit

Permalink
Use a persistent connection to Artifactory for downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
barometz committed Aug 24, 2023
1 parent a76c6a7 commit d5906aa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions voyager/artifactdownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import click
from pathlib import Path
from artifactory import ArtifactoryPath
import requests
from semver import valid_range, max_satisfying
import semver

Expand All @@ -34,6 +35,9 @@ def __init__(self, libraries: list, are_build_tools: bool, download_runtime_deps
self.build_tools = are_build_tools
self.download_runtime_deps = download_runtime_deps

self.artifactory_session = requests.Session()
self.artifactory_session.headers['X-JFrog-Art-Api'] = self.config.api_key

def clear_directory(self):
try:
shutil.rmtree(self._download_dir)
Expand Down Expand Up @@ -196,7 +200,7 @@ def find_versions_for_package(self, repo, library, override_archs):
archs = self._get_active_archs()
versions = []

path = ArtifactoryPath(self.config.artifactory_url, apikey=self.config.api_key)
path = ArtifactoryPath(self.config.artifactory_url, session=self.artifactory_session)

args = [
"items.find",
Expand Down Expand Up @@ -237,7 +241,7 @@ def _find_download_extract_package(self, repo, library, version, output_dir, ove
for arch in archs:
package_dir = f"{repo}/{library}/{version}/{arch}"
url = f"{self.config.artifactory_url}/{package_dir}/voyager_package.tgz"
path = ArtifactoryPath(url, apikey=self.config.api_key)
path = ArtifactoryPath(url, session=self.artifactory_session)

if path.exists():
click.echo(click.style(f'{arch} @ {version} ', fg='bright_blue'), nl=False)
Expand Down

0 comments on commit d5906aa

Please sign in to comment.