Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed dataset download re-linking. #1989

Merged
merged 4 commits into from
Feb 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions src_python/habitat_sim/utils/datasets_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,33 +697,35 @@ def main(args):
args = parser.parse_args(args)
replace = args.replace

# get a default data_path "./data/"
data_path = args.data_path
if not data_path:
try:
data_path = os.path.abspath("./data/")
print(
f"No data-path provided, default to: {data_path}. Use '--data-path' to specify another location."
)
if not os.path.exists(data_path):
os.makedirs(data_path)
except Exception:
traceback.print_exc(file=sys.stdout)
print("----------------------------------------------------------------")
print(
"Aborting download, failed to create default data_path and none provided."
)
print("Try providing --data-path (e.g. '/path/to/habitat-sim/data/')")
print("----------------------------------------------------------------")
parser.print_help()
exit(2)
default_data_path = "./data"
data_path = os.path.realpath(
args.data_path if args.data_path else default_data_path
)
if not args.data_path:
print(
f"No data-path provided, defaults to: {default_data_path}. Use '--data-path' to specify another location."
)
if os.path.islink(default_data_path):
print(f"Note, {default_data_path} is a symbolic link that points to {data_path}.")

try:
os.makedirs(data_path, exist_ok=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of errors can arise here? I think it would just be permission errors?
What is the advantage of printing these messages over just raising the error?

Copy link
Collaborator Author

@rpartsey rpartsey Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I didn't ask myself these questions during fixing, but it seems to me that this is a "graceful way" to exit a program. Exceptions should be raised on program errors. Here everything is fine, user specified wrong path and we inform him about it. Why the program should fail with exception?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rpartsey probably should still be restricted to IOException? LIke no reason to catch SystemError exceptions from Python etc.

except Exception:
traceback.print_exc(file=sys.stdout)
print("----------------------------------------------------------------")
print(
"Aborting download, failed to create data_path."
)
print("Try providing --data-path (e.g. '/path/to/habitat-sim/data/')")
print("----------------------------------------------------------------")
parser.print_help()
exit(2)

# initialize data_sources and data_groups with test and example assets
os.makedirs(data_path, exist_ok=True)
data_path = os.path.abspath(data_path) + "/"
initialize_test_data_sources(data_path=data_path)

# validatation: ids are unique between groups and sources
# validation: ids are unique between groups and sources
for key in data_groups:
assert key not in data_sources, "Duplicate key: " + key

Expand Down