def get_checkpoints_from_s3_path(path):
import boto3
s3_resource = boto3.resource('s3')
bucket_name, key_name = split_s3_bucket_key(path)
bucket = s3_resource.Bucket(bucket_name)
all_objects = list(bucket.objects.filter(Prefix=key_name))
all_keys = [o.key for o in all_objects]
keys = fnmatch.filter(all_keys, S3_KEY_PATTERN)
checkpoints = []
for f in keys:
try:
file_path = os.path.join(bucket_name, f)
checkpoints.append(parse_checkpoint_s3_path(file_path))
except ValueError:
continue
return sorted(checkpoints, key=lambda cp: cp.start)
评论列表
文章目录