cboettig / minioclient

R Interface to the MINIO client
https://cboettig.github.io/minioclient/
Other
22 stars 3 forks source link

mc fails with tag set #11

Closed asitemade4u closed 12 months ago

asitemade4u commented 12 months ago

Hi, And thank you for the package which is very useful!

I have an issue with mc.

mio_tag <- function(thepth = "", thekey = "", theval = "") {
    if (stringr::str_length(thekey) > 2) {
        minioclient::mc(command = glue::glue('tag set {thepth} "{thekey}={theval}"'))
    }
}

I have followed the syntax of the native function in mc, mc tag set. For example, with test values as:

    thepth <- paste0(bkttst)
    thekey <- "tst"
    theval <- "test"

my function outputs this command in Minio's mc, which seems valid to me:

tag set mio/play-rcpgpefnjwks "tst=test"

Yet, I get this execution error:

! System command 'mc' failed
---
Exit status: 1
Stderr:
mc: <ERROR> Failed to set tags for http://192.168.1.221:9000/play-rcpgpefnjwks. The TagKey you have provided is invalid.

What am I doing wrong? S.

cboettig commented 12 months ago

thanks for the bug report! I'll take a look.

cboettig commented 12 months ago

Can you try the dev version? I think this was fixed in https://github.com/cboettig/minioclient/pull/7 but not yet released to CRAN. (Will try and prep a CRAN release now!)

asitemade4u commented 12 months ago

Hi Carl, And many thanks for the prompt response. Unfortunately, the last version (which I installed by executing remotes::install_github("cboettig/minioclient")) did not change the outcome. S.

cboettig commented 12 months ago

can you give me a reprex? I see:

library(minioclient)

mc_mb("play/test-tag")
#> Bucket created successfully `play/test-tag`.
mc("tag set play/test-tag key=value", verbose = TRUE)
#> Tags set for https://play.min.io/test-tag.

Created on 2023-11-05 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.1 (2023-06-16) #> os Ubuntu 22.04.3 LTS #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Etc/UTC #> date 2023-11-05 #> pandoc 3.1.1 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> cli 3.6.1 2023-03-23 [1] RSPM (R 4.3.0) #> digest 0.6.33 2023-07-07 [1] RSPM (R 4.3.0) #> evaluate 0.21 2023-05-05 [1] RSPM (R 4.3.0) #> fastmap 1.1.1 2023-02-24 [1] RSPM (R 4.3.0) #> fs 1.6.3 2023-07-20 [1] RSPM (R 4.3.0) #> glue 1.6.2 2022-02-24 [1] RSPM (R 4.3.0) #> htmltools 0.5.6 2023-08-10 [1] RSPM (R 4.3.0) #> knitr 1.44 2023-09-11 [1] RSPM (R 4.3.0) #> lifecycle 1.0.3 2022-10-07 [1] RSPM (R 4.3.0) #> minioclient * 0.0.6 2023-11-05 [1] local #> processx 3.8.2 2023-06-30 [1] RSPM (R 4.3.0) #> ps 1.7.5 2023-04-18 [1] RSPM (R 4.3.0) #> R6 2.5.1 2021-08-19 [1] RSPM (R 4.3.0) #> reprex 2.0.2 2022-08-17 [1] RSPM (R 4.3.0) #> rlang 1.1.1 2023-04-28 [1] RSPM (R 4.3.0) #> rmarkdown 2.25 2023-09-18 [1] RSPM (R 4.3.0) #> rstudioapi 0.15.0 2023-07-07 [1] RSPM (R 4.3.0) #> sessioninfo 1.2.2 2021-12-06 [1] RSPM (R 4.3.0) #> withr 2.5.2 2023-10-30 [1] RSPM (R 4.3.0) #> xfun 0.40 2023-08-09 [1] RSPM (R 4.3.0) #> yaml 2.3.7 2023-01-23 [1] RSPM (R 4.3.0) #> #> [1] /usr/local/lib/R/site-library #> [2] /usr/local/lib/R/library #> #> ────────────────────────────────────────────────────────────────────────────── ```
asitemade4u commented 12 months ago

Here you go:

bkttst <- paste0(sample(letters, 12, replace = TRUE), collapse = "") %>%
    paste0("mio/play-", .)
