Package: pylabnet
pylabnetClient-server, python-based laboratory softwareThis 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 usersInstallationThe package can be installed from the commandline usingpipinstallpylabnetYou can nowimport pylabnetand its submodules in your own scripts and notebooks. The package can be updated to the latest version using the commandpipinstall--upgradepylabnetUsageAfterpipinstallation of pylabnet, two executables will be created in the systemPATH:pylabnet.exeandpylabnet_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 thedevices.icoicon (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 commandlineopensslreq-new-x509-days365-nodes-outpylabnet.pem-keyoutpylabnet.pemYou may adjust the value of thedaysflag in order to change the period over which the key is valid. This private key filepylabnet.pemis automatically placed in theC:/Windows/System32directory of the machine it is generated on. It can then be copied into the equivalent directory of any other machines using the samepylabnetwork.The master Launch Control runs aLogServerto 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 followingLaunch a masterLogServer. Can be done from a cusftom script, but easiest to just use thepylabnetexecutable.Connect to hardware locally. This is done through use of drivers located in thepylabnet/hardwaresubmodule. These drivers can also be used for standalone control of hardware, if desired.Instantiate aGenericServerfor each device (or logical module) to allow remote programming from anywhere in the networkCreate clients for the hardware servers, which can be used to perform arbitrary functions on devices present across the networkSteps 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 developersInstallationFirst, 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 commandgitclonehttps://github.com/lukingroup/pylabnet.gitNOTE ON DEVELOPMENT IN DEDICATED ENVIRONMENTFor 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 usingpython-mvenv/path/to/new/virtual/testenvActivate the development environment using the command/path/to/new/virtual/testenv/Scripts/activateBe sure to set the interpreter in your IDE to/path/to/new/virtual/testenv/Scripts/python.exeif you will be launching pylabnet scripts directly from the IDE.Next, navigate to the root directory in the commandline and run the commandpythonsetup.pydevelopNOTE 1:there may be some errors during dependency installation, but as long as the command terminates with outputFinished processing dependencies for pylabnet==x.y.zthe installation has worked. If it fails, try runningpip 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 tosetup.py.This will now allow you toimport pylabnetfrom your scripts, and ensures you have the dependencies installed. It also creates apylabnet.egg-infofile 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 (seeabove). Just be careful that you are using the correct execuatable if you have installed pylabnet in environments.DevelopmentCreate 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, usinggit checkout -b new-branch-nameImplement and test your changes.For GUI-based applications, it is recommended to create a launcher module (see pylabnet/launchers/README.md for more details.For non-GUI applications, please make a Jupyter notebook in the pylabnet/demo folder in order to demonstrate and test the added functionality.Note that pushing changes to thelukingroup/pylabnetrepository requires administrative access. Please contact one of the previous contributors for details.Try to keep the your local repository up to date with the online repository to avoid unnecessary merge conflicts down the line.Once stable + working, submit a pull request.Publishing a new version to pipGenerally, 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:Make sure theinstall_requireskwarg insetup.pyis 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.Update the version number in__init__.pyin the root module. We have adoped a 3 digit versioning schemex.y.zwherexis the major version, each newydigit corresponds to a substantially new release (with new software components), and thezdigit can increment with any improvements, changes, and bug fixes.UpdateCHANGELOG.mdRun the following from the commandlinepythonsetup.pysdistbdist_wheelThis 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 topip install wheel.To upload to pip, run the commandtwineuploaddist/*NOTE:This requires credentials onhttps://pypi.org, as well as the twine package which can be installed withpip install twine. You may also run into issues if yourdist/folder has older distributions, these should be deleted prior to upload.NOTEIf 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 commandpip uninstall pylabnetfrom a directory that does not havepylabnetinside it.Your local repository can now be deleted and pylabnet can be installed, used, and maintained via pip.