-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the option to import from Github #8858
Conversation
@lilyclements could you check that this is ok. I notice that the github option does not have the check facility. @Vitalis95 Isn't that still needed, when adding from github? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vitalis95 - this is great! There's one comment given in the R code, then two other bits below:
- We discussed last week about having a check, but I did a little bit of coding today and was able to sort it out. Can you add the following function into the "stand_alone_functions.R" file:
# Function to check if a repo exists and is in R
check_github_repo <- function(owner, repo) {
tryCatch({
response <- gh::gh("/repos/:owner/:repo", owner = owner, repo = repo, verb = "GET", silent = TRUE)
if (response$language == "R") {
return(1) # Repository exists and is in the R language
} else {
return(2) # Repository exists, but isn't in the R language
}
}, error = function(e) {
return(3) # Error occurred, repository doesn't exist
})
}
Then we want to add for the messages something like this:
Case "1"
ucrInputMessage.SetText("Package exists in the repo and is ready for installation")
ucrInputMessage.txtInput.BackColor = Color.LightGreen
Case "2"
ucrInputMessage.SetText("Package exists in the repo but is not in the R language")
ucrInputMessage.txtInput.BackColor = Color.LightGreen
Case "3"
ucrInputMessage.SetText("Not a package in the given repo. Perhaps spelled wrongly?")
ucrInputMessage.txtInput.BackColor = Color.LightCoral
- Can you add as a new argument in the function
upgrade = "never"
. This can be hardcoded in.
Otherwise looks good!
instat/dlgRPackages.vb
Outdated
clsPasteFunction.AddParameter("paste", Chr(34) & ucrInputRepositoryName.GetText & "/" & ucrInputTextBoxRPackage.GetText & Chr(34), bIncludeArgumentName:=False) | ||
|
||
clsRepositoryFunction.AddParameter("package", clsRFunctionParameter:=clsPasteFunction, iPosition:=0, bIncludeArgumentName:=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need your paste
function here since you've already combined it with your code! So you can just change this to
clsRepositoryFunction.AddParameter("paste", Chr(34) & ucrInputRepositoryName.GetText & "/" & ucrInputTextBoxRPackage.GetText & Chr(34), bIncludeArgumentName:=False)
And then you can remove the bit on line 180, and remove clsPasteFunction
entirely :)
@lilyclements , have a look at it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vitalis95 this is nice that you've removed the paste0
function, and worked on that.
There's a few changes with the check needed for the GitHub option.
My previous comment gave a function as well as suggestions to the code to amend for this check. Does it make sense to you? It's ok if not, I do need to work on my explanations!
Then another point is that I noticed the tab order is out. Can you sort this as well?
@lilyclements , I've fixed the tab order , I'm researching how we can further enhance the suggestions you provided |
@lilyclements , have a look at this |
Designer additions
This is good - I have tidied up the design a little bit, so before you make further changes then make sure that you pull the most recent changes. If you don't agree with the changes, we can revert the commit (it's very minor bits of aligning etc). I can't see the addition of the |
@lilyclements , I have added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vitalis95 this is good. Just one small thing - is it possible for the OK to be disabled if the check fails (i.e., is in red). This is done elsewhere - like when checking unique in the dlgKeys dialog, if you want to look at the code?
@lilyclements , have a look at it |
@lilyclements and @Vitalis95 this looks like a nice enhancement. I had a quick look, partly to check that the Help button works, which it does. I wonder also if the repository name field should be wider than the package name? It is a URL and likely to be quite long? Are there any examples that we know we may use? If so, then could this be a drop down, where you can paste a new url, but there are (say) a couple of obvious examples? |
@rdstern some examples from various R packages we've developed at IDEMS: Repo: IDEMSInternational |
Great. How about that repo and sone, or all, those examples in a drop down. The default is still blank, (so the user types or pastes the contents) but this would give at least one example where no typing is needed? And we could use that in the help on how to do this. |
@lilyclements , what do you think about this? |
@Vitalis95 I think this is a good idea, but, perhaps I'm a little late with my response. If I'm too late then ignore me! |
@lilyclements @rdstern , I have added |
@lilyclements @rdstern can you re-test this? |
@rdstern over to you |
@Vitalis95 and @lilyclements I am not quite sure what is expected here? a) I first tried with each of the packages in the drop-down menu: This goes green - they all go green. (So I assume none as currently installed, or are not the most current version?) So I installed the first package. I assume it installed. Then I tried again and it still was green. Shouldn't it now say the package is already installed? Some of the options it says are not R packages - but they are still green. What does that mean? I take green to mean I should install it. Can I install a not R package? b) Then I tried with a climatic package - CDT that is also only in Github? I could not get it so I could install? I first assumed I could find the whole directory and copy it over. Then I got rid of the start as shown below. Am I supposed to be able to install this sort of package or just our own? (Note the instructions are i9n the CDT github directory and they work in the script window. So is this dialog only meant for the IDEMSInternational packages?) c) Finally I returned to your packages in the drop-down menu. Now I don't know the location any more. I can get it back, by pressing Reset and then going back to the Github. So not a real problem. But couldn't it also give that directory when I choose from the dropdown? |
@Vitalis95 I have updated the R function here. When you next work on this, make sure you pull changes to your Visual Studio
@rdstern thanks for this review. There are certainly changes in the R code that you have highlighted here. I have worked on these, so let me know what you think: Installing New Packages This is really great to see how it can be interpreted - perhaps we should have two options: One where you import from a URL, and one like how we have it now?
It is very straightforward to do this in R, so I have added it as an option in the R code for now. We don't have to put this in the dialog if you disagree - good to get opinions though @rdstern or @Vitalis95 - what do you think? Adding more options when importing from GitHub - I've done this on the checks now
@rdstern @Vitalis95 what are your thoughts on this? Hopefully makes it a bit easier for the user if they encounter issues when installing.
|
@lilyclements that's great: c) However with (at least some of) the IDEMS packages the Check doesn't work now. It doesn't give anything now for Rpicsa or epicsawrap:: d) With CDMS Products (and carbonr and openappr) it gives the wrong message - I know it isn't a CRAN package! e) With carbonr and rapidpror is gives the following incorrect message! |
I am musing now. Suppose we rewrite R-Instat to use the 3 main R packages that you have just documented. (You bravely said that might be a boring but feasible job for one of our programmers???!) |
@rdstern glad that (a) is now working. |
@rdstern @Vitalis95 I just, I hope, updated the VB code to reflect the new options of 0-6 in this dialog. If you try again, it should hopefully work now! I haven't done any other bits (like, adding a URL option, if we wanted that) |
@rdstern good point! This could be a great "easy" way to get this done |
@lilyclements that's great. All the options in your pull down now work and give useful messages. This is all very nice. I don't think we need the option of the url. The insalling of packages, like CDT works fine. The only item remaining is to check on packages like CDT and to give the installed message when it is there. Then let's merge. |
@lilyclements I now noticed that as well as importing a package it now seems to check and list all the other packages in R-Instat that are out-of date. That's new and I wonder if it will worry users unnecessarily? We usually update the packages with successive releases. So gradually they will become not the most recent. But that is not usually a problem for the user? |
@rdstern , have a look at it. |
@Vitalis95 I don't see what's different? I had 2 minor problems before: and they are still here |
instat/dlgRPackages.vb
Outdated
ucrInputMessage.SetText("Not a package in the given repo. Check spelling?") | ||
ucrInputMessage.txtInput.BackColor = Color.LightCoral | ||
ucrInputMessage.SetText("Error occurred, repository doesn't exist") | ||
ucrInputMessage.txtInput.BackColor = Color.Red |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vitalis95 is there a reason you changed the colours to be Red/Green instead of LightCoral, etc? Just out of interest
@rdstern to (a), this is very interesting since I am not having this problem. There is some coding going on with checking your version vs the version on GitHub, but perhaps the check we need to do is slightly different between our computers. I think this is something to investigate "in person" - we can set as an issue for now? To (b), this is something that comes up in R from the code. We can remove this by adding
I've added this in @Vitalis95. If you make any other changes, make sure you pull this branch first (sorry for interfering -- just know you have a lot to do and it's a one-line bit I can actually do!). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lilyclements it now doesn't show the out-of-date packages.
It still shows CDT to be installed always, but you say that might be a machine issue.
Anyway I am accepting, because Chris and @N-thony have now changed the "system", so all the packages on installation continue to be in the original directory, while all we install with this dialog, go into a second directory - and R-Instat looks there first!
I am keen to use this new dialog, in the new version to test all this. I also often have problems updateing some CRAN packages, because R-Instat loads them at the start. We perhaps need a list of those so we don't try to update, them, or learn how that is done. @N-thony perhaps you can supply this list, so we can include it in the help?
@N-thony over to you to check and merge. Really good to have this in the forthcoming release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vitalis95 thanks for changing the colours. Very minor, but very appreciated! I'll approve since @rdstern was happy with it before this minor change and this commit made his approval stale.
@N-thony over to you to check and merge
PS: Might help if I actually click "Approve" this time (hence the removed comment above)
Fixes #8823
@lilyclements @rdstern @N-thony , Added the option (
R package
-button) to install a package directly from GitHub