minioclient::mc_mb(bkttst, verbose = TRUE)
system(command = "touch /tmp/test.csv")
minioclient::mc_cp("/tmp/test.csv", bkttst, recursive = TRUE, verbose = TRUE)
thekey <- "tst"
theval <- "test"
minioclient::mc(command = glue::glue('tag set {bkttst}/test.csv "{thekey}={theval}"'))
asitemade4u commented 12 months ago

Basically:

  1. I create a bucket with a random name into a Minio server aliased as mio
  2. I create an empty csv file
  3. I copy the csv file to the bucket
  4. I then try to add a tag to the file > error

The only external thing I need in the reprex is the alias of the Minio server, mio in that case. Please change it for something you have on your side.

asitemade4u commented 12 months ago

Oh sorry, I did not know about the package reprex... Is what I sent enough for you?

cboettig commented 12 months ago

@asitemade4u apologies I was unclear. Can you

a. Test my reprex above for you and let me know precisely what output you see. As you see in my example above, that works for me.

b. Can you please provide the output of sessionInfo() or sessioninfo::sessioninfo() so we know the version of the packages and operating system details you are running? Again, you can see an example of my session info in my reprex above.

c. You did the right thing to install the dev version from github. please confirm you also restarted your R session after doing that, otherwise you would still be running the old version.

d. I did run the code you gave above without any issue. Note that I modified it slightly, it really helps to use the play alias that ships with the minio client. Technically your code above is not a "reprex" example because it implicitly assumes that the alias mio exists, which is not accurate. However, it runs fine for me with the default test alias:

library(minioclient)
library(magrittr)
bkttst <- paste0(sample(letters, 12, replace = TRUE), collapse = "") %>%
  paste0("play/play-", .)
minioclient::mc_mb(bkttst, verbose = TRUE)
#> Bucket created successfully `play/play-njmnrivqubcx`.
system(command = "touch /tmp/test.csv")
minioclient::mc_cp("/tmp/test.csv", bkttst, recursive = TRUE, verbose = TRUE)
#> `/tmp/test.csv` -> `play/play-njmnrivqubcx/test.csv`
#> Total: 0 B, Transferred: 0 B, Speed: 0 B/s
thekey <- "tst"
theval <- "test"
minioclient::mc(command = glue::glue('tag set {bkttst}/test.csv "{thekey}={theval}"'))

Created on 2023-11-05 with reprex v2.0.2

Note the footer included by the reprex R package -- I know it's a bit pedantic but using the 'reprex' facility in R helps make sure you are sharing copy-paste examples that a developer can run.

I could reproduce your issue on the CRAN version, but it is resolved for me on the dev version, so I can only guess that perhaps you did not restart the R session and didn't get the dev version? Do try the minimal example I sent above

library(minioclient)

mc_mb("play/test-tag")
#> Bucket created successfully `play/test-tag`.
mc("tag set play/test-tag key=value", verbose = TRUE)
#> Tags set for https://play.min.io/test-tag.

and do tell me the sessionInfo() output.

asitemade4u commented 12 months ago

OK, here are my answers:

  1. Your reprex indeed works here too
  2. I am executing R from CodeServer. I had restarted CodeServer between sessions and I have again a minute ago.
  3. I still face the issue when executing my code though.
  4. Here is the outcome of sessioninfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=C.UTF-8    LC_NUMERIC=C       
 [3] LC_TIME=C           LC_COLLATE=C       
 [5] LC_MONETARY=C       LC_MESSAGES=C      
 [7] LC_PAPER=C          LC_NAME=C          
 [9] LC_ADDRESS=C        LC_TELEPHONE=C     
[11] LC_MEASUREMENT=C    LC_IDENTIFICATION=C

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils    
[5] datasets  methods   base     

other attached packages:
 [1] yaml_2.3.7        utf8_1.2.3       
 [3] tibble_3.2.1      sys_3.4.2        
 [5] stringr_1.5.0     stringi_1.7.12   
 [7] RMariaDB_1.2.2    rlang_1.1.1      
 [9] readr_2.1.4.9000  purrr_1.0.2      
