I have created a report on ipython notebook with widgets embedded.I want to validate the content of this created notebook as expected.
Some of the checks are :
1) When kernel loaded, I can see this output in cell1.
2) when I click on this widget button, I get the following output.
eg: I have created below notebook(just demo real notebook is big and heavy coded)
enter image description here
I want to validate the content and behavior of widgets(List of checks).
Related
I wanted to make a script that closes all Data Viewer tabs in RStudio (those invoked by clicking on a data object in the Environment pane, or by calling utils::View()) but keeps all the "usual" document tabs.
First, I found rstudioapi::documentClose() function - not sure if it works for Data Viewer tabs, it requires the document id that seems to be not applicable here: calling getActiveDocumentContext() on Data Viewer tab returns #console.
Then, there's executeCommand('closeSourceDoc') option that closes the current tab, whether it is Data Viewer or standard document. I could probably use executeCommand('nextTab') to loop through all opened tabs, but I can't find how to determine if the active tab is Data Viewer or not...
Any hints?
The following code seems to do what you want.
Tabs=c()
doc=rstudioapi::documentPath()
while (is.null(doc)||!doc%in% Tabs) {
if(is.null(doc)){
rstudioapi::executeCommand('closeSourceDoc')
}
rstudioapi::executeCommand('nextTab')
Tabs=c(Tabs,doc);
doc=rstudioapi::documentPath()
}
I am trying to link a Jupyter Notebook from IBM Cloud Pak.
The issue is that this is registered (for my account) as a fully public, fully shared notebook for anyone with a link
The notebook opens to a single cell with In [ ]: and no content.
Is this a common issue?
When you create a share link in CPD, you can select whether you want to share:
just cell output
cell output and non-sensitive code cells
cell output and all code cells
Note that the share link always points to the latest version, created with the "Save Version" menu item. If you created the initial version with only an empty cell, and didn't save a new version with more contents afterwards, users still see the empty cell. Just saving with "Save" isn't enough, you need to use "Save Version" to update the shared content.
I have been using a jupyter notebook to explore some output files I created and compare performance. Nothing fancy - mostly just using pandas to clean, read, and write. Today, seemingly out of the blue, this particular notebook raises a "Notebook validation failed" error. Here is the text in the error:
"Notebook validation failed: Non-unique cell id 'irish-profile' detected. Corrected to 'sexual-
vitamin'.:
"<UNKNOWN>""
The language changes from message to message. Earlier the message had a non-unique cell of 'solid-congress' and changed it to 'happy-america'. Any idea what this is - am I hacked?
You can test this :
Select all the cells in the Jupyter Notebook, then press the "cut/scissors" button, and finally press the "paste" button.
I am writing a vignette for my Shiny application package. At the beginning of my vignette, I source a file called screenshots.R that produces nice screenshots of my application. I am producing them like so:
webshot::appshot(mypackage::run_datepicker_app(),
file = "man/figures/datepicker.png", vwidth = 500, vheight = 200)
This works great and it gives me a great screenshot of what is - in this case - a couple dateInput fields. However, I'd like to be able to get a screenshot of the dateInput in use (say, with the calendar selection exposed).
Is there a way to issue commands to the application object in a script so I can get screenshots of the application in use, rather than having to do it manually?
Have you tried using ShinyDriver from the shinytest package?
You can use shinytest to have a headless browser run the app, interact with it, and take screenshots programmatically. If you don't have phantomJS installed, you'll need to run shinytest::installDependencies() before using ShinyDriver. All you need to do is point it to a directory containing a shiny app (in my case, the folder is 'myApp').
install.packages("shinytest")
shinytest::installDependencies()
app <- shinytest::ShinyDriver$new("myApp")
app$takeScreenshot("screenshot1.png")
button <- app$findElement("#button")
button$click()
Sys.sleep(1)
app$takeScreenshot("screenshot2.png")
app$stop()
I am starting the app in a headless browser, taking a screenshot, finding the button with the id 'button', clicking it, and taking another screenshot, then closing the app. Navigate to specific elements using "#id", where id is just the id you gave the shiny input. You can specify a file path to a png file in the takeScreenshot calls, so that you can then use them in your code elsewhere. Note that you may need to use Sys.sleep to stop the screenshots from being taken before the UI updates.
In my notebook, I print some data from scraped web pages. Some of these are hyperlinks without tags e.g. https://stackoverflow.com. Unfortunately, Notebook prints these out as an actual hyperlink (i.e. wraps it in tags) on the output page and shortens it. (So the final result in HTML looks like this: https://stacko....) The field is set to code, but this still happens. Is there a way to disable this behaviour?
Solution:
Enter the following text in the empty cell of your Jupyter notebook:
%%javascript
Jupyter.utils.autoLinkUrls = function (txt) {
return txt;
}
Explanation:
The ability to locate URLs in text output and convert them to hyperlinks appeared in IPython notebook (a Jupyter's predecessor) as a result of a merge request in Oct' 2012. Since then every piece of output is scanned for URLs and each found URL is replaced with an anchor <a href=.../>. There's no easy way to alter this behavior because function autoLinkUrls(...) doesn't provide any configuration parameters.
So, the only way to disable URL "autolinking" is to simply replace JavaScript function autoLinkUrls, which is exposed through global Jupyter object, and %%javascript magic command makes the job done.