Skip to content

Commit

Permalink
download: clean after aws
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Dec 15, 2023
1 parent 17fc0e8 commit 6ef25a4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions happypose/toolbox/utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
logger = get_logger(__name__)

MIRRORS = {
"wired": "https://aws-w.saurel.me/",
"eduroam": "https://aws.saurel.me/",
"inria": "https://www.paris.inria.fr/archive_ylabbeprojectsdata/",
"laas": "https://gepettoweb.laas.fr/data/happypose/",
"bop": "https://bop.felk.cvut.cz/media/data/bop_datasets/",
Expand Down Expand Up @@ -353,7 +351,7 @@ async def adownload(self, download_path, local_path, flags=None):
for mirror in self.mirrors:
dl = mirror + download_path
try:
await asyncio.sleep(random.randint(1, 5))
await asyncio.sleep(random.uniform(0, 3))
head = await self.client.head(dl)
except (httpx.PoolTimeout, httpx.ReadTimeout, httpx.ConnectTimeout):
continue
Expand All @@ -375,7 +373,7 @@ async def adownload(self, download_path, local_path, flags=None):

async def download_dir(self, download_path, local_path, flags):
try:
await asyncio.sleep(random.randint(1, 5))
await asyncio.sleep(random.uniform(0, 3))
r = await self.client.get(download_path)
except (httpx.PoolTimeout, httpx.ReadTimeout, httpx.ConnectTimeout):
logger.error(f"Failed {download_path} with GET timeout")
Expand Down Expand Up @@ -408,7 +406,7 @@ async def download_file(self, download_path, local_path):
# logger.info(f"Existing {download_path=}")
local_size = local_path.stat().st_size
try:
await asyncio.sleep(random.randint(1, 5))
await asyncio.sleep(random.uniform(0, 3))
head = await self.client.head(download_path)
except (httpx.PoolTimeout, httpx.ReadTimeout, httpx.ConnectTimeout):
logger.error(f"Failed {download_path} with HEAD timeout")
Expand All @@ -423,7 +421,7 @@ async def download_file(self, download_path, local_path):
local_path.parent.mkdir(parents=True, exist_ok=True)
with local_path.open("wb") as f:
try:
await asyncio.sleep(random.randint(5, 20))
await asyncio.sleep(random.uniform(5, 10))
async with self.client.stream("GET", download_path) as r:
total = None
if "Content-Length" in r.headers:
Expand Down

0 comments on commit 6ef25a4

Please sign in to comment.