Skip to content
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

Use attach_session_metadata decorator #16

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/actions/install_requirements/action.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I'd like the dropping 3.9 changes in a separate PR

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
required: true
python_version:
description: Python version to install
default: "3.9"
default: "3.11"

runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
python: ["3.9", "3.10", "3.11"]
python: ["3.10", "3.11"]
install: [".[dev]", "-e .[dev]"]

runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ name = "dls-bluesky-core"
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
Expand All @@ -16,11 +15,12 @@ dependencies = [
"ophyd",
"ophyd_async",
"scanspec",
"dls-dodal",
] # Add project dependencies here, e.g. ["click", "numpy"]
dynamic = ["version"]
license.file = "LICENSE"
readme = "README.rst"
requires-python = ">=3.9"
requires-python = ">=3.10"

[project.optional-dependencies]
dev = [
Expand Down
39 changes: 19 additions & 20 deletions src/dls_bluesky_core/plans/wrapped.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Any, List, Mapping, Optional, Union

import bluesky.plans as bp
import bluesky.preprocessors as bpp
from bluesky.protocols import Readable
from dodal.plans.data_session_metadata import attach_data_session_metadata_decorator

from dls_bluesky_core.core import MsgGenerator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should import this from dodal.common.types too while we're at it


Expand All @@ -14,37 +16,34 @@ def count(
detectors: List[Readable],
num: int = 1,
delay: Optional[Union[float, List[float]]] = None,
baseline: Optional[List[Readable]] = None,
metadata: Optional[Mapping[str, Any]] = None,
) -> MsgGenerator:
"""
Take `n` readings from a device

Args:
detectors (List[Readable]): Readable devices to read
num (int, optional): Number of readings to take. Defaults to 1.
delay (Optional[Union[float, List[float]]], optional): Delay between readings.
Defaults to None.
metadata (Optional[Mapping[str, Any]], optional): Key-value metadata to include
in exported data.
Defaults to None.
num (int): Number of readings to take. Defaults to 1.
delay (Optional[Union[float, List[float]]]): Delay between readings.
Defaults to None.
baseline (Optional[List[Readable]]): List of devices to read at start
and end of scan
metadata (Optional[Mapping[str, Any]]): Key-value metadata to include
in exported data.
Defaults to None.

Returns:
MsgGenerator: _description_

Yields:
Iterator[MsgGenerator]: _description_
"""
plan_args = (
{ # If bp.count added delay to plan_args, we could remove all md handling
"detectors": list(map(repr, detectors)),
"num": num,
"delay": delay,
}
)

_md = {
"plan_args": plan_args,
**(metadata or {}),
}

yield from bp.count(detectors, num, delay=delay, md=_md)
baseline = baseline or []

@bpp.baseline_decorator(baseline)
@attach_data_session_metadata_decorator(provider=None)
def inner_plan() -> MsgGenerator:
yield from bp.count(detectors, num, delay=delay, md=metadata)

yield from inner_plan()
60 changes: 0 additions & 60 deletions src/dls_bluesky_core/stubs/flyables.py

This file was deleted.

54 changes: 0 additions & 54 deletions tests/stubs/test_flyables.py

This file was deleted.

1 change: 1 addition & 0 deletions tests/test_boilerplate_removed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This file checks that all the example boilerplate text has been removed.
It can be deleted when all the contained tests pass
"""

import sys
from pathlib import Path

Expand Down
Loading