OpenScope databook: a collaborative, versioned, data-centric collection of foundational analyses for reproducible systems neuroscience šš§ š¬š„ļøš
The notebook mentions that "If you want to just download all the files within a directory of the dandiset, you can set the first argument of download_directory below to a more specific path within the dandiset."
It would be useful to provide an example. This doesn't work (but does not return an error):
my_ds = client.get_dandiset(dandiset_id)
for asset_dir in my_ds.get_assets():
print(f"Downloading {asset_dir.path}")
try:
my_ds.download_directory(asset_dir.path, f"{download_loc}/{dandiset_id}")
except Exception as e:
print(f"Error downloading {asset_dir.path}: {e}")
I also tried with os.path.join("./", asset_dir.path).
The more standard approach works, however:
for asset_dir in my_ds.get_assets():
filename = asset_dir.path.split("/")[-1]
filepath = f"{download_loc}/{asset_dir.path}"
if not os.path.exists(os.path.dirname(filepath)):
os.makedirs(os.path.dirname(filepath), exist_ok=True)
file = my_ds.get_asset_by_path(asset_dir.path)
try:
print(f"Downloading {asset_dir.path}")
file.download(filepath)
print(f"Downloaded file to {filepath}")
except Exception as e:
print(f"Error downloading {asset_dir.path}: {e}")
The notebook mentions that "If you want to just download all the files within a directory of the dandiset, you can set the first argument of download_directory below to a more specific path within the dandiset." It would be useful to provide an example. This doesn't work (but does not return an error):
I also tried with
os.path.join("./", asset_dir.path)
.The more standard approach works, however: