labscript-suite / labscript

The 𝗹𝗮𝗯𝘀𝗰𝗿𝗶𝗽𝘁 library provides a translation from expressive Python code to low-level hardware instructions.
http://labscriptsuite.org
BSD 2-Clause "Simplified" License
9 stars 48 forks source link

Save the full import path of unit conversion classes #84

Closed chrisjbillington closed 2 years ago

chrisjbillington commented 2 years ago

This allows unit conversion classes located outside of labscript_utils to be used.

Closes #71

chrisjbillington commented 2 years ago

Tested, seems to work:

image

dihm commented 2 years ago

Awesome! Maybe I'll be better about actually using custom unitconversion classes now.

Is there a recommended place where users should store their unitconversion classes? Presumably they have to live on the path somewhere, and would best be in the labscript-profile somewhere?

chrisjbillington commented 2 years ago

Anywhere in the import path will do, I would recommend putting them them in labscriptlib I think.

zakv commented 2 years ago

I'm a bit confused by that screenshot. Isn't it showing that all of the unit conversion classes used there are contained within labscript_utils.unitconversions?

zakv commented 2 years ago

Oh, is it just showing that the full import path is saved? Then it shouldn't matter whether or not the import path starts with labscript_utils?

chrisjbillington commented 2 years ago

Correct, any unit conversion class that is importable will work, and this PR is just to make labscript save the full import path of the class. The rest of the machinery in BLACS and labscript_utils should work to make BLACS be able to find them, and this PR ought to be the final piece needed to let you use classes defined outside of labscript_utils. These ones are in labscript_utils just because I compiled example.py to test.

dihm commented 2 years ago

Anywhere in the import path will do, I would recommend putting them them in labscriptlib I think.

Great. I can't say I've ever imported anything from the labscriptlib before. Would it be something like: labscriptlib.common.myconversions.my_special_unit_conversion ?

chrisjbillington commented 2 years ago

Yeah, something like that would do fine!

I can't say I've ever imported anything from the labscriptlib before

In principle labscriptlib is a place for putting modular bits of experiment scrips that are re-used, but in practice most scripts seem to tend toward an all-in-one philosophy.