Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 2.6.0
_commit: 4.2.0
_src_path: gh:DiamondLightSource/python-copier-template
author_email: gary.yendell@diamond.ac.uk
author_name: Gary Yendell
Expand All @@ -16,4 +16,5 @@ github_org: DiamondLightSource
package_name: fastcs
pypi: true
repo_name: FastCS
strict_typing: false
type_checker: pyright
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"features": {
// add in eternal history and other bash features
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1.0.0": {}
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1": {}
},
// Create the config folder for the bash-config feature
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/bash-config",
Expand Down
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua

This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects.

For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.6.0/how-to.html).
For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/4.2.0/how-to.html).
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ assignees: ''

---

Describe the bug, including a clear and concise description of the expected behavior, the actual behavior and the context in which you encountered it (ideally include details of your environment).
Describe the bug, including a clear and concise description of the expected behaviour, the actual behavior and the context in which you encountered it (ideally include details of your environment).

## Steps To Reproduce
Steps to reproduce the behavior:
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/install_requirements/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ runs:
run: |
PYTHON_VERSION="${{ inputs.python-version }}"
if [ $PYTHON_VERSION == "dev" ]; then
PYTHON_VERSION=$(sed -n "s/ARG PYTHON_VERSION=//p" Dockerfile)
# python version from Dockerfile, removing potential pinned sha
PYTHON_VERSION=$(sed -Ene "s/ARG PYTHON_VERSION=([0-9\.]+).*/\1/p" Dockerfile)
fi
echo "PYTHON_VERSION=$PYTHON_VERSION" >> "$GITHUB_ENV"
shell: bash
Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ updates:
actions:
patterns:
- "*"
commit-message:
prefix: "chore"

- package-ecosystem: "pip"
directory: "/"
Expand All @@ -22,3 +24,5 @@ updates:
dev-dependencies:
patterns:
- "*"
commit-message:
prefix: "chore"
27 changes: 0 additions & 27 deletions .github/workflows/_check.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/_docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
on:
workflow_call:


jobs:
build:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Create GitHub Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: "*"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
run: tox -e tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
name: ${{ inputs.python-version }}/${{ inputs.runs-on }}
files: cov.xml
Expand Down
21 changes: 8 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@ name: CI

on:
push:
branches:
- main
tags:
- '*'
pull_request:

jobs:
check:
uses: ./.github/workflows/_check.yml

lint:
needs: check
if: needs.check.outputs.branch-pr == ''
uses: ./.github/workflows/_tox.yml
with:
tox: pre-commit,type-checking

test:
needs: check
if: needs.check.outputs.branch-pr == ''
strategy:
matrix:
runs-on: ["ubuntu-latest"] # can add windows-latest, macos-latest
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
include:
# Include one that runs in the dev environment
- runs-on: "ubuntu-latest"
Expand All @@ -35,13 +33,10 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

docs:
needs: check
if: needs.check.outputs.branch-pr == ''
uses: ./.github/workflows/_docs.yml


dist:
needs: check
if: needs.check.outputs.branch-pr == ''
uses: ./.github/workflows/_dist.yml

helm:
Expand All @@ -52,14 +47,14 @@ jobs:

pypi:
if: github.ref_type == 'tag'
needs: [helm, dist]
needs: [dist, test, helm]
uses: ./.github/workflows/_pypi.yml
permissions:
id-token: write

