Hi Chris,
I’m in the process of making a version of my experiment to use on iOS. My current protocol runs a python file to set experiment and trial-level variables. Running this protocol now gives me the following error:
ERROR: Failed to create object.
Extended information:
reason: No factory for object type: action/run_python_file
Is running python files possible on iOS? The version of MWorks on the iPad I’m using is 0.8.1
Best,
Aída
Hi Aída,
Is running python files possible on iOS? The version of MWorks on the iPad I’m using is 0.8.1
Yes, it is possible, but you need MWorks 0.9 (the version currently on the App Store).
Cheers,
Chris
Hi Chris,
Thanks for the quick reply! I’ve run into another issue: the Python file is
now run by the server (the client is running on my Mac), but I’m having an
issue reading in a pickle file used in the python script to set block-level
variables, as I’m getting the following error:
No such file or directory: '~/Documents/MWorks/Data/subject_0.pkl’
I’ve saved the .pkl file in what I think is the above directory, but I’m
not super familiar with file paths in iOS - is there a particular place I
be saving the .pkl file on the iPad so that the Python file can access it?
I’m also happy to come into your office whenever is convenient for you if
the question is unclear!
Thanks again,
Aída
Hi Aída,
The best and sanest way to get the pickle file to the server is to add it to the experiment as a file resource. However, as noted in the docs, once your experiment contains a file resource, all supporting files (images, Python scripts, etc.) must be declared as resources.
To make this simpler, you could move all the supporting files and directories (e.g. constants.py
, images
) into a single subdirectory called resources
and then include that one directory as a resource:
resource ('resources')
Once that’s done, you’ll need to change the supplied paths for all supporting files to be relative to the resources directory. For example, instead of
run_python_file ('utils.py')
you would use
run_python_file ('resources/utils.py')
Alternatively, you could leave the files and directories where they are and declare separate resources for each.
If you want help setting this up, feel free to stop by my office.
Cheers,
Chris