statnet / statnetWeb

A graphical user interface for network modeling with the 'statnet' software
GNU General Public License v3.0
29 stars 17 forks source link

Error messages in statnetWeb: fixing before SunBelt #66

Closed skhan890 closed 5 years ago

skhan890 commented 5 years ago

@martinamorris @chad-klumb

This is just an issue to get us started on documenting errors and fixes.

I've been able to get the app running and have successfully (perhaps unfortunately) the same errors Martina showed us.

Here is the list:

image This can be recreated: Data -> upload network -> filetype (built in network is faux.mesa.high) ; Network Descriptives -> More -> Run the default term on 100 simulations.

I'll be away from my laptop till 7PM EST (4PM PST) but will bug test this out as much as possible when I return

chad-klumb commented 5 years ago

There's also a plot.gofobject error. I think I know how to fix both this and the summary.formula error (relatively quickly). I'm looking through the code for other possible issues now.

I am less sure where to start on the opening warnings/errors:

Listening on http://127.0.0.1:6656
Warning in if (!is.na(attribValue)) { :
  the condition has length > 1 and only the first element will be used
Warning in charToRaw(enc2utf8(text)) :
  argument should be a character vector of length 1
all but the first element will be ignored
Warning in pngfun(filename = filename, width = width, height = height, res = res,  :
  unable to allocate bitmap
Warning in pngfun(filename = filename, width = width, height = height, res = res,  :
  opening device failed
Warning: Error in pngfun: unable to start png() device
  128: pngfun
  127: startPNG
  126: drawPlot
  112: <reactive:plotObj>
   96: drawReactive
   83: origRenderFunc
   82: output$diagnosticsplot
    2: shiny::runApp
    1: run_sw

These appear to relate to the shiny code (with which I have zero experience).

skhan890 commented 5 years ago

I'm more than happy to review and fix the Shiny relates bugs when I return, Chad

chad-klumb commented 5 years ago

opened PR #67 to address the ergm version issues I found

chad-klumb commented 5 years ago

Another warning: when first plotting a new network, I get

Warning in `<reactive:nwdf>`(...) : NAs introduced by coercion

(under Network Descriptives -> Network Plot)

martinamorris commented 5 years ago

which network did you choose?

chad-klumb commented 5 years ago

Several: flobusiness, flomarriage, kapferer, samplk1, samplk2, they all give this warning for me

kapferer2 appears to not give the warning

chad-klumb commented 5 years ago

it shows up in the R console, btw (not in the browser/app)

skhan890 commented 5 years ago

For R console related "warnings" - they're usually pretty benign, as long as it's not showing up in red text on the Shiny app. Most people will probably have the browser up, and not be looking at the console?

skhan890 commented 5 years ago

By the way I merged your pull request in, Chad:

As documentation, you fixed the summary issue: image

chad-klumb commented 5 years ago

Thanks.

It should have also fixed the gofplot issue (i.e. the goodness of fit tab should now work correctly).

skhan890 commented 5 years ago

How do you replicate the gofplot? I just did a model called "edges+nodematch("Grade",diff=T)", but it might not be working

image

chad-klumb commented 5 years ago

you need a fitted model to run GoF (note the Please fit a model text at the top)

chad-klumb commented 5 years ago

the way to get the gof error (before the pull request was merged) was simply to click Run on that page (once you had a fitted model) and some red text would show up saying it couldn't find the plot.gofobject function

what you should get now is the actual gof plots on the right half of the screen (and tabular results on the LHS)

skhan890 commented 5 years ago

Ah gotcha. So, yes - the figure is now fixed! :)! Great work.

image

@martinamorris With this - would it be sufficient enough for you to submit to CRAN? The other shiny related errors in the console might take longer to fix, but they're not causing any specific error in the UI.

martinamorris commented 5 years ago

Might be enough. Would still prefer if we could track down the other error that Chad noted (console only):

Another warning: when first plotting a new network, I get

Warning in `<reactive:nwdf>`(...) : NAs introduced by coercion
(under Network Descriptives -> Network Plot)
martinamorris commented 5 years ago

BTW, great work both of you. It's such a pleasure to have this level of support!

martinamorris commented 5 years ago

And that other console error which happens on startup https://github.com/statnet/statnetWeb/issues/66#issuecomment-501876649

Looking at the traceback, the first error is for output$diagnosticsplot

that shows up here https://github.com/statnet/statnetWeb/blob/dbdc339d4b09e8d23149a178c8cc8b2cc6154472/inst/shiny/server.R#L3157

but i don't know enough about shiny to understand why this would be triggered on launch.

chad-klumb commented 5 years ago

soooo.....

changing suspendWhenHidden from FALSE to TRUE (immediately after output$diagnosticsplot) got rid of the png-related startup warnings/errors

do we want to try and merge this now? it's one change but I'm not a shiny expert and while everything else appears fine I'm not totally sure what I'm doing here

martinamorris commented 5 years ago

thx so much. lemme check if it works for me.

chad-klumb commented 5 years ago

although think I figured out the NA coercion thing

that just leaves those other two start-up warnings:

Warning in if (!is.na(attribValue)) { :
  the condition has length > 1 and only the first element will be used
Warning in charToRaw(enc2utf8(text)) :
  argument should be a character vector of length 1
all but the first element will be ignored

which unfortunately don't give a traceback anymore (now that png's fixed) so I'm not sure where to start looking for these

martinamorris commented 5 years ago

did you push your changes? i've just pulled, and am still getting the same png error at launch

chad-klumb commented 5 years ago

no I can't push (I don't have access)

chad-klumb commented 5 years ago

you can use the little pencil icon to make in-code changes within github in your browser; this one's small enough that might be the fastest option (just change FALSE to TRUE in that one location)

martinamorris commented 5 years ago

just did, that worked. would love to figure out that last error

chad-klumb commented 5 years ago

for the NA coercion warning, change

if(is.na(as.numeric(network.vertex.names(nw()))[1])){

to

if(suppressWarnings(is.na(as.numeric(network.vertex.names(nw()))[1]))){

i.e. wrap the expression in the conditional in suppressWarnings

martinamorris commented 5 years ago

Ok, I made both changes above, fixes the errors. I changed your permissions too

chad-klumb commented 5 years ago

Okay I just made a PR with these two changes; idk if it's needed anymore but there it is

If Sara could comment on the suspendWhenHidden thing (since she surely knows more shiny than I do) that would be great; I don't think it will cause any problems but she'd know better than I would

martinamorris commented 5 years ago

I'm also getting an inconsistent warning from fitting the following model and then simulating from it:

edges + nodefactor("Grade") + nodematch("Grade")

Warning is:

Warning in sum[4] <- paste("Constraints: ", format(attr(sim, "constraints")), : number of items to replace is not a multiple of replacement length

But I just tried to replicate it, and the warning didn't pop up.

So, I'll submit this version for now.

chad-klumb commented 5 years ago

possible fix for that (not tested, just speculation): replace single brackets [] with double brackets [[]] on lines 3610-3614 and 3680-3686 (10 total cases) in server.R

edited to add: for the record, this didn't fix it :); it appears the 'constraints' attribute has a bunch of information in it, more than just the name(s) of any constraints, so we may need to more carefully select exactly what we want

running Martina's model above gave me the warning (in the R console) that she mentioned, and displayed this in the shiny app:

Untitled

Is TNT a constraint, or just a sampler (proposal)? We might be pulling the wrong data out of the 'constraints' attribute and printing it to the shiny app.

skhan890 commented 5 years ago

I think the suspendWhenHidden worked, as my console is just showing these errors (is that the question?)"

Warning in if (!is.na(attribValue)) { : the condition has length > 1 and only the first element will be used Warning in charToRaw(enc2utf8(text)) : argument should be a character vector of length 1 all but the first element will be ignored Warning in if (!is.na(attribValue)) { :

Martina - I successfully got a simluation after fitting the model for faux.mesa with your above model, and did not get that warning: image

With that I'm heading to bed now - good work all!

martinamorris commented 5 years ago

@skhan890

I think the suspendWhenHidden worked, as my console is just showing these errors (is that the question?)"

I think Chad's question is whether the change we made to suspendWhenHidden will have any negative side-effects. Neither of us knows exactly what the purpose of this feature is or how it works.

So, this is the last thing to fix:

Warning in if (!is.na(attribValue)) { : the condition has length > 1 and only the first element will be used Warning in charToRaw(enc2utf8(text)) : argument should be a character vector of length 1 all but the first element will be ignored Warning in if (!is.na(attribValue)) {

skhan890 commented 5 years ago

As a follow-up to this issue warning:

Warning in if (!is.na(attribValue)) { : the condition has length > 1 and only the first element will be used Warning in charToRaw(enc2utf8(text)) : argument should be a character vector of length 1 all but the first element will be ignored Warning in if (!is.na(attribValue)) {

I've been trying to debug it, and here are solutions I've tried that haven't worked: 1) Wrapping each reactive container with a "req" for the object needed. 2) Commenting/uncommenting each section of the UI to narrow down which page is giving the error.

What I've learned: 1) I believe the error is coming from the simulation tabPanel. It will need to be narrowed in further, as there are many objects that play into each other. It's definitely one of the reactive objects, and then there's a separate issue for a charToRaw (might be an HTML issue)?

chad-klumb commented 5 years ago

Think I figured out the sum[4] thing. The 'constraints' attribute of simulate results currently has a bunch of fields (not just a single field telling you what the constraints were), and when you try to assign using sum[4] <- ... where ... has length > 1 it gives you a warning (and only copies the first thing, which happened to be TNT in the example Martina gave, hence TNT is printed as the constraint in the figure I uploaded a few posts above).

This may ultimately be an ergm issue rather than a statnetWeb issue; depending on how statnet/ergm#93 is resolved we may not have to change anything in statnetWeb to fix this. (Even if changes are required to statnetWeb, I think they'd be minimal.)

martinamorris commented 5 years ago

thx for tracking this down Chad. let's see how Pavel responds to https://github.com/statnet/ergm/issues/93