release:
if: github.ref_type == 'tag'
needs: [dist, docs, helm]
needs: [dist, test, docs, helm]
uses: ./.github/workflows/_release.yml
permissions:
contents: write
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: ruff
name: lint with ruff
language: system
entry: ruff check --force-exclude
entry: ruff check --force-exclude --fix
types: [python]
require_serial: true

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ classifiers = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
description = "Control system agnostic framework for building Device support in Python that will work for both EPICS and Tango"
dependencies = [
Expand Down Expand Up @@ -128,6 +129,7 @@ lint.select = [
"C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"E", # pycodestyle errors - https://docs.astral.sh/ruff/rules/#error-e
"F", # pyflakes rules - https://docs.astral.sh/ruff/rules/#pyflakes-f
"N", # pep8-naming - https://docs.astral.sh/ruff/rules/#pep8-naming-n
"W", # pycodestyle warnings - https://docs.astral.sh/ruff/rules/#warning-w
"I", # isort - https://docs.astral.sh/ruff/rules/#isort-i
"UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up
Expand Down
6 changes: 3 additions & 3 deletions src/fastcs/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .attributes import ONCE, AttrHandlerR, AttrHandlerW, AttrR, AttrW
from .controller import BaseController, Controller
from .controller_api import ControllerAPI
from .exceptions import FastCSException
from .exceptions import FastCSError
from .util import validate_hinted_attributes


Expand Down Expand Up @@ -63,7 +63,7 @@ def _scan_done(self, task: asyncio.Task):
try:
task.result()
except Exception as e:
raise FastCSException(
raise FastCSError(
"Exception raised in scan method of "
f"{self._controller.__class__.__name__}"
) from e
Expand All @@ -86,7 +86,7 @@ def _link_put_tasks(controller_api: ControllerAPI) -> None:
case AttrW():
attribute.add_process_callback(method.fn)
case _:
raise FastCSException(
raise FastCSError(
f"Mode {attribute.access_mode} does not "
f"support put operations for {name}"
)
Expand Down
18 changes: 9 additions & 9 deletions src/fastcs/cs_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from fastcs.controller import BaseController

from .exceptions import FastCSException
from .exceptions import FastCSError

MethodCallback = Callable[..., Coroutine[None, None, None]]
"""Generic base class for all `Controller` methods"""
Expand Down Expand Up @@ -48,10 +48,10 @@ def __init__(self, fn: MethodCallback, *, group: str | None = None) -> None:

def _validate(self, fn: MethodCallback) -> None:
if self.return_type not in (None, Signature.empty):
raise FastCSException("Method return type must be None or empty")
raise FastCSError("Method return type must be None or empty")

if not iscoroutinefunction(fn):
raise FastCSException("Method must be async function")
raise FastCSError("Method must be async function")

@property
def return_type(self):
Expand Down Expand Up @@ -89,7 +89,7 @@ def _validate(self, fn: CommandCallback) -> None:
super()._validate(fn)

if not len(self.parameters) == 0:
raise FastCSException(f"Command method cannot have arguments: {fn}")
raise FastCSError(f"Command method cannot have arguments: {fn}")

async def __call__(self):
return await self._fn()
Expand All @@ -116,7 +116,7 @@ def _validate(self, fn: ScanCallback) -> None:
super()._validate(fn)

if not len(self.parameters) == 0:
raise FastCSException("Scan method cannot have arguments")
raise FastCSError("Scan method cannot have arguments")

async def __call__(self):
return await self._fn()
Expand All @@ -132,7 +132,7 @@ def _validate(self, fn: PutCallback) -> None:
super()._validate(fn)

if not len(self.parameters) == 1:
raise FastCSException("Put method can only take one argument")
raise FastCSError("Put method can only take one argument")

async def __call__(self, value: Any):
return await self._fn(value)
Expand All @@ -158,7 +158,7 @@ def _validate(self, fn: UnboundCommandCallback[Controller_T]) -> None:
super()._validate(fn)

if not len(self.parameters) == 1:
raise FastCSException("Command method cannot have arguments")
raise FastCSError("Command method cannot have arguments")

def bind(self, controller: Controller_T) -> Command:
return Command(MethodType(self.fn, controller), group=self.group)
Expand Down Expand Up @@ -191,7 +191,7 @@ def _validate(self, fn: UnboundScanCallback[Controller_T]) -> None:
super()._validate(fn)

if not len(self.parameters) == 1:
raise FastCSException("Scan method cannot have arguments")
raise FastCSError("Scan method cannot have arguments")

def bind(self, controller: Controller_T) -> Scan:
return Scan(MethodType(self.fn, controller), self._period)
Expand All @@ -210,7 +210,7 @@ def _validate(self, fn: UnboundPutCallback[Controller_T]) -> None:
super()._validate(fn)

if not len(self.parameters) == 2:
raise FastCSException("Put method can only take one argument")
raise FastCSError("Put method can only take one argument")

def bind(self, controller: Controller_T) -> Put:
return Put(MethodType(self.fn, controller))
Expand Down
4 changes: 2 additions & 2 deletions src/fastcs/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class FastCSException(Exception):
class FastCSError(Exception):
"""Base class for general problems in the running of a FastCS transport."""


class LaunchError(FastCSException):
class LaunchError(FastCSError):
"""For when there is an error in launching FastCS with the given
transports and controller.
"""
4 changes: 2 additions & 2 deletions src/fastcs/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from .transport.adapter import TransportAdapter
from .transport.epics.ca.options import EpicsCAOptions
from .transport.epics.pva.options import EpicsPVAOptions
from .transport.graphQL.options import GraphQLOptions
from .transport.graphql.options import GraphQLOptions
from .transport.rest.options import RestOptions
from .transport.tango.options import TangoOptions

Expand Down Expand Up @@ -76,7 +76,7 @@ def __init__(
option,
)
case GraphQLOptions():
from .transport.graphQL.adapter import GraphQLTransport
from .transport.graphql.adapter import GraphQLTransport

transport = GraphQLTransport(
self._backend.controller_api,
Expand Down
4 changes: 2 additions & 2 deletions src/fastcs/transport/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from .epics.options import EpicsGUIOptions as EpicsGUIOptions
from .epics.options import EpicsIOCOptions as EpicsIOCOptions
from .epics.pva.options import EpicsPVAOptions as EpicsPVAOptions
from .graphQL.options import GraphQLOptions as GraphQLOptions
from .graphQL.options import GraphQLServerOptions as GraphQLServerOptions
from .graphql.options import GraphQLOptions as GraphQLOptions
from .graphql.options import GraphQLServerOptions as GraphQLServerOptions
from .rest.options import RestOptions as RestOptions
from .rest.options import RestServerOptions as RestServerOptions
from .tango.options import TangoDSROptions as TangoDSROptions
Expand Down
4 changes: 2 additions & 2 deletions src/fastcs/transport/epics/ca/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from fastcs.attributes import Attribute, AttrR, AttrRW, AttrW
from fastcs.datatypes import Bool, DataType, Enum, Float, Int, String, T, Waveform
from fastcs.exceptions import FastCSException
from fastcs.exceptions import FastCSError

_MBB_FIELD_PREFIXES = (
"ZR",
Expand Down Expand Up @@ -151,6 +151,6 @@ def builder_callable_from_attribute(
case Waveform():
return builder.WaveformIn if make_in_record else builder.WaveformOut
case _:
raise FastCSException(
raise FastCSError(
f"EPICS unsupported datatype on {attribute}: {attribute.datatype}"
)
Loading