Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 348bbeb
Author: Phil Starkey <[email protected]>
Date:   Thu Jun 25 19:47:34 2020 +1000

    Update dependencies in setup.cfg

    Bumped labscript_devices and labscript_utils versions to `>=3.0.0`

commit 24b3728
Merge: f3a5f41 0a3df34
Author: Phil Starkey <[email protected]>
Date:   Thu Jun 25 12:55:47 2020 +1000

    Merge pull request #77 from chrisjbillington/anywhere-unit-conversions

    Allow BLACS to use conversion classes defined outside labscript_utils

commit 0a3df34
Author: chrisjbillington <[email protected]>
Date:   Wed Jun 24 22:50:15 2020 -0400

    Fix error message formatting args being the wrong way around

commit 9ed2890
Author: chrisjbillington <[email protected]>
Date:   Wed Jun 24 19:26:10 2020 -0400

    Allow BLACS to use conversion classes defined outside labscript_utils

    Labscript has long-since saved unit conversions with their full import
    path instead of just a class name, and
    `labscript_utils.unitconversisons` has provided a function
    `get_unit_conversion_class()` to look them up.

    Here we just use that function to look up unit calibration classes.
    `get_unit_conversion_class()` falls back to the old behaviour of
    importing all unit conversion modules in
    `labscript_utils.unitconversisons` and looking for the given class if it
    encounters an unqualified class name.

commit f3a5f41
Merge: 88eb635 cb41ec0
Author: Chris Billington <[email protected]>
Date:   Wed Jun 24 20:47:58 2020 -0400

    Merge pull request #78 from philipstarkey/fix-h5py-file-mode

    Addresses labscript-suite/labscript-utils#47

commit cb41ec0
Author: philipstarkey <[email protected]>
Date:   Thu Jun 25 10:32:57 2020 +1000

    Addresses labscript-suite/labscript-utils#47

commit 88eb635
Merge: 968afbc 6439a26
Author: Russell Anderson <[email protected]>
Date:   Mon Jun 22 18:07:29 2020 +1000

    Merge pull request #76 from philipstarkey/master

    fix docs conf bugs identified in labscript-suite/labscript-utils#57

commit 6439a26
Author: philipstarkey <[email protected]>
Date:   Sat Jun 20 18:32:02 2020 +1000

    fix docs conf bugs identified in labscript-suite/labscript-utils#57

commit 968afbc
Merge: 51a47c1 de2d967
Author: Phil Starkey <[email protected]>
Date:   Fri Jun 19 19:00:41 2020 +1000

    Merge pull request #75 from philipstarkey/master

    Empty sphinx project following our template

commit de2d967
Author: philipstarkey <[email protected]>
Date:   Fri Jun 19 17:18:04 2020 +1000

    Empty sphinx project following our template

commit 51a47c1
Author: Russell Anderson <[email protected]>
Date:   Wed Jun 17 10:24:16 2020 +1000

    Abbreviate installation instructions in README.md

commit fe40066
Author: Russell Anderson <[email protected]>
Date:   Tue Jun 16 22:19:12 2020 +1000

    Populated README.md with styling, iconogrpahy, prose, and badges

commit 06e430b
Merge: e739553 1d1e9c4
Author: Russell Anderson <[email protected]>
Date:   Tue Jun 16 12:07:07 2020 +1000

    Merge pull request #73 from rpanderson/master

    experiment_name changed to apparatus_name

commit 1d1e9c4
Author: Russell Anderson <[email protected]>
Date:   Wed Jun 10 22:50:36 2020 +1000

    experiment_name changed to apparatus_name

    Per labscript-suite/labscript-utils#53

Co-authored-by: chrisjbillington <[email protected]>
Co-authored-by: Russell Anderson <[email protected]>
  • Loading branch information
3 people committed Jun 25, 2020
1 parent 3d93acb commit 6ea046b
Show file tree
Hide file tree
Showing 20 changed files with 1,802 additions and 28 deletions.
167 changes: 160 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,161 @@
*.pyc
# 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]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
*.orig
*.aux
*.toc
dist/*
*.egg-info
*.eggs
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
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
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
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
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# BLACS
<img src="https://raw.githubusercontent.com/labscript-suite/labscript-suite/master/art/blacs_32nx32n.svg" height="64" alt="the labscript suite – blacs" align="right">

Part of the labscript suite, provides an interface to hardware used to control a buffered experiment. It manages a queue of shots to be run as well as providing manual control over devices between shots.
# the _labscript suite_ » blacs

(
[view on Bitbucket](https://bitbucket.org/labscript_suite/blacs)
)
### Graphical interface to scientific instruments and experiment supervision

* For install instructions, see the [labscript suite install guide](https://bitbucket.org/labscript_suite/install-guide)
[![Actions Status](https://github.com/labscript-suite/blacs/workflows/Build%20and%20Release/badge.svg?branch=maintenance%2F3.0.x)](https://github.com/labscript-suite/blacs/actions)
[![License](https://img.shields.io/pypi/l/blacs.svg)](https://github.com/labscript-suite/blacs/raw/master/LICENSE.txt)
[![Python Version](https://img.shields.io/pypi/pyversions/blacs.svg)](https://python.org)
[![PyPI](https://img.shields.io/pypi/v/blacs.svg)](https://pypi.org/project/blacs)
[![Conda Version](https://img.shields.io/conda/v/labscript-suite/lyse)](https://anaconda.org/labscript-suite/blacs)
[![Google Group](https://img.shields.io/badge/Google%20Group-labscriptsuite-blue.svg)](https://groups.google.com/forum/#!forum/labscriptsuite)
<!--[![DOI](http://img.shields.io/badge/DOI-10.1063%2F1.4817213-0F79D0.svg)](https://doi.org/10.1063/1.4817213)-->


**blacs** supervises the execution of experiments controlled by the [*labscript suite*](https://github.com/labscript-suite/labscript-suite). It manages experiment queuing and hardware-timed execution, and provides manual control over devices between experiment shots.


## Installation

blacs 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.
2 changes: 1 addition & 1 deletion blacs/experiment_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def process_request(self,h5_filepath):
result,error = inmain(self.BLACS.connection_table.compare_to,new_conn)
if result:
# Has this run file been run already?
with h5py.File(h5_filepath) as h5_file:
with h5py.File(h5_filepath, 'r') as h5_file:
if 'data' in h5_file['/']:
rerun = True
else:
Expand Down
27 changes: 16 additions & 11 deletions blacs/output_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
from labscript_utils.qtwidgets.digitaloutput import DigitalOutput, InvertedDigitalOutput
from labscript_utils.qtwidgets.ddsoutput import DDSOutput
from labscript_utils.qtwidgets.imageoutput import ImageOutput
try:
from labscript_utils.unitconversions import *
except Exception:
print('failed to import unit conversion classes')
from labscript_utils.unitconversions import get_unit_conversion_class


class AO(object):
Expand Down Expand Up @@ -54,22 +51,30 @@ def __init__(self, hardware_name, connection_name, device_name, program_function
# Initialise Calibrations
self._comboboxmodel.appendRow(QStandardItem(self._base_unit))
if calib_class is not None:
if calib_class not in globals() or not isinstance(calib_params,dict) or globals()[calib_class].base_unit != default_units:
try:
cls = get_unit_conversion_class(calib_class)
# ImportError if module doesn't exist. Attribute error if it does but the
# class name does not exist within it. KeyError if the unit conversion class
# is an old-style unqualified class name expected to be in the globals()
# dict of the unitconversions module, but does not exist.
except (ImportError, AttributeError, KeyError):
cls = None
if cls is None or not isinstance(calib_params, dict) or cls.base_unit != default_units:
# log an error:
reason = ''
if calib_class not in globals():
reason = 'The unit conversion class was not imported. Is it in the correct folder? Is it imported when you call "from unitconversions import *" from a python terminal?'
elif not isinstance(calib_params,dict):
if calib_class is None:
reason = f'The unit conversion class {calib_class} could not be imported. Ensure it is available on the computer running BLACS.'
elif not isinstance(calib_params, dict):
reason = 'The parameters for the unit conversion class are not a dictionary. Check your connection table code for errors and recompile it'
elif globals()[calib_class].base_unit != default_units:
reason = 'The base unit of your unit conversion class does not match this hardware channel. The hardware channel has base units %s while your unit conversion class uses %s'%(globals()[calib_class].base_unit,default_units)
elif cls.base_unit != default_units:
reason = f'The base unit of your unit conversion class does not match this hardware channel. The hardware channel has base units {default_units} while your unit conversion class uses {cls.base_unit}'
self._logger.error('The unit conversion class (%s) could not be loaded. Reason: %s'%(calib_class,reason))
# Use default units
self._calibration = None
else:
try:
# initialise calibration class
self._calibration = globals()[calib_class](calib_params)
self._calibration = cls(calib_params)
self._logger.debug('unit conversion class instantiated')
for unit in self._calibration.derived_units:
try:
Expand Down
2 changes: 1 addition & 1 deletion blacs/plugins/cycle_time/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def pre_transition_to_buffered(self, h5_filepath):
self.target_cycle_time = self.next_target_cycle_time
self.delay_after_programming = self.next_delay_after_programming

with h5py.File(h5_filepath) as f:
with h5py.File(h5_filepath, 'r') as f:
try:
group = f['shot_properties']
except KeyError:
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
63 changes: 63 additions & 0 deletions docs/source/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Add space between collapsible details HTML tags */
details {
margin-bottom: 1em;
}

/* Darker pygment highlighing of console input/output */
.highlight .go {
color: #404040;
}

/* White captions in sidebar */
.wy-nav-side p.caption {
color: #f5f5f5;
}

/* labscript blue, alpha = 83% */
.wy-side-nav-search {
background: #2946bbd3;
}

.wy-nav-top {
background: #2946bbd3;
}

/* labscript green, alpha = 75% */
.rst-content .note .admonition-title {
background: #00804fbf;
}

/* labscript green, alpha = 25% */
.rst-content .note {
background: #00804f3f;
}

/* labscript red, alpha = 75% */
.rst-content .warning .admonition-title {
background: #bc294cbf
}

/* labscript red, alpha = 25% */
.rst-content .warning {
background: #bc294c3b;
}

/* Elevation
*
* Style box-shadows using Material Design's idea of elevation. These particular numbers are taken from here:
*
* https://github.com/material-components/material-components-web
* https://material-components-web.appspot.com/elevation.html
*/

.rst-content img.screenshot {
border: none;
/* MD Elevation 8 */
box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2),
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;
}
Loading

0 comments on commit 6ea046b

Please sign in to comment.