Closed oobianom closed 2 weeks ago
I suspected that this might happen. NOTHING is reliable online in terms of web pages. I don't even trust the Wayback machine. This is quite irritating to say the least.
I am going to have to conduct additional research on this issue to resolve. For now, my recommendation is to remove the genRandImg from the next version of quickcode.
I am requesting that you get this next version out as soon as possible in that I will be heavily relying (and waiting) on some of the latest functions to be included in my R monitoring tool.
This issue irritated me so bad that I decided to fix the damn breakage in the link. Unsplash is washed up as far as I'm concerned.
The code below is the proposed replacement for the genRandImg function:
genRandImg = function (fp, n = 1, w.px = 500, h.px = 500,
ext = "jpg", paths = FALSE)
{
if (!dir.exists(fp))
stop(paste0("The directory path declared in the 'fp' argument must exist."))
if (n > 99) {
warning("The value of n exceeds 99, so n was set to 99")
n <- 99L
}
checksum.files <- c()
downloaded.files <- c()
while (n > 0) {
file.store <- file.path(fp, paste0("img_", randString(1, 5), n, ".", ext))
download.file(url = paste0("https://picsum.photos/", w.px, "/", h.px), destfile = file.store, mode = "wb")
Sys.sleep(1)
checksum <- as.vector(tools::md5sum(file.store))
if (checksum %in% checksum.files) {
unlink(file.store)
}
else {
vector_push(checksum.files, checksum)
vector_push(downloaded.files, file.store)
minus(n)
}
}
message(paste0("Downloaded ", length(downloaded.files), " files to ",
fp))
if (paths)
gsub("\\\\", "/", downloaded.files)
}
SUPPLEMENTAL NOTES: The cat argument was removed as it doesn't apply nor is it available to the updated URL used. Some testing was conducted on the function but additional testing should also be initiated.
I am also NOT interested in applying a mandated API just to download an image. Using APIs in R functions in a publicly available package is a security risk to say the least. Using an API would mean that YOU would have to use YOUR account access to provide access to others for functionality. That is a non-starter.
The code I've offered does NOT use NOR does it require an API.
CAVEAT If this damn URL gets changed or breaks, there are two more options that can be explored that would definitely work. However, an additional breakage, if it occurs, will ensure that I will be finished with future mitigations for this function. It's irritating beyond words that 1) the damn link doesn't work for whatever reason, and 2) that the lack of websites available to facilitate such a simple request for downloading random images is a joke. It took me longer to find the damn URL than it did to modify the damn function.
Thanks for the quick turnaround on this, Brice. Yes, this too is the reason I don't like to use other people's stuff (websites, packages and so on) in developing my packages because once something goes wrong, my package is affected. I had already submitted the 0.9 version with a message in the current genRandImg function. Basically, I noted that we may either deprecate or update the function for version 1.0
I provided the quick turnaround so that you could get the package published and out, with the remediated function.
I am hoping it will be approved, assuming you resubmitted it, so that it will be made available by tomorrow am.
From: Obi Obianom @.> Sent: Sunday, June 30, 2024 9:10 PM To: oobianom/quickcode @.> Cc: brichard1638 @.>; Comment @.> Subject: Re: [oobianom/quickcode] genRandImg links to Unsplash.com severed due to change in API call (Issue #32)
Thanks for the quick turnaround on this, Brice. Yes, this too is the reason I don't like to use other people's stuff (websites, packages and so on) in developing my packages because once something goes wrong, my package is affected. I had already submitted the 0.9 version with a message in the current genRandImg function. Basically, I noted that we may either deprecate or update the function for version 1.0
— Reply to this email directly, view it on GitHubhttps://github.com/oobianom/quickcode/issues/32#issuecomment-2198857308, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASLI5UPZYUN5HAZGCB32I2TZKCUBJAVCNFSM6AAAAABKEHCATGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYHA2TOMZQHA. You are receiving this because you commented.Message ID: @.***>
One more thought here. There's actually a way to generate random images using an R package itself.
So, if this URL issue gets too frenetic, I will reconstruct the function once and for all with a workaround that does NOT rely on a URL.
From: Obi Obianom @.> Sent: Sunday, June 30, 2024 9:10 PM To: oobianom/quickcode @.> Cc: brichard1638 @.>; Comment @.> Subject: Re: [oobianom/quickcode] genRandImg links to Unsplash.com severed due to change in API call (Issue #32)
Thanks for the quick turnaround on this, Brice. Yes, this too is the reason I don't like to use other people's stuff (websites, packages and so on) in developing my packages because once something goes wrong, my package is affected. I had already submitted the 0.9 version with a message in the current genRandImg function. Basically, I noted that we may either deprecate or update the function for version 1.0
— Reply to this email directly, view it on GitHubhttps://github.com/oobianom/quickcode/issues/32#issuecomment-2198857308, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASLI5UPZYUN5HAZGCB32I2TZKCUBJAVCNFSM6AAAAABKEHCATGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYHA2TOMZQHA. You are receiving this because you commented.Message ID: @.***>
One more option to consider: I mean, this function is a really interesting and compelling function in my opinion. I don't want to lose it. Here's my proposal...if you are interested, I can send you a few thousand or more images that are ROYALTY free, and you can store them perhaps on your https://quickcode.obi.obianom.com/ site and we can just reference images in a folder there. I can reconstruct the algorithm so that it uses an RNG to pull the images, assuming there is a specific naming convention that compliments the RNG.
For example, img0001, 0002, etc. The RNG will extract random images based on the numeric values.
I can also send you AI-generated images which would be something unprecedented for use in R. I have a "forever" membership with a generative AI company in Canada where I can produce images all day every day if needed. Of course, all of these images are royalty free.
Your thoughts?
From: Obi Obianom @.> Sent: Sunday, June 30, 2024 9:10 PM To: oobianom/quickcode @.> Cc: brichard1638 @.>; Comment @.> Subject: Re: [oobianom/quickcode] genRandImg links to Unsplash.com severed due to change in API call (Issue #32)
Thanks for the quick turnaround on this, Brice. Yes, this too is the reason I don't like to use other people's stuff (websites, packages and so on) in developing my packages because once something goes wrong, my package is affected. I had already submitted the 0.9 version with a message in the current genRandImg function. Basically, I noted that we may either deprecate or update the function for version 1.0
— Reply to this email directly, view it on GitHubhttps://github.com/oobianom/quickcode/issues/32#issuecomment-2198857308, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASLI5UPZYUN5HAZGCB32I2TZKCUBJAVCNFSM6AAAAABKEHCATGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYHA2TOMZQHA. You are receiving this because you commented.Message ID: @.***>
If you are unable to publish the latest version of quickcode to CRAN due to the frailties of the genRandImg function, my recommendation would be to remove it and move to publish ASAP.
From: Brice Richard @.> Sent: Sunday, June 30, 2024 10:21 PM To: oobianom/quickcode @.> Subject: Re: [oobianom/quickcode] genRandImg links to Unsplash.com severed due to change in API call (Issue #32)
One more option to consider: I mean, this function is a really interesting and compelling function in my opinion. I don't want to lose it. Here's my proposal...if you are interested, I can send you a few thousand or more images that are ROYALTY free, and you can store them perhaps on your https://quickcode.obi.obianom.com/ site and we can just reference images in a folder there. I can reconstruct the algorithm so that it uses an RNG to pull the images, assuming there is a specific naming convention that compliments the RNG.
For example, img0001, 0002, etc. The RNG will extract random images based on the numeric values.
I can also send you AI-generated images which would be something unprecedented for use in R. I have a "forever" membership with a generative AI company in Canada where I can produce images all day every day if needed. Of course, all of these images are royalty free.
Your thoughts?
From: Obi Obianom @.> Sent: Sunday, June 30, 2024 9:10 PM To: oobianom/quickcode @.> Cc: brichard1638 @.>; Comment @.> Subject: Re: [oobianom/quickcode] genRandImg links to Unsplash.com severed due to change in API call (Issue #32)
Thanks for the quick turnaround on this, Brice. Yes, this too is the reason I don't like to use other people's stuff (websites, packages and so on) in developing my packages because once something goes wrong, my package is affected. I had already submitted the 0.9 version with a message in the current genRandImg function. Basically, I noted that we may either deprecate or update the function for version 1.0
— Reply to this email directly, view it on GitHubhttps://github.com/oobianom/quickcode/issues/32#issuecomment-2198857308, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASLI5UPZYUN5HAZGCB32I2TZKCUBJAVCNFSM6AAAAABKEHCATGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYHA2TOMZQHA. You are receiving this because you commented.Message ID: @.***>
No that's not the reason for the wait, they are probably busy. I submitted few days ago, still awaiting response.
Thank you for the update.
From: Obi Obianom @.> Sent: Tuesday, July 2, 2024 10:04 AM To: oobianom/quickcode @.> Cc: brichard1638 @.>; Comment @.> Subject: Re: [oobianom/quickcode] genRandImg links to Unsplash.com severed due to change in API call (Issue #32)
No that's not the reason for the wait, they are probably busy. I submitted few days ago, still awaiting response.
— Reply to this email directly, view it on GitHubhttps://github.com/oobianom/quickcode/issues/32#issuecomment-2203297215, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASLI5UJDQLKXQKVX6T3CB6LZKKXQRAVCNFSM6AAAAABKEHCATGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBTGI4TOMRRGU. You are receiving this because you commented.Message ID: @.***>
The quickcode package was made available today on CRAN. It is still showing the issue with the genRandImg function. I don't know if the tests were re-executed or if there were no updates made to the package on resubmit. In any event, my recommendation would be for now to remove the function and resubmit.
Yes it is published now. the issue is no longer there, I just checked.
Hey Brice, we need to recode the links for Unsplash.com because the current links no longer work. I think API key may now be required.