Closed stevepowell99 closed 4 months ago
Sorry about that can you share the versions of paws.storage
and paws.common
.
paws.storage version 0.6.0 paws version 0.6.0 paws.common version 0.7.2 thanks
R version 4.3.3
Hmm I am currently unable to replicate:
library(paws)
Bucket <- "paws-delete"
Key <- "demo-file.txt"
client <- s3(config(credentials(profile = "paws")))
client$create_bucket(
Bucket = Bucket
)
#> $Location
#> [1] "/paws-delete"
resp <- client$put_bucket_versioning(
Bucket = Bucket,
VersioningConfiguration=list(
Status = "Enabled"
)
)
resp <- client$put_object(
Bucket = Bucket,
Key = Key,
Body = charToRaw("helloworld")
)
client$list_object_versions(
Bucket,
Prefix = Key,
MaxKeys=10
)$Versions
#> [[1]]
#> [[1]]$ETag
#> [1] "\"fc5e038d38a57032085441e7fe7010b0\""
#>
#> [[1]]$ChecksumAlgorithm
#> list()
#>
#> [[1]]$Size
#> [1] 10
#>
#> [[1]]$StorageClass
#> [1] "STANDARD"
#>
#> [[1]]$Key
#> [1] "demo-file.txt"
#>
#> [[1]]$VersionId
#> [1] "tr254HqS3q0PvX7NHWhuIS.qhL3KMMPe"
#>
#> [[1]]$IsLatest
#> [1] TRUE
#>
#> [[1]]$LastModified
#> [1] "2024-05-13 14:55:47 GMT"
#>
#> [[1]]$Owner
#> [[1]]$Owner$DisplayName
#> [1] "dyfan.r.jones"
#>
#> [[1]]$Owner$ID
#> [1] "b3f6bed018b0c5c65f68de63469c0b80f9cde5fb347710d610f837a735773e0f"
#>
#>
#> [[1]]$RestoreStatus
#> [[1]]$RestoreStatus$IsRestoreInProgress
#> logical(0)
#>
#> [[1]]$RestoreStatus$RestoreExpiryDate
#> POSIXct of length 0
resp <- client$list_object_versions(Bucket, Prefix = Key) |>
paginate_lapply(\(resp){
list(
Objects = lapply(resp$Versions, \(r) {
list(
Key = r$Key,
VersionId = r$VersionId
)
})
)
},
PageSize = 1000
)
for (i in resp) client$delete_objects(Bucket, Delete = i)
client$delete_bucket(Bucket)
#> list()
Created on 2024-05-13 with reprex v2.1.0
I will down grade my R to see if it is a R version issue.
It seems to work fine on R 4.3.3
library(paws)
Bucket <- "paws-delete"
Key <- "demo-file.txt"
client <- s3(config(credentials(profile = "paws")))
client$create_bucket(
Bucket = Bucket
)
#> $Location
#> [1] "/paws-delete"
resp <- client$put_bucket_versioning(
Bucket = Bucket,
VersioningConfiguration=list(
Status = "Enabled"
)
)
for (i in 1:3) {
resp <- client$put_object(
Bucket = Bucket,
Key = Key,
Body = charToRaw("helloworld")
)
}
client$list_object_versions(
Bucket,
Prefix = Key,
MaxKeys=10
)$Versions
#> [[1]]
#> [[1]]$ETag
#> [1] "\"fc5e038d38a57032085441e7fe7010b0\""
#>
#> [[1]]$ChecksumAlgorithm
#> list()
#>
#> [[1]]$Size
#> [1] 10
#>
#> [[1]]$StorageClass
#> [1] "STANDARD"
#>
#> [[1]]$Key
#> [1] "demo-file.txt"
#>
#> [[1]]$VersionId
#> [1] "IxkANu3PhsWk7m3rxGprmLjN_gC1x6w7"
#>
#> [[1]]$IsLatest
#> [1] TRUE
#>
#> [[1]]$LastModified
#> [1] "2024-05-13 15:03:17 GMT"
#>
#> [[1]]$Owner
#> [[1]]$Owner$DisplayName
#> [1] "dyfan.r.jones"
#>
#> [[1]]$Owner$ID
#> [1] "b3f6bed018b0c5c65f68de63469c0b80f9cde5fb347710d610f837a735773e0f"
#>
#>
#> [[1]]$RestoreStatus
#> [[1]]$RestoreStatus$IsRestoreInProgress
#> logical(0)
#>
#> [[1]]$RestoreStatus$RestoreExpiryDate
#> POSIXct of length 0
#>
#>
#>
#> [[2]]
#> [[2]]$ETag
#> [1] "\"fc5e038d38a57032085441e7fe7010b0\""
#>
#> [[2]]$ChecksumAlgorithm
#> list()
#>
#> [[2]]$Size
#> [1] 10
#>
#> [[2]]$StorageClass
#> [1] "STANDARD"
#>
#> [[2]]$Key
#> [1] "demo-file.txt"
#>
#> [[2]]$VersionId
#> [1] "K8v3VJHiPeOonYzU.yUf7h8Iq4cndsqo"
#>
#> [[2]]$IsLatest
#> [1] FALSE
#>
#> [[2]]$LastModified
#> [1] "2024-05-13 15:03:16 GMT"
#>
#> [[2]]$Owner
#> [[2]]$Owner$DisplayName
#> [1] "dyfan.r.jones"
#>
#> [[2]]$Owner$ID
#> [1] "b3f6bed018b0c5c65f68de63469c0b80f9cde5fb347710d610f837a735773e0f"
#>
#>
#> [[2]]$RestoreStatus
#> [[2]]$RestoreStatus$IsRestoreInProgress
#> logical(0)
#>
#> [[2]]$RestoreStatus$RestoreExpiryDate
#> POSIXct of length 0
#>
#>
#>
#> [[3]]
#> [[3]]$ETag
#> [1] "\"fc5e038d38a57032085441e7fe7010b0\""
#>
#> [[3]]$ChecksumAlgorithm
#> list()
#>
#> [[3]]$Size
#> [1] 10
#>
#> [[3]]$StorageClass
#> [1] "STANDARD"
#>
#> [[3]]$Key
#> [1] "demo-file.txt"
#>
#> [[3]]$VersionId
#> [1] "CgcVhSCXmAKeH4kVjjOPltkCFUrn2gac"
#>
#> [[3]]$IsLatest
#> [1] FALSE
#>
#> [[3]]$LastModified
#> [1] "2024-05-13 15:03:16 GMT"
#>
#> [[3]]$Owner
#> [[3]]$Owner$DisplayName
#> [1] "dyfan.r.jones"
#>
#> [[3]]$Owner$ID
#> [1] "b3f6bed018b0c5c65f68de63469c0b80f9cde5fb347710d610f837a735773e0f"
#>
#>
#> [[3]]$RestoreStatus
#> [[3]]$RestoreStatus$IsRestoreInProgress
#> logical(0)
#>
#> [[3]]$RestoreStatus$RestoreExpiryDate
#> POSIXct of length 0
resp <- client$list_object_versions(Bucket, Prefix = Key) |>
paginate_lapply(\(resp){
list(
Objects = lapply(resp$Versions, \(r) {
list(
Key = r$Key,
VersionId = r$VersionId
)
})
)
},
PageSize = 1000
)
for (i in resp) client$delete_objects(Bucket, Delete = i)
client$delete_bucket(Bucket)
#> list()
Created on 2024-05-13 with reprex v2.1.0
I wonder if it is an os issue 🤔 . @stevepowell99 what os are you using? A reprex
would be perfect :)
yes I used your reprex and can save the file (versions) but get this:
> client$list_object_versions(
+ Bucket,
+ Prefix = Key,
+ MaxKeys=10
+ )$Versions
list()
(I wasn't able to create a bucket with the reprex, I got IllegalLocationConstraintException
but used an existing bucket which has versioning enabled:
> client$get_bucket_versioning(Bucket)
$Status
[1] "Enabled"
$MFADelete
character(0)
then ran the put_object loop and can see the versions in the AWS console. Just not with list_object_versions
I am on Windows 11 build 22621.3447
Does the code work with paws.common 0.7.1?
Hmm it is still working on my windows machine 🤔 (please see results below with session information). @stevepowell99 What AWS region are you working with? I am struggling to replicate your issue.
library(paws)
Bucket <- "paws-delete"
Key <- "demo-file.txt"
client <- s3()
client$create_bucket(
Bucket = Bucket
)
#> $Location
#> [1] "/paws-delete"
resp <- client$put_bucket_versioning(
Bucket = Bucket,
VersioningConfiguration=list(
Status = "Enabled"
)
)
for (i in 1:2) {
resp <- client$put_object(
Bucket = Bucket,
Key = Key,
Body = charToRaw("helloworld")
)
}
client$list_object_versions(
Bucket,
Prefix = Key,
MaxKeys=10
)$Versions
#> [[1]]
#> [[1]]$ETag
#> [1] "\"fc5e038d38a57032085441e7fe7010b0\""
#>
#> [[1]]$ChecksumAlgorithm
#> list()
#>
#> [[1]]$Size
#> [1] 10
#>
#> [[1]]$StorageClass
#> [1] "STANDARD"
#>
#> [[1]]$Key
#> [1] "demo-file.txt"
#>
#> [[1]]$VersionId
#> [1] "ZINUI6lTmZLPTmZqePIYyNdDuB7K9VyK"
#>
#> [[1]]$IsLatest
#> [1] TRUE
#>
#> [[1]]$LastModified
#> [1] "2024-05-13 21:41:47 GMT"
#>
#> [[1]]$Owner
#> [[1]]$Owner$DisplayName
#> [1] "dyfan.r.jones"
#>
#> [[1]]$Owner$ID
#> [1] "b3f6bed018b0c5c65f68de63469c0b80f9cde5fb347710d610f837a735773e0f"
#>
#>
#> [[1]]$RestoreStatus
#> [[1]]$RestoreStatus$IsRestoreInProgress
#> logical(0)
#>
#> [[1]]$RestoreStatus$RestoreExpiryDate
#> POSIXct of length 0
#>
#>
#>
#> [[2]]
#> [[2]]$ETag
#> [1] "\"fc5e038d38a57032085441e7fe7010b0\""
#>
#> [[2]]$ChecksumAlgorithm
#> list()
#>
#> [[2]]$Size
#> [1] 10
#>
#> [[2]]$StorageClass
#> [1] "STANDARD"
#>
#> [[2]]$Key
#> [1] "demo-file.txt"
#>
#> [[2]]$VersionId
#> [1] "5kr9RxpImTrNtuE60Zo7cl3ai2bGXX.0"
#>
#> [[2]]$IsLatest
#> [1] FALSE
#>
#> [[2]]$LastModified
#> [1] "2024-05-13 21:41:47 GMT"
#>
#> [[2]]$Owner
#> [[2]]$Owner$DisplayName
#> [1] "dyfan.r.jones"
#>
#> [[2]]$Owner$ID
#> [1] "b3f6bed018b0c5c65f68de63469c0b80f9cde5fb347710d610f837a735773e0f"
#>
#>
#> [[2]]$RestoreStatus
#> [[2]]$RestoreStatus$IsRestoreInProgress
#> logical(0)
#>
#> [[2]]$RestoreStatus$RestoreExpiryDate
#> POSIXct of length 0
resp <- client$list_object_versions(Bucket, Prefix = Key) |>
paginate_lapply(\(resp){
list(
Objects = lapply(resp$Versions, \(r) {
list(
Key = r$Key,
VersionId = r$VersionId
)
})
)
},
PageSize = 1000
)
for (i in resp) client$delete_objects(Bucket, Delete = i)
client$delete_bucket(Bucket)
#> list()
Created on 2024-05-13 with reprex v2.1.0
tx
I tried installing devtools::install_github("paws-r/paws@v0.7.1")
but this did not work (got a 404).
so I am using 0.7.2
my config.r has aws: AWS_ACCESS_KEY_ID: "xxx" AWS_SECRET_ACCESS_KEY: "xxx" AWS_REGION: "eu-west-2" AWS_DEFAULT_REGION: "eu-west-2"
so first part of my reprex:
library(paws)
library(configr)
config = configr::read.config("config.yml")$default
Sys.setenv(AWS_ACCESS_KEY_ID = config$aws$AWS_ACCESS_KEY_ID)
Sys.setenv(AWS_SECRET_ACCESS_KEY = config$aws$AWS_SECRET_ACCESS_KEY)
Sys.setenv(AWS_REGION = "eu-west-2")
Sys.setenv(AWS_DEFAULT_REGION = "eu-west-2")
Key <- "demo-file.txt"
Bucket = "deletebucketttt"
client <- paws::s3()
client$list_buckets()
# works fine, lists all buckets. I can also put and get objects
# however;
client$create_bucket(
Bucket = Bucket
)
# Error: IllegalLocationConstraintException (HTTP 400). The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
maybe this is related?
Ah my apologises I didn't include method to install paws.common 0.7.1:
remotes::install_version("paws.common", "0.7.1")
yes! It works with version 0.7.1: I can list versions. Thanks!
hmm i will have to investigate why it has started to fail with v0.7.2 and why i can't replicate it
but this will explain why it suddenly started not working, I must have somewhere updated all packages without checking.
It is interesting it didn't appear on my windows machine plus all the unit tests we are currently doing.
@stevepowell99 Does this hold true in your R environment?
x <- list(list(a = 1, b = 2), list(a = 3, b = 4), list(a = 5, b = 6))
setNames(.mapply(list, x, NULL), names(x[[1]]))
#> $a
#> $a[[1]]
#> [1] 1
#>
#> $a[[2]]
#> [1] 3
#>
#> $a[[3]]
#> [1] 5
#>
#>
#> $b
#> $b[[1]]
#> [1] 2
#>
#> $b[[2]]
#> [1] 4
#>
#> $b[[3]]
#> [1] 6
identical(
setNames(.mapply(list, x, NULL), names(x[[1]])),
purrr::list_transpose(x, simplify = F)
)
#> [1] TRUE
bench::mark(
base = setNames(.mapply(list, x, NULL), names(x[[1]])),
purrr = purrr::list_transpose(x, simplify = F)
)
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 base 1.97µs 2.38µs 370007. 0B 37.0
#> 2 purrr 55.68µs 60.93µs 16004. 0B 33.6
Created on 2024-05-14 with reprex v2.1.0
yes it is TRUE
unfortunately I now can't deploy my shiny app because I get
Error building image: Error fetching paws.compute (0.6.0) source. <CRANPackageSource repo='http://cran.rstudio.org'> unable to satisfy package: paws.compute (0.6.0)
Should I be using another version of paws.compute??
I am currently in the process of releasing 0.6.0 https://github.com/paws-r/paws/issues/776. You can use r-universe https://paws-r.r-universe.dev/builds to get the latest version.
Hmm I was thinking it would of been .mapply
that had caused the issue (https://github.com/cran/paws.common/commit/cb6efad434fa4d48bcc875e395ec22796be4900d#diff-769cd5041a0c33c7590ddc41aca9f3e5237da7c1eaeedbdfb310698a43e43727) but it doesn't look like.
I will finish release 0.6.0 and revisit this issue.
I tried uninstalling paws and paws.storage and paws.common and reinstalling from CRAN but again I can't list_versions
I have managed to replicate this issue. I will see what has caused it to fail and get it in the next paws.common release :)
I believe i have found the issue:
obj <- list(
var1 = c(1, 2, 3),
var2 = letters[1:3],
var3 = list(),
var4 = list()
)
.mapply(list, obj, NULL)
#> list()
purrr::list_transpose(obj, simplify = F)
#> [[1]]
#> [[1]]$var1
#> [1] 1
#>
#> [[1]]$var2
#> [1] "a"
#>
#> [[1]]$var3
#> NULL
#>
#> [[1]]$var4
#> NULL
#>
#>
#> [[2]]
#> [[2]]$var1
#> [1] 2
#>
#> [[2]]$var2
#> [1] "b"
#>
#> [[2]]$var3
#> NULL
#>
#> [[2]]$var4
#> NULL
#>
#>
#> [[3]]
#> [[3]]$var1
#> [1] 3
#>
#> [[3]]$var2
#> [1] "c"
#>
#> [[3]]$var3
#> NULL
#>
#> [[3]]$var4
#> NULL
transpose <- function(x) {
if (any(found <- lengths(x) == 0)) {
n_row <- length(x[[1]])
x[found] <- list(rep_len(x[found], n_row))
}
.mapply(list, x, NULL)
}
transpose(obj)
#> [[1]]
#> [[1]]$var1
#> [1] 1
#>
#> [[1]]$var2
#> [1] "a"
#>
#> [[1]]$var3
#> list()
#>
#> [[1]]$var4
#> list()
#>
#>
#> [[2]]
#> [[2]]$var1
#> [1] 2
#>
#> [[2]]$var2
#> [1] "b"
#>
#> [[2]]$var3
#> list()
#>
#> [[2]]$var4
#> list()
#>
#>
#> [[3]]
#> [[3]]$var1
#> [1] 3
#>
#> [[3]]$var2
#> [1] "c"
#>
#> [[3]]$var3
#> list()
#>
#> [[3]]$var4
#> list()
bench::mark(
purrr::list_transpose(obj, simplify = F),
transpose(obj),
check = F
)
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:t> <bch:t> <dbl> <bch:byt> <dbl>
#> 1 purrr::list_transpose(obj, simpl… 73.39µs 81.1µs 11853. 0B 36.2
#> 2 transpose(obj) 4.14µs 4.71µs 198624. 4.41MB 39.7
Created on 2024-05-15 with reprex v2.1.0
thanks so what should I do? wait for the upcoming version?
@stevepowell99 I have submitted paws.common 0.7.3 to the cran. Will let you know when it has been accepted
paws.common 0.7.3 has been released to the cran. Also paws.compute has been released to the cran
thanks! please could you clarify what is the procedure to update now on Windows? Is it to install just paws and/or paws.common and/or paws.compute and/or paws.storage?
If you update paws.common it will fix your issue. You can also update the entire SDK by update all paws packages.
Note: paws.common holds all the functionality i.e how it builds the API call (similar to botocore). The other packages create the client for each Aws service.
works perfectly 🥇 🥇 🥇
My code has included
s3$list_object_versions("bucketname",Prefix = "filename",MaxKeys=10000)$Versions
for a couple of years, all was working fine. Now I notice that this has started to return an emptylist()
. Everything else continues to work fine, I can save versions and restore versions if I know the ID of the version. Nothing has changed at my end except updated packages etc. If this isn't a known issue I will post a reprex.