brainlit icon indicating copy to clipboard operation
brainlit copied to clipboard

Cannot download .swc files for axon_geometry experiments

Open mlemyco opened this issue 4 years ago • 7 comments

Trying to run download_segments.py but it's not downloading the appropriate files: this loop and this loop do nothing

Successfully makes the directories but does not download anything.

mlemyco avatar Feb 24 '21 21:02 mlemyco

weird, it works for me.

If I remember correctly, you are on windows, while jacopo and i are on mac. Maybe it has something to do with paths. For example, the "prefix" variable might use backslashes for you, when it may be necessary to use forward slashes for bucket.objects.filter(Prefix=prefix) to work. Can you try hard coding the path "s3://open-neurodata/brainlit/axon_geometry/brain1/segments_swc/" and seeing what happens? Is this what your script uses for the prefix variable?

tathey1 avatar Feb 24 '21 21:02 tathey1

Hi! Thank you for reporting this issue.

It seems to be working on my laptop, so it could be an AWS initialization/authorization error.

Could you please provide the console output when you try and run download_segments.py? Do you see any warning messages regarding AWS/S3 initialization?

One other thing that you could try to do is add

 print(list(bucket.objects.filter(Prefix=prefix)))

before the for loop you mentioned. You should be getting an output similar to

[s3.ObjectSummary(bucket_name='open-neurodata', key='brainlit/axon_geometry/brain1/segments_swc/2018-08-01_G-002_consensus.swc'), s3.ObjectSummary(bucket_name='open-neurodata', key='brainlit/axon_geometry/brain1/segments_swc/2018-08-01_G-007_consensus.swc'), s3.ObjectSummary(bucket_name='open-neurodata', key='brainlit/axon_geometry/brain1/segments_swc/2018-08-01_G-011_consensus.swc'), s3.ObjectSummary(bucket_name='open-neurodata', key='brainlit/axon_geometry/brain1/segments_swc/2018-08-01_G-012_consensus.swc'), s3.ObjectSummary(bucket_name='open-neurodata', key='brainlit/axon_geometry/brain1/segments_swc/2018-08-01_G-013_consensus.swc'), s3.ObjectSummary(bucket_name='open-neurodata', key='brainlit/axon_geometry/brain1/segments_swc/2018-08-01_G-014_consensus.swc'), s3.ObjectSummary(bucket_name='open-neurodata', key='brainlit/axon_geometry/brain1/segments_swc/2018-08-01_G-020_consensus.swc'), ...

As Thommy pointed out, it is probably a Windows/Mac difference in how os.path.join concatenates paths.

JacopoTeneggi avatar Feb 24 '21 21:02 JacopoTeneggi

Hi, thank you for the guidance!

This is the console output when I try to run download_segments.py with the print statement:

Downloading segments to C:\Users\mycol\OneDrive\Documents\GitHub\neurodata\brainlit\experiments\axon_geometry\data
[]
[]

No warnings--simply those 3 lines. The output is the same when I try hardcoding the path into the prefix variable.

This is the output when I add a couple more print statements to see what prefix and seg_dir are:

Downloading segments to C:\Users\mycol\OneDrive\Documents\GitHub\neurodata\brainlit\experiments\axon_geometry\data
prefix - brainlit\axon_geometry\brain1\segments_swc
seg_dir - C:\Users\mycol\OneDrive\Documents\GitHub\neurodata\brainlit\experiments\axon_geometry\data\brain1\segments_swc
[]
prefix - brainlit\axon_geometry\brain2\segments_swc
seg_dir - C:\Users\mycol\OneDrive\Documents\GitHub\neurodata\brainlit\experiments\axon_geometry\data\brain2\segments_swc
[]

Do you possibly see anything wrong?

mlemyco avatar Mar 02 '21 06:03 mlemyco

what about if you use forward slashes for prefix instead of backslashes?

i.e. prefix = "brainlit/axon_geometry/brain1/segments_swc"

tathey1 avatar Mar 02 '21 13:03 tathey1

Oof, I completely forgot to change the backslashes to forward slashes when I hardcoded the path in. That worked! It downloaded all the files now--thank you so much!

mlemyco avatar Mar 02 '21 23:03 mlemyco

@JacopoTeneggi Any reason why we need to use os.path to make the s3 path? Can prefix just be hardcorded?

tathey1 avatar Mar 03 '21 14:03 tathey1

Yes it definitely can, and should

JacopoTeneggi avatar Mar 03 '21 14:03 JacopoTeneggi

Stale issue message

github-actions[bot] avatar Feb 11 '23 19:02 github-actions[bot]