From 592615ff511987f9d3a0009aad5407c1fd72c059 Mon Sep 17 00:00:00 2001 From: pculbertson-bdai Date: Wed, 3 Jul 2024 15:43:59 -0400 Subject: [PATCH] Make `awscli` an optional dependency (#3279) * removed awscli from deps + added warning during attempted download. * update docs to flag manual awscli install to users. * add awscli to dev dependencies * add proper awscli error handling to ns-download-data * minor typing fix for ns-download-data when awscli is not installed --- docs/quickstart/existing_dataset.md | 8 +++++ nerfstudio/scripts/downloads/download_data.py | 33 +++++++++++++++++-- nerfstudio/scripts/downloads/eyeful_tower.py | 8 ++++- pyproject.toml | 2 +- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/docs/quickstart/existing_dataset.md b/docs/quickstart/existing_dataset.md index 81ae0ebcd..1aea4f285 100644 --- a/docs/quickstart/existing_dataset.md +++ b/docs/quickstart/existing_dataset.md @@ -17,6 +17,7 @@ ns-download-data blender ns-download-data nerfstudio --capture-name nerfstudio-dataset # Download a few room-scale scenes from the EyefulTower dataset at different resolutions +pip install awscli # Install `awscli` for EyefulTower downloads. ns-download-data eyefultower --capture-name riverview seating_area apartment --resolution-name jpeg_1k jpeg_2k # Download the full D-NeRF dataset of dynamic synthetic scenes @@ -87,3 +88,10 @@ In the tables below, each dataset was placed into a bucket based on the table's [record3d]: https://record3d.app/ [sdfstudio]: https://github.com/autonomousvision/sdfstudio/blob/master/docs/sdfstudio-data.md#Existing-dataset [sitcoms3d]: https://github.com/ethanweber/sitcoms3D/blob/master/METADATA.md + +### Eyeful Tower +Downloading Eyeful Tower scenes requires installing the AWS CLI, an optional dependency. To do so, run: +```bash +conda activate nerfstudio +pip install awscli +``` diff --git a/nerfstudio/scripts/downloads/download_data.py b/nerfstudio/scripts/downloads/download_data.py index cb0865119..5c976ba16 100644 --- a/nerfstudio/scripts/downloads/download_data.py +++ b/nerfstudio/scripts/downloads/download_data.py @@ -32,7 +32,6 @@ import tyro from typing_extensions import Annotated from nerfstudio.process_data import process_data_utils -from nerfstudio.scripts.downloads.eyeful_tower import EyefulTowerDownload from nerfstudio.scripts.downloads.utils import DatasetDownload from nerfstudio.utils import install_checks from nerfstudio.utils.scripts import run_command @@ -551,10 +550,40 @@ Commands = Union[ Annotated[SDFstudioDemoDownload, tyro.conf.subcommand(name="sdfstudio")], Annotated[NeRFOSRDownload, tyro.conf.subcommand(name="nerfosr")], Annotated[Mill19Download, tyro.conf.subcommand(name="mill19")], - Annotated[EyefulTowerDownload, tyro.conf.subcommand(name="eyefultower")], ] +@dataclass +class NotInstalled(DatasetDownload): + def main(self) -> None: ... + + +# Add eyefultower subcommand if awscli is installed. +try: + import awscli +except ImportError: + awscli = None + +if awscli is not None: + from nerfstudio.scripts.downloads.eyeful_tower import EyefulTowerDownload + + Commands = Union[ + Commands, + Annotated[EyefulTowerDownload, tyro.conf.subcommand(name="eyefultower")], + ] +else: + Commands = Union[ + Commands, + Annotated[ + NotInstalled, + tyro.conf.subcommand( + name="eyefultower", + description="**Not installed.** Downloading EyefulTower data requires `pip install awscli`.", + ), + ], + ] + + def main( dataset: DatasetDownload, ): diff --git a/nerfstudio/scripts/downloads/eyeful_tower.py b/nerfstudio/scripts/downloads/eyeful_tower.py index 56a05c7ca..d4b1d7628 100644 --- a/nerfstudio/scripts/downloads/eyeful_tower.py +++ b/nerfstudio/scripts/downloads/eyeful_tower.py @@ -16,15 +16,21 @@ import collections import copy import json +import sys import xml.etree.ElementTree as ET from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING, Tuple -import awscli.clidriver import numpy as np import tyro +try: + import awscli.clidriver +except ImportError: + print("awscli is required for EyefulTower download. Please install it with `pip install awscli`.") + sys.exit(1) + from nerfstudio.scripts.downloads.utils import DatasetDownload from nerfstudio.utils.rich_utils import CONSOLE diff --git a/pyproject.toml b/pyproject.toml index 6bcde5153..499815b3e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ classifiers = [ dependencies = [ "appdirs>=1.4", "av>=9.2.0", - "awscli>=1.31.10", "comet_ml>=3.33.8", "cryptography>=38", "tyro>=0.6.6", @@ -104,6 +103,7 @@ dev = [ "projectaria-tools>=1.3.1; sys_platform != 'win32'", # pin torch to <=2.1 to fix https://github.com/pytorch/pytorch/issues/118736 "torch>=1.13.1,<2.2", + "awscli==1.33.18" ] # Documentation related packages