[11] minioclient_0.0.5 jsonlite_1.8.7   
[13] httr_1.4.7.9000   hms_1.1.3.9002   
[15] dplyr_1.1.3       DBI_1.1.3        
[17] data.table_1.14.8 curl_5.1.0       
[19] magrittr_2.0.3    glue_1.6.2       

loaded via a namespace (and not attached):
 [1] crayon_1.5.2      vctrs_0.6.3      
 [3] cli_3.6.1         processx_3.8.2   
 [5] generics_0.1.3    bit_4.0.5        
 [7] ps_1.7.5          fansi_1.0.5      
 [9] tzdb_0.4.0        lifecycle_1.0.3  
[11] config_0.3.2.9000 compiler_4.3.1   
[13] sessioninfo_1.2.2 fs_1.6.3         
[15] Rcpp_1.0.11       pkgconfig_2.0.3  
[17] R6_2.5.1          tidyselect_1.2.0 
[19] pillar_1.9.0      tools_4.3.1      
[21] bit64_4.0.5 
asitemade4u commented 12 months ago

When I execute my code modified by you, ie:

library(minioclient)
library(magrittr)
bkttst <- paste0(sample(letters, 12, replace = TRUE), collapse = "") %>%
  paste0("play/play-", .)
minioclient::mc_mb(bkttst, verbose = TRUE)
#> Bucket created successfully `play/play-njmnrivqubcx`.
system(command = "touch /tmp/test.csv")
minioclient::mc_cp("/tmp/test.csv", bkttst, recursive = TRUE, verbose = TRUE)
#> `/tmp/test.csv` -> `play/play-njmnrivqubcx/test.csv`
#> Total: 0 B, Transferred: 0 B, Speed: 0 B/s
thekey <- "tst"
theval <- "test"
minioclient::mc(command = glue::glue('tag set {bkttst}/test.csv "{thekey}={theval}"'))

I get the exact same error as before. That is weird because I do not get it with the simpler code from the reprex, ie:

mc_mb("play/test-tag")
#> Bucket created successfully `play/test-tag`.
mc("tag set play/test-tag key=value", verbose = TRUE)
#> Tags set for https://play.min.io/test-tag.
asitemade4u commented 12 months ago

Please notice that in your reprex you are assigning the tag to a BUCKET, not to a file. Maybe the issue occurs only when assigning tags to files...

asitemade4u commented 12 months ago

And yet, when I execute my+your code after transforming it to tag the bucket, ie:

library(minioclient)
library(magrittr)
bkttst <- paste0(sample(letters, 12, replace = TRUE), collapse = "") %>%
  paste0("play/play-", .)
minioclient::mc_mb(bkttst, verbose = TRUE)
thekey <- "tst"
theval <- "test"
minioclient::mc(command = glue::glue('tag set {bkttst} "{thekey}={theval}"'))

I still get the error.

asitemade4u commented 12 months ago

Also, I just noticed that in the sessioninfo dump, minioclient's version is still 0.0.5. Have you changed the version in the GitHub repo or am I wrong when I say I installed the last version?

asitemade4u commented 12 months ago

As a test, I will:

  1. uninstall the package altogether
  2. install the dev version
  3. restart the session
  4. and test again.
cboettig commented 12 months ago

All looks good. Note in the failing reprex you still have version 0.0.5.

Please ensure you use the dev version, which should be 0.0.6

I think that should resolve the issue

On Sun, Nov 5, 2023 at 4:03 PM Stephen S. @.***> wrote:

Please notice that in your reprex you are assigning the tag to a BUCKET, not to a file. Maybe the issue occurs only when assigning tags to files...

— Reply to this email directly, view it on GitHub https://github.com/cboettig/minioclient/issues/11#issuecomment-1793890468, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABWK6WFQSH4QKXQC3AKK7LYDALKZAVCNFSM6AAAAAA66TDQYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTHA4TANBWHA . You are receiving this because you commented.Message ID: @.***>

asitemade4u commented 12 months ago

APOLOGIES!!! I must have messed up because I did as above and IT WORKS. I am ashamed of having wasted your time like that... S.

asitemade4u commented 12 months ago

At least, I have learned about reprex...

cboettig commented 12 months ago

no worries, we've all been there! these things are so often more confusing than they look! Learning tools like reprex & sessionInfo() do help a lot though!