-
Notifications
You must be signed in to change notification settings - Fork 117
Upgrade S3 ListObjects version, allow >1000 model files #225
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
Conversation
a90af4e to
f49bcae
Compare
| " due to exception: " + | ||
| list_objects_outcome.GetError().GetExceptionName() + | ||
| ", error message: " + | ||
| list_objects_outcome.GetError().GetMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this before the success handling, so the failure handle is a bit more obvious:
if (not_success) {
return error;
}
// Check content..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea! Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @GuanLuo means this?
while (!done_listing) {
auto list_objects_outcome = client_->ListObjectsV2(objects_request);
if (!list_objects_outcome.IsSuccess()) {
return Status(
Status::Code::INTERNAL,
"Could not list contents of directory at " + true_path +
" due to exception: " +
list_objects_outcome.GetError().GetExceptionName() +
", error message: " +
list_objects_outcome.GetError().GetMessage());
}
const auto& list_objects_result = list_objects_outcome.GetResult();
for (const auto& s3_object : list_objects_result.GetContents()) {
// In the case of empty directories, the directory itself will appear here
if (s3_object.GetKey().c_str() == full_dir) {
continue;
}
// We have to make sure that subdirectory contents do not appear here
std::string name(s3_object.GetKey().c_str());
int item_start = name.find(full_dir) + full_dir.size();
// S3 response prepends parent directory name
int item_end = name.find("/", item_start);
// Let set take care of subdirectory contents
std::string item = name.substr(item_start, item_end - item_start);
contents->insert(item);
// Fail-safe check to ensure the item name is not empty
if (item.empty()) {
return Status(
Status::Code::INTERNAL,
"Cannot handle item with empty name at " + true_path);
}
}
// If there are more pages to retrieve, set the marker to the next page.
if (list_objects_result.GetIsTruncated()) {
objects_request.SetContinuationToken(
list_objects_result.GetNextContinuationToken());
} else {
done_listing = true;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this have one less nesting for the success case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still passes CI after removing the nesting. Please review when you get a chance!
1c96d87 to
a2d86ca
Compare
This PR upgrades the version of ListObjectsRequest and ListObjectsResult, as per AWS recommendations here to switch to V2. It also enables Triton to load all files in an S3 bucket, beyond the page limit of 1000.