Skip to content

Commit

Permalink
Merge pull request #591 from BCDA-APS/590-deprecations
Browse files Browse the repository at this point in the history
remove deprecated items
  • Loading branch information
prjemian authored Nov 28, 2021
2 parents e006da2 + 8b3a7b2 commit 3f6a7e3
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 710 deletions.
15 changes: 15 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ Maintenance

Now testing with Python versions 3.7 - 3.10.

Deprecations
---------------

* Devices
* ``ApsCycleComputedRO``
* ``move_energy()`` method in ``KohzuSeqCtl_Monochromator`` class
* ``ProcessController``

* Utilities
* ``device_read2table``
* ``json_export``
* ``json_import``
* ``listdevice_1_5_2``
* ``listruns_v1_4``
* ``object_explorer``

1.5.4
******
Expand Down
2 changes: 0 additions & 2 deletions apstools/_devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
AD_prime_plugin
AD_prime_plugin2
ApsBssUserInfoDevice
ApsCycleComputedRO
ApsCycleDM
ApsMachineParametersDevice
ApsPssShutter
Expand Down Expand Up @@ -55,7 +54,6 @@

# other imports
from .aps_bss_user import ApsBssUserInfoDevice
from .aps_cycle import ApsCycleComputedRO
from .aps_cycle import ApsCycleDM
from .aps_machine import ApsMachineParametersDevice
from .aps_undulator import ApsUndulator
Expand Down
33 changes: 0 additions & 33 deletions apstools/_devices/aps_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
.. autosummary::
~ApsCycleComputedRO
~ApsCycleDM
"""

Expand Down Expand Up @@ -141,38 +140,6 @@ def get(self):
return self._cycle_name


class ApsCycleComputedRO(SynSignalRO):
"""
DEPRECATED (1.5.4): Use newer ``ApsCycleDM`` instead.
Compute the APS cycle name based on the calendar and the usual practice.
.. index:: Ophyd Signal; ApsCycleComputedRO
Absent any facility PV that provides the name of the current operating
cycle, this can be approximated by python computation (as long as the
present scheduling pattern is maintained)
This signal is read-only.
NOTE: There is info provided by the APS proposal & ESAF systems. See
:class:`~ApsCycleDM`.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
"DEPRECATED: ApsCycleComputedRO() will be removed"
" in a future release. Instead, use newer ``ApsCycleDM``.",
DeprecationWarning,
)
super().__init__(*args, **kwargs)

def get(self):
dt = datetime.datetime.now()
aps_cycle = f"{dt.year}-{int((dt.month-0.1)/4) + 1}"
return aps_cycle


# -----------------------------------------------------------------------------
# :author: Pete R. Jemian
# :email: [email protected]
Expand Down
19 changes: 1 addition & 18 deletions apstools/_devices/kohzu_monochromator.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,8 @@ class KohzuSeqCtl_Monochromator(Device):
crystal_2d_spacing = Component(EpicsSignal, "Bragg2dSpacingAO", kind="config")
crystal_type = Component(EpicsSignal, "BraggTypeMO", string=True, kind="config")

def move_energy(self, energy):
"""
DEPRECATED: Simple command-line use to change the energy.
USAGE::
kohzu_mono.energy_move(8.2)
INSTEAD::
%mov kohzu_mono.mode "Auto" kohzu_mono.energy 8.2
To be removed in apstools release 1.6.0
"""
self.move_button.put(1)
self.energy.put(energy)

def calibrate_energy(self, value):
"""Calibrate the mono energy.
"""Calibrate the monochromator energy.
PARAMETERS
Expand Down
13 changes: 0 additions & 13 deletions apstools/_devices/tests/test_aps_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pytest
import socket

from .. import ApsCycleComputedRO
from .. import ApsCycleDM
from .. import aps_cycle

Expand All @@ -16,18 +15,6 @@ def using_APS_workstation():
return hostname.lower().endswith(".aps.anl.gov")


def test_ApsCycleComputedRO():
signal = ApsCycleComputedRO(name="signal")
assert signal.connected

cycle = signal.get() # expect 2021-3 or such
assert isinstance(cycle, str)
assert cycle != ""
assert len(cycle) == 6
assert cycle.startswith("20")
assert cycle.find("-") >= 0


def test_ApsCycleDM():
signal = ApsCycleDM(name="signal")
assert signal.connected
Expand Down
6 changes: 0 additions & 6 deletions apstools/_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
__all__ = """
device_read2table
getDefaultNamespace
ipython_profile_name
ipython_shell_namespace
listdevice
listdevice_1_5_2
listplans
object_explorer
OverrideParameters
""".split()

