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

[BUG] Fixes to S3 Native Lister with correct Error propagation #1401

Merged
merged 3 commits into from
Sep 21, 2023

Conversation

samster25
Copy link
Member

@samster25 samster25 commented Sep 21, 2023

  • Fixes s3 listing infinte loop
  • correct error propagation in the recursive file lister
  • return directories in the recursive file lister
  • Fixes bug when you pass in an exact file
  • Adds tests to cover the above cases
  • Adds s3fs recursive lister utility

@github-actions github-actions bot added the bug Something isn't working label Sep 21, 2023
@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Merging #1401 (325bc33) into main (ad81ae2) will increase coverage by 0.01%.
Report is 2 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1401      +/-   ##
==========================================
+ Coverage   87.78%   87.80%   +0.01%     
==========================================
  Files          60       60              
  Lines        6036     6041       +5     
==========================================
+ Hits         5299     5304       +5     
  Misses        737      737              
Files Changed Coverage Δ
daft/api_annotations.py 89.06% <100.00%> (+0.92%) ⬆️

@samster25 samster25 changed the title [BUG] Sammy/fix s3 native list [BUG] Fixes to S3 Native Lister with correct Error propagation Sep 21, 2023
@samster25 samster25 merged commit 2bb2aa4 into main Sep 21, 2023
31 checks passed
@samster25 samster25 deleted the sammy/fix-s3-native-list branch September 21, 2023 22:38
FileType::File => tx.send(tr).await.unwrap(),
FileType::Directory => add_to_channel(source.clone(), tx.clone(), tr.filepath),
};
let tr = tr;
Copy link
Contributor

Choose a reason for hiding this comment

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

This line appears to be redundant now.

Copy link
Member Author

Choose a reason for hiding this comment

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

.map(|k| k.strip_suffix('/').unwrap_or(k));
let key = key.unwrap_or("");

let key = key.strip_prefix('/').unwrap_or("");
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm this seems like this will coerce the key to an empty string if it doesn't have a "/" prefix (i.e. if it isn't a base URL); for example, it appears that "foo/bar" would be coerced to "". Do we have a guarantee that all provided URLs will contain base URLs when URL-parsed?

Shouldn't this be .unwrap_or(key) just to be safe?

Copy link
Member Author

Choose a reason for hiding this comment

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

The UrlParse library leaves the prefix when your parse the url so "foo/bar" is hostname="foo", key="/bar". so if theres no prefix then it means it's an empty string.

} else {
let key = key.strip_suffix('/').unwrap_or(key);
format!("{key}/")
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this might be more simply expressed as:

let key = key.strip_prefix('/').unwrap_or(key);
let key = if !key.ends_with('/') { format!("{key}/") } else { key };

Copy link
Member Author

Choose a reason for hiding this comment

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

What I wanted to take care of here is to drop trailing slashes but ensure that there's atleast one. looks like the right call was actually trim_** in https://github.com/Eventual-Inc/Daft/pull/1404/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants