Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Update to jsPsych 7 #35

Merged
merged 9 commits into from
Jul 18, 2023
Merged

Conversation

jodeleeuw
Copy link
Contributor

This updates the basic template to jsPsych 7.

Before merging, I would recommend adding in docs changes. Folks will need to use yarn add for each jsPsych plugin that they want to include. The experiment.js file also returns a function that generates the timeline. This is so that you can pass the reference to jsPsych into the function and use jsPsych scoped methods as you construct the timeline.

I've got a react hooks based version of this too, but it isn't tested yet.

@jodeleeuw
Copy link
Contributor Author

jodeleeuw commented Jul 12, 2023

@jkhartshorne I think e7d4eed fixes the line ending problem. It runs the shell script through dos2unix to repair any windows line ending characters.

I tested on a clean install of the entire pushkin process on a new windows machine. Everything worked using this experiment template and my modified base site template.

I'm still running into at least one unrelated issue with the startExperiment API. I'll see if I can debug that before this is merged.

@jodeleeuw
Copy link
Contributor Author

Have you seen this error before? I'm a bit stumped on where to look:

Proxy error: Could not proxy request /api/demo/startExperiment from localhost to http://api:3000 (ENOTFOUND).

@jessestorbeck
Copy link
Contributor

@jodeleeuw Can you give a bit more detail about running yarn add for each plugin? I wasn't sure if it was required just to run the "hello world" example, since I already saw mention of html-keyboard-response in package.json. I tried to run the example without any yarn add, and saw the error below:

Screen Shot 2023-07-17 at 3 39 15 PM

Also, if I wanted to use a custom plugin, would the guidance here (https://languagelearninglab.gitbook.io/pushkin/advanced/modifying-experiment-templates#adding-custom-jspsych-plugins) still apply?

@jodeleeuw
Copy link
Contributor Author

Hey @jessestorbeck what version of the cli are you using? I think that error is a cli error that Josh H fixed during the hackathon

@jodeleeuw
Copy link
Contributor Author

The native jsPsych plugins currently get added to the index.js of an experiment, accessing the files on CDN online. If you build a custom plugin, you will need to:

  1. Add the plugin file to the web page/src folder of the experiment
  2. Import jsPsych into the top of the custom plugin file like so: import jsPsych from 'pushkin-jspsych';
  3. Add the plugin towards the top of your experiment.js file like so: require("./jspsych-moving-window.js");

I think the second item on this list is a bit out of date with jsPsych 7 plugins. Our templates should handle the appropriate jsPsych imports, and we don't want to import pushkin-jspsych.

The require() statement would also need to be updated. Using an import is probably the best way to handle it:

import jsPsychMovingWindow from './jspsych-moving-window.js';

This will match the syntax in the sample experiment.

@jessestorbeck
Copy link
Contributor

@jodeleeuw I'm running version 3.0.2 of the CLI (I believe this was the latest as of the first day of the hackathon).

@jodeleeuw
Copy link
Contributor Author

Try updating to the most recent, I think it is 3.0.7ish. i bet that will solve this issue.

@jkhartshorne
Copy link
Contributor

jkhartshorne commented Jul 18, 2023

Another possible issue is that I think @jessestorbeck might not be using the updated site template. That pull request (pushkin-consortium/pushkin-sitetemplate-basic#4) is still open (I'm looking at it now).

@jkhartshorne
Copy link
Contributor

UPDATE: I've merged pushkin-consortium/pushkin-sitetemplate-basic#4 and released a new version of the basic site template using that update. So you shouldn't need to use the path install; you can install directly using the CLI.

@jessestorbeck
Copy link
Contributor

@jodeleeuw @jkhartshorne Aha, I was not using the updated site template. I will download the newest version and try with the updated site template.

@jkhartshorne jkhartshorne merged commit 266601b into pushkin-consortium:master Jul 18, 2023
@jkhartshorne
Copy link
Contributor

This broke the Jest tests, though. I'm going to post an issue to have them fixed.

@jodeleeuw
Copy link
Contributor Author

@jkhartshorne I'm guessing the merge means that you are not also getting an API error that I mentioned above?

@jkhartshorne
Copy link
Contributor

@jodeleeuw sorry, I overlooked that. No, it's working fine for me. But I also merged the master into this branch first, so maybe there was something missing? I just published the new version of the experiment template. Maybe try re-installing the site and experiment and make sure you are still getting the error?

@jodeleeuw
Copy link
Contributor Author

Error is gone on a clean install of site template 0.2 and exp template 5.0! 🥳

@jessestorbeck
Copy link
Contributor

I'm getting an error when I try to install the new exp template:

jessestorbeck@jesses-air-4 jessePushkinSite % pushkin install experiment
? What do you want to call your experiment? wordAssociation
? Which experiment template do you want to use? basic
? Which version? (Recommend:v5.0.0) v5.0.0
Making wordAssociation in /Users/jessestorbeck/Desktop/jessePushkinSite/experiments
retrieving from https://api.github.com/repos/pushkin-consortium/pushkin-exptemplates-basic/releases/112689021
be patient...
finished downloading
Error occurred: [Error: EMFILE: too many open files, open '/Users/jessestorbeck/Desktop/jessePushkinSite/experiments/wordAssociation/worker/node_modules/core-js/full/string/starts-with.js'] {
errno: -24,
code: 'EMFILE',
syscall: 'open',
path: '/Users/jessestorbeck/Desktop/jessePushkinSite/experiments/wordAssociation/worker/node_modules/core-js/full/string/starts-with.js'
}
Could not read migrations folder
node:fs:1533
handleErrorFromBinding(ctx);
^

Error: EMFILE: too many open files, scandir '/Users/jessestorbeck/Desktop/jessePushkinSite/experiments/wordAssociation/migrations'
at Object.readdirSync (node:fs:1533:3)
at _callee2$ (/Users/jessestorbeck/.config/yarn/global/node_modules/pushkin-cli/build/commands/experiments/index.js:380:44)
at tryCatch (/Users/jessestorbeck/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:64:40)
at Generator.invoke (/Users/jessestorbeck/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:299:22)
at Generator.throw (/Users/jessestorbeck/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:124:21)
at asyncGeneratorStep (/Users/jessestorbeck/.config/yarn/global/node_modules/pushkin-cli/build/commands/experiments/index.js:42:103)
at _throw (/Users/jessestorbeck/.config/yarn/global/node_modules/pushkin-cli/build/commands/experiments/index.js:44:291) {
errno: -24,
syscall: 'scandir',
code: 'EMFILE',
path: '/Users/jessestorbeck/Desktop/jessePushkinSite/experiments/wordAssociation/migrations'
}

Node.js v20.3.1

@jkhartshorne
Copy link
Contributor

jkhartshorne commented Jul 19, 2023 via email

@jessestorbeck
Copy link
Contributor

@jkhartshorne This is on my Mac, and Adam got the same error on the lab Mac mini when trying v5.0.0 of the exp template. Incidentally, v4.0.0 will run. I've rebooted and tried install experiment with v5.0.0 a few times, and I get the same error. This problem doesn't seem to be probabilistic, unlike the errors I've gotten with install site (see pushkin-consortium/pushkin-cli#110). I did eventually get install site to run today, which is why I was able to move on to install experiment. I'll see what I can dig up on Error: EMFILE.

@jkhartshorne
Copy link
Contributor

jkhartshorne commented Jul 19, 2023 via email

@jessestorbeck
Copy link
Contributor

docker system prune didn't seem to do anything, but I found here that I could run ulimit -n 2048 to increase the maximum number of open file descriptors. That got rid of the EMFILE error, but then I got some very similar errors to the ones I've been getting with install site, like:

Error: Command failed: yarn run build
Error: Cannot find package '@babel/preset-env'

However, I tried it a few more times, and on the last try, it ran without any errors. I was then able to run prep, but start failed. It gave me an error referencing the worker from an experiment I had deleted before. The only experiment in my experiments folder at this point was called "exp2":

jessestorbeck@jesses-air-4 jessePushkinSite % pushkin start
starting start...
Setting front-end 'environment variable'
running setEnv()
Setting front-end 'environment variable'
...
jessetest_worker Pulling
message-queue Pulling
jessetest_worker Error
message-queue Error
Error response from daemon: pull access denied for jessetest_worker, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
something went wrong: {
exitCode: 18,
err: 'jessetest_worker Pulling \n' +
'message-queue Pulling \n' +
'jessetest_worker Error \n' +
'message-queue Error \n' +
"Error response from daemon: pull access denied for jessetest_worker, repository does not exist or may require 'docker login': denied: requested access to the resource is denied\n",
out: ''
}

Here's the full output for one of the errors I got running install experiment:

jessestorbeck@jesses-air-4 jessePushkinSite % pushkin install experiment
? What do you want to call your experiment? exp1
? Which experiment template do you want to use? basic
? Which version? (Recommend:v5.0.0) v5.0.0
Making exp1 in /Users/jessestorbeck/Desktop/jessePushkinSite/experiments
retrieving from https://api.github.com/repos/pushkin-consortium/pushkin-exptemplates-basic/releases/112689021
be patient...
finished downloading
Installing dependencies for api controllers
Installing dependencies for web page
Installing dependencies for worker
loaded compFile
Building exp1_web from web page
exp1_web is built
exp1_web is published locally via yalc
exp1_web added to build cycle via yalc
Building exp1_api from api controllers
node:internal/errors:865
const err = new Error(message);
^

Error: Command failed: yarn run build
Error: Cannot find package '@babel/preset-env' imported from /Users/jessestorbeck/Desktop/jessePushkinSite/experiments/exp1/api controllers/babel-virtual-resolve-base.js
at new NodeError (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:203:5)
at packageResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:873:9)
at moduleResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:902:20)
at defaultResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:985:15)
at resolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:999:12)
at resolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/import-meta-resolve.js:13:10)
at tryImportMetaResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:137:45)
at resolveStandardizedNameForImport (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:159:19)
at resolveStandardizedName (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:168:12)
at loadPreset (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:56:20) {
code: 'ERR_MODULE_NOT_FOUND'
}
Error: Cannot find package '@babel/preset-env' imported from /Users/jessestorbeck/Desktop/jessePushkinSite/experiments/exp1/api controllers/babel-virtual-resolve-base.js
at new NodeError (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:203:5)
at packageResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:873:9)
at moduleResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:902:20)
at defaultResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:985:15)
at resolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:999:12)
at resolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/import-meta-resolve.js:13:10)
at tryImportMetaResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:137:45)
at resolveStandardizedNameForImport (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:159:19)
at resolveStandardizedName (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:168:12)
at loadPreset (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:56:20) {
code: 'ERR_MODULE_NOT_FOUND'
}
error Command failed with exit code 1.

at ChildProcess.exithandler (node:child_process:419:12)
at ChildProcess.emit (node:events:511:28)
at maybeClose (node:internal/child_process:1098:16)
at Socket.<anonymous> (node:internal/child_process:456:11)
at Socket.emit (node:events:511:28)
at Pipe.<anonymous> (node:net:334:12) {

code: 1,
killed: false,
signal: null,
cmd: 'yarn run build',
stdout: 'yarn run v1.22.19\n' +
'$ babel src -d build\n' +
'info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n',
stderr: "Error: Cannot find package '@babel/preset-env' imported from /Users/jessestorbeck/Desktop/jessePushkinSite/experiments/exp1/api controllers/babel-virtual-resolve-base.js\n" +
' at new NodeError (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:203:5)\n' +
' at packageResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:873:9)\n' +
' at moduleResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:902:20)\n' +
' at defaultResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:985:15)\n' +
' at resolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:999:12)\n' +
' at resolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/import-meta-resolve.js:13:10)\n' +
' at tryImportMetaResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:137:45)\n' +
' at resolveStandardizedNameForImport (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:159:19)\n' +
' at resolveStandardizedName (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:168:12)\n' +
' at loadPreset (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:56:20) {\n' +
" code: 'ERR_MODULE_NOT_FOUND'\n" +
'}\n' +
"Error: Cannot find package '@babel/preset-env' imported from /Users/jessestorbeck/Desktop/jessePushkinSite/experiments/exp1/api controllers/babel-virtual-resolve-base.js\n" +
' at new NodeError (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:203:5)\n' +
' at packageResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:873:9)\n' +
' at moduleResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:902:20)\n' +
' at defaultResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:985:15)\n' +
' at resolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:999:12)\n' +
' at resolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/import-meta-resolve.js:13:10)\n' +
' at tryImportMetaResolve (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:137:45)\n' +
' at resolveStandardizedNameForImport (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:159:19)\n' +
' at resolveStandardizedName (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:168:12)\n' +
' at loadPreset (/usr/local/Cellar/babel/7.22.5/libexec/lib/node_modules/@babel/cli/node_modules/@babel/core/lib/config/files/plugins.js:56:20) {\n' +
" code: 'ERR_MODULE_NOT_FOUND'\n" +
'}\n' +
'error Command failed with exit code 1.\n'
}

Node.js v20.3.1

@jkhartshorne
Copy link
Contributor

Interesting. A couple things:

  1. What version of the CLI are you using? (If it's a local development version, what commit is it? You can find out by going in the terminal to the root directory of the CLI repo and typing git log. It'll be the first one on the list.)

  2. What version of MacOS do you have? And what type of Mac? The "About This Mac" command shows that I have a MacBook Air (M1, 2020) running macOS Monterey.
    Screen Shot 2023-07-19 at 8 05 47 PM

  3. The error involving migrations is the one I described at CLI / migrations error with new template #38 (comment). You can use the same solution.

As far as the other issues, I'm really not sure. I don't think the answers to Qs 1 & 2 will actually tell me what's wrong, but I want to rule out a couple things.

@jessestorbeck
Copy link
Contributor

@jkhartshorne For the CLI, I'm running release 3.0.7. This is on a MacBook Air (Retina, 13-inch, 2020) with an Intel chip (1.1 GHz Quad-Core Intel Core i5) running MacOS 12.4.

@ayang21
Copy link
Contributor

ayang21 commented Jul 20, 2023

I ran it after editing the experiment.js with a few more trials and after adding a different plugin: survey-text and it all compiled and worked out great in localhost.

@jkhartshorne
Copy link
Contributor

@ayang21 -- can you compare what you are doing with what @jessestorbeck is doing and see if you can find a difference that might explain his difficulties?

@jkhartshorne
Copy link
Contributor

g a different plugin: survey-text and it all compiled and worked out great in localhost.

Confirming that you are

@jkhartshorne For the CLI, I'm running release 3.0.7. This is on a MacBook Air (Retina, 13-inch, 2020) with an Intel chip (1.1 GHz Quad-Core Intel Core i5) running MacOS 12.4.

Confirming that you are not using a local copy of the CLI, but the npm release 3.0.7.

@jessestorbeck
Copy link
Contributor

@jkhartshorne Correct, it's the npm release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants