From 7534801d3b30c312109f290401728cc37e9aba02 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Tue, 30 Nov 2021 11:58:32 -0500 Subject: [PATCH 1/8] Squashed commit of the following: commit a79d0e4e734338ab02bb5511031c0d0a1183e081 Author: David Meyer Date: Tue Nov 30 11:20:27 2021 -0500 Update setup.cfg in preparation for release. commit 811b43d06f98f44d2f68323e1e43b29ad8102c80 Merge: b8726ad a3be0db Author: David Meyer Date: Wed Nov 10 17:07:51 2021 -0500 Merge pull request #81 from chrisjbillington/py36-path-bug Fix bug on Python3.6 commit b8726ad7da12e5bba23fc0332f0c0fa5be79f03d Merge: d309a5f c4dd2a8 Author: David Meyer Date: Wed Nov 10 17:06:47 2021 -0500 Merge pull request #78 from zakv/setup-logging-jupyter Make setup_logging() more Jupyter-friendly. commit d309a5f6c7c5009951591ee8b36e36ccd0889065 Merge: d5dfea7 12db878 Author: David Meyer Date: Wed Nov 10 17:06:02 2021 -0500 Merge pull request #82 from dihm/zlog_port_profile Add default zlog port to default profile configuration file. commit c4dd2a83bdcf9b7318007a3a9970a599ba50f70c Author: Zak V Date: Tue Nov 9 20:12:19 2021 -0500 Removed duplicate call to sys.stdout.fileno() in setup_logging.setup_logging(). Probably best practice to call it just once rather than calling it first to check if it raises an error then again later to actually use the value it returns. commit 2e381071508dca12f8b2e017f5c13d0cd7984a5e Author: Zak V Date: Tue Nov 9 20:04:37 2021 -0500 Restructured try/except block in setup_logging.setup_logging() to avoid catching any UnsupportedOperation errors thrown by code other than sys.stdout.fileno(). commit 97e70c7d4faa83d0f0fb9462891fd16c3c8c1006 Author: Zak V Date: Tue Nov 9 19:56:07 2021 -0500 Added warning message when setup_logging.setup_logging() cannot send output to stdout and stderr. commit b7119231cf1b3d658e1462a5b006630eba13a77a Author: Zak V Date: Mon Jun 7 17:48:41 2021 -0400 setup_logging.py is now more Jupyter-friendly. commit d5dfea7bb44a4ca0f0757177ad19c24ba7cb2ae8 Merge: 9b76dcb b149e19 Author: David Meyer Date: Wed Nov 10 08:54:21 2021 -0500 Merge pull request #74 from zakv/unitconversions-import-bugfix Fixed bug in unitconversions._All._import_all() commit 12db878ead890839860b013a8d523855cd18d302 Author: David Meyer Date: Mon Nov 8 10:20:28 2021 -0500 Add default zlog port to default profile configuration file. commit 9b76dcb779195fe3559d49506a525b5c900e3034 Merge: e13c992 e5cf3fb Author: David Meyer Date: Fri Oct 22 17:53:17 2021 -0400 Merge pull request #80 from dihm/default_labconfig_docs Add default labconfig file to docs commit a3be0db563c0795fcd436fcfaa6643122cf9255e Author: chrisjbillington Date: Tue Sep 21 13:45:13 2021 +1000 Fix bug on Python3.6, where Path object not able to be treated as a string in ConfigParser. commit e5cf3fbe0579f6660f9704ef1ebe5ba95acc428a Author: David Meyer Date: Tue Aug 31 15:29:45 2021 -0400 Create a doc page that displays the current default labconfig.ini file, for easy reference. commit e13c992622f6c5294068e808c59ad0f32dae14c0 Merge: e74472c 461dc9f Author: David Meyer Date: Fri Jul 16 15:12:37 2021 -0400 Merge pull request #79 from dihm/labscript_utils-docs Update docs to match autogenerating templates used in other modules of labscript. commit 461dc9f69fe5f074cd20c728e2cbe7bdbd9390a8 Author: David Meyer Date: Thu Jul 15 10:26:41 2021 -0400 Add docstring coverage test to build. commit f90a4cc4d28e483b254c32f1c8a1472d483af059 Author: David Meyer Date: Thu Jul 15 10:26:26 2021 -0400 Update sphinx version. commit e45107d718a029b52e73a5fad6c9d86c15b076e8 Author: David Meyer Date: Mon Jul 12 12:57:18 2021 -0400 Converting docs build to fully automated version based on recursive autosummary calls. This more closely resembles how docs are built in the other modules, but is slightly different in that submodules are also recursively generated. commit 56d64f71d218809d1e2694a17e26814f3dbd8183 Author: David Meyer Date: Mon Jul 12 09:25:18 2021 -0400 Update sphinx pins to same versions as rest of suite. commit e74472c6371bd863d6268092f31000bc96ad81d7 Merge: f0999f5 c543328 Author: Chris Billington Date: Tue Feb 9 08:54:16 2021 +1100 Merge pull request #76 from zakv/fix-27 Work around infinite recursion in ToolPalette.resizeEvent() commit c543328b284e73fd58d075a563ac2d4d68e24ff6 Author: Zak V Date: Mon Feb 8 13:30:47 2021 -0500 Removed some python 2 debugging print statements from toolpalette.py. commit d9eb80fdd3a63ad5258ef85a84a67219235ab39d Author: Zak V Date: Sun Feb 7 23:44:47 2021 -0500 Fixed #27; worked around bug where ToolPalette.resizeEvent() could trigger itself in an infinite resursion loop. commit f0999f51b33c162ccb5c98a3ca34348087900184 Merge: 8371585 7d14b65 Author: Chris Billington Date: Mon Jan 4 13:46:54 2021 +1100 Merge pull request #75 from chrisjbillington/master Do not use deprecated set-env command commit 7d14b65dc1843fb77f19f36ba8a5e5f1bb43faff Author: chrisjbillington Date: Mon Jan 4 13:40:14 2021 +1100 Do not use deprecated set-env command commit b149e1955c4b122ec443d67b30545c724f557773 Author: Zak V Date: Tue Nov 24 18:06:11 2020 -0500 Fixed bug in unitconversions._All._import_all() where self.__all__ wasn't always changed from None to an empty list before appending things to it. --- .github/workflows/release.yml | 6 +- .gitignore | 3 +- docs/source/_templates/autosummary-class.rst | 32 ++++++++ docs/source/_templates/autosummary-module.rst | 66 ++++++++++++++++ docs/source/api/connections.rst | 8 -- docs/source/api/dict_diff.rst | 8 -- docs/source/api/double_import_denier.rst | 8 -- docs/source/api/filewatcher.rst | 8 -- docs/source/api/h5_lock.rst | 8 -- docs/source/api/impprof.rst | 8 -- docs/source/api/index.rst | 62 ++------------- docs/source/api/labconfig.rst | 8 -- docs/source/api/labscript_utils.rst | 7 -- docs/source/api/ls_zprocess.rst | 8 -- docs/source/api/memprof.rst | 8 -- docs/source/api/modulewatcher.rst | 8 -- docs/source/api/properties.rst | 8 -- docs/source/api/qtwidgets.rst | 78 ------------------- docs/source/api/remote.rst | 8 -- docs/source/api/settings.rst | 8 -- docs/source/api/setup_logging.rst | 8 -- docs/source/api/shared_drive.rst | 8 -- docs/source/api/splash.rst | 8 -- docs/source/api/testing_utils.rst | 8 -- docs/source/api/tracelog.rst | 8 -- docs/source/api/unitconversions.rst | 64 --------------- docs/source/api/versions.rst | 8 -- docs/source/api/zlock.rst | 8 -- docs/source/api/zlog.rst | 8 -- docs/source/conf.py | 43 ++++++++++ docs/source/index.rst | 1 + docs/source/labconfig.rst | 25 ++++++ labscript_profile/__init__.py | 5 +- .../default_profile/labconfig/example.ini | 1 + labscript_utils/filewatcher.py | 43 +++++----- labscript_utils/labconfig.py | 3 +- labscript_utils/qtwidgets/toolpalette.py | 67 ++++++++++++---- labscript_utils/setup_logging.py | 43 ++++++---- labscript_utils/unitconversions/__init__.py | 3 +- setup.cfg | 7 +- 40 files changed, 290 insertions(+), 437 deletions(-) create mode 100644 docs/source/_templates/autosummary-class.rst create mode 100644 docs/source/_templates/autosummary-module.rst delete mode 100644 docs/source/api/connections.rst delete mode 100644 docs/source/api/dict_diff.rst delete mode 100644 docs/source/api/double_import_denier.rst delete mode 100644 docs/source/api/filewatcher.rst delete mode 100644 docs/source/api/h5_lock.rst delete mode 100644 docs/source/api/impprof.rst delete mode 100644 docs/source/api/labconfig.rst delete mode 100644 docs/source/api/labscript_utils.rst delete mode 100644 docs/source/api/ls_zprocess.rst delete mode 100644 docs/source/api/memprof.rst delete mode 100644 docs/source/api/modulewatcher.rst delete mode 100644 docs/source/api/properties.rst delete mode 100644 docs/source/api/qtwidgets.rst delete mode 100644 docs/source/api/remote.rst delete mode 100644 docs/source/api/settings.rst delete mode 100644 docs/source/api/setup_logging.rst delete mode 100644 docs/source/api/shared_drive.rst delete mode 100644 docs/source/api/splash.rst delete mode 100644 docs/source/api/testing_utils.rst delete mode 100644 docs/source/api/tracelog.rst delete mode 100644 docs/source/api/unitconversions.rst delete mode 100644 docs/source/api/versions.rst delete mode 100644 docs/source/api/zlock.rst delete mode 100644 docs/source/api/zlog.rst create mode 100644 docs/source/labconfig.rst diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f1c8db5..b917ac2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,8 +110,8 @@ jobs: else CONDA_BUILD_ARGS="" fi - echo "::set-env name=CONDA_INSTALLER::$CONDA_INSTALLER" - echo "::set-env name=CONDA_BUILD_ARGS::$CONDA_BUILD_ARGS" + echo "CONDA_INSTALLER=$CONDA_INSTALLER" >> $GITHUB_ENV + echo "CONDA_BUILD_ARGS=$CONDA_BUILD_ARGS" >> $GITHUB_ENV - name: Conda package (Unix) if: runner.os != 'Windows' @@ -210,7 +210,7 @@ jobs: if: github.event.ref_type == 'tag' run: | VERSION="${GITHUB_REF/refs\/tags\/v/}" - echo "::set-env name=VERSION::$VERSION" + echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Create GitHub Release if: github.event.ref_type == 'tag' diff --git a/.gitignore b/.gitignore index 70c27dc..583228d 100644 --- a/.gitignore +++ b/.gitignore @@ -158,4 +158,5 @@ conda_packages/ # Sphinx documentation docs/html/ docs/source/_build/ -docs/source/components.rst \ No newline at end of file +docs/source/components.rst +docs/source/api/_autosummary \ No newline at end of file diff --git a/docs/source/_templates/autosummary-class.rst b/docs/source/_templates/autosummary-class.rst new file mode 100644 index 0000000..4a2889e --- /dev/null +++ b/docs/source/_templates/autosummary-class.rst @@ -0,0 +1,32 @@ +{{ fullname | escape | underline}} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + :members: + :undoc-members: + :show-inheritance: + + {% block methods %} + .. automethod:: __init__ + + {% if methods %} + .. rubric:: {{ _('Methods') }} + + .. autosummary:: + {% for item in methods %} + ~{{ name }}.{{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block attributes %} + {% if attributes %} + .. rubric:: {{ _('Attributes') }} + + .. autosummary:: + {% for item in attributes %} + ~{{ name }}.{{ item }} + {%- endfor %} + {% endif %} + {% endblock %} diff --git a/docs/source/_templates/autosummary-module.rst b/docs/source/_templates/autosummary-module.rst new file mode 100644 index 0000000..2ce2afd --- /dev/null +++ b/docs/source/_templates/autosummary-module.rst @@ -0,0 +1,66 @@ +{{ fullname | escape | underline}} + +{% block submodules %} +{% if modules %} +.. rubric:: {{ _('Sub-Modules') }} +.. autosummary:: + :toctree: + :template: autosummary-module.rst + :recursive: + + {% for item in modules %} + {{ item }} + {%- endfor %} +{% endif %} +{% endblock %} + +.. automodule:: {{ fullname }} + + {% block attributes %} + {% if attributes %} + .. rubric:: {{ _('Module Attributes') }} + + .. autosummary:: + :toctree: + {% for item in attributes %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block functions %} + {% if functions %} + .. rubric:: {{ _('Functions') }} + + .. autosummary:: + :toctree: + {% for item in functions %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block classes %} + {% if classes %} + .. rubric:: {{ _('Classes') }} + + .. autosummary:: + :toctree: + :template: autosummary-class.rst + {% for item in classes %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block exceptions %} + {% if exceptions %} + .. rubric:: {{ _('Exceptions') }} + + .. autosummary:: + :toctree: + {% for item in exceptions %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} diff --git a/docs/source/api/connections.rst b/docs/source/api/connections.rst deleted file mode 100644 index d4e5745..0000000 --- a/docs/source/api/connections.rst +++ /dev/null @@ -1,8 +0,0 @@ -=========================== -labscript_utils.connections -=========================== - -.. automodule:: labscript_utils.connections - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/dict_diff.rst b/docs/source/api/dict_diff.rst deleted file mode 100644 index 13b571b..0000000 --- a/docs/source/api/dict_diff.rst +++ /dev/null @@ -1,8 +0,0 @@ -========================= -labscript_utils.dict_diff -========================= - -.. automodule:: labscript_utils.dict_diff - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/double_import_denier.rst b/docs/source/api/double_import_denier.rst deleted file mode 100644 index be00f09..0000000 --- a/docs/source/api/double_import_denier.rst +++ /dev/null @@ -1,8 +0,0 @@ -==================================== -labscript_utils.double_import_denier -==================================== - -.. automodule:: labscript_utils.double_import_denier - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/filewatcher.rst b/docs/source/api/filewatcher.rst deleted file mode 100644 index b9dc72e..0000000 --- a/docs/source/api/filewatcher.rst +++ /dev/null @@ -1,8 +0,0 @@ -=========================== -labscript_utils.filewatcher -=========================== - -.. automodule:: labscript_utils.filewatcher - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/h5_lock.rst b/docs/source/api/h5_lock.rst deleted file mode 100644 index 7647103..0000000 --- a/docs/source/api/h5_lock.rst +++ /dev/null @@ -1,8 +0,0 @@ -======================= -labscript_utils.h5_lock -======================= - -.. automodule:: labscript_utils.h5_lock - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/impprof.rst b/docs/source/api/impprof.rst deleted file mode 100644 index 3948b81..0000000 --- a/docs/source/api/impprof.rst +++ /dev/null @@ -1,8 +0,0 @@ -======================= -labscript_utils.impprof -======================= - -.. automodule:: labscript_utils.impprof - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/index.rst b/docs/source/api/index.rst index 9e9ff9a..59bde58 100644 --- a/docs/source/api/index.rst +++ b/docs/source/api/index.rst @@ -2,62 +2,10 @@ API Reference ************* -Labscript Tools -~~~~~~~~~~~~~~~ - -.. toctree:: - :maxdepth: 2 +.. autosummary:: + :toctree: _autosummary + :template: autosummary-module.rst + :recursive: labscript_utils - connections - dict_diff - labconfig - settings - testing_utils - properties - unitconversions - -Communications -~~~~~~~~~~~~~~ - -.. toctree:: - :maxdepth: 2 - - h5_lock - ls_zprocess - remote - shared_drive - zlock - zlog - -GUI -~~~~ - -.. toctree:: - :maxdepth: 2 - - splash - qtwidgets - -Logging and Profiling -~~~~~~~~~~~~~~~~~~~~~ - -.. toctree:: - :maxdepth: 2 - - impprof - memprof - setup_logging - tracelog - - -Module and File Tools -~~~~~~~~~~~~~~~~~~~~~ - -.. toctree:: - :maxdepth: 2 - - double_import_denier - filewatcher - modulewatcher - versions + labscript_profile diff --git a/docs/source/api/labconfig.rst b/docs/source/api/labconfig.rst deleted file mode 100644 index d95907d..0000000 --- a/docs/source/api/labconfig.rst +++ /dev/null @@ -1,8 +0,0 @@ -========================= -labscript_utils.labconfig -========================= - -.. automodule:: labscript_utils.labconfig - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/labscript_utils.rst b/docs/source/api/labscript_utils.rst deleted file mode 100644 index f73d1e1..0000000 --- a/docs/source/api/labscript_utils.rst +++ /dev/null @@ -1,7 +0,0 @@ -=============== -labscript_utils -=============== - -.. automodule:: labscript_utils - :members: - :undoc-members: \ No newline at end of file diff --git a/docs/source/api/ls_zprocess.rst b/docs/source/api/ls_zprocess.rst deleted file mode 100644 index 27ddede..0000000 --- a/docs/source/api/ls_zprocess.rst +++ /dev/null @@ -1,8 +0,0 @@ -=========================== -labscript_utils.ls_zprocess -=========================== - -.. automodule:: labscript_utils.ls_zprocess - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/memprof.rst b/docs/source/api/memprof.rst deleted file mode 100644 index f52ff07..0000000 --- a/docs/source/api/memprof.rst +++ /dev/null @@ -1,8 +0,0 @@ -======================= -labscript_utils.memprof -======================= - -.. automodule:: labscript_utils.memprof - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/modulewatcher.rst b/docs/source/api/modulewatcher.rst deleted file mode 100644 index 95055be..0000000 --- a/docs/source/api/modulewatcher.rst +++ /dev/null @@ -1,8 +0,0 @@ -============================= -labscript_utils.modulewatcher -============================= - -.. automodule:: labscript_utils.modulewatcher - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/properties.rst b/docs/source/api/properties.rst deleted file mode 100644 index 0c4d364..0000000 --- a/docs/source/api/properties.rst +++ /dev/null @@ -1,8 +0,0 @@ -========================== -labscript_utils.properties -========================== - -.. automodule:: labscript_utils.properties - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/qtwidgets.rst b/docs/source/api/qtwidgets.rst deleted file mode 100644 index 1df32fe..0000000 --- a/docs/source/api/qtwidgets.rst +++ /dev/null @@ -1,78 +0,0 @@ -========================= -labscript_utils.qtwidgets -========================= - -.. automodule:: labscript_utils.qtwidgets - :members: - :undoc-members: - -Helper Widgets -~~~~~~~~~~~~~~ - -.. automodule:: labscript_utils.qtwidgets.dragdroptab - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.elide_label - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.fingertab - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.headerview_with_widgets - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.InputPlotWindow - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.outputbox - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.toolpalette - :members: - :undoc-members: - :show-inheritance: - -Input/Output Widgets -~~~~~~~~~~~~~~~~~~~~ - -.. automodule:: labscript_utils.qtwidgets.analoginput - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.analogoutput - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.ddsoutput - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.digitaloutput - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.enumoutput - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.qtwidgets.imageoutput - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/source/api/remote.rst b/docs/source/api/remote.rst deleted file mode 100644 index 3704a84..0000000 --- a/docs/source/api/remote.rst +++ /dev/null @@ -1,8 +0,0 @@ -====================== -labscript_utils.remote -====================== - -.. automodule:: labscript_utils.remote - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/settings.rst b/docs/source/api/settings.rst deleted file mode 100644 index f42d1aa..0000000 --- a/docs/source/api/settings.rst +++ /dev/null @@ -1,8 +0,0 @@ -======================== -labscript_utils.settings -======================== - -.. automodule:: labscript_utils.settings - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/setup_logging.rst b/docs/source/api/setup_logging.rst deleted file mode 100644 index ac72f74..0000000 --- a/docs/source/api/setup_logging.rst +++ /dev/null @@ -1,8 +0,0 @@ -============================= -labscript_utils.setup_logging -============================= - -.. automodule:: labscript_utils.setup_logging - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/shared_drive.rst b/docs/source/api/shared_drive.rst deleted file mode 100644 index 612fdf2..0000000 --- a/docs/source/api/shared_drive.rst +++ /dev/null @@ -1,8 +0,0 @@ -============================ -labscript_utils.shared_drive -============================ - -.. automodule:: labscript_utils.shared_drive - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/splash.rst b/docs/source/api/splash.rst deleted file mode 100644 index 1c487ea..0000000 --- a/docs/source/api/splash.rst +++ /dev/null @@ -1,8 +0,0 @@ -====================== -labscript_utils.splash -====================== - -.. automodule:: labscript_utils.splash - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/testing_utils.rst b/docs/source/api/testing_utils.rst deleted file mode 100644 index dba7879..0000000 --- a/docs/source/api/testing_utils.rst +++ /dev/null @@ -1,8 +0,0 @@ -============================= -labscript_utils.testing_utils -============================= - -.. automodule:: labscript_utils.testing_utils - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/tracelog.rst b/docs/source/api/tracelog.rst deleted file mode 100644 index 2acedd0..0000000 --- a/docs/source/api/tracelog.rst +++ /dev/null @@ -1,8 +0,0 @@ -======================== -labscript_utils.tracelog -======================== - -.. automodule:: labscript_utils.tracelog - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/unitconversions.rst b/docs/source/api/unitconversions.rst deleted file mode 100644 index 553d98b..0000000 --- a/docs/source/api/unitconversions.rst +++ /dev/null @@ -1,64 +0,0 @@ -=============================== -labscript_utils.unitconversions -=============================== - -.. automodule:: labscript_utils.unitconversions - :members: - :undoc-members: - -Basic Unit Conversion Classes -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. automodule:: labscript_utils.unitconversions.test - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.unitconversions.example - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.unitconversions.UnitConversionBase - :members: - :undoc-members: - :show-inheritance: - -Unit Conversion Classes -~~~~~~~~~~~~~~~~~~~~~~~ - -.. automodule:: labscript_utils.unitconversions.aom - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.unitconversions.detuning - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.unitconversions.linear_coil_driver - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.unitconversions.NovaTechDDS9m - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.unitconversions.optotunelens - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.unitconversions.quad_driver - :members: - :undoc-members: - :show-inheritance: - -.. automodule:: labscript_utils.unitconversions.quad_monitor - :members: - :undoc-members: - :show-inheritance: - diff --git a/docs/source/api/versions.rst b/docs/source/api/versions.rst deleted file mode 100644 index 996d686..0000000 --- a/docs/source/api/versions.rst +++ /dev/null @@ -1,8 +0,0 @@ -============================ -labscript_utils.versions -============================ - -.. automodule:: labscript_utils.versions - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/zlock.rst b/docs/source/api/zlock.rst deleted file mode 100644 index 0d9aac1..0000000 --- a/docs/source/api/zlock.rst +++ /dev/null @@ -1,8 +0,0 @@ -===================== -labscript_utils.zlock -===================== - -.. automodule:: labscript_utils.zlock - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/api/zlog.rst b/docs/source/api/zlog.rst deleted file mode 100644 index 160db96..0000000 --- a/docs/source/api/zlog.rst +++ /dev/null @@ -1,8 +0,0 @@ -==================== -labscript_utils.zlog -==================== - -.. automodule:: labscript_utils.zlog - :members: - :undoc-members: - :private-members: \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index e3df35c..fd757b8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -40,6 +40,7 @@ # ones. extensions = [ "sphinx.ext.autodoc", + "sphinx.ext.autosummary", "sphinx.ext.autosectionlabel", "sphinx.ext.intersphinx", "sphinx.ext.napoleon", @@ -50,6 +51,8 @@ ] autodoc_typehints = 'description' +autosummary_generate = True +numfig = True # mock missing site packages methods import site @@ -241,3 +244,43 @@ def setup(app): img_path=img_path ) ) + + # hooks to test docstring coverage + app.connect('autodoc-process-docstring', doc_coverage) + app.connect('build-finished', doc_report) + + +members_to_watch = ['module', 'class', 'function', 'exception', 'method', 'attribute'] +doc_count = 0 +undoc_count = 0 +undoc_objects = [] +undoc_print_objects = False + + +def doc_coverage(app, what, name, obj, options, lines): + global doc_count + global undoc_count + global undoc_objects + + if (what in members_to_watch and len(lines) == 0): + # blank docstring detected + undoc_count += 1 + undoc_objects.append(name) + else: + doc_count += 1 + + +def doc_report(app, exception): + global doc_count + global undoc_count + global undoc_objects + # print out report of documentation coverage + total_docs = undoc_count + doc_count + if total_docs != 0: + print(f'\nAPI Doc coverage of {doc_count/total_docs:.1%}') + if undoc_print_objects or os.environ.get('READTHEDOCS'): + print('\nItems lacking documentation') + print('===========================') + print(*undoc_objects, sep='\n') + else: + print('No docs counted, run \'make clean\' then rebuild to get the count.') diff --git a/docs/source/index.rst b/docs/source/index.rst index 86f2cab..89647bc 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -14,6 +14,7 @@ This documentation is primarily for developers who might want to use this common :hidden: :caption: DOCUMENTATION + labconfig api/index .. toctree:: diff --git a/docs/source/labconfig.rst b/docs/source/labconfig.rst new file mode 100644 index 0000000..9ca2399 --- /dev/null +++ b/docs/source/labconfig.rst @@ -0,0 +1,25 @@ +The *labconfig.ini* file +======================== + +The `labconfig.ini` file is a global configuration file for your **labscript-suite** installation. +It contains configurable settings that govern how the individual components of the suite operate. +The name of this file must be the host computer's system name. +So if my system's name was `heisenberg`, the labconfig file name would be `heisenberg.ini`. +This file should be located in the `labscript-suite` directory in the user space, in the `labconfig` subdirectory. + +When :doc:`installing the **labscript-suite** for the first time `, running the `labscript-profile-create` command will automatically generate the `labscript-suite` user space directory in the correct place and generate a `labconfig.ini` file for use on your system. +By editing the `ini` file named after your system, you can update the configuration settings of your **labscript-suite** installation. + +The Default *labconfig.ini* +--------------------------- + +Below is a copy of the default lab configuration if you were to install the **labscript-suite** today. + +.. note:: + + When updates are made to the suite that add or change keys available in the labconfig, your local file will **NOT** be automatically updated to include them. + Instead, if keys are missing from your local profile, default behavior will be assumed. + To implement the added functionality, you will need to manually add/change the keys in your local labconfig. + +.. include:: ../../labscript_profile/default_profile/labconfig/example.ini + :code: diff --git a/labscript_profile/__init__.py b/labscript_profile/__init__.py index a679ff5..55571f7 100644 --- a/labscript_profile/__init__.py +++ b/labscript_profile/__init__.py @@ -49,7 +49,10 @@ def add_userlib_and_pythonlib(): time the interpreter starts up""" labconfig = default_labconfig_path() if labconfig is not None and labconfig.exists(): - config = ConfigParser(defaults={'labscript_suite': LABSCRIPT_SUITE_PROFILE}) + # str() below is for py36 compat, where ConfigParser can't deal with Path objs + config = ConfigParser( + defaults={'labscript_suite': str(LABSCRIPT_SUITE_PROFILE)} + ) config.read(labconfig) for option in ['userlib', 'pythonlib']: try: diff --git a/labscript_profile/default_profile/labconfig/example.ini b/labscript_profile/default_profile/labconfig/example.ini index 38ffeb2..99c9503 100644 --- a/labscript_profile/default_profile/labconfig/example.ini +++ b/labscript_profile/default_profile/labconfig/example.ini @@ -23,6 +23,7 @@ lyse = 42519 runviewer = 42521 runmanager = 42523 zlock = 7339 +zlog = 7340 zprocess_remote = 7341 [timeouts] diff --git a/labscript_utils/filewatcher.py b/labscript_utils/filewatcher.py index c5b9dd5..4b6f84b 100644 --- a/labscript_utils/filewatcher.py +++ b/labscript_utils/filewatcher.py @@ -24,28 +24,27 @@ def __init__(self, callback, files=None, folders=None, clean_modified_info=None, Detect modification, deletion, creation, or restoration of specific files (and all files in specific folders). - callback -- elicited whenever file events are detected, requires at least - (name, info) arguments. Event specific callback requires - (name, info, event) arguments, where event is on of: - 'modified', 'deleted' (or None), 'created', 'restored', 'original' - The 'original' event corresponds to a state change that results in - the original file info at instantiation. - - Keyword arguments: - files -- List of specific files to watch. - A single file can be specified as a string (default None). - folders -- List of specific folders to watch. - A single folder can be specified as a string (default None). - If a file is created/deleted in/from any watched folder, it is added/ - removed to/from the FileWatcher.files attribute. - clean_modified_info -- File info to detect modification/restoration with respect - to. If None (default), or for files not present in clean_modified_info, the - initial modified info will be based on the first polling of files. - hashable_types -- File extensions for which MD5 checksum will be used to - detect modification/restoration with (default None). Files of any - other type will be watched using their modified time. - Restoration cannot be detected for types not in hashable_types. - interval -- Polling interval in seconds (default 1). + Args: + callback (function): elicited whenever file events are detected, requires at least + (name, info) arguments. Event specific callback requires + (name, info, event) arguments, where event is on of: + 'modified', 'deleted' (or None), 'created', 'restored', 'original' + The 'original' event corresponds to a state change that results in + the original file info at instantiation. + files (list, optional): List of specific files to watch. + A single file can be specified as a string (default None). + folders (list, optional): List of specific folders to watch. + A single folder can be specified as a string (default None). + If a file is created/deleted in/from any watched folder, it is added/ + removed to/from the FileWatcher.files attribute. + clean_modified_info (dict, optional): File info to detect modification/restoration with respect + to. If None (default), or for files not present in clean_modified_info, the + initial modified info will be based on the first polling of files. + hashable_types (iterable, optional): File extensions for which MD5 checksum will be used to + detect modification/restoration with (default None). Files of any + other type will be watched using their modified time. + Restoration cannot be detected for types not in hashable_types. + interval (float, optional): Polling interval in seconds (default 1). """ if len(getfullargspec(callback)[0]) > 2: # For backwards compatability, allow callback to have only two args diff --git a/labscript_utils/labconfig.py b/labscript_utils/labconfig.py index d9c2057..d110fe8 100644 --- a/labscript_utils/labconfig.py +++ b/labscript_utils/labconfig.py @@ -43,7 +43,8 @@ def __init__( required_params = {} if defaults is None: defaults = {} - defaults['labscript_suite'] = LABSCRIPT_SUITE_PROFILE + # str() below is for py36 compat, where ConfigParser can't deal with Path objs + defaults['labscript_suite'] = str(LABSCRIPT_SUITE_PROFILE) if isinstance(config_path, list): self.config_path = config_path[0] else: diff --git a/labscript_utils/qtwidgets/toolpalette.py b/labscript_utils/qtwidgets/toolpalette.py index 21e9ef1..c4619fb 100644 --- a/labscript_utils/qtwidgets/toolpalette.py +++ b/labscript_utils/qtwidgets/toolpalette.py @@ -19,6 +19,8 @@ EXPAND_ICON = ':/qtutils/fugue/toggle-small-expand' CONTRACT_ICON = ':/qtutils/fugue/toggle-small' +_ENABLE_LAYOUT_EVENT_TYPE = QEvent.User + class ToolPaletteGroup(QVBoxLayout): def __init__(self,*args,**kwargs): @@ -265,6 +267,10 @@ def __init__(self,parent,name,*args,**kwargs): self._column_count = 0 self._row_count = 0 + # Variable for controlling whether or not self._layout_widgets() is + # called in self.resizeEvent(). + self._layout_widgets_during_resizeEvent = True + def addWidget(self,widget,force_relayout=True): # Append to end of tool pallete #widget.clicked.connect(embed) @@ -385,24 +391,53 @@ def minimumSizeHint(self): height = self.minimumSize().height() return QSize(width, height) + def event(self, event): + # Handle the custom event for reenabling the call to + # self._layout_widgets() during self.resizeEvent(). + if (event.type() == _ENABLE_LAYOUT_EVENT_TYPE): + self._layout_widgets_during_resizeEvent = True + # Return True so that this event isn't sent along to other event + # handlers as well. + return True + + # Handle all other events in the usual way. + return super().event(event) + def resizeEvent(self, event): # overwrite the resize event! - # print '--------- %s'%self._name - # print self._widget_list[0].size() - # print self._widget_list[0].sizeHint() - # print self._widget_list[0].minimumSizeHint() - # print self._layout.rowMinimumHeight(0) - # print self.size() - # print self.minimumSize() - # print self.sizeHint() - # print self.minimumSizeHint() - #pass resize event on to qwidget - # call layout() - QWidget.resizeEvent(self, event) - size = event.size() - if size.width() == self.size().width() and size.height() == self.size().height(): - # print 'relaying out widgets' - self._layout_widgets() + # This method can end up undergoing infinite recursion for some window + # layouts, see + # https://github.com/labscript-suite/labscript-utils/issues/27. It seems + # that sometimes self._layout_widgets() increases the number of columns, + # which then triggers a resizeEvent, which then calls + # self._layout_widgets() which then decreases the number of columns to + # its previous value, which triggers a resizeEvent, and so on. That loop + # may occur e.g. if increasing/decreasing the number of columns + # add/removes a scrollbar, which then changes the number of widgets that + # can fit in a row. Keeping track of the recursion depth isn't trivial + # because _layout_widgets() doesn't directly call itself; it just causes + # more resizing events to be added to the event queue. To work around + # that, this method will mark that future calls to this method shouldn't + # call _layout_widgets() but will also add an event to the event queue + # to reenable calling _layout_widgets() again once all of the resize + # events caused by this call to it have been processed. + + try: + #pass resize event on to qwidget + QWidget.resizeEvent(self, event) + size = event.size() + if size.width() == self.size().width() and size.height() == self.size().height(): + if self._layout_widgets_during_resizeEvent: + # Avoid calling this again until all the resize events that + # will be put in the queue by self._layout_widgets() have + # run. + self._layout_widgets_during_resizeEvent = False + self._layout_widgets() + finally: + # Add event to end of the event queue to allow _layout_widgets() in + # future calls. This event shouldn't be handled until the resize + # events generated during _layout_widgets() have run. + QCoreApplication.instance().postEvent(self, QEvent(_ENABLE_LAYOUT_EVENT_TYPE)) # A simple test! diff --git a/labscript_utils/setup_logging.py b/labscript_utils/setup_logging.py index df97448..aee409d 100644 --- a/labscript_utils/setup_logging.py +++ b/labscript_utils/setup_logging.py @@ -11,7 +11,9 @@ # # ##################################################################### import sys, os +from io import UnsupportedOperation import logging, logging.handlers +import warnings from labscript_utils.ls_zprocess import Handler, ensure_connected_to_zlog @@ -52,21 +54,32 @@ def setup_logging(program_name, log_level=logging.DEBUG, terminal_level=logging. handler.setFormatter(formatter) handler.setLevel(log_level) logger.addHandler(handler) - if sys.stdout is not None and sys.stdout.fileno() >= 0: - stdout_handler = logging.StreamHandler(sys.stdout) - stdout_handler.setFormatter(formatter) - stdout_handler.setLevel(terminal_level) - logger.addHandler(stdout_handler) - if sys.stderr is not None and sys.stderr.fileno() >= 0: - # Send warnings and greater to stderr instead of stdout: - stdout_handler.addFilter(LessThanFilter(logging.WARNING)) - sterr_handler = logging.StreamHandler(sys.stderr) - sterr_handler.setFormatter(formatter) - sterr_handler.setLevel(logging.WARNING) - logger.addHandler(sterr_handler) + try: + # Check that sys.stdout.fileno is callable, which is needed below. It is NOT + # callable in Jupyter notebooks. + stdout_fileno = sys.stdout.fileno() + except UnsupportedOperation: + # In this case the code is likely being run from a Jupyter notebook, warn the + # user that log messages won't be printed to stdout or stderr. + warnings.warn( + "Logging to stdout and stderr is disabled. See the log files for log messages." + ) else: - # Prevent bug on windows where writing to stdout without a command - # window causes a crash: - sys.stdout = sys.stderr = open(os.devnull, 'w') + if sys.stdout is not None and stdout_fileno >= 0: + stdout_handler = logging.StreamHandler(sys.stdout) + stdout_handler.setFormatter(formatter) + stdout_handler.setLevel(terminal_level) + logger.addHandler(stdout_handler) + if sys.stderr is not None and sys.stderr.fileno() >= 0: + # Send warnings and greater to stderr instead of stdout: + stdout_handler.addFilter(LessThanFilter(logging.WARNING)) + sterr_handler = logging.StreamHandler(sys.stderr) + sterr_handler.setFormatter(formatter) + sterr_handler.setLevel(logging.WARNING) + logger.addHandler(sterr_handler) + else: + # Prevent bug on windows where writing to stdout without a command + # window causes a crash: + sys.stdout = sys.stderr = open(os.devnull, 'w') logger.setLevel(logging.DEBUG) return logger diff --git a/labscript_utils/unitconversions/__init__.py b/labscript_utils/unitconversions/__init__.py index da49116..a1b01d3 100644 --- a/labscript_utils/unitconversions/__init__.py +++ b/labscript_utils/unitconversions/__init__.py @@ -26,7 +26,6 @@ class _All(object): def __getitem__(self, ix): if self.__all__ is None: - self.__all__ = [] self._import_all() return self.__all__[ix] @@ -34,6 +33,8 @@ def _import_all(self): """imports all unit conversion classes in module within this subpackage into this module's globals. This is used only for backward compatibility with unit conversion classes that were not specified with a fully qualified name""" + if self.__all__ is None: + self.__all__ = [] for filename in os.listdir(os.path.split(__file__)[0]): if filename.endswith('.py') and filename != '__init__.py': module = filename[:-3] diff --git a/setup.cfg b/setup.cfg index 235bcb7..88a1f37 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,6 +18,7 @@ classifiers = Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 [options] zip_safe = False @@ -29,7 +30,7 @@ install_requires = h5py>=2.9 numpy>=1.15 packaging>=20.4 - pyqtgraph>=0.11.0rc0 + pyqtgraph>=0.11.0 qtutils>=2.2.3 scipy setuptools_scm>=4.1.0 @@ -38,8 +39,8 @@ install_requires = [options.extras_require] docs = PyQt5 - Sphinx==3.0.1 - sphinx-rtd-theme==0.4.3 + Sphinx==3.5.3 + sphinx-rtd-theme==0.5.2 recommonmark==0.6.0 m2r==0.2.1 From 6ee210731e45e28c349d9fca02b31fd92fb900c9 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Mon, 21 Mar 2022 17:23:56 -0400 Subject: [PATCH 2/8] Squashed commit of the following: commit 95965b869793d70b5f2865c637a41bc79c68c1a8 Merge: a88582d f2f0ac7 Author: Chris Billington Date: Thu Mar 17 08:02:09 2022 +1100 Merge pull request #86 from dihm/replace_distutils Replace distutils commit f2f0ac78922888a4440418517476dff6ab77f19b Author: David Meyer Date: Wed Mar 16 09:43:51 2022 -0400 Replace `distutils.log` with basic `logging` in `setup.py`. commit b6b78231b0c40801817f3f4c5a9a3439a1000aa0 Author: David Meyer Date: Wed Mar 16 09:04:46 2022 -0400 Replace `distutils.sysconfig` with stdlib `sysconfig` in `modulewatcher`. commit 9840228ebc3033771b0e27e5152ae04da8c0fd1d Author: David Meyer Date: Wed Mar 16 09:04:10 2022 -0400 Replace `distutils.version.LooseVersion` with `packaging.version.Version` in `ls_zprocess`. commit a88582d7136854368db669b83ee2e572e0dc1d3e Merge: 66c68ab 75a7df6 Author: David Meyer Date: Thu Mar 3 09:28:57 2022 -0500 Merge pull request #84 from dihm/generic_freq_conv Add generic frequency conversion class commit 75a7df6c3a4f4b8a570e3bc186d2d7b305e4df25 Author: David Meyer Date: Wed Feb 9 12:27:17 2022 -0500 Add generic frequency conversion class that goes between standard SI prefixes from a base of Hz. commit 66c68ab24904d1fe33a9a26e96527c0d87dc7baf Merge: 7a3d58c 27501a3 Author: David Meyer Date: Wed Feb 9 10:47:36 2022 -0500 Merge pull request #83 from dihm/fix_docs_build Prevent starting a zlock server when importing `h5_lock` on RTD. commit 27501a3676ddb5fdec452d266c5a5dc546a367bf Author: David Meyer Date: Wed Feb 9 10:34:22 2022 -0500 Prevent starting a zlock server when importing `h5_lock` on RTD. commit 7a3d58c53e11b11f4e5c8403572c12acc6b27234 Author: David Meyer Date: Wed Feb 2 17:24:26 2022 -0500 Pin `mistune` to fix doc builds on RTD. commit 36c3c6a8d1e118bd35f5fa69167275fb18619aaa Author: chrisjbillington Date: Fri Jan 7 17:23:48 2022 +1100 Ensure only ints passed to QFrame.move in splash Otherwise this is a TypeError in the latest PyQt5. commit f4da12ebfb3dd85b364b95849de5e153639fcf6d Author: David Meyer Date: Tue Nov 30 13:00:27 2021 -0500 Triggering build of release branch by undoing unnecessary pin change for pyqtgraph. commit a79d0e4e734338ab02bb5511031c0d0a1183e081 Author: David Meyer Date: Tue Nov 30 11:20:27 2021 -0500 Update setup.cfg in preparation for release. commit 811b43d06f98f44d2f68323e1e43b29ad8102c80 Merge: b8726ad a3be0db Author: David Meyer Date: Wed Nov 10 17:07:51 2021 -0500 Merge pull request #81 from chrisjbillington/py36-path-bug Fix bug on Python3.6 commit b8726ad7da12e5bba23fc0332f0c0fa5be79f03d Merge: d309a5f c4dd2a8 Author: David Meyer Date: Wed Nov 10 17:06:47 2021 -0500 Merge pull request #78 from zakv/setup-logging-jupyter Make setup_logging() more Jupyter-friendly. commit d309a5f6c7c5009951591ee8b36e36ccd0889065 Merge: d5dfea7 12db878 Author: David Meyer Date: Wed Nov 10 17:06:02 2021 -0500 Merge pull request #82 from dihm/zlog_port_profile Add default zlog port to default profile configuration file. commit c4dd2a83bdcf9b7318007a3a9970a599ba50f70c Author: Zak V Date: Tue Nov 9 20:12:19 2021 -0500 Removed duplicate call to sys.stdout.fileno() in setup_logging.setup_logging(). Probably best practice to call it just once rather than calling it first to check if it raises an error then again later to actually use the value it returns. commit 2e381071508dca12f8b2e017f5c13d0cd7984a5e Author: Zak V Date: Tue Nov 9 20:04:37 2021 -0500 Restructured try/except block in setup_logging.setup_logging() to avoid catching any UnsupportedOperation errors thrown by code other than sys.stdout.fileno(). commit 97e70c7d4faa83d0f0fb9462891fd16c3c8c1006 Author: Zak V Date: Tue Nov 9 19:56:07 2021 -0500 Added warning message when setup_logging.setup_logging() cannot send output to stdout and stderr. commit b7119231cf1b3d658e1462a5b006630eba13a77a Author: Zak V Date: Mon Jun 7 17:48:41 2021 -0400 setup_logging.py is now more Jupyter-friendly. commit d5dfea7bb44a4ca0f0757177ad19c24ba7cb2ae8 Merge: 9b76dcb b149e19 Author: David Meyer Date: Wed Nov 10 08:54:21 2021 -0500 Merge pull request #74 from zakv/unitconversions-import-bugfix Fixed bug in unitconversions._All._import_all() commit 12db878ead890839860b013a8d523855cd18d302 Author: David Meyer Date: Mon Nov 8 10:20:28 2021 -0500 Add default zlog port to default profile configuration file. commit 9b76dcb779195fe3559d49506a525b5c900e3034 Merge: e13c992 e5cf3fb Author: David Meyer Date: Fri Oct 22 17:53:17 2021 -0400 Merge pull request #80 from dihm/default_labconfig_docs Add default labconfig file to docs commit a3be0db563c0795fcd436fcfaa6643122cf9255e Author: chrisjbillington Date: Tue Sep 21 13:45:13 2021 +1000 Fix bug on Python3.6, where Path object not able to be treated as a string in ConfigParser. commit e5cf3fbe0579f6660f9704ef1ebe5ba95acc428a Author: David Meyer Date: Tue Aug 31 15:29:45 2021 -0400 Create a doc page that displays the current default labconfig.ini file, for easy reference. commit e13c992622f6c5294068e808c59ad0f32dae14c0 Merge: e74472c 461dc9f Author: David Meyer Date: Fri Jul 16 15:12:37 2021 -0400 Merge pull request #79 from dihm/labscript_utils-docs Update docs to match autogenerating templates used in other modules of labscript. commit 461dc9f69fe5f074cd20c728e2cbe7bdbd9390a8 Author: David Meyer Date: Thu Jul 15 10:26:41 2021 -0400 Add docstring coverage test to build. commit f90a4cc4d28e483b254c32f1c8a1472d483af059 Author: David Meyer Date: Thu Jul 15 10:26:26 2021 -0400 Update sphinx version. commit e45107d718a029b52e73a5fad6c9d86c15b076e8 Author: David Meyer Date: Mon Jul 12 12:57:18 2021 -0400 Converting docs build to fully automated version based on recursive autosummary calls. This more closely resembles how docs are built in the other modules, but is slightly different in that submodules are also recursively generated. commit 56d64f71d218809d1e2694a17e26814f3dbd8183 Author: David Meyer Date: Mon Jul 12 09:25:18 2021 -0400 Update sphinx pins to same versions as rest of suite. commit e74472c6371bd863d6268092f31000bc96ad81d7 Merge: f0999f5 c543328 Author: Chris Billington Date: Tue Feb 9 08:54:16 2021 +1100 Merge pull request #76 from zakv/fix-27 Work around infinite recursion in ToolPalette.resizeEvent() commit c543328b284e73fd58d075a563ac2d4d68e24ff6 Author: Zak V Date: Mon Feb 8 13:30:47 2021 -0500 Removed some python 2 debugging print statements from toolpalette.py. commit d9eb80fdd3a63ad5258ef85a84a67219235ab39d Author: Zak V Date: Sun Feb 7 23:44:47 2021 -0500 Fixed #27; worked around bug where ToolPalette.resizeEvent() could trigger itself in an infinite resursion loop. commit f0999f51b33c162ccb5c98a3ca34348087900184 Merge: 8371585 7d14b65 Author: Chris Billington Date: Mon Jan 4 13:46:54 2021 +1100 Merge pull request #75 from chrisjbillington/master Do not use deprecated set-env command commit 7d14b65dc1843fb77f19f36ba8a5e5f1bb43faff Author: chrisjbillington Date: Mon Jan 4 13:40:14 2021 +1100 Do not use deprecated set-env command commit b149e1955c4b122ec443d67b30545c724f557773 Author: Zak V Date: Tue Nov 24 18:06:11 2020 -0500 Fixed bug in unitconversions._All._import_all() where self.__all__ wasn't always changed from None to an empty list before appending things to it. --- labscript_utils/h5_lock.py | 9 ++-- labscript_utils/ls_zprocess.py | 4 +- labscript_utils/modulewatcher.py | 10 ++-- labscript_utils/splash.py | 2 +- .../unitconversions/generic_frequency.py | 54 +++++++++++++++++++ setup.cfg | 1 + setup.py | 4 +- 7 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 labscript_utils/unitconversions/generic_frequency.py diff --git a/labscript_utils/h5_lock.py b/labscript_utils/h5_lock.py index ad84a2c..4466074 100644 --- a/labscript_utils/h5_lock.py +++ b/labscript_utils/h5_lock.py @@ -89,6 +89,9 @@ def hack_locks_onto_h5py(): # Monkeypatch h5py so all files are locked: h5py.File = File - -connect_to_zlock_server() -hack_locks_onto_h5py() +if os.environ.get('READTHEDOCS'): + # prevent starting a zlock server on RTD, which always fails + pass +else: + connect_to_zlock_server() + hack_locks_onto_h5py() diff --git a/labscript_utils/ls_zprocess.py b/labscript_utils/ls_zprocess.py index 7173719..802e229 100644 --- a/labscript_utils/ls_zprocess.py +++ b/labscript_utils/ls_zprocess.py @@ -13,7 +13,7 @@ import sys import os from socket import gethostbyname -from distutils.version import LooseVersion +from packaging.version import Version import zmq import zprocess @@ -337,7 +337,7 @@ def connect_to_zlock_server(): global _zlock_server_supports_readwrite if hasattr(client, 'get_protocol_version'): version = client.get_protocol_version() - if LooseVersion(version) >= LooseVersion('1.1.0'): + if Version(version) >= Version('1.1.0'): _zlock_server_supports_readwrite = True # The user can call these functions to change the timeouts later if they diff --git a/labscript_utils/modulewatcher.py b/labscript_utils/modulewatcher.py index 7e33b6d..25df904 100644 --- a/labscript_utils/modulewatcher.py +++ b/labscript_utils/modulewatcher.py @@ -16,16 +16,16 @@ import os import imp import site -import distutils.sysconfig +import sysconfig # Directories in which the standard library and installed packages may be located. # Modules in these locations will be whitelisted: PKGDIRS = [ - distutils.sysconfig.get_python_lib(plat_specific=True, standard_lib=True), - distutils.sysconfig.get_python_lib(plat_specific=True, standard_lib=False), - distutils.sysconfig.get_python_lib(plat_specific=False, standard_lib=True), - distutils.sysconfig.get_python_lib(plat_specific=False, standard_lib=False), + sysconfig.get_path('platstdlib'), + sysconfig.get_path('platlib'), + sysconfig.get_path('stdlib'), + sysconfig.get_path('purelib'), site.getusersitepackages(), ] PKGDIRS += site.getsitepackages() diff --git a/labscript_utils/splash.py b/labscript_utils/splash.py index 6137510..3aecf8a 100644 --- a/labscript_utils/splash.py +++ b/labscript_utils/splash.py @@ -72,7 +72,7 @@ def __init__(self, imagepath): center_point = QtWidgets.QDesktopWidget().availableGeometry().center() x0, y0 = center_point.x(), center_point.y() - self.move(x0 - self.w / 2, y0 - self.h / 2) + self.move(x0 - self.w // 2, y0 - self.h // 2) self._first_paint_complete = False def paintEvent(self, event): diff --git a/labscript_utils/unitconversions/generic_frequency.py b/labscript_utils/unitconversions/generic_frequency.py new file mode 100644 index 0000000..9e7c4d6 --- /dev/null +++ b/labscript_utils/unitconversions/generic_frequency.py @@ -0,0 +1,54 @@ +##################################################################### +# # +# generic_frequency.py # +# # +# Copyright 2022, Monash University and contributors # +# # +# This file is part of the labscript suite (see # +# http://labscriptsuite.org) and is licensed under the Simplified # +# BSD License. See the license.txt file in the root of the project # +# for the full license. # +# # +##################################################################### +"""Generic frequency conversion""" + +from .UnitConversionBase import * + +class FreqConversion(UnitConversion): + """ + A Generic frequency conversion class that covers standard SI prefixes from a base of Hz. + """ + + base_unit = 'Hz' # must be defined here and match default hardware unit in BLACS tab + + def __init__(self, calibration_parameters = None): + self.parameters = calibration_parameters + if hasattr(self, 'derived_units'): + self.derived_units += ['kHz', 'MHz', 'GHz'] + else: + self.derived_units = ['kHz', 'MHz', 'GHz'] + UnitConversion.__init__(self,self.parameters) + + def kHz_to_base(self,kHz): + Hz = kHz*1e3 + return Hz + + def kHz_from_base(self,Hz): + kHz = Hz*1e-3 + return kHz + + def MHz_to_base(self,MHz): + Hz = MHz*1e6 + return Hz + + def MHz_from_base(self,Hz): + MHz = Hz*1e-6 + return MHz + + def GHz_to_base(self,GHz): + Hz = GHz*1e9 + return Hz + + def GHz_from_base(self,Hz): + GHz = Hz*1e-9 + return GHz \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 88a1f37..5bff886 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,7 @@ docs = sphinx-rtd-theme==0.5.2 recommonmark==0.6.0 m2r==0.2.1 + mistune<2.0.0 [options.package_data] labscript_profile = ../labscript-suite.pth diff --git a/setup.py b/setup.py index a12d0a0..eb36d8e 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ import os from setuptools import setup from setuptools.command.develop import develop -from distutils import log +import logging class develop_command(develop): @@ -11,7 +11,7 @@ def run(self): path = os.path.join(self.install_dir, 'labscript-suite.pth') super().run() if not self.uninstall: - log.info(f'Copying labscript-suite.pth to {path}') + logging.info(f'Copying labscript-suite.pth to {path}') if not self.dry_run: self.copy_file('labscript-suite.pth', path) From d4a6a3a6e5b4143df15ea9726c2441548e243ca3 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Thu, 2 Jun 2022 10:31:27 -0400 Subject: [PATCH 3/8] Merge pull request #88 from dihm/fix_docs_build Bump sphinx pin and update intersphinx links --- docs/source/conf.py | 6 +++--- setup.cfg | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index fd757b8..93b69f8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -93,15 +93,15 @@ intersphinx_mapping = { 'python': ('https://docs.python.org/3/', None), 'numpy': ('https://numpy.org/doc/stable/', None), - 'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None), + 'scipy': ('https://docs.scipy.org/doc/scipy/', None), 'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None), 'qtutils': ('https://qtutils.readthedocs.io/en/stable/', None), 'pyqtgraph': ( 'https://pyqtgraph.readthedocs.io/en/latest/', None, ), # change to stable once v0.11 is published - 'matplotlib': ('https://matplotlib.org/', None), - 'h5py': ('http://docs.h5py.org/en/stable/', None), + 'matplotlib': ('https://matplotlib.org/stable/', None), + 'h5py': ('https://docs.h5py.org/en/stable/', None), 'pydaqmx': ('https://pythonhosted.org/PyDAQmx/', None), 'qt': ( '', diff --git a/setup.cfg b/setup.cfg index 5bff886..0a59b27 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,7 +39,7 @@ install_requires = [options.extras_require] docs = PyQt5 - Sphinx==3.5.3 + Sphinx==4.4.0 sphinx-rtd-theme==0.5.2 recommonmark==0.6.0 m2r==0.2.1 From b990539208c92c5e2af35e9d8041d341457ff8e8 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Fri, 5 Aug 2022 16:44:48 -0400 Subject: [PATCH 4/8] Merge pull request #89 from dihm/update-workflow Bring workflow up to date with sandbox --- .github/workflows/release.yml | 149 ++++++++++++++++------------------ 1 file changed, 69 insertions(+), 80 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b917ac2..acd1c06 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,10 +9,6 @@ on: tags: - 'v[0-9]+.[0-9]+.[0-9]+*' -defaults: - run: - shell: bash - env: PACKAGE_NAME: labscript-utils SCM_LOCAL_SCHEME: no-local-version @@ -41,26 +37,30 @@ jobs: strategy: matrix: include: - - { os: ubuntu-latest, python: 3.8, arch: x64 } - # - { os: ubuntu-latest, python: 3.7, arch: x64 } - # - { os: ubuntu-latest, python: 3.6, arch: x64 } - - # - { os: macos-latest, python: 3.8, arch: x64 } - # - { os: macos-latest, python: 3.7, arch: x64 } - # - { os: macos-latest, python: 3.6, arch: x64 } - - # - { os: windows-latest, python: 3.8, arch: x64 } - # - { os: windows-latest, python: 3.7, arch: x64 } - # - { os: windows-latest, python: 3.6, arch: x64 } - - # - { os: windows-latest, python: 3.8, arch: x86 } - # - { os: windows-latest, python: 3.7, arch: x86 } - # - { os: windows-latest, python: 3.6, arch: x86 } + # - { os: ubuntu-latest, python: '3.10', arch: x64 } + # - { os: ubuntu-latest, python: '3.9', arch: x64 } + - { os: ubuntu-latest, python: '3.8', arch: x64 } + # - { os: ubuntu-latest, python: '3.7', arch: x64 } + + # - { os: macos-latest, python: '3.10', arch: x64 } + # - { os: macos-latest, python: '3.9', arch: x64 } + # - { os: macos-latest, python: '3.8', arch: x64 } + # - { os: macos-latest, python: '3.7', arch: x64 } + + # - { os: windows-latest, python: '3.10', arch: x64 } + # - { os: windows-latest, python: '3.9', arch: x64 } + # - { os: windows-latest, python: '3.8', arch: x64 } + # - { os: windows-latest, python: '3.7', arch: x64 } + + # - { os: windows-latest, python: '3.10', arch: x86 } + # - { os: windows-latest, python: '3.9', arch: x86 } + # - { os: windows-latest, python: '3.8', arch: x86 } + # - { os: windows-latest, python: '3.7', arch: x86 } if: github.repository == 'labscript-suite/labscript-utils' && (github.event_name != 'create' || github.event.ref_type != 'branch') steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -69,7 +69,7 @@ jobs: run: git tag -d $(git tag --points-at HEAD) - name: Install Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} architecture: ${{ matrix.arch }} @@ -77,72 +77,66 @@ jobs: - name: Source Distribution if: strategy.job-index == 0 run: | - python -m pip install --upgrade pip setuptools wheel pep517 - python -m pep517.build -s . + python -m pip install --upgrade pip setuptools wheel build + python -m build -s . - name: Wheel Distribution # Impure Linux wheels are built in the manylinux job. if: (env.PURE == 'true' && strategy.job-index == 0) || (env.PURE == 'false' && runner.os != 'Linux') run: | - python -m pip install --upgrade pip setuptools wheel pep517 - python -m pep517.build -b . + python -m pip install --upgrade pip setuptools wheel build + python -m build -w . - name: Upload Artifact if: strategy.job-index == 0 || (env.PURE == 'false' && runner.os != 'Linux') - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: dist path: ./dist - name: Set Variables for Conda Build + shell: bash run: | - if [ $RUNNER_OS == Windows ] && [ ${{ matrix.arch }} == x64 ]; then - CONDA_INSTALLER=Miniconda3-latest-Windows-x86_64.exe - elif [ $RUNNER_OS == Windows ]; then - CONDA_INSTALLER=Miniconda3-latest-Windows-x86.exe - elif [ $RUNNER_OS == Linux ]; then - CONDA_INSTALLER=Miniconda3-latest-Linux-x86_64.sh - else - CONDA_INSTALLER=Miniconda3-latest-MacOSX-x86_64.sh - fi if [ $NOARCH == true ]; then CONDA_BUILD_ARGS="--noarch" else CONDA_BUILD_ARGS="" fi - echo "CONDA_INSTALLER=$CONDA_INSTALLER" >> $GITHUB_ENV echo "CONDA_BUILD_ARGS=$CONDA_BUILD_ARGS" >> $GITHUB_ENV + - name: Install Miniconda + # We need https://github.com/conda-incubator/setup-miniconda/pull/189 in order + # to be able to install 32-bit miniconda on Windows. Once setup-miniconda 2.1.2 + # is released with this fix, can change to @v2. + uses: conda-incubator/setup-miniconda@1a875d105ac03256664b54c882c8c374ce617ef6 + with: + auto-update-conda: true + python-version: ${{ matrix.python }} + architecture: ${{ matrix.arch }} + miniconda-version: "latest" + + - name: Workaround conda-build incompatibility with xcode >12 + if: runner.os == 'macOS' + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: 11.7 + - name: Conda package (Unix) if: runner.os != 'Windows' + shell: bash -l {0} run: | - curl -LO https://repo.continuum.io/miniconda/$CONDA_INSTALLER - bash "$CONDA_INSTALLER" -b -p .miniconda - source .miniconda/etc/profile.d/conda.sh - conda activate - conda update -n base -c defaults conda - conda create -n py${{ matrix.python }} python=${{ matrix.python }} - conda activate py${{ matrix.python }} - conda install -c cbillington setuptools-conda - pip install --upgrade setuptools_scm + conda install -c labscript-suite setuptools-conda setuptools-conda build $CONDA_BUILD_ARGS . - name: Conda Package (Windows) if: runner.os == 'Windows' - shell: cmd + shell: cmd /C CALL {0} run: | - curl -LO https://repo.continuum.io/miniconda/%CONDA_INSTALLER% - %CONDA_INSTALLER% /S /D=%CD%\.miniconda && ^ - .miniconda\Scripts\activate && ^ - conda update -n base -c defaults conda && ^ - conda create -n py${{ matrix.python }} python=${{ matrix.python }} && ^ - conda activate py${{ matrix.python }} && ^ - conda install -c cbillington setuptools-conda && ^ - pip install --upgrade setuptools_scm && ^ - setuptools-conda build %CONDA_BUILD_ARGS% . + conda install -c labscript-suite setuptools-conda && ^ + setuptools-conda build %CONDA_BUILD_ARGS% --croot ${{ runner.temp }}\cb . - name: Upload Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: conda_packages path: ./conda_packages @@ -151,16 +145,11 @@ jobs: manylinux: name: Build Manylinux runs-on: ubuntu-latest - strategy: - matrix: - include: - - { python: 'cp36-cp36m cp37-cp37m cp38-cp38' } - if: github.repository == 'labscript-suite/labscript-utils' && (github.event_name != 'create' || github.event.ref_type != 'branch') steps: - name: Checkout if: env.PURE == 'false' - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 @@ -170,16 +159,17 @@ jobs: - name: Build Manylinux Wheels if: env.PURE == 'false' - uses: RalfG/python-wheels-manylinux-build@v0.2.2-manylinux2010_x86_64 + uses: RalfG/python-wheels-manylinux-build@v0.4.2 with: - python-versions: ${{ matrix.python }} + python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310' + pre-build-command: 'git config --global --add safe.directory "*"' - name: Upload Artifact if: env.PURE == 'false' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: dist - path: wheelhouse/*manylinux*.whl + path: dist/*manylinux*.whl release: name: Release @@ -188,19 +178,19 @@ jobs: steps: - name: Download Artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: dist path: ./dist - name: Download Artifact - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: conda_packages path: ./conda_packages - name: Publish on TestPyPI - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.testpypi }} @@ -242,19 +232,19 @@ jobs: user: __token__ password: ${{ secrets.pypi }} - - name: Install Miniconda and cloud client - run: | - curl -LO https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh - bash Miniconda3-latest-Linux-x86_64.sh -b -p .miniconda - source .miniconda/etc/profile.d/conda.sh - conda activate - conda install anaconda-client + - name: Install Miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + + - name: Install Anaconda cloud client + shell: bash -l {0} + run: conda install anaconda-client - name: Publish to Anaconda test label if: github.event.ref_type != 'tag' + shell: bash -l {0} run: | - source .miniconda/etc/profile.d/conda.sh - conda activate anaconda \ --token ${{ secrets.ANACONDA_API_TOKEN }} \ upload \ @@ -263,10 +253,9 @@ jobs: conda_packages/*/* - name: Publish to Anaconda main label + shell: bash -l {0} if: github.event.ref_type == 'tag' run: | - source .miniconda/etc/profile.d/conda.sh - conda activate anaconda \ --token ${{ secrets.ANACONDA_API_TOKEN }} \ upload \ From ac51bb71231a54ef6cdabc527b37936c6af4397e Mon Sep 17 00:00:00 2001 From: Chris Billington Date: Tue, 20 Dec 2022 12:04:33 +1030 Subject: [PATCH 5/8] Merge pull request #91 from labscript-suite/pep660-fix Include labscript-suite.pth in editable wheels --- setup.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index eb36d8e..5f958c3 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,25 @@ from setuptools.command.develop import develop import logging +# Setupstools >=64 +try: + from setuptools.command.editable_wheel import editable_wheel +except ImportError: + editable_wheel_command = None +else: + from wheel.wheelfile import WheelFile + class editable_wheel_command(editable_wheel): + """Custom editable_wheel command which installs the .pth file to the + wheel file for editable installs.""" + def _create_wheel_file(self, bdist_wheel): + wheel_path = super()._create_wheel_file(bdist_wheel) + with WheelFile(wheel_path, 'a') as wheel: + wheel.write("labscript-suite.pth") + return wheel_path + + +# Setuptools <= 63: class develop_command(develop): """Custom develop command which installs the .pth file to site-packages for editable installs.""" @@ -21,4 +39,10 @@ def run(self): "local_scheme": os.getenv("SCM_LOCAL_SCHEME", "node-and-date"), } -setup(use_scm_version=VERSION_SCHEME, cmdclass={'develop': develop_command}) +setup( + use_scm_version=VERSION_SCHEME, + cmdclass={ + 'develop': develop_command, + 'editable_wheel': editable_wheel_command, + }, +) From f27efc403e7b91fd833e4542d5af36361638eb80 Mon Sep 17 00:00:00 2001 From: David Meyer Date: Fri, 10 Mar 2023 14:56:40 -0500 Subject: [PATCH 6/8] Merge pull request #93 from labscript-suite/philipstarkey/no-hg Change labconfig default for `save_hg_info` to `False` --- labscript_profile/default_profile/labconfig/example.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labscript_profile/default_profile/labconfig/example.ini b/labscript_profile/default_profile/labconfig/example.ini index 99c9503..7f219dc 100644 --- a/labscript_profile/default_profile/labconfig/example.ini +++ b/labscript_profile/default_profile/labconfig/example.ini @@ -36,7 +36,7 @@ hdf5_viewer = %%LOCALAPPDATA%%\HDF_Group\HDFView\3.1.0\hdfview.bat hdf5_viewer_arguments = {file} [labscript] -save_hg_info = True +save_hg_info = False save_git_info = False [BLACS/plugins] From 29a40a0d887ae96ca68958a101d92e01662a1dfa Mon Sep 17 00:00:00 2001 From: David Meyer Date: Fri, 10 Mar 2023 15:58:55 -0500 Subject: [PATCH 7/8] Merge pull request #92 from johannesschabbauer/fix-h5py-memoryleak Fix memory leak of h5py when accessing dataset with composite dtypes. --- labscript_utils/properties.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/labscript_utils/properties.py b/labscript_utils/properties.py index f0a8ffb..8c2402f 100644 --- a/labscript_utils/properties.py +++ b/labscript_utils/properties.py @@ -124,7 +124,7 @@ def _get_con_table_properties(h5_file, device_name): # Compare with the name in the connection table # whether it is np.bytes_ or vlenstr: - namecol_dtype = dataset['name'].dtype + namecol_dtype = dataset.dtype['name'] if namecol_dtype.type is np.bytes_: device_name = device_name.encode('utf8') elif namecol_dtype is h5py.special_dtype(vlen=str): @@ -143,7 +143,7 @@ def _get_unit_conversion_parameters(h5_file, device_name): # Compare with the name in the connection table # whether it is np.bytes_ or vlenstr: - namecol_dtype = dataset['name'].dtype + namecol_dtype = dataset.dtype['name'] if namecol_dtype.type is np.bytes_: device_name = device_name.encode('utf8') elif namecol_dtype is h5py.special_dtype(vlen=str): From c6ce7ec2750573393791f8e03bf2964730d65241 Mon Sep 17 00:00:00 2001 From: chrisjbillington Date: Wed, 10 May 2023 10:05:04 +1000 Subject: [PATCH 8/8] pyzmq 25 compatibility Handle a new keyword argument to `Context.socket` in our subclass. --- labscript_utils/ls_zprocess.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/labscript_utils/ls_zprocess.py b/labscript_utils/ls_zprocess.py index 802e229..f3f2021 100644 --- a/labscript_utils/ls_zprocess.py +++ b/labscript_utils/ls_zprocess.py @@ -18,7 +18,7 @@ import zprocess import zprocess.process_tree -from zprocess.security import SecureContext +from zprocess.security import SecureContext, SecureSocket from labscript_utils.labconfig import LabConfig from labscript_utils import dedent import zprocess.zlog @@ -248,10 +248,19 @@ def instance(cls): # Super required to call unbound class method of parent class: return super(Context, cls).instance(shared_secret=config['shared_secret']) - def socket(self, *args, **kwargs): - config = get_config() - kwargs['allow_insecure'] = config['allow_insecure'] - return SecureContext.socket(self, *args, **kwargs) + def socket(self, socket_type, socket_class=None, **kwargs): + # socket_class kwarg introduced in pyzmq 25. Pass it through if it was given, + # otherwise don't. + if socket_class is not None: + kwargs['socket_class'] = socket_class + # Only insert our security-related args to the socket if we know it's going to + # be a SecureSocket. If caller has explicitly requested a different socket type + # (e.g since pyzmq 25, ThreadAuthenticator sets up an internal socket by calling + # `Context.socket(..., socket_class=zmq.Socket)), then don't.` + if socket_class is None or issubclass(socket_class, SecureContext): + config = get_config() + kwargs['allow_insecure'] = config['allow_insecure'] + return SecureContext.socket(self, socket_type=socket_type, **kwargs) def Lock(*args, **kwargs): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy