Using RStudio in Code Studios#
This article covers the main features of RStudio in Code Studios. You can follow this tutorial if you have never set up Code Studio.
To use RStudio in Code Studios, you need a Dataiku 11+ instance with:
A working Code Studio instance with an RStudio block, a configured Kubernetes cluster, and an Elastic AI computation instance set up by an admin user. For details, visit RStudio Server in Code Studios.
Edit a Dataiku recipe#
RStudio in Code Studios lets you edit your code recipe quickly and dynamically.
You can do it from the Flow by:
Clicking on the code recipe you wish to edit.
Clicking on Edit in Code Studio on the top-right corner of the recipe page.
You can also access your recipe directly from RStudio in Code Studios:
From the Files panel, in the bottom-right, navigate Home > workspace > recipes
Click on the recipe you want to edit to open it in the Source Editor panel.
You can execute your code in Code Studio. However, to create a new recipe or build the output, you still have to do it from the Flow.
The recipe can be debugged with the proper tools of RStudio. For example:
Setting a diagnosis by launching
rlang::last_trace()in the Console panel.
Using a linting package such as
library(lintr)to detect typos.
Explore and export your code environment#
Code Studios can be seen as a place of experimentation where you can try out a different environment to test which package best suits your code. To get the details of your environment:
In the Source Editor panel, enter :
# Get information about installed packages installed_packages <- installed.packages() # Extract the package names package_names <- rownames(installed_packages) # Save the package names to a text file writeLines(package_names, "project-lib-versioned/requirements.txt")
Run the code with Ctrl + Enter (or Cmd + Enter on Mac).
Click Sync files with DSS to save the change in your instance.
In the top navigation bar, navigate to the Libraries menu (
G+L) to open your new file.
You can notice that the
project-lib-versionedis the folder for managing your libraries, and it refers to the lib folder on this page.
requirements.txtfile, click the More options icon, and Move it to the R folder.
For security purposes, the R folder is invisible in the Code Studio instance when empty.
When the Code Studio is created according to the template, if a code environment block is provided, the new packages are in this text file alongside with default R packages.
Using Code Studio to edit code in a Git reference#
If you have imported code from Git in Libraries, you will be able to edit this code within Code Studio. You can commit the changes made in Code Studio to the Git reference:
Edit the files in
project-lib-versionedin Code Studio and click Sync files with DSS.
Go back to DSS Project Libraries, click Commit and push all….
Congratulations, you should now have a functional setup to leverage RStudio in Code Studios to edit your code in Dataiku as if you were working with your local RStudio!