Importing from other tasks #152
Replies: 1 comment
-
Hi @jonahpearl, pyControl does not currently support splitting task code across multiple files. When you upload a task to the pyboard, the selected task file is copied across to the pyboard and renamed One possible workaround for reusing code across multiple tasks is the functionallity for automatically copying device driver files needed for a task from the devices folder on the computer to the pyboard. This functionallity, implemented in Pycboard.transfer_device_files, scans the task file to identify any classes defined in the modules in the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all — I'm interested in using a little bit of pythonic abstraction / inheritance in my task files. Specifically, I have written a task file for initial behavioral shaping (working towards a 2AFC task) that implements the core skeleton of the task, and has lots of little details that help the mice perform the task well (i.e. accounting for their reaction times before counting certain things as errors). To change the task I have into the next task I want to use, all I really need to do is 1) import everything from the working task, then 2) add a few actions in a few states by using dummy functions in the first task and re-defining them in the new one. I tried to do 1) by something like
from my_first_task import *
at the top of the new task. The issue is that when I try to upload the task file to the pyBoard, I get the errorI see that when I do something like
import pyControl.utility as pc
at the top of a task, it's coming from the pyControl "framework" that is uploaded onto the pyBoard once (the code that lives in source/pyControl). And obviously that's not where my task file is. Is there a way to get the uploader / compiler to look for imports in the local files before uploading the task file to the pyBoard?Thanks!
PS: I also tried
from .my_first_task import *
and got an import error, "cant perform relative import", I assume for the same reason.Beta Was this translation helpful? Give feedback.
All reactions