Skip to content

Save the full import path of unit conversion classes #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

chrisjbillington
Copy link
Member

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

Closes #71

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

Closes labscript-suite#71
@chrisjbillington
Copy link
Member Author

Tested, seems to work:

image

@dihm
Copy link
Contributor

dihm commented Nov 9, 2021

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
Copy link
Member Author

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

@zakv
Copy link
Contributor

zakv commented Nov 10, 2021

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
Copy link
Contributor

zakv commented Nov 10, 2021

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
Copy link
Member Author

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 dihm merged commit 62455b5 into labscript-suite:master Nov 10, 2021
@dihm
Copy link
Contributor

dihm commented Nov 10, 2021

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
Copy link
Member Author

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.

@chrisjbillington chrisjbillington deleted the full-unitconversion-import-path branch November 19, 2021 11:31
dihm added a commit that referenced this pull request Dec 7, 2021
commit f6409e0
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Tue Dec 7 10:11:56 2021 -0500

    Update setup.cfg to show python 3.9 support.

commit 4d26344
Merge: 62455b5 deca5d8
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Wed Nov 10 18:42:45 2021 -0500

    Merge pull request #77 from zakv/square-wave

    Added AnalogQuantity.square_wave().

commit deca5d8
Author: Zak V <zakven@mit.edu>
Date:   Wed Nov 10 18:00:24 2021 -0500

    Changed the parameterization of AnalogQuantity.square_wave() inputs, then added square_wave_levels() method which uses the old parameterization.

    This PR also inverts the previous meaning of duty cycle in the old parameterization. Now duty cycle is the fraction of the time spent outputing `level_0` rather than `level_1` in square_wave_levels().

commit 62455b5
Merge: 13239cc bda942a
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Wed Nov 10 08:53:04 2021 -0500

    Merge pull request #84 from chrisjbillington/full-unitconversion-import-path

    Save the full import path of unit conversion classes

commit bda942a
Author: chrisjbillington <chrisjbillington@gmail.com>
Date:   Tue Nov 9 16:50:14 2021 +1100

    Save the full import path of unit conversion classes

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

    Closes #71

commit 13239cc
Merge: 83e10e5 4716ceb
Author: zakv <4721629+zakv@users.noreply.github.com>
Date:   Fri Aug 20 16:48:15 2021 -0400

    Merge pull request #72 from zakv/save-git-info

    Save git info

commit 83e10e5
Merge: 9fbd24c ea17d77
Author: zakv <4721629+zakv@users.noreply.github.com>
Date:   Fri Aug 20 16:47:49 2021 -0400

    Merge pull request #73 from philipstarkey/feature/performance-improvements

    Performance improvements

commit 9fbd24c
Merge: 04db899 736cb32
Author: zakv <4721629+zakv@users.noreply.github.com>
Date:   Fri Aug 20 08:33:57 2021 -0400

    Merge pull request #79 from zakv/fix-78

    Fix #78: labscript.py accidentally overwrites dedent()

commit 04db899
Merge: a805b69 9915e50
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Fri Jul 16 14:54:58 2021 -0400

    Merge pull request #74 from dihm/labscript-docs

    Initial pass at API docs for labscript

commit 9915e50
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Thu Jul 15 10:17:58 2021 -0400

    Even more docstring coverage in the API.

commit a4057e5
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Wed Jul 14 10:38:13 2021 -0400

    Adding more docstrings to the API.

commit 846377d
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Wed Jul 14 10:34:02 2021 -0400

    Remove colorama stuff. Doesn't work on RTD anyway. Now everything will
    be more consistent.

commit 073ceb4
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Wed Jul 14 10:08:19 2021 -0400

    Add missing dependency that sphinx should bring in automatically but doesn't on RTD.

commit 08071b1
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Wed Jul 14 09:51:36 2021 -0400

    Update sphinx pin to newest stable version.

commit 4b6f805
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Wed Jul 14 09:41:26 2021 -0400

    Quick hack to get a coverage percentage of the API documentation.

    We can't easily use the coverage extension because it counts things
    documented via the `undoc-members` flag as documented!

    Actual items that need documenting can also be printed if desired by
    setting the `undoc_print_objects` flag in conf.py.
    This is automatically done for RTD builds.

