pachadotdev / analogsea

Digital Ocean R client
https://pacha.dev/analogsea/
Apache License 2.0
154 stars 24 forks source link

droplet_create can't generate a random name without library(analogsea) #125

Closed trestletech closed 7 years ago

trestletech commented 7 years ago

I'm a bit rusty on my R package import lifetime, so pardon me for not being of more help with a suggested fix here, but...

If I attempt to use analogsea without first library()ing it, most things seem to work, however generating a random name for an image does not because of failures in the random name generation.

> analogsea::droplet_create()
Using default ssh keys: trestle-secure-rsa
Error in sample(x, size = 1) : object 'adjectives' not found
> adjectives <- c("red", "blue")
> analogsea::droplet_create()
Using default ssh keys: trestle-secure-rsa
Error in sample(x, size = 1) : object 'nouns' not found
> nouns <- c("horse", "canary")
> analogsea::droplet_create()
Using default ssh keys: mySSHKey
NB: This costs $0.00744 / hour until you droplet_delete() it
Waiting for create ..

It looks like the adjectives and nouns variables need to be made available earlier in the package lifetime in order to be used by these functions.

The more obvious workaround to the one above is just to call library(analogsea) which makes those datasets available and then everything just works out the box like you'd expect.

I'm not sure what impact this would have on packages that want to import analogsea, but I suspect I'll find out momentarily! ;)

sckott commented 7 years ago

Thanks for the issue @trestletech

Not sure what the right answer is here, but what about loading the datasets in onLoad?

Made the change in https://github.com/sckott/analogsea/tree/datasets branch - thoughts?

trestletech commented 7 years ago

Hm... I may have not restarted my session properly, but I'm not getting

> analogsea::droplet_create()
Using default ssh keys: trestle-secure-rsa
Error in sample(x, size = 1) : object 'adjectives' not found
In addition: Warning messages:
1: In utils::data("words") : data set ‘words’ not found
2: In utils::data("adjectives") : data set ‘adjectives’ not found
3: In utils::data("nouns") : data set ‘nouns’ not found
> 

unfortunately, I'd have to brush up on my R package loading details before I'd be qualified to give a meaningful code review here. Just trying to test empirically.

It's entirely possible that the above message is user error, so feel free to disregard if you think your branch fixes things.

sckott commented 7 years ago

you did install from datasets branch?

trestletech commented 7 years ago

I did, indeed. And then I restarted the R session and that was the result I got. This is, of course, without having analogsea library()'d or otherwise loaded.

sckott commented 7 years ago

okay, i'll take another look at that branch

sckott commented 7 years ago

can you try again after reinstalling from datasets - moved the data sets into the package in an R file as vectors. still works for me, but question is does work for you

trestletech commented 7 years ago

Perfect! Had to downgrade openssl to get around #126 but once I did that I was able to run the following just fine:

> devtools::install_github("sckott/analogsea", ref="datasets")
> analogsea::droplet_create()
sckott commented 7 years ago

great!

sckott commented 7 years ago

sorted in b948b19