diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml index 06bf7d0d..4da5017b 100644 --- a/.github/workflows/code.yml +++ b/.github/workflows/code.yml @@ -31,19 +31,11 @@ jobs: run: | set -vxeuo pipefail python -m pip install --upgrade pip - pip install ruff flake8 - - - name: Run flake8 - run: flake8 - # # TODO: will replace flake8 - # - name: Run ruff - # uses: davidslusser/actions_python_ruff@v1.0.0 - # with: - # # src: "." - # # options: "--cov=src" - # pip_install_command: "pip install -e .[dev]" - # python_version: "3.11" + - name: Run ruff + uses: davidslusser/actions_python_ruff@v1.0.0 + with: + python_version: "3.11" tests: name: CI py${{ matrix.python-version }} diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 00000000..f03f66b3 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,86 @@ +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +# Same as Black. +line-length = 115 +indent-width = 4 + +# Assume Python 3.8 +target-version = "py38" + +[lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = ["E402", "F405"] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[lint.per-file-ignores] +"__init__.py" = ["F403"] +"bluesky/console/__start_bluesky_instrument__.py" = ["F403"] +"bluesky/instrument/collection.py" = ["F403"] +"bluesky/instrument/qstarter.py" = ["F401", "F403"] +"bluesky/instrument/queueserver.py" = ["F401", "F403"] +"bluesky/qstarter.py" = ["F401"] +"**/{tests,docs,tools}/*" = ["E402"] + +[format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" diff --git a/.wip/pack_unpack/export_db.py b/.wip/pack_unpack/export_db.py index b5426eb8..b744c1df 100644 --- a/.wip/pack_unpack/export_db.py +++ b/.wip/pack_unpack/export_db.py @@ -6,10 +6,12 @@ see: https://github.com/APS-3ID-IXN/ipython-s3blue/issues/2 """ -from databroker import Broker -import datetime, os, shutil, time +import datetime +import os +import shutil + import pyRestTable -from dask.bag import text +from databroker import Broker def main(): @@ -101,6 +103,7 @@ def main(): import re + ACCEPTABLE_PATTERN = r"[A-Za-z_][\w_]*" @@ -127,9 +130,7 @@ def tester(): 'mca_elapsed_real_time', 'mca_preset_real_time', 'mca_spectrum', 'neat_stage_x', 'neat_stage_x_user_setpoint', 'neat_stage_y', 'neat_stage_y_user_setpoint', 'scaler_time'] - safe_keys = make_safe(keys) - keymap = {k:v for k, v in zip(keys, safe_keys)} - for old_key, new_key in zip(keys, safe_keys): + for old_key, new_key in zip(keys, make_safe(keys)): tbl.addRow((old_key, new_key)) print(tbl) diff --git a/CHANGES.rst b/CHANGES.rst index a9577bbb..f0504309 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -24,28 +24,37 @@ describe future plans. 1.0.3 ****** - release expected by 2024-04-01 + release expected by 2024-04-02 1.0.2 ****** -release expected by 2024-03-01 +released 2024-02-26 New Features ------------ +* Add options to instrument configuration (iconfig.yml): + + * After every run, verify that files were saved, print a confirmation message. + * Debugging and message options. + * Add package(s) to environment: * ophyd-registry -* Build ``registry`` of all ophyd objects. +* Build ``oregistry`` of all ophyd objects. +* Post a warning if at APS but not on controls subnet. Maintenance ------------ +* Add 'Hello, World!' test to installation checklist. * Drop the (unused now) *stdlogpj* package for configuring Python's *logging*. * Environment for bluesky_2024_1. - +* Lint the code (for style and syntax errors) using the 'ruff' package. +* Updates (learned from 2-ID) for new installations. +* Various documentation updates. v1.0.1 ****** diff --git a/README.md b/README.md index 38714dd1..2e470798 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,14 @@ beamlines to use the [Bluesky](https://blueskyproject.io) framework. - [HowTo guides, tutorials, & references](https://bcda-aps.github.io/bluesky_training/) demonstrating use of the Bluesky framework at a typical beamline. -- a [template](./bluesky/) for beamlines to configure their instrument -- a [list of APS instrument](https://github.com/BCDA-APS/bluesky_training/wiki/) +- A [template](./bluesky/) for beamlines to configure their instrument. +- A [checklist](https://bcda-aps.github.io/bluesky_training/instrument/_install_new_instrument.html#installation-checklist) to install a new instrument. +- A [list of APS instrument](https://github.com/BCDA-APS/bluesky_training/wiki/) repositories -Unit Tests | License | GH tag ---- | --- | --- -[![Unit Tests](https://github.com/BCDA-APS/bluesky_training/workflows/Unit%20Tests/badge.svg)](https://github.com/BCDA-APS/bluesky_training/actions/workflows/unit_tests.yml) | [![license: ANL](https://img.shields.io/badge/license-ANL-brightgreen)](/LICENSE.txt) | [![tag](https://img.shields.io/github/tag/BCDA-APS/bluesky_training.svg)](https://github.com/BCDA-APS/bluesky_training/tags) +Unit Tests | License | GH tag | Code Coverage +--- | --- | --- | --- +[![Unit Tests](https://github.com/BCDA-APS/bluesky_training/workflows/Unit%20Tests/badge.svg)](https://github.com/BCDA-APS/bluesky_training/actions/workflows/unit_tests.yml) | [![license: ANL](https://img.shields.io/badge/license-ANL-brightgreen)](/LICENSE.txt) | [![tag](https://img.shields.io/github/tag/BCDA-APS/bluesky_training.svg)](https://github.com/BCDA-APS/bluesky_training/tags) | [![Coverage Status](https://coveralls.io/repos/github/BCDA-APS/bluesky_training/badge.svg?branch=main)](https://coveralls.io/github/BCDA-APS/bluesky_training?branch=main)