Skip to content

Commit

Permalink
Merge pull request #160 from nim65s/low-hanging-fruits
Browse files Browse the repository at this point in the history
Low hanging fruits
  • Loading branch information
nim65s authored Apr 29, 2024
2 parents 888f536 + e65fa4b commit da27971
Show file tree
Hide file tree
Showing 7 changed files with 384 additions and 509 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/conda-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ jobs:
refiner-bop-hope-pbr--955392
- name: Run tests
run: python -m unittest
run: |
python -m unittest
pytest
4 changes: 3 additions & 1 deletion .github/workflows/pip-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ jobs:
refiner-bop-hope-pbr--955392
- name: Run tests
run: python -m unittest
run: |
python -m unittest
pytest
10 changes: 6 additions & 4 deletions .github/workflows/poetry-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ jobs:
refiner-bop-hope-pbr--955392
- name: Run tests
run: poetry run coverage run --source=happypose -m unittest
run: |
poetry run coverage run --source=happypose -m unittest
poetry run coverage run --source=happypose -m pytest
- name: Process coverage
run: poetry run coverage xml

- uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
#- uses: codecov/codecov-action@v4
#env:
#CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def run_inference(
return data_TCO.cpu()


if __name__ == "__main__":
def main():
set_logging_level("info")
parser = argparse.ArgumentParser()
parser.add_argument("example_name")
Expand All @@ -77,7 +77,7 @@ def run_inference(
assert (
example_dir.exists()
), "Example {args.example_name} not available, follow download instructions"
dataset_to_use = args.dataset # hope/tless/ycbv
# dataset_to_use = args.dataset # hope/tless/ycbv

# Load data
detections = load_detections(example_dir).to(device)
Expand Down Expand Up @@ -118,3 +118,7 @@ def run_inference(
make_poses_visualization(
rgb, object_dataset, object_datas, camera_data, example_dir
)


if __name__ == "__main__":
main()
24 changes: 21 additions & 3 deletions happypose/toolbox/utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,20 @@ async def adownload(self, download_path, local_path, flags=None):
break
else:
err = f"Can't find mirror for {download_path}."
raise ValueError(err)
logger.warning(f"{err} -- retrying soon...")
await asyncio.sleep(random.uniform(5, 10))
for mirror in self.mirrors:
dl = mirror + download_path
try:
await asyncio.sleep(random.uniform(0, 3))
head = await self.client.head(dl)
except (httpx.PoolTimeout, httpx.ReadTimeout, httpx.ConnectTimeout):
continue
if head.is_success or head.is_redirect:
download_path = dl
break
else:
raise ValueError(err)
if (
not download_path.endswith("/")
and not httpx.head(download_path).is_redirect
Expand Down Expand Up @@ -410,8 +423,13 @@ async def download_file(self, download_path, local_path):
try:
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")
except (
httpx.PoolTimeout,
httpx.ReadTimeout,
httpx.ConnectTimeout,
httpx.RemoteProtocolError,
) as e:
logger.error(f"Failed {download_path} with {e}")
return
if "content-length" in head.headers:
if local_size == int(head.headers["content-length"]):
Expand Down
Loading

0 comments on commit da27971

Please sign in to comment.