Skip to main content

Client-server, python-based laboratory software

Project description

pylabnet

Client-server, python-based laboratory software

Devices

This is the repository for pylabnet, a software package for client-server, python-based experiment control, designed for use in solid-state quantum optics + quantum network experiments in the Lukin group.

For users

Installation

The package can be installed from the commandline using

pip install pylabnet

You can now import pylabnet and its submodules in your own scripts and notebooks. The package can be updated to the latest version using the command

pip install --upgrade pylabnet

Usage

After pip installation of pylabnet, two executables will be created in the system PATH: pylabnet.exe and pylabnet_proxy.exe. These can be used to launch master and proxy versions of the Launch Control GUI, from which relevant experimental software can be accessed over pylabnet. If desired, you can create shortcuts for these executables and pin the devices.ico icon (shown above and located in the root directory) for bonus style.

NOTE 1: You will likely need to allow python through Windows firewall the first time you run Launch Control on a new machine.

NOTE 2: The package uses SSL authentication via a self-signed private key. You can generate this key using OpenSSL from the commandline

openssl req -new -x509 -days 365 -nodes -out pylabnet.pem -keyout pylabnet.pem

You may adjust the value of the days flag in order to change the period over which the key is valid. This private key file pylabnet.pem is automatically placed in the C:/Windows/System32 directory of the machine it is generated on. It can then be copied into the equivalent directory of any other machines using the same pylabnetwork.

The master Launch Control runs a LogServer to keep track of all clients and servers on the network, and proxy Launch Control units simply connect to the master and mirror its information for convenience on remote machines.

The general workflow is the following

  1. Launch a master LogServer. Can be done from a cusftom script, but easiest to just use the pylabnet executable.
  2. Connect to hardware locally. This is done through use of drivers located in the pylabnet/hardware submodule. These drivers can also be used for standalone control of hardware, if desired.
  3. Instantiate a GenericServer for each device (or logical module) to allow remote programming from anywhere in the network
  4. Create clients for the hardware servers, which can be used to perform arbitrary functions on devices present across the network

Steps 2-4 can also be done manually from an interactive python notebook or custom script, but common functionality is incorporated into the Launch Control GUI for automatic "double-click" running of these steps.

For developers

Installation

First, clone the repository onto the local machine. Make sure git is installed. Cloning can be done from the command line, (preferrably in your home user directory) with the command

git clone https://github.com/lukingroup/pylabnet.git

NOTE ON DEVELOPMENT IN DEDICATED ENVIRONMENT

For installation in a dedicated pip virtual environment to prevent conflicts with the base python package, create a virtual environment - can be done from the command line using

python -m venv /path/to/new/virtual/testenv

Activate the development environment using the command

/path/to/new/virtual/testenv/Scripts/activate

Be sure to set the interpreter in your IDE to /path/to/new/virtual/testenv/Scripts/python.exe if you will be launching pylabnet scripts directly from the IDE.


Next, navigate to the root directory in the commandline and run the command

python setup.py develop

NOTE 1: there may be some errors during dependency installation, but as long as the command terminates with output Finished processing dependencies for pylabnet==x.y.z the installation has worked. If it fails, try running pip install --upgrade setuptools.

NOTE 2: this command can also be re-used at a later time to maintain the environment (either virtual or base) if new package requirements are added to setup.py.

This will now allow you to import pylabnet from your scripts, and ensures you have the dependencies installed. It also creates a pylabnet.egg-info file which can be safely deleted if desired (it should not be tracked by github).

This also creates the standard pylabnet executables which can be used for launching (see above). Just be careful that you are using the correct execuatable if you have installed pylabnet in environments.

Development

  1. Create a new working branch before making any changes to the repository. Please do not make the changes directly in the master branch! This can be done either from your IDE of choice, or from the commandline within the local github repository, using git checkout -b new-branch-name

  2. Implement and test your changes.

  3. For GUI-based applications, it is recommended to create a launcher module (see pylabnet/launchers/README.md for more details.

  4. For non-GUI applications, please make a Jupyter notebook in the pylabnet/demo folder in order to demonstrate and test the added functionality.

  5. Note that pushing changes to the lukingroup/pylabnet repository requires administrative access. Please contact one of the previous contributors for details.

  6. Try to keep the your local repository up to date with the online repository to avoid unnecessary merge conflicts down the line.

  7. Once stable + working, submit a pull request.

Publishing a new version to pip

Generally, not every commit or even merge into master needs to be published to pip as a new version. However, if substantial functionality is added that could be useful to other users (especially ones that are not actively developing the platform), it is a good idea to release a new version on pip. In this case, you can do this with the following steps:

  1. Make sure the install_requires kwarg in setup.py is up to date with all mandatory packages. If you have added new depedendencies, add them here.

NOTE: The preferred format is to use >= to constrain package versions, rather than ==. Try not to write code that requires a < constraint, since this could cause user-dependent conflicts. As an example of this poor practice, the latest version of spyder has a conflict with the latest versions of pyqt5.

  1. Update the version number in __init__.py in the root module. We have adoped a 3 digit versioning scheme x.y.z where x is the major version, each new y digit corresponds to a substantially new release (with new software components), and the z digit can increment with any improvements, changes, and bug fixes.

  2. Update CHANGELOG.md

  3. Run the following from the commandline

python setup.py sdist bdist_wheel

This will create a pylabnet/dist directory (which should not be tracked by github) containing the build files for this version. Note that this requires one to pip install wheel.

  1. To upload to pip, run the command
twine upload dist/*

NOTE: This requires credentials on https://pypi.org, as well as the twine package which can be installed with pip install twine. You may also run into issues if your dist/ folder has older distributions, these should be deleted prior to upload.


NOTE

If you are done using a particular machine for development and would like to use and update the package the standard way via pip, you can remove the pylabnet installation by running the command pip uninstall pylabnet from a directory that does not have pylabnet inside it.

Your local repository can now be deleted and pylabnet can be installed, used, and maintained via pip.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylabnet-1.0.0.tar.gz (27.9 MB view details)

Uploaded Source

Built Distribution

pylabnet-1.0.0-py3-none-any.whl (496.8 kB view details)

Uploaded Python 3

File details

Details for the file pylabnet-1.0.0.tar.gz.

File metadata

  • Download URL: pylabnet-1.0.0.tar.gz
  • Upload date:
  • Size: 27.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8rc1

File hashes

Hashes for pylabnet-1.0.0.tar.gz
Algorithm Hash digest
SHA256 52baaeb1a5ee35874672490a51b44678315ffd6e90135d6e836d36760a0946cc
MD5 97b68cfc2e9c3b66b1263eec61c33a3d
BLAKE2b-256 e0986fc071114a73cc684c46d27b67dfc25a9fdfb724a1b62c4bcd7b22911082

See more details on using hashes here.

File details

Details for the file pylabnet-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pylabnet-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 496.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.8rc1

File hashes

Hashes for pylabnet-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c232e08d9332e6776590886584d6f743bae842269741791331362a9cae8d6aa6
MD5 97d800ae1e496fe8fbb574e5beabcc34
BLAKE2b-256 5387c008eca740e00257cd1edd1151588f7e52320ec8a2d6170b7e81681e501c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page