from .device_info import device_read2table
from .device_info import listdevice
from .device_info import listdevice_1_5_2
from .device_info import object_explorer
from .list_plans import listplans
from .override_parameters import OverrideParameters
from .profile_support import getDefaultNamespace
Expand Down
102 changes: 1 addition & 101 deletions apstools/_utils/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@
.. autosummary::
~device_read2table
~listdevice
~listdevice_1_5_2
~object_explorer
"""

__all__ = """
device_read2table
listdevice
listdevice_1_5_2
object_explorer
""".split()
__all__ = ["listdevice", ]


from collections import defaultdict
Expand Down Expand Up @@ -91,29 +83,6 @@ def _list_epics_signals(obj):
return items


def device_read2table(
# fmt:off
device, show_ancient=True, use_datetime=True, printing=True
# fmt:on
):
"""
DEPRECATED (release 1.3.8): Use listdevice() instead. (Remove in 1.6.0.)
"""
# fmt: off
warnings.warn(
"DEPRECATED: device_read2table() will be removed"
" in release 1.6.0. Use listdevice() instead.",
DeprecationWarning,
)
listdevice_1_5_2(
device,
show_ancient=show_ancient,
use_datetime=use_datetime,
printing=printing,
)
# fmt: on


def listdevice(
obj,
scope=None,
Expand Down Expand Up @@ -208,75 +177,6 @@ def listdevice(
return pd.DataFrame(dd)


def listdevice_1_5_2(
# fmt:off
device, show_ancient=True, use_datetime=True, printing=True
# fmt:on
):
"""
DEPRECATED (release 1.5.3): Use listdevice() instead. (Remove in 1.6.0.)
Read an ophyd device and return a pyRestTable Table.
Include an option to suppress ancient values identified
by timestamp from 1989. These are values only defined in
the original ``.db`` file.
"""
table = pyRestTable.Table()
table.labels = "name value timestamp".split()
ANCIENT_YEAR = 1989
for k, rec in device.read().items():
value = rec["value"]
ts = rec["timestamp"]
dt = datetime.datetime.fromtimestamp(ts)
if dt.year > ANCIENT_YEAR or show_ancient:
if use_datetime:
ts = dt
table.addRow((k, value, ts))

if printing:
print(table)

return table


def object_explorer(obj, sortby=None, fmt="simple", printing=True):
"""
DEPRECATED (release 1.5.3): Use listdevice() instead. (Remove in 1.6.0.)
print the contents of obj
"""
t = pyRestTable.Table()
t.addLabel("name")
t.addLabel("PV reference")
t.addLabel("value")
items = _list_epics_signals(obj)
if items is None:
logger.debug("No EPICS signals found.")
else:
logger.debug(f"number of items: {len(items)}")

def sorter(obj):
if sortby is None:
key = obj.dotted_name
elif str(sortby).lower() == "pv":
key = _get_pv(obj) or "--"
else:
# fmt: off
raise ValueError(
f"sortby should be None or 'PV', found sortby='{sortby}'"
)
# fmt: on
return key

for item in sorted(items, key=sorter):
t.addRow((item.dotted_name, _get_pv(item), item.get()))

if printing:
print(t.reST(fmt=fmt))
return t


# -----------------------------------------------------------------------------
# :author: Pete R. Jemian
# :email: [email protected]
Expand Down
49 changes: 0 additions & 49 deletions apstools/_utils/tests/test_listdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from ...devices import SwaitRecord
from ..device_info import _list_epics_signals
from ..device_info import listdevice
from ..device_info import listdevice_1_5_2
from ..device_info import object_explorer


# set default timeout for all EpicsSignal connections & communications
Expand Down Expand Up @@ -57,24 +55,6 @@ def test_calcs():
assert isinstance(calcs, Device)


@pytest.mark.parametrize(
"obj, length",
[
(calcs, 28),
(calcs.calc5.description, 1),
(signal, 1),
(motor, 2),
(motor.user_setpoint, 1),
],
)
def test_listdevice_1_5_2(obj, length):
result = listdevice_1_5_2(obj)
assert isinstance(result, pyRestTable.Table)
assert len(result.labels) == 3
assert result.labels == ["name", "value", "timestamp"]
assert len(result.rows) == length


@pytest.mark.parametrize(
"obj, length",
[
Expand All @@ -96,24 +76,6 @@ def test_listdevice(obj, length):
assert r in expected


@pytest.mark.parametrize(
"obj, length",
[
(calcs, 126),
(calcs.calc5.description, 1),
(signal, 0),
(motor, 19),
(motor.user_setpoint, 1),
],
)
def test_object_explorer(obj, length):
result = object_explorer(obj)
assert isinstance(result, pyRestTable.Table)
assert len(result.labels) == 3
assert result.labels == ["name", "PV reference", "value"]
assert len(result.rows) == length


@pytest.mark.parametrize(
"obj, length, ref",
[
Expand Down Expand Up @@ -144,17 +106,6 @@ def test__list_epics_signals(obj, length, ref):
(listdevice, 2, "value", 0.0),
(listdevice, 27, "data name", "calcs_calc6_channels_L_input_value"),
(listdevice, 27, "value", 0.0),
(listdevice_1_5_2, 0, 0, "calcs_signals_background"),
(listdevice_1_5_2, 0, 1, True),
(listdevice_1_5_2, 2, 0, "calcs_calc5_calculated_value"),
(listdevice_1_5_2, 2, 1, 0.0),
(listdevice_1_5_2, 27, 0, "calcs_calc6_channels_L_input_value"),
(listdevice_1_5_2, 27, 1, 0.0),
(object_explorer, 0, 0, "calc5.alarm_severity"),
(object_explorer, 0, 1, f"{IOC}userCalc5.SEVR"),
(object_explorer, 125, 0, "calc6.trace_processing"),
(object_explorer, 125, 1, f"{IOC}userCalc6.TPRO"),
(object_explorer, 125, 2, 0),
],
)
def test_spotchecks(function, row, column, value):
Expand Down
Loading

0 comments on commit 3f6a7e3

Please sign in to comment.