Skip to content

Commit

Permalink
pyyaml linting
Browse files Browse the repository at this point in the history
  • Loading branch information
olliesilvester committed Sep 19, 2023
1 parent 418b146 commit 6716559
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 69 deletions.
3 changes: 0 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@
("py:class", "typing_extensions.Literal"),
]

# Exclude the 'PyYAML' module from type checking
autodoc_mock_imports = ["yaml"]

# Both the class’ and the __init__ method’s docstring are concatenated and
# inserted into the main body of the autoclass directive
autoclass_content = "both"
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ dev = [
"tox-direct",
"types-mock",
"pyyaml",
"types-pyyaml",
]

[project.scripts]
Expand Down
67 changes: 1 addition & 66 deletions src/ophyd_async/core/_device/device_save_loader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import Any, Dict, List, Union
from typing import Any, Dict, List

import yaml
from bluesky import Msg
Expand Down Expand Up @@ -119,68 +119,3 @@ def save_device(device: Device, savename: str, ignore: List[str] = []):
filename = f"{savename}.yaml"
with open(filename, "w") as file:
yaml.dump(phase_outputs, file)


# async def load_device(device, savename: str):
# """Does an abs_set on each signalRW which has differing values to the savefile"""

# # Locate all signals to later compare with loaded values, then only
# # change differing values

# signalRWs: Dict[str, SignalRW] = get_signal_RWs_from_device(
# device, ""
# ) # {'device.subdevice.etc: signalRW}
# signal_name_values = (
# {}
# ) # we want this to be {'device.subdevice.etc: signal location}
# signals_to_locate = []
# for sig in signalRWs.values():
# signals_to_locate.append(sig.locate())

# signal_values = await asyncio.gather(*signals_to_locate)

# # Copy logic from save plan to convert enums and np arrays
# for index, value in enumerate(signal_values):
# if isinstance(value, dict):
# for inner_key, inner_value in value.items():
# if isinstance(inner_value, ndarray):
# value[inner_key] = inner_value.tolist()
# # Convert enums to their values
# elif isinstance(signal_values[index], Enum):
# signal_values[index] = value.value

# for index, key in enumerate(signalRWs.keys()):
# signal_name_values[key] = signal_values[index]

# # Get PV info from yaml file
# filename = f"{savename}.yaml"
# with open(filename, "r") as file:
# data_by_phase: List[Dict[str, Any]] = yaml.full_load(file)

# """For each phase, find the location of the SignalRW's in that phase,
# load them
# to the correct value, and wait for the load to complete"""
# for phase_number, phase in enumerate(data_by_phase):
# phase_load_statuses: List[AsyncStatus] = []
# for key, value in phase.items():
# # If the values are different then do an abs_set
# if signal_name_values[key] != value:
# # Key is subdevices_x.subdevices_x+1.etc.signalname. First get
# # the attribute hierarchy
# components = key.split(".")
# lowest_device = device

# # If there are subdevices
# if len(components) > 1:
# signal_name: str = components[
# -1
# ] # Last string is the signal name
# for attribute in components[:-1]:
# lowest_device = getattr(lowest_device, attribute)
# else:
# signal_name: str = components[0]
# signalRW: SignalRW = getattr(lowest_device, signal_name)

# phase_load_statuses.append(signalRW.set(value, timeout=5))

# await asyncio.gather(*phase_load_statuses)

0 comments on commit 6716559

Please sign in to comment.