commit 09091e3
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Tue Jul 13 18:02:21 2021 -0400

    Add docstrings for all of the defined functions.

commit c1960c0
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Jul 9 11:45:36 2021 -0400

    Clean up warning messages and dead code.

commit b9be2c3
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Jul 9 11:23:00 2021 -0400

    Version bump RTD theme.

commit 7e086b6
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Apr 2 13:23:33 2021 -0400

    Version bump sphinx build requirement to 3.2.1

commit 689bc40
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Fri Apr 2 12:19:55 2021 -0400

    Adding the connection diagram figure from Phil's thesis.

commit f5b8eed
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Tue Nov 17 07:29:34 2020 -0500

    Version bump sphinx to 3.1.2

    This fixes issue where autodoc does not correctly handle decorated function
    signatures.

commit 6512ac6
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Mon Nov 16 20:17:19 2020 -0500

    Version bump sphinx

    Fixes issue with using autosummary templates

commit 0e91b09
Author: David Meyer <dihm.meyer@gmail.com>
Date:   Mon Nov 16 18:39:30 2020 -0500

    Initial pass at API docs for labscript.

    This relies on recursive features and custom templates for autosummary,
    as described in https://stackoverflow.com/questions/2701998/sphinx-autodoc-is-not-automatic-enough/62613202#62613202

commit 736cb32
Author: Zak V <zakven@mit.edu>
Date:   Thu Feb 25 19:23:29 2021 -0500

    Fixed issue 78 in which labscript.py accidentally overwrote labscript_utils.dedent() with matplotlib.cbook.dedent().

commit 054e281
Author: Zak V <zakven@mit.edu>
Date:   Thu Feb 25 18:40:41 2021 -0500

    Added AnalogQuantity.square_wave().

commit 4716ceb
Author: Zak V <zakven@mit.edu>
Date:   Thu Oct 15 05:47:31 2020 -0400

    Reduced _vcs_cache_rlock contention in save_labscripts().

commit ea17d77
Author: Phil Starkey <philipstarkey@users.noreply.github.com>
Date:   Thu Oct 15 18:50:45 2020 +1100

    Performance improvements

    These small changes seem to improve compilation time significantly. Tests (done with saving of hg info disabled) indicate compilation time for a complex experiment is decreased somewhere between 25-33%.

commit 903cc43
Author: Zak V <zakven@mit.edu>
Date:   Wed Oct 14 03:59:16 2020 -0400

    Worked on some thread safety issues with vcs caching.

commit 0f3f187
Author: Zak V <zakven@mit.edu>
Date:   Tue Oct 13 02:01:49 2020 -0400

    Results from git/hg are now cached for faster shot compilation.

commit 6022d97
Author: Zak V <zakven@mit.edu>
Date:   Sun Oct 4 12:52:10 2020 -0400

    Added '--tags' to call to git describe.

commit 2025755
Author: Zak V <zakven@mit.edu>
Date:   Sun Oct 4 12:38:10 2020 -0400

    Updated git/hg error message.

commit dc8d917
Author: Zak V <zakven@mit.edu>
Date:   Sun Oct 4 12:35:39 2020 -0400

    Added "git describe --always HEAD" to git commands.

commit 9a20221
Author: Zak V <zakven@mit.edu>
Date:   Sun Oct 4 12:30:44 2020 -0400

    Removed "--verify" from git rev-parse call.

commit 58ed6db
Author: Zak V <zakven@mit.edu>
Date:   Sun Oct 4 12:28:35 2020 -0400

    save_labscripts()'s calls to git/hg for a given file now run in parallel.

commit df4e17f
Author: Zak V <zakven@mit.edu>
Date:   Sat Oct 3 14:35:59 2020 -0400

    Added support for save_hg_info and save_git_info options in the labconfig [labscript] section.

commit e0073ea
Author: Zak V <zakven@mit.edu>
Date:   Sat Oct 3 13:48:15 2020 -0400

    Added support for saving git repo info.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unit conversion classes do not work if located outside labscript_utils.unit_conversions
3 participants