From a953031d2f92af9077486b33b9dab459e297b052 Mon Sep 17 00:00:00 2001 From: philipstarkey Date: Thu, 25 Jun 2020 16:38:27 +1000 Subject: [PATCH] Squashed commit of the following: commit d8b8343f10ee8235a113a9f18a5b07fe2fa474c3 Merge: 9bc7a39 bfa6932 Author: Chris Billington Date: Wed Jun 24 20:48:39 2020 -0400 Merge pull request #59 from philipstarkey/fix-h5py-file-mode Addresses #47 for this module commit 9bc7a399aa76a50764ac1b71d765b6f6f39d5006 Merge: 1189334 66d0be4 Author: Chris Billington Date: Wed Jun 24 20:30:42 2020 -0400 Merge pull request #55 from rpanderson/example_IMAQdx_remote Example labscript and analysis scripts for IMAQdxCamera and RemoteBLACS commit bfa69322ef0eb00c3fc5722d05e418bd3d9d0f6c Author: philipstarkey Date: Thu Jun 25 10:25:49 2020 +1000 Addresses #47 for this module commit 118933424d3893353879b67a662b0956d428e60c Merge: 5025b1b 0b0d07a Author: Chris Billington Date: Wed Jun 24 19:35:15 2020 -0400 Merge pull request #54 from rpanderson/example_experiment Minimal working connection table and example experiment script commit 66d0be49b78d52fe0c870b2a335185c59d04826e Author: Russell Anderson <5637107+rpanderson@users.noreply.github.com> Date: Mon Jun 15 13:37:23 2020 +1000 lyse analysis script demonstrating some Run methods for example_IMAQdx_remote commit a48a9c01d3f25e5cee48acb447e1908e5e2ba4fe Author: Russell Anderson <5637107+rpanderson@users.noreply.github.com> Date: Mon Jun 15 13:15:48 2020 +1000 Example connection table and labscript experiment script for RemoteBLACS and IMAQdxCamera commit 5025b1ba2d43fdeb3f34a08f4fd6557b6da54933 Merge: f77525f ed76901 Author: Chris Billington Date: Wed Jun 24 02:16:29 2020 -0400 Merge pull request #58 from philipstarkey/philipstarkey/issue43 Fixes .pth file has no effect in editable install commit ed769017d81b26bb4470dbc56e1a101037e59b25 Author: chrisjbillington Date: Wed Jun 24 01:23:44 2020 -0400 Move copying of .pth file into setup.py Use a custom develop command to copy the .pth file into site-packages when `python setup.py develop` is run - this is what pip does under the hood for `pip install -e`. No longer need desktop-app to locate site-packages, as the setuptools command class knows it as `self.install_dir`. The file is not removed by `pip uninstall`, but due to the `try: except:`s in the `.pth` file, leaving it behind is harmless. It is removed if the user runs whatever `setup.py` command undoies commit 894e2456109de7c20a3e158fd384310248376bb0 Author: chrisjbillington Date: Wed Jun 24 00:04:13 2020 -0400 Require desktop-app 0.2.6 Which renames `_get_install_directory` to not have an underscore, and which fixes a bug preventing docs from building on RTD. commit 271439eb1305d66bcf154455e483d8c9cefb7e10 Author: philipstarkey Date: Wed Jun 24 12:53:49 2020 +1000 Removed support for custom development directories from path commit dd098a5cd477b4102112ee720a076b018d77b61b Author: philipstarkey Date: Wed Jun 24 12:38:19 2020 +1000 Fixes .pth file has no effect in editable install Fixes #43 The .pth file is now copied during `labscript-profile-create` if it does not exist in the site-packages dir (where the .egg-info files exist) and if it the .pth file exists in the package structure (aka labscript-utils it is an editable install) The labscript-suite.pth file has been updated to not raise an exception if labscript-suite has been uninstalled (so we do not have to worry about cleanup). Also updated the `labscript_profile.add_userlib_and_pythonlib` function to use the `site` library for adding userlib and pythonlib to the system path. commit 0b0d07abced5caa5ba2f5bea0083b0f8ec03ef6b Author: Russell Anderson <5637107+rpanderson@users.noreply.github.com> Date: Mon Jun 22 17:48:00 2020 +1000 start()/stop() in __main__ block so connection table can be imported commit 4c19de9110fd139b318d95a51fa871baedd0de9c Author: Russell Anderson <5637107+rpanderson@users.noreply.github.com> Date: Mon Jun 15 13:12:52 2020 +1000 Add AnalogOut with ramp example, rename DigitalOut connection commit 9b64a0dac9b27af224c74a0bf87d9bf0c797fedb Author: Russell Anderson <5637107+rpanderson@users.noreply.github.com> Date: Wed Jun 10 23:09:03 2020 +1000 Minimal example connection table and labscript using dummy devices commit f77525f9d94eb2f96485f4369d01d0166c984b44 Author: Phil Starkey Date: Sat Jun 20 18:09:53 2020 +1000 Removed unnecessary fixed title from main TOC This was erroneously added in #57 commit 5e02b015674e228da4b29e006e74bd101c2e3f5c Merge: 3f78207 8b19766 Author: Phil Starkey Date: Sat Jun 20 18:07:04 2020 +1000 Merge pull request #57 from philipstarkey/master Changed URL for API reference to be shorter Fixed bug with readthedocs auto PR build commit 8b19766bcd3415ca0da1fb38e8b688f11ab6dd1f Author: philipstarkey Date: Sat Jun 20 12:02:51 2020 +1000 Updated method call for stylesheet to remove deprecated warning in build commit 56fdd63313e881797128a3b094a38bad754de31e Author: philipstarkey Date: Sat Jun 20 11:46:33 2020 +1000 Fixed sphinx conf to detect PR builds and link to 'latest' instead of stable commit 9889d19cbcc0e265ce06fcd5eee59f7365ac92d0 Author: philipstarkey Date: Sat Jun 20 10:44:04 2020 +1000 Changed URL for API reference to be shorter commit 3f78207d6c4b36fc0631a81a176f40e1fe4c0826 Merge: bbd928a bf9d10e Author: Phil Starkey Date: Fri Jun 19 18:58:37 2020 +1000 Merge pull request #56 from philipstarkey/master Added links to other component docs commit bf9d10e26a704c846f4f19d6a8a30fac01e65b8f Author: philipstarkey Date: Fri Jun 19 16:06:09 2020 +1000 Addressing latest review comments commit e75b6bcbf284c875c4d40b09f2c14953f3ed1ff9 Author: philipstarkey Date: Fri Jun 19 11:23:49 2020 +1000 Updated docs to use jinja template for component doc links commit 9c612387e0ae192cf1831acc03d8eee8ff3ad139 Author: philipstarkey Date: Thu Jun 18 17:14:57 2020 +1000 Removed autogenerated rst file from version control commit 23031853038a2e04d3138a7707d7077dc76dc02a Author: philipstarkey Date: Thu Jun 18 16:43:29 2020 +1000 Updated .gitignore with latest GitHub defaults commit 87b757eb712bda37bfccb0aa076a782062916795 Author: philipstarkey Date: Thu Jun 18 16:39:52 2020 +1000 Relocated custom sphinx gitignore rules commit 75813a520995537e9bbb3b3f2030448223ed4514 Author: philipstarkey Date: Thu Jun 18 16:31:01 2020 +1000 Updated PR as per review in labscript-suite/labscript-suite#48 commit bbd928aa51c2d2268a40e6f7532ccae17144dc88 Author: Russell Anderson <5637107+rpanderson@users.noreply.github.com> Date: Wed Jun 17 11:39:17 2020 +1000 Populated README.md with styling, iconogrpahy, prose, and badges commit 573c5211b10acb3fe8fd4b0ee278cd0264b4dee2 Author: philipstarkey Date: Tue Jun 16 18:10:25 2020 +1000 Added links to other component docs --- .gitignore | 29 +- README.md | 22 +- docs/source/_static/custom.css | 4 + docs/source/_templates/components.rst | 47 ++ .../{api_reference => api}/connections.rst | 0 docs/source/{api_reference => api}/index.rst | 0 .../labscript_utils.rst | 0 docs/source/conf.py | 90 ++- docs/source/img/blacs_32nx32n.svg | 178 ++++++ ...suite-rectangular-transparent_138nx70n.svg | 579 ++++++++++++++++++ docs/source/img/labscript-utils.svg | 112 ---- .../{labscript-utils.ico => labscript.ico} | Bin docs/source/img/labscript_32nx32n.svg | 186 ++++++ docs/source/img/labscript_64x64.svg | 42 ++ docs/source/img/lyse_32nx32n.svg | 256 ++++++++ docs/source/img/runmanager_32nx32n.svg | 267 ++++++++ docs/source/img/runviewer_32nx32n.svg | 223 +++++++ docs/source/index.rst | 23 +- labscript-suite.pth | 3 +- labscript_profile/__init__.py | 21 +- .../default_profile/labconfig/example.ini | 4 +- .../example_IMAQdx_remote.py | 46 ++ .../example_apparatus/connection_table.py | 27 + .../connection_table_IMAQdx_remote.py | 40 ++ .../example_IMAQdx_remote.py | 51 ++ .../example_apparatus/example_experiment.py | 48 ++ labscript_utils/camera_server.py | 2 +- setup.py | 17 +- 28 files changed, 2149 insertions(+), 168 deletions(-) create mode 100644 docs/source/_templates/components.rst rename docs/source/{api_reference => api}/connections.rst (100%) rename docs/source/{api_reference => api}/index.rst (100%) rename docs/source/{api_reference => api}/labscript_utils.rst (100%) create mode 100644 docs/source/img/blacs_32nx32n.svg create mode 100644 docs/source/img/labscript-suite-rectangular-transparent_138nx70n.svg delete mode 100644 docs/source/img/labscript-utils.svg rename docs/source/img/{labscript-utils.ico => labscript.ico} (100%) create mode 100644 docs/source/img/labscript_32nx32n.svg create mode 100644 docs/source/img/labscript_64x64.svg create mode 100644 docs/source/img/lyse_32nx32n.svg create mode 100644 docs/source/img/runmanager_32nx32n.svg create mode 100644 docs/source/img/runviewer_32nx32n.svg create mode 100644 labscript_profile/default_profile/userlib/analysislib/example_apparatus/example_IMAQdx_remote.py create mode 100644 labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table.py create mode 100644 labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table_IMAQdx_remote.py create mode 100644 labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_IMAQdx_remote.py create mode 100644 labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_experiment.py diff --git a/.gitignore b/.gitignore index adca393..70c27dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ +# This gitignore file consists of 2 parts: +# * The standard Python .gitignore rules from GitHub +# * custom ignore rules for the labscript suite. +# +# These should be kept separate so that the generic rules can be updated with a +# copy/paste without having to worry about whether we are removing custom rules + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -20,7 +27,6 @@ parts/ sdist/ var/ wheels/ -pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg @@ -50,6 +56,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +cover/ # Translations *.mo @@ -69,11 +76,10 @@ instance/ .scrapy # Sphinx documentation -docs/html/ docs/_build/ -docs/source/_build/ # PyBuilder +.pybuilder/ target/ # Jupyter Notebook @@ -84,6 +90,8 @@ profile_default/ ipython_config.py # pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: .python-version # pipenv @@ -130,9 +138,24 @@ dmypy.json # Pyre type checker .pyre/ +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# +# Custom labscript suite .gitignore rules start below +# + # Editors .vscode/ # conda build results conda_build/ conda_packages/ + +# Sphinx documentation +docs/html/ +docs/source/_build/ +docs/source/components.rst \ No newline at end of file diff --git a/README.md b/README.md index 557a1b1..9963d95 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,21 @@ -# labscript_utils +the labscript suite -Shared modules used by the labscript suite. Includes a graphical exception handler, debug tools, configuration management, cross platform filepath conversions, unit conversions and custom GUI widgets. +# the _labscript suite_ ยป labscript-utils -( -[view on Github](https://github.com/labscript-suite/labscript_utils) -) +### Shared modules used by the _labscript suite_ +[![Actions Status](https://github.com/labscript-suite/labscript-utils/workflows/Build%20and%20Release/badge.svg?branch=maintenance%2F3.0.x)](https://github.com/labscript-suite/labscript-utils/actions) +[![License](https://img.shields.io/pypi/l/labscript-utils.svg)](https://github.com/labscript-suite/labscript-utils/raw/master/LICENSE.txt) +[![Python Version](https://img.shields.io/pypi/pyversions/labscript-utils.svg)](https://python.org) +[![PyPI](https://img.shields.io/pypi/v/labscript-utils.svg)](https://pypi.org/project/labscript-utils) +[![Conda Version](https://img.shields.io/conda/v/labscript-suite/labscript-utils)](https://anaconda.org/labscript-suite/labscript-utils) +[![Google Group](https://img.shields.io/badge/Google%20Group-labscriptsuite-blue.svg)](https://groups.google.com/forum/#!forum/labscriptsuite) + + +Shared modules used by the [*labscript suite*](https://github.com/labscript-suite/labscript-suite). Includes a graphical exception handler, debug tools, configuration management, cross-platform filepath conversions, physical unit conversions and custom GUI widgets. + + +## Installation + +labscript-utils is distributed as a Python package on [PyPI](https://pypi.org/user/labscript-suite) and [Anaconda Cloud](https://anaconda.org/labscript-suite), and should be installed with other components of the _labscript suite_. Please see the [installation guide](https://docs.labscriptsuite.org/en/latest/installation) for details. diff --git a/docs/source/_static/custom.css b/docs/source/_static/custom.css index ad5c1a8..d766bfa 100644 --- a/docs/source/_static/custom.css +++ b/docs/source/_static/custom.css @@ -57,3 +57,7 @@ details { 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12); margin-bottom: 24px; } + +img.labscript-suite-icon { + min-width: 32px; +} \ No newline at end of file diff --git a/docs/source/_templates/components.rst b/docs/source/_templates/components.rst new file mode 100644 index 0000000..f966939 --- /dev/null +++ b/docs/source/_templates/components.rst @@ -0,0 +1,47 @@ +{% if current_project != 'the labscript suite' %} +.. toctree:: + :maxdepth: 2 + :hidden: + + the labscript suite <{{intersphinx_mapping['labscript-suite'][0]}}> + +{% endif %} +*labscript suite* components +============================ + +The *labscript suite* is modular by design, and is comprised of: + +.. list-table:: Python libraries + :widths: 10 90 + :header-rows: 0 + + {% for prog, item in programs.items() if item.type == 'lib' %} + * - .. image:: {{img_path}}/{{item.icon}} + :target: {{intersphinx_mapping['%s' | format(prog)][0]}} + :class: labscript-suite-icon + - |{{prog}}|_ --- {{item.desc}} + {% endfor %} + +.. list-table:: Graphical applications + :widths: 10 90 + :header-rows: 0 + + {% for prog, item in programs.items() if item.type == 'gui' %} + * - .. image:: {{img_path}}/{{item.icon}} + :target: {{intersphinx_mapping['%s' | format(prog)][0]}} + :class: labscript-suite-icon + - |{{prog}}|_ --- {{item.desc}} + {% endfor %} + +.. toctree:: + :maxdepth: 2 + :hidden: + + {% for prog in programs|sort if prog != current_project %} + {{prog}} <{{intersphinx_mapping['%s' | format(prog)][0]}}> + {% endfor %} + +{% for prog in programs %} +.. |{{prog}}| replace:: **{{prog}}** +.. _{{prog}}: {{intersphinx_mapping['%s' | format(prog)][0]}} +{% endfor %} \ No newline at end of file diff --git a/docs/source/api_reference/connections.rst b/docs/source/api/connections.rst similarity index 100% rename from docs/source/api_reference/connections.rst rename to docs/source/api/connections.rst diff --git a/docs/source/api_reference/index.rst b/docs/source/api/index.rst similarity index 100% rename from docs/source/api_reference/index.rst rename to docs/source/api/index.rst diff --git a/docs/source/api_reference/labscript_utils.rst b/docs/source/api/labscript_utils.rst similarity index 100% rename from docs/source/api_reference/labscript_utils.rst rename to docs/source/api/labscript_utils.rst diff --git a/docs/source/conf.py b/docs/source/conf.py index a458123..675d806 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,8 +11,10 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os +from pathlib import Path from m2r import MdInclude from recommonmark.transform import AutoStructify +from jinja2 import FileSystemLoader, Environment # -- Project information (unique to each project) ------------------------------------- @@ -26,8 +28,9 @@ release = version # HTML icons -html_logo = "img/{}.svg".format(project) -html_favicon = "img/{}.ico".format(project) +img_path = 'img' +html_logo = img_path + "/labscript_64x64.svg" +html_favicon = img_path + "/labscript.ico" # -- General configuration (should be identical across all projects) ------------------ @@ -79,38 +82,66 @@ 'matplotlib': ('https://matplotlib.org/', None), 'h5py': ('http://docs.h5py.org/en/stable/', None), 'pydaqmx': ('https://pythonhosted.org/PyDAQmx/', None), - # from https://github.com/MSLNZ/msl-qt/blob/master/docs/create_pyqt_objects.py - # under MIT License 'qt': ( '', 'pyqt5-modified-objects.inv', - ) + ) # from https://github.com/MSLNZ/msl-qt/blob/master/docs/create_pyqt_objects.py + # under MIT License # TODO # desktop-app # spinapi/pynivision/etc } # list of all labscript suite components that have docs -labscript_suite_programs = [ - 'labscript', - 'runmanager', - 'runviewer', - 'blacs', - 'lyse', - 'labscript-utils', - 'labscript-devices', -] -# remove this current repo from the list -if project in labscript_suite_programs: - labscript_suite_programs.remove(project) +labscript_suite_programs = { + 'labscript': { + 'desc': 'Expressive composition of hardware-timed experiments', + 'icon': 'labscript_32nx32n.svg', + 'type': 'lib', + }, + 'labscript-devices': { + 'desc': 'Plugin architecture for controlling experiment hardware', + 'icon': 'labscript_32nx32n.svg', + 'type': 'lib', + }, + 'labscript-utils': { + 'desc': 'Shared modules used by the *labscript suite*', + 'icon': 'labscript_32nx32n.svg', + 'type': 'lib', + }, + 'runmanager': { + 'desc': 'Graphical and remote interface to parameterized experiments', + 'icon': 'runmanager_32nx32n.svg', + 'type': 'gui', + }, + 'blacs': { + 'desc': 'Graphical interface to scientific instruments and experiment supervision', + 'icon': 'blacs_32nx32n.svg', + 'type': 'gui', + }, + 'lyse': { + 'desc': 'Online analysis of live experiment data', + 'icon': 'lyse_32nx32n.svg', + 'type': 'gui', + }, + 'runviewer': { + 'desc': 'Visualize hardware-timed experiment instructions', + 'icon': 'runviewer_32nx32n.svg', + 'type': 'gui', + }, +} # whether to use stable or latest version -labscript_suite_doc_version = 'stable' # 'stable' or 'latest' +labscript_suite_doc_version = os.environ.get('READTHEDOCS_VERSION', 'latest') +if '.' in labscript_suite_doc_version: + labscript_suite_doc_version = 'stable' +elif labscript_suite_doc_version not in ['stable', 'latest']: + labscript_suite_doc_version = 'latest' # add intersphinx references for each component for ls_prog in labscript_suite_programs: intersphinx_mapping[ls_prog] = ( - 'https://docs.labscript_suite.org/projects/{}/en/{}/'.format( + 'https://docs.labscriptsuite.org/projects/{}/en/{}/'.format( ls_prog, labscript_suite_doc_version ), None, @@ -119,7 +150,7 @@ # add intersphinx reference for the metapackage if project != "the labscript suite": intersphinx_mapping['labscript-suite'] = ( - 'https://docs.labscript_suite.org/en/{}/'.format(labscript_suite_doc_version), + 'https://docs.labscriptsuite.org/en/{}/'.format(labscript_suite_doc_version), None, ) @@ -137,6 +168,7 @@ todo_include_todos = False else: todo_include_todos = True + # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -158,7 +190,6 @@ # Customize the html_theme html_theme_options = {'navigation_depth': 3} - # Use m2r only for mdinclude and recommonmark for everything else # https://github.com/readthedocs/recommonmark/issues/191#issuecomment-622369992 def setup(app): @@ -176,4 +207,19 @@ def setup(app): app.add_config_value('m2r_anonymous_references', False, 'env') app.add_config_value('m2r_disable_inline_math', False, 'env') app.add_directive('mdinclude', MdInclude) - app.add_stylesheet('custom.css') + app.add_css_file('custom.css') + + # generate the components.rst file dynamically so it points to stable/latest + # of subprojects correctly + loader = FileSystemLoader(Path(__file__).resolve().parent / templates_path[0]) + env = Environment(loader=loader) + template = env.get_template('components.rst') + with open(Path(__file__).resolve().parent / 'components.rst', 'w') as f: + f.write( + template.render( + intersphinx_mapping=intersphinx_mapping, + programs=labscript_suite_programs, + current_project=project, + img_path=img_path + ) + ) diff --git a/docs/source/img/blacs_32nx32n.svg b/docs/source/img/blacs_32nx32n.svg new file mode 100644 index 0000000..d6a2b0e --- /dev/null +++ b/docs/source/img/blacs_32nx32n.svg @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/docs/source/img/labscript-suite-rectangular-transparent_138nx70n.svg b/docs/source/img/labscript-suite-rectangular-transparent_138nx70n.svg new file mode 100644 index 0000000..828b77e --- /dev/null +++ b/docs/source/img/labscript-suite-rectangular-transparent_138nx70n.svg @@ -0,0 +1,579 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/labscript-utils.svg b/docs/source/img/labscript-utils.svg deleted file mode 100644 index 24d9ee6..0000000 --- a/docs/source/img/labscript-utils.svg +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/source/img/labscript-utils.ico b/docs/source/img/labscript.ico similarity index 100% rename from docs/source/img/labscript-utils.ico rename to docs/source/img/labscript.ico diff --git a/docs/source/img/labscript_32nx32n.svg b/docs/source/img/labscript_32nx32n.svg new file mode 100644 index 0000000..97272af --- /dev/null +++ b/docs/source/img/labscript_32nx32n.svg @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/labscript_64x64.svg b/docs/source/img/labscript_64x64.svg new file mode 100644 index 0000000..987cfe6 --- /dev/null +++ b/docs/source/img/labscript_64x64.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/lyse_32nx32n.svg b/docs/source/img/lyse_32nx32n.svg new file mode 100644 index 0000000..1ddcdcc --- /dev/null +++ b/docs/source/img/lyse_32nx32n.svg @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/runmanager_32nx32n.svg b/docs/source/img/runmanager_32nx32n.svg new file mode 100644 index 0000000..d9df689 --- /dev/null +++ b/docs/source/img/runmanager_32nx32n.svg @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/source/img/runviewer_32nx32n.svg b/docs/source/img/runviewer_32nx32n.svg new file mode 100644 index 0000000..ee5aa68 --- /dev/null +++ b/docs/source/img/runviewer_32nx32n.svg @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/source/index.rst b/docs/source/index.rst index 7956870..86f2cab 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -11,6 +11,27 @@ This documentation is primarily for developers who might want to use this common .. toctree:: :maxdepth: 2 + :hidden: + :caption: DOCUMENTATION - api_reference/index + api/index + +.. toctree:: + :maxdepth: 2 + :hidden: + :caption: FURTHER DOCUMENTATION + + components + +.. toctree:: + :maxdepth: 2 + :hidden: + :caption: LINKS + + Home Page + Source Code + PyPI + Anaconda Cloud + BitBucket Archive +.. todolist:: diff --git a/labscript-suite.pth b/labscript-suite.pth index 81cf668..8992fe1 100644 --- a/labscript-suite.pth +++ b/labscript-suite.pth @@ -1,2 +1 @@ -import labscript_profile; labscript_profile.add_userlib_and_pythonlib() -import labscript_profile; labscript_profile.add_development_directories() +import sys; exec("try: import labscript_profile; labscript_profile.add_userlib_and_pythonlib()\nexcept ModuleNotFoundError: pass") diff --git a/labscript_profile/__init__.py b/labscript_profile/__init__.py index d9b2018..a679ff5 100644 --- a/labscript_profile/__init__.py +++ b/labscript_profile/__init__.py @@ -1,3 +1,4 @@ +import site import sys import os from configparser import ConfigParser, NoSectionError, NoOptionError @@ -56,22 +57,4 @@ def add_userlib_and_pythonlib(): except (NoSectionError, NoOptionError): paths = [] for path in paths: - if os.path.exists(path): - sys.path.append(path) - - -def add_development_directories(): - """Prepend directories in /dev to the search path, if they - are listed in the file /dev/enabled (if that file - exists).""" - if LABSCRIPT_SUITE_PROFILE is None: - return - dev_dir = LABSCRIPT_SUITE_PROFILE / 'dev' - enabled_file = dev_dir / 'enabled' - if not os.path.exists(enabled_file): - return - with open(enabled_file) as f: - for line in f: - repository = dev_dir / line.strip() - if os.path.isdir(repository): - sys.path.insert(0, repository) + site.addsitedir(path) diff --git a/labscript_profile/default_profile/labconfig/example.ini b/labscript_profile/default_profile/labconfig/example.ini index f72dca5..63851aa 100644 --- a/labscript_profile/default_profile/labconfig/example.ini +++ b/labscript_profile/default_profile/labconfig/example.ini @@ -10,8 +10,8 @@ app_saved_configs = %(labscript_suite)s\app_saved_configs\%(apparatus_name)s user_devices = user_devices [paths] -connection_table_h5 = %(experiment_shot_storage)s\connectiontable.h5 -connection_table_py = %(labscriptlib)s\connectiontable.py +connection_table_h5 = %(experiment_shot_storage)s\connection_table.h5 +connection_table_py = %(labscriptlib)s\connection_table.py [servers] zlock = localhost diff --git a/labscript_profile/default_profile/userlib/analysislib/example_apparatus/example_IMAQdx_remote.py b/labscript_profile/default_profile/userlib/analysislib/example_apparatus/example_IMAQdx_remote.py new file mode 100644 index 0000000..e4c30b7 --- /dev/null +++ b/labscript_profile/default_profile/userlib/analysislib/example_apparatus/example_IMAQdx_remote.py @@ -0,0 +1,46 @@ +import lyse +from pathlib import Path +import matplotlib.pyplot as plt + +# Is this script being run from within an interactive lyse session? +if lyse.spinning_top: + # If so, use the filepath of the current shot + h5_path = lyse.path +else: + # If not, get the filepath of the last shot of the lyse DataFrame + df = lyse.data() + h5_path = df.filepath.iloc[-1] + +# Instantiate a lyse.Run object for this shot +run = lyse.Run(h5_path) + +# Get a dictionary of the global variables used in this shot +run_globals = run.get_globals() + +# Extract the images 'before' and 'after' generated from camera.expose +before, after = run.get_images('camera', 'comparison', 'before', 'after') + +# Compute the difference of the two images, after casting them to signed integers +# (otherwise negative differences wrap to 2**16 - 1 - diff) +diff = after.astype('int16') - before.astype('int16') + +# Plot the row-wise mean of each image +plt.plot(before.mean(axis=0), label='before') +plt.plot(after.mean(axis=0), label='after') +plt.xlabel('pixel coordinate (column)') +plt.ylabel('counts') + +# Label the plot with a unique string representing the shot +plt.title(Path(run.h5_path).name) + +# Plot adornments +plt.legend(loc='lower left') +plt.grid() + +# Show the plot +plt.show() + +# Compute a result based on the image processing and save it to the 'results' group of +# the shot file +result = diff.std() +run.save_result('foobar', result) diff --git a/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table.py b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table.py new file mode 100644 index 0000000..9a5f5e6 --- /dev/null +++ b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table.py @@ -0,0 +1,27 @@ +from labscript import start, stop, add_time_marker, AnalogOut, DigitalOut +from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock +from labscript_devices.DummyIntermediateDevice import DummyIntermediateDevice + +# Use a virtual, or 'dummy', device for the psuedoclock +DummyPseudoclock(name='pseudoclock') + +# An output of this DummyPseudoclock is its 'clockline' attribute, which we use +# to trigger children devices +DummyIntermediateDevice(name='intermediate_device', parent_device=pseudoclock.clockline) + +# Create an AnalogOut child of the DummyIntermediateDevice +AnalogOut(name='analog_out', parent_device=intermediate_device, connection='ao0') + +# Create a DigitalOut child of the DummyIntermediateDevice +DigitalOut( + name='digital_out', parent_device=intermediate_device, connection='port0/line0' +) + + +if __name__ == '__main__': + # Begin issuing labscript primitives + # start() elicits the commencement of the shot + start() + + # Stop the experiment shot with stop() + stop(1.0) diff --git a/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table_IMAQdx_remote.py b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table_IMAQdx_remote.py new file mode 100644 index 0000000..5bc412f --- /dev/null +++ b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/connection_table_IMAQdx_remote.py @@ -0,0 +1,40 @@ +from labscript import start, stop, add_time_marker, Trigger, RemoteBLACS +from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock +from labscript_devices.DummyIntermediateDevice import DummyIntermediateDevice +from labscript_devices.IMAQdxCamera.labscript_devices import IMAQdxCamera + +# Use a virtual ('dummy') device for the psuedoclock +DummyPseudoclock(name='pseudoclock') + +# An output of this DummyPseudoclock is its 'clockline' attribute, which we use +# to trigger children devices +DummyIntermediateDevice(name='intermediate_device', parent_device=pseudoclock.clockline) + +# Instantiate a labscript.Trigger instance used to trigger the camera exposure +# This will be specified as the camera's parent device later +Trigger( + name='camera_trigger', parent_device=intermediate_device, connection='port0/line0' +) + +# On the host specified below, start the RemoteBLACS server by running the following: +# $ python - m labscript_utils.remote +RemoteBLACS(name='test_remote', host='localhost') + +# We then initiate an IMAQdxCamera using this RemoteBLACS instance +# using mock=True to bypass any attempts to commmunicate with an +# actual camera, and generate fake data at the end of the shot +IMAQdxCamera( + name='camera', + parent_device=camera_trigger, + connection='trigger', + serial_number=0xDEADBEEF, + worker=test_remote, + mock=True, +) + +# Begin issuing labscript primitives +# start() elicits the commencement of the shot +start() + +# Stop the experiment shot with stop() +stop(1.0) diff --git a/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_IMAQdx_remote.py b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_IMAQdx_remote.py new file mode 100644 index 0000000..d0a3a61 --- /dev/null +++ b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_IMAQdx_remote.py @@ -0,0 +1,51 @@ +from labscript import start, stop, add_time_marker, Trigger, RemoteBLACS +from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock +from labscript_devices.DummyIntermediateDevice import DummyIntermediateDevice +from labscript_devices.IMAQdxCamera.labscript_devices import IMAQdxCamera + +# Use a virtual ('dummy') device for the psuedoclock +DummyPseudoclock(name='pseudoclock') + +# An output of this DummyPseudoclock is its 'clockline' attribute, which we use +# to trigger children devices +DummyIntermediateDevice(name='intermediate_device', parent_device=pseudoclock.clockline) + +# Instantiate a labscript.Trigger instance used to trigger the camera exposure +# This will be specified as the camera's parent device later +Trigger( + name='camera_trigger', parent_device=intermediate_device, connection='port0/line0' +) + +# On the host specified below, start the RemoteBLACS server by running the following: +# $ python - m labscript_utils.remote +RemoteBLACS(name='test_remote', host='localhost') + +# We then initiate an IMAQdxCamera using this RemoteBLACS instance +# using mock=True to bypass any attempts to commmunicate with an +# actual camera, and generate fake data at the end of the shot +IMAQdxCamera( + name='camera', + parent_device=camera_trigger, + connection='trigger', + serial_number=0xDEADBEEF, + worker=test_remote, + mock=True, +) + +# Begin issuing labscript primitives +# A timing variable t is used for convenience +# start() elicits the commencement of the shot +t = 0 +add_time_marker(t, "Start", verbose=True) +start() + +t += 1 +add_time_marker(t, "Exposure: 'before' image", verbose=True) +camera.expose(t, name='comparison', frametype='before', trigger_duration=0.2) + +t += 0.5 +add_time_marker(t, "Exposure: 'after' image", verbose=True) +camera.expose(t, name='comparison', frametype='after', trigger_duration=0.2) + +t += 0.5 +stop(t) diff --git a/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_experiment.py b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_experiment.py new file mode 100644 index 0000000..1f3c33e --- /dev/null +++ b/labscript_profile/default_profile/userlib/labscriptlib/example_apparatus/example_experiment.py @@ -0,0 +1,48 @@ +from labscript import start, stop, add_time_marker, AnalogOut, DigitalOut +from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock +from labscript_devices.DummyIntermediateDevice import DummyIntermediateDevice + +# Use a virtual, or 'dummy', device for the psuedoclock +DummyPseudoclock(name='pseudoclock') + +# An output of this DummyPseudoclock is its 'clockline' attribute, which we use +# to trigger children devices +DummyIntermediateDevice(name='intermediate_device', parent_device=pseudoclock.clockline) + +# Create an AnalogOut child of the DummyIntermediateDevice +AnalogOut(name='analog_out', parent_device=intermediate_device, connection='ao0') + +# Create a DigitalOut child of the DummyIntermediateDevice +DigitalOut( + name='digital_out', parent_device=intermediate_device, connection='port0/line0' +) + +# Begin issuing labscript primitives +# A timing variable t is used for convenience +# start() elicits the commencement of the shot +t = 0 +add_time_marker(t, "Start", verbose=True) +start() + +# Wait for 1 second with all devices in their default state +t += 1 + +# Change the state of digital_out, and denote this using a time marker +add_time_marker(t, "Toggle digital_out (high)", verbose=True) +digital_out.go_high(t) + +# Wait for 0.5 seconds +t += 0.5 + +# Ramp analog_out from 0.0 V to 1.0 V over 0.25 s with a 1 kS/s sample rate +t += analog_out.ramp(t=t, initial=0.0, final=1.0, duration=0.25, samplerate=1e3) + +# Change the state of digital_out, and denote this using a time marker +add_time_marker(t, "Toggle digital_out (low)", verbose=True) +digital_out.go_low(t) + +# Wait for 0.5 seconds +t += 0.5 + +# Stop the experiment shot with stop() +stop(t) diff --git a/labscript_utils/camera_server.py b/labscript_utils/camera_server.py index 3389e66..cf576b5 100644 --- a/labscript_utils/camera_server.py +++ b/labscript_utils/camera_server.py @@ -158,7 +158,7 @@ def transition_to_static(self, h5_filepath): them to the h5 file""" import pyfits start_time = time.time() - with h5py.File(h5_filepath) as f: + with h5py.File(h5_filepath, 'r+') as f: group = f['devices']['camera'] if not 'EXPOSURES' in group: print('no images taken this shot') diff --git a/setup.py b/setup.py index 12b22ca..66a147b 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,24 @@ import os from setuptools import setup +from setuptools.command.develop import develop +from distutils import log + + +class develop_command(develop): + """Custom develop command which installs the .pth file to site-packages for editable + installs.""" + 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}') + if not self.dry_run: + self.copy_file('labscript-suite.pth', path) + VERSION_SCHEME = { "version_scheme": os.getenv("SCM_VERSION_SCHEME", "guess-next-dev"), "local_scheme": os.getenv("SCM_LOCAL_SCHEME", "node-and-date"), } -setup(use_scm_version=VERSION_SCHEME) +setup(use_scm_version=VERSION_SCHEME, cmdclass={'develop': develop_command}) 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