Scripting task configuration#
The hubAdmin
package provides tools to help with the configuration of tasks that are run on the hub. Specifically, the package has various create
functions that can be used to create objects that are used to build a "tasks"
config file that can ultimately be written as a tasks.json
file.
As mentioned previously, the tasks.json
file specifies the three components of modeling tasks (task ID variables, output types, and target metadata) used in the hub. The hubAdmin
package provides functions to help create these objects.
In this section, we will walk through the process of scripting task configuration using functions from the hubAdmin
package in an order similar to that used in the previous configuring tasks section.
Step 1: Create an src
folder#
Open RStudio and ensure you are in your repo’s main folder. Click on the “New Folder” icon to create a new folder called src
.

Step 2: Create a new R script within the src
folder#
In the files pane, click on the src
folder and ensure you are inside the folder by checking the path at the top of the pane. The path (circled below in green) should now show the src
folder. Click on the “New Blank File” icon and select “R Script”. Name the file “scripting-task-config”.

Step 3: Install the hubAdmin
package#
In the Console of RSudio, install the latest version of the hubAdmin
package from the R-universe by running the following command:
install.packages("hubAdmin", repos = c("https://hubverse-org.r-universe.dev", "https://cloud.r-project.org"))

Step 4: Write the script to create and configure a "tasks"
config file#
For this step, please visit the Scripting task configuration files vignette from the hubAdmin
package and follow the steps in the Creation of a tasks.json
file section.
And note, while you can copy and paste the code snippets to your console, we strongly recommend to manually enter the commands in your script and run them as you go along.
Step 5: Save and run the script#
Click on the “save” icon to save the script. Then, click on the “Source” icon to run the script.

Congratulations!#
You have successfully scripted the task configuration for your modeling hub. The tasks.json
file has been created and saved in the hub-config
folder. You can now move on to configuring the model metadata for your hub.