-
Notifications
You must be signed in to change notification settings - Fork 60
Make example labscript functional and format using black #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Just out of interest, why did it not compile? Skimming it I don't see anything that jumps out as broken. Edit: Oh I guess it it was the |
import __init__ yields: Traceback (most recent call last):
File "C:\Users\rpanderson\labscript-dev\labscript\example.py", line 14, in <module>
import __init__ # only have to do this because we're inside the labscript directory
RuntimeError: Double import! The same file has been imported under two different names, resulting in two copies of the module. This is almost certainly a mistake. If you are running a script from within a package and want to import another submodule of that package, import it by its full path: 'import module.submodule' instead of just 'import submodule.'
Path imported: C:\Users\rpanderson\labscript-dev\runmanager\runmanager\__init__.py NI_PCIe_6363(name='ni_card_0', parent_device=pulseblaster_0_clockline_fast, clock_terminal='ni_pcie_6363_0/PFI0', MAX_name='ni_pcie_6363_0', acquisition_rate=100e3) yields: C:\Users\rpanderson\labscript-dev\labscript\example.py:27: UserWarning: Importing NI_PCIe_6363 from labscript_devices.NI_PCIe_6363 is deprecated, please instead import it from labscript_devices.NI_DAQmx.labscript_devices. Importing anyway for backward compatibility, but this may cause some unexpected behaviour. Ditto for NI_PCI_6733. Remaining issue resolved by this PR:
|
I'm not convinced a black formatted connection table is easier to parse than a series of very long lines. Maybe it would be OK if each argument was turned into a keyword argument so it was obvious what it was? Even then I'm not sure |
I find it easier to parse, regardless of whether the args have names or not (though once there are more than a few, keyword argument names are basically mandatory for code to be readable at all). It's definitely something you get used to, but once you're used to it newlines are stronger delimiters than commas and spaces - so one can see at a glance how many args there are and is less likely to confuse e.g. two short args for one long one. At the end of the day though this is less important to me than the fact that it fits in a text editor snapped to half the screen. Having to scroll or maximise to read, and having scroll to view diffs (which are also much improved when each arg is on its own line) is the dealbreaker for me. Also it's the standard. I would not have made all the choices black did (spaces around the slice operator |
Named all args in connection table, device methods, and other labscript primitives. |
Looks better! It is a bit odd having the example in here now it's a proper package. Maybe we should relocate it to labscript-utils? The existing example is very basic. It's good to have a basic example, but perhaps this could serve as a complex example in the default profile? |
Yep, I edited the PR description earlier to countenance this alternative. I'd be happy to migrate or rewrite this example in labscript-utils, perhaps separately to (and after) merging this PR. |
Were it not for the use of labscript-utils, it's not entirely unconventional. Examples would otherwise be useful here for testing and for sourcing documentation from. But I prefer the convention of using the default profile in labscript-utils, as this means they get distributed. |
They only get distributed when people first create the profile though. Subsequent updates we make will be buried in the package just like they are here. |
Yes; these would benefit from a |
Well I'm happy to merge as-is then |
commit c3b7988 Author: Phil Starkey <[email protected]> Date: Thu Jun 25 18:27:06 2020 +1000 Update labscript_utils dependency to `>=3.0.0` commit 822e5d5 Merge: 2e2785c 39c6f0b Author: Russell Anderson <[email protected]> Date: Thu Jun 25 15:48:15 2020 +1000 Merge pull request #69 from rpanderson/example_fix Make example labscript functional and format using black commit 39c6f0b Author: Russell Anderson <[email protected]> Date: Thu Jun 25 12:34:08 2020 +1000 Name all the args commit 255d74e Author: Russell Anderson <[email protected]> Date: Thu Jun 25 12:11:48 2020 +1000 Name all arguments in connection table commit e3d3ece Author: Russell Anderson <[email protected]> Date: Thu Jun 25 11:08:25 2020 +1000 Omit __init__ import and comply with flake8 F403 commit 6b26f1f Author: Russell Anderson <[email protected]> Date: Sun May 31 17:38:18 2020 +1000 Make example labscript functional and format using black commit 2e2785c Merge: 62b9098 4e77810 Author: Chris Billington <[email protected]> Date: Wed Jun 24 21:22:05 2020 -0400 Merge pull request #70 from rpanderson/is-syntax-warning-bugfix Bugfix for ValueError introduced in #68 commit 4e77810 Author: Russell Anderson <[email protected]> Date: Thu Jun 25 11:18:56 2020 +1000 Abbreviated bugfix. commit a667f7e Author: Russell Anderson <[email protected]> Date: Thu Jun 25 11:17:11 2020 +1000 Bugfix for ValueError introduced in #68 commit 62b9098 Merge: 0e23ed0 1746399 Author: Chris Billington <[email protected]> Date: Wed Jun 24 20:49:32 2020 -0400 Merge pull request #67 from philipstarkey/fix-h5py-file-mode Fix h5py deprecation warning commit 0e23ed0 Merge: 5b52c20 6373f02 Author: Chris Billington <[email protected]> Date: Wed Jun 24 18:47:18 2020 -0400 Merge pull request #68 from rpanderson/is-syntax-warning Do not use 'is' for numeric literal comparisons commit 6373f02 Author: Russell Anderson <[email protected]> Date: Thu Jun 25 08:36:55 2020 +1000 Omitted 'is' with numeric literal comparisons commit 1746399 Author: philipstarkey <[email protected]> Date: Wed Jun 24 18:29:12 2020 +1000 Fix h5py deprecation warning Addresses labscript-suite/labscript-utils#47 for the labscript module commit 5b52c20 Merge: 0362fa7 88ce952 Author: Russell Anderson <[email protected]> Date: Mon Jun 22 18:09:54 2020 +1000 Merge pull request #66 from philipstarkey/master Doc updates commit 88ce952 Author: philipstarkey <[email protected]> Date: Sat Jun 20 18:17:23 2020 +1000 Doc updates Renamed API reference URL to match labscript utils and updated config to fix bugs identified in labscript-suite/labscript-utils#57 commit 0362fa7 Merge: 74869ef 52d3b9f Author: Phil Starkey <[email protected]> Date: Fri Jun 19 18:58:04 2020 +1000 Merge pull request #65 from philipstarkey/master Updated docs to follow our standard conf commit 52d3b9f Author: philipstarkey <[email protected]> Date: Fri Jun 19 16:04:04 2020 +1000 Addressing latest review comments commit 7674a8f Author: philipstarkey <[email protected]> Date: Fri Jun 19 11:19:33 2020 +1000 Updated docs to use jinja template for component doc links commit d4474e2 Author: philipstarkey <[email protected]> Date: Thu Jun 18 16:43:10 2020 +1000 Updated .gitignore with latest GitHub defaults commit a18a0d1 Author: philipstarkey <[email protected]> Date: Thu Jun 18 16:39:35 2020 +1000 Relocated custom sphinx git ignore rules commit 80aa5a1 Author: philipstarkey <[email protected]> Date: Thu Jun 18 16:21:44 2020 +1000 Restored 64 pixel logo accidentally replaced with 32 pixel logo commit 42d3bc6 Author: philipstarkey <[email protected]> Date: Thu Jun 18 16:17:42 2020 +1000 Updated install requirement to 3.0.0rc1+ commit 1961a2c Author: philipstarkey <[email protected]> Date: Thu Jun 18 16:13:40 2020 +1000 testing dependency fix commit 234753d Author: philipstarkey <[email protected]> Date: Thu Jun 18 16:07:41 2020 +1000 Updated as per the review in labscript-suite/labscript-suite#48 commit 74869ef Author: Russell Anderson <[email protected]> Date: Wed Jun 17 10:24:43 2020 +1000 Populated README.md with styling, iconogrpahy, prose, and badges commit 28dc675 Author: philipstarkey <[email protected]> Date: Tue Jun 16 18:24:26 2020 +1000 Removed unnecessary header and added intersphinx link commit 35c5466 Author: philipstarkey <[email protected]> Date: Tue Jun 16 17:19:33 2020 +1000 Updated docs to follow our standard conf Also added links to other labscript suite docs and standard links. Co-authored-by: chrisjbillington <[email protected]> Co-authored-by: Russell Anderson <[email protected]>
This PR fixes example.py which presently does not compile without warnings/errors, and omits the wildcard import (
from labscript import *
).An alternative would be to remove this example now that we have established a convention of writing and distributing examples in the default_profile/userlib/labscriptlib/example_apparatus folder of labscript-utils.