if (!require('pak')) install.packages('pak'); pak::pkg_install("gorkang/jsPsychAdmin")
if (!require('pak')) install.packages('pak'); pak::pkg_install("gorkang/jsPsychMaker")
if (!require('pak')) install.packages('pak'); pak::pkg_install("gorkang/jsPsychMonkeys")
if (!require('pak')) install.packages('pak'); pak::pkg_install("gorkang/jsPsychHelpeR")
9 Common Tasks
9.1 Install dependencies
Install the last versions of all the packages:
9.2 Developing a protocol
9.2.1 Adding new tasks
Copy example tasks to a local folder, and adapt with the information of the new task. For example:
::copy_example_tasks(
jsPsychMakerdestination_folder = "~/Downloads/ExampleTasks",
which_tasks = "MultiChoice")
9.2.2 Creating a protocol
You can choose any of the canonical tasks (jsPsychMaker::list_available_tasks()$tasks
), and/or a folder with the new tasks (~/Downloads/ExampleTasks
).
::create_protocol(
jsPsychMakercanonical_tasks = c("BNT"), # Berlin Numeracy Test
folder_tasks = "~/Downloads/ExampleTasks/",
folder_output = "~/Downloads/protocol9996",
launch_browser = TRUE
)
9.2.3 Piloting the protocol
Use local_folder_tasks
to test local protocols.
::release_the_monkeys(
jsPsychMonkeysuid = 1:10,
sequential_parallel = "parallel",
number_of_cores = 10,
local_folder_tasks = "~/Downloads/protocol9996/",
open_VNC = FALSE
)
If your protocol is on a server, use server_folder_tasks
. You will need a credentials_folder
with the server access credentials.
::release_the_monkeys(
jsPsychMonkeysuid = "1:10",
sequential_parallel = "parallel",
number_of_cores = 10,
server_folder_tasks = "test/protocols_DEV/999",
DEBUG = FALSE,
credentials_folder = "~/my_location/.vault/",
open_VNC = FALSE
)
9.2.4 Creating helper project
If it is a local protocol:
::run_initial_setup(
jsPsychHelpeRpid = 9996,
data_location = "~/Downloads/protocol9996/.data/",
folder = "~/Downloads/jsPsychHelpeR9996",
dont_ask = TRUE
)
If it is an online protocol:
::run_initial_setup(
jsPsychHelpeRpid = 9996,
download_files = TRUE,
credentials_file = "/path_to_credentials/.credentials",
folder = "~/Downloads/jsPsychHelpeR9996",
dont_ask = TRUE
)
9.2.5 Deleting pilot data
# Delete the XYZ protocol rows in all the MYSQL tables
source("admin/mysql_helper_functions.R")
# list_credentials = decrypt_data(key_public = readLines(".vault/data_public_key.txt"), data_encrypted = ".vault/data_encrypted.rds", mysupersecretpassword = rstudioapi::askForPassword())
delete_MySQL_tables_pid(pid)
# 3) Limpiar los archivos de resultados de Monkeys -----------------------
# Delete csv files in .data/
# rstudioapi::navigateToFile(".vault/.credentials")
DELETE_data_server(pid = PROTOCOLID)
9.2.6 Preparing Helper project
9.2.6.1 Get data
Will download a zip file with the data.
# if (!require('renv')) utils::install.packages('renv'); renv::install('gorkang/jsPsychHelpeR')
# Developing protocol
::get_zip(pid = "test/protocols_DEV/31",
jsPsychHelpeRwhat = "data",
where = "data/")
# Production protocol
::get_zip(pid = "999",
jsPsychHelpeRwhat = "data",
where = "data/")
9.3 Protocol to production
From admin/000_PREPARE_protocol_for_production.R
in jsPsychAdmin
# Checklist para pasar protocolos de test/protocols_DEV/ a produccion
# PARAMETERS --------------------------------
= "test/protocols_DEV/31"
PROTOCOLID = "1:100"
number_of_monkeys
# -------------------------------------------
# Automatic parameters
= gsub("test/protocols_DEV/", "", PROTOCOLID)
pid
::cli_h1("PROTOCOL {pid}")
cli
# 1) Pilotaje final on Monkeys! -------------------------------------------
# Clean data and MySQL DB
# rstudioapi::navigateToFile(".vault/.credentials")
::clean_up_dev_protocol(protocol_id = PROTOCOLID) # Will ask for server password
jsPsychAdmin
# LAUNCH MONKEYS
::release_the_monkeys(uid = number_of_monkeys,
jsPsychMonkeysserver_folder_tasks = PROTOCOLID,
sequential_parallel = "parallel",
number_of_cores = 10,
big_container = TRUE,
keep_alive = FALSE,
open_VNC = FALSE,
screenshot = FALSE,
credentials_folder = here::here(".vault/"))
# CHECK jsPsychHelpeR runs OK
# || THIS WILL take a while, as all the renv packages need to update
# Create NEW jsPsychHelpeR project, downloading the files from the server
::run_initial_setup(pid = PROTOCOLID,
jsPsychHelpeRdownload_files = TRUE,
folder = "~/Downloads/jsPsychR_TESTING_for_PRODUCTION")
# REMEMBER TO DO targets::tar_make() in jsPsychHelpeR project!
# 2) Clean data and MySQL DB --------------------------------------------
# rstudioapi::navigateToFile(".vault/.credentials")
::clean_up_dev_protocol(protocol_id = pid) # Will ask for server password
jsPsychAdmin
# 3) Revisar el config.js para pasar el experiment a produccion ----------
# -[] online = true
# -[] pid OK?
# -[] debug_mode = false
# - ETC...
# 4) Copiar protocolo ZIPeado a test/protocols_DEV/OLD_TESTS/ -------------
# TODO: automatico!
# 5) Copiar protocolo a protocols/ ----------------------------------------
# TODO: automatico!
# 6) BORRAR protocolo de test/protocols_DEV/OLD_TESTS/ --------------------
# TODO: automatico!