diff --git a/.pylintrc b/.pylintrc index 505656610cd89992ffac096564313cc51da3f2ab..b525115dfdbae35c577421c23b5d06fe6dd748f8 100644 --- a/.pylintrc +++ b/.pylintrc @@ -16,10 +16,6 @@ ignore-patterns= # Python code to execute, usually for sys.path manipulation such as # pygtk.require(). #init-hook= -# FIXME These init-hooks should be removed, they are presently needed due to namespace problems with this repo -init-hook='sys.path.append("./skabase/SKABaseDevice"); - sys.path.append("./skabase/auxiliary"); - sys.path.append("./skabase/SKAObsDevice")' # Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the # number of processors available to use. diff --git a/.release b/.release index 7d9b5377be3c06be82ba3abd1f3cde409c1e4210..2f42e5fbb4223eeaaaec7129741f8468f38010ae 100644 --- a/.release +++ b/.release @@ -1,2 +1,2 @@ -release=0.4.1 -tag=lmcbaseclasses-0.4.1 +release=0.5.0.dev0 +tag=lmcbaseclasses-0.5.0.dev0 diff --git a/Dockerfile b/Dockerfile index 95534ea7fc2a4b9c3fb061f072a37f977409a9c6..032adbf30f3c1d2959126c6021c82a3820fc8533 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,11 @@ FROM nexus.engageska-portugal.pt/ska-docker/ska-python-runtime:9.3.1 AS runtime # create ipython profile to so that itango doesn't fail if ipython hasn't run yet RUN ipython profile create +# TODO: move this dependency to ska-docker/docker/tango/ska-python-buildenv/requirements.txt +RUN python3 -m pip install --user pytest-forked + # Note: working dir is `/app` which will have a copy of our repo -RUN python3 -m pip install -e . --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple -CMD ["python3", "/app/skabase/SKABaseDevice/SKABaseDevice.py"] +# The pip install will be a "user installation" so update path to access console scripts +ENV PATH=/home/tango/.local/bin:$PATH +RUN python3 -m pip install -e . --user --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple +CMD ["SKABaseDevice"] diff --git a/README.md b/README.md index 6d1ad22af5a33323197c41af6bff2e0b474b9fdd..34bf4e140b2146168439305573e6d41809308d93 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,15 @@ The lmc-base-classe repository contains set of eight classes as mentioned in SKA ## Version History +#### 0.5.0 - WIP... +- Breaking change: Major restructuring of the package to simplify imports and reduce confusion. + - The single word `skabase` module has now changed to two words: `ska.base`. + - Instead of `from skabase.SKABaseDevice.SKABaseDevice import SKABaseDevice` to import the + class, just use `from ska.base import SKABaseDevice`. + - Instead of `skabase.control_mode` use `ska.base.control_mode`. + - The `SKATestDevice` was removed. Note that this class was only intended + for internal use in lmc-base-classes and is no longer needed. + #### 0.4.1 - Fix lost properties when re-initialising test device (remove `get_name` mock). - Fix Sphinx doc building. @@ -111,9 +120,9 @@ code analysis is also done and code coverage report is prepared. After testing is done, the containers are taken down. ## Usage -The base classes are installed as python package in the system. The intended usage of the base classes is to inherit the class according to the requirement. The class needs to be imported in the module. e.g. +The base classes are installed as a Python package in the system. The intended usage of the base classes is to inherit the class according to the requirement. The class needs to be imported in the module. e.g. ``` -from skabase.SKABaseDevice.SKABaseDevice import SKABaseDevice +from ska.base import SKABaseDevice class DishLeafNode(SKABaseDevice): . @@ -121,7 +130,19 @@ class DishLeafNode(SKABaseDevice): . ``` -**Note: The lmc-base-classes repository will be repackaged soon. That will change the way of importing it.** +## Development + +### PyCharm + +The Docker integration is recommended. For development, use the +`nexus.engageska-portugal.pt/tango-example/lmcbaseclasses:latest` image +as the Python Interpreter for the project. + +As this project uses a `src` [folder structure](https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure), +Under _Preferences > Project Structure_, the src folder(s) needs to be marked as "Sources". That will +allow the interpreter to be aware of the code from folders outside of `src`, such as the `tests`. +Under the Run/Debug configurations, make sure "Add content roots to PYTHONPATH" and +"Add source roots to PYTHONPATH" are checked. ## Docs - SKA Control System guidelines: [Google docs folder](https://drive.google.com/drive/folders/0B8fhAW5QnZQWQ2ZlcjhVS0NmRms) diff --git a/docker-compose.yml b/docker-compose.yml index 2926da791869db7df8af8945d53e8efa2258d417..6858167c160f3bc607ab6b28b332a1e0676deb4e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,7 @@ # - obsdevice: Container having SKAObsDevice class # - subarray: Container having SKASubarray class # - telstate: Container having SKATelState class +# - logtest: Container having SKASubarray class for SKALogger testing # # Requires: # - None @@ -71,7 +72,7 @@ services: command: > sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- tango_admin --add-server SKABaseDevice/01 SKABaseDevice ska/basedevice/01 &&\ - /venv/bin/python /app/skabase/SKABaseDevice/SKABaseDevice.py 01" + SKABaseDevice 01" alarmhandler: image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/lmcbaseclasses:latest @@ -85,7 +86,7 @@ services: command: > sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- tango_admin --add-server SKAAlarmHandler/01 SKAAlarmhandler ska/alarmhandler/01 &&\ - /venv/bin/python /app/skabase/SKAAlarmHandler/SKAAlarmHandler.py 01" + SKAAlarmHandler 01" capability: image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/lmcbaseclasses:latest @@ -99,7 +100,7 @@ services: command: > sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- tango_admin --add-server SKACapability/01 SKACapability ska/capability/01 &&\ - /venv/bin/python /app/skabase/SKACapability/SKACapability.py 01" + SKACapability 01" logger: image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/lmcbaseclasses:latest @@ -113,7 +114,7 @@ services: command: > sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- tango_admin --add-server SKALogger/01 SKALogger ska/logger/01 &&\ - /venv/bin/python /app/skabase/SKALogger/SKALogger.py 01" + SKALogger 01" master: image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/lmcbaseclasses:latest @@ -127,7 +128,7 @@ services: command: > sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- tango_admin --add-server SKAMaster/01 SKAMaster ska/master/01 &&\ - /venv/bin/python /app/skabase/SKAMaster/SKAMaster.py 01" + SKAMaster 01" obsdevice: image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/lmcbaseclasses:latest @@ -141,7 +142,7 @@ services: command: > sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- tango_admin --add-server SKAObsDevice/01 SKAObsDevice ska/obsdevice/01 &&\ - /venv/bin/python /app/skabase/SKAObsDevice/SKAObsDevice.py 01" + SKAObsDevice 01" subarray: image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/lmcbaseclasses:latest @@ -155,7 +156,7 @@ services: command: > sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- tango_admin --add-server SKASubarray/01 SKASubarray ska/subarray/01 &&\ - /venv/bin/python /app/skabase/SKASubarray/SKASubarray.py 01" + SKASubarray 01" telstate: image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/lmcbaseclasses:latest @@ -169,4 +170,18 @@ services: command: > sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- tango_admin --add-server SKATelState/01 SKATelState ska/telstate/01 &&\ - /venv/bin/python /app/skabase/SKATelState/SKATelState.py 01" + SKATelState 01" + + logtest: + image: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}/lmcbaseclasses:latest + restart: unless-stopped + depends_on: + - databaseds + network_mode: ${NETWORK_MODE} + container_name: ${CONTAINER_NAME_PREFIX}testdevice + environment: + - TANGO_HOST=${TANGO_HOST} + command: > + sh -c "wait-for-it.sh ${TANGO_HOST} --timeout=30 --strict -- + tango_admin --add-server SKASubarray/02 SKASubarray logger/test/1 &&\ + SKASubarray 02" diff --git a/pogo/SKAAlarmHandler.xmi b/pogo/SKAAlarmHandler.xmi index 4a058909c9c13b7d8165fea5337023388effcf02..fe91c09bb45d3f2b2d4d7a2564648374cf5caa71 100644 --- a/pogo/SKAAlarmHandler.xmi +++ b/pogo/SKAAlarmHandler.xmi @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKAAlarmHandler" pogoRevision="9.6"> - <description description="A generic base device for Alarms for SKA." title="SKAAlarmHandler" sourcePath="/home/pogo/src/lmc-base-classes/skabase/SKAAlarmHandler" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic base device for Alarms for SKA." title="SKAAlarmHandler" sourcePath="/home/tango/src/lmc-base-classes/pogo/" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> - <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> + <inheritances classname="SKABaseDevice" sourcePath="."/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKAAlarmHandler"/> </description> <deviceProperties name="SubAlarmHandlers" description="List of sub-element AlarmHandlers:
name1:FQDN1,name2:FQDN2"> diff --git a/pogo/SKABaseDevice.xmi b/pogo/SKABaseDevice.xmi index 081e4c5651cfb6bdd70d2187c15acc1722dc4149..696245a5011f6b2af23e8eb686f92819e77075c3 100644 --- a/pogo/SKABaseDevice.xmi +++ b/pogo/SKABaseDevice.xmi @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKABaseDevice" pogoRevision="9.6"> - <description description="A generic base device for SKA." title="SKABASE" sourcePath="/home/pogo/src/lmc-base-classes/skabase/SKABaseDevice" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic base device for SKA." title="SKABASE" sourcePath="/home/tango/src/lmc-base-classes/pogo/" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKABaseDevice"/> </description> diff --git a/pogo/SKACapability.xmi b/pogo/SKACapability.xmi index 22e171401b666ae2387ad5964d30bed99e87df73..4cef4573abd86666ffed39edcd301abf1a28f58f 100644 --- a/pogo/SKACapability.xmi +++ b/pogo/SKACapability.xmi @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKACapability" pogoRevision="9.6"> - <description description="Subarray handling device" title="SKACapability" sourcePath="/home/pogo/src/lmc-base-classes/skabase/SKACapability" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="true" hasAbstractAttribute="false"> + <description description="Subarray handling device" title="SKACapability" sourcePath="/home/tango/src/lmc-base-classes/pogo/" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="true" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> - <inheritances classname="SKAObsDevice" sourcePath="../SKAObsDevice"/> + <inheritances classname="SKAObsDevice" sourcePath="."/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="SkaBase" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> </description> <deviceProperties name="SkaLevel" description="Indication of importance of the device in the SKA hierarchy 
to support drill-down navigation: 1..6, with 1 highest.
Default is 4, making provision for 
EltMaster, EltAlarms, EltTelState = 1
SubEltMaster = 2
Subarray, Capability = 2/3
Others = 4 (or 5 or 6)"> diff --git a/pogo/SKALogger.xmi b/pogo/SKALogger.xmi index decb758c4cd7609df721987bbe163c3939d6a61e..8d98bbd1bc912816e330fe77020fda7e24e55b5c 100644 --- a/pogo/SKALogger.xmi +++ b/pogo/SKALogger.xmi @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKALogger" pogoRevision="9.6"> - <description description="A generic base device for Logging for SKA." title="SKALogger" sourcePath="/home/tango-cs/src/lmc-base-classes/skabase/SKALogger" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic base device for Logging for SKA." title="SKALogger" sourcePath="/home/tango/src/lmc-base-classes/pogo/" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> - <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> + <inheritances classname="SKABaseDevice" sourcePath="."/> <identification contact="at gmail.com - lochanb.ska" author="lochanb.ska" emailDomain="gmail.com" classFamily="SKA Base Class" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKA" reference="SKA-SKALogger"/> </description> <deviceProperties name="SkaLevel" description="Indication of importance of the device in the SKA hierarchy 
to support drill-down navigation: 1..6, with 1 highest.
Default is 4, making provision for 
EltMaster, EltAlarms, EltTelState = 1
SubEltMaster = 2
Subarray, Capability = 2/3
Others = 4 (or 5 or 6)"> diff --git a/pogo/SKAMaster.xmi b/pogo/SKAMaster.xmi index 0aa080b1d918654d0300372e2c71459d872b3dff..61d794dfa8f688e6b695d3f9d1ec61d454755827 100644 --- a/pogo/SKAMaster.xmi +++ b/pogo/SKAMaster.xmi @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKAMaster" pogoRevision="9.6"> - <description description="A master test" title="SKAMaster" sourcePath="/home/pogo/src/lmc-base-classes/skabase/SKAMaster" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A master test" title="SKAMaster" sourcePath="/home/tango/src/lmc-base-classes/pogo/" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> - <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> + <inheritances classname="SKABaseDevice" sourcePath="."/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="SkaBase" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> </description> <deviceProperties name="SkaLevel" description="Indication of importance of the device in the SKA hierarchy 
to support drill-down navigation: 1..6, with 1 highest.
Default is 4, making provision for 
EltMaster, EltAlarms, EltTelState = 1
SubEltMaster = 2
Subarray, Capability = 2/3
Others = 4 (or 5 or 6)"> diff --git a/pogo/SKAObsDevice.xmi b/pogo/SKAObsDevice.xmi index 4d3e4dad9d3b3ed68bb581d696dbba0377c90bb7..72e2c83fbfe22ade9ff6af241143ee01633a2c62 100644 --- a/pogo/SKAObsDevice.xmi +++ b/pogo/SKAObsDevice.xmi @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKAObsDevice" pogoRevision="9.6"> - <description description="A generic base device for Observations for SKA." title="SKAObsDevice" sourcePath="/home/tango-cs/src/lmc-base-classes/skabase/SKAObsDevice" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="true" hasAbstractAttribute="false"> + <description description="A generic base device for Observations for SKA." title="SKAObsDevice" sourcePath="/home/tango/src/lmc-base-classes/pogo/" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="true" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> - <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> + <inheritances classname="SKABaseDevice" sourcePath="."/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKAObsDevice"/> </description> <deviceProperties name="SkaLevel" description="Indication of importance of the device in the SKA hierarchy 
to support drill-down navigation: 1..6, with 1 highest.
Default is 4, making provision for 
EltMaster, EltAlarms, EltTelState = 1
SubEltMaster = 2
Subarray, Capability = 2/3
Others = 4 (or 5 or 6)"> diff --git a/pogo/SKASubarray.xmi b/pogo/SKASubarray.xmi index 45a541f3d3b1323e2d94fc507cdb9c1840148095..24be7310128c15fd987e62a00c396b6085936eb8 100644 --- a/pogo/SKASubarray.xmi +++ b/pogo/SKASubarray.xmi @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKASubarray" pogoRevision="9.6"> - <description description="SubArray handling device" title="SKASubarray" sourcePath="/home/pogo/src/lmc-base-classes/skabase/SKASubarray" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="SubArray handling device" title="SKASubarray" sourcePath="/home/tango/src/lmc-base-classes/pogo/" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> - <inheritances classname="SKAObsDevice" sourcePath="../SKAObsDevice"/> + <inheritances classname="SKAObsDevice" sourcePath="."/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="SkaBase" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> </description> <deviceProperties name="CapabilityTypes" description="List of Capability types e.g. capCorr, capPss,
capPstBf, capVlbi, this will be used to dynamically
define groups for subarray."> diff --git a/pogo/SKATelState.xmi b/pogo/SKATelState.xmi index 503ad91b7a2fcf78543bd52f04e90f893462768a..c325fc0b22a3a895470f22b636d73506b493959b 100644 --- a/pogo/SKATelState.xmi +++ b/pogo/SKATelState.xmi @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKATelState" pogoRevision="9.6"> - <description description="A generic base device for Telescope State for SKA." title="SKATelState" sourcePath="/home/pogo/src/lmc-base-classes/skabase/SKATelState" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic base device for Telescope State for SKA." title="SKATelState" sourcePath="/home/tango/src/lmc-base-classes/pogo/" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> - <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> + <inheritances classname="SKABaseDevice" sourcePath="."/> <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKATelState"/> </description> <deviceProperties name="TelStateConfigFile" description="JSON file with forwarded attributes to expose."> diff --git a/pogo/SKATestDevice.xmi b/pogo/SKATestDevice.xmi deleted file mode 100644 index 9bbd09b4f3a1b6872eb657ece3c9e0826ee6634b..0000000000000000000000000000000000000000 --- a/pogo/SKATestDevice.xmi +++ /dev/null @@ -1,212 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> - <classes name="SKATestDevice" pogoRevision="9.6"> - <description description="A generic Test device for testing SKA base class functionalites." title="SKATestDevice" sourcePath="/home/tango-cs/src/lmc-base-classes/skabase/SKATestDevice" language="PythonHL" filestogenerate="XMI file,Code files,Python Package,Protected Regions" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false"> - <inheritances classname="Device_Impl" sourcePath=""/> - <inheritances classname="SKABaseDevice" sourcePath="../SKABaseDevice"/> - <identification contact="at ska.ac.za - cam" author="cam" emailDomain="ska.ac.za" classFamily="OtherInstruments" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="SKASA" reference="SKA-SKATestDevice"/> - </description> - <deviceProperties name="SkaLevel" description="Indication of importance of the device in the SKA hierarchy 
to support drill-down navigation: 1..6, with 1 highest.
Default is 4, making provision for 
EltMaster, EltAlarms, EltTelState = 1
SubEltMaster = 2
Subarray, Capability = 2/3
Others = 4 (or 5 or 6)"> - <type xsi:type="pogoDsl:ShortType"/> - <status abstract="false" inherited="true" concrete="true"/> - <DefaultPropValue>4</DefaultPropValue> - </deviceProperties> - <deviceProperties name="LoggingLevelDefault" description="Default logging level at device startup.
(0=OFF, 1=FATAL, 2=ERROR, 3=WARNING, 4=INFO, 5=DEBUG)"> - <type xsi:type="pogoDsl:UShortType"/> - <status abstract="false" inherited="true" concrete="true"/> - <DefaultPropValue>4</DefaultPropValue> - </deviceProperties> - <deviceProperties name="LoggingTargetsDefault" description="Default logging targets at device startup.
Each item has the format: target_type::target_name.
To log to stdout, use 'console::cout'.
To log to syslog, use 'syslog::<address>',
 where <address> is a file path,
 for example 'syslog::/var/run/rsyslog/dev/log'.
To log to a file, use 'file::<path>',
 where <path> is a file path,
 for example 'file::/tmp/my_dev.log'."> - <type xsi:type="pogoDsl:StringVectorType"/> - <status abstract="false" inherited="true" concrete="true"/> - </deviceProperties> - <deviceProperties name="GroupDefinitions" description="Each string in the list is a JSON serialised dict defining the ``group_name``,
``devices`` and ``subgroups`` in the group. A TANGO Group object is created
for each item in the list, according to the hierarchy defined. This provides
easy access to the managed devices in bulk, or individually.

The general format of the list is as follows, with optional ``devices`` and
``subgroups`` keys:
 [ {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ...]},
 {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ``<dev name>``, ...],
 ``subgroups`` : [{<nested group>},
 {<nested group>}, ...]},
 ...
 ]

For example, a hierarchy of racks, servers and switches:
 [ {``group_name``: ``servers``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/server/3``, ``elt/server/4``]},
 {``group_name``: ``switches``,
 ``devices``: [``elt/switch/A``, ``elt/switch/B``]},
 {``group_name``: ``pdus``,
 ``devices``: [``elt/pdu/rackA``, ``elt/pdu/rackB``]},
 {``group_name``: ``racks``,
 ``subgroups``: [
 {``group_name``: ``rackA``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/switch/A``, ``elt/pdu/rackA``]},
 {``group_name``: ``rackB``,
 ``devices``: [``elt/server/3``, ``elt/server/4``,
 ``elt/switch/B``, ``elt/pdu/rackB``],
 ``subgroups``: []}
 ]} ]"> - <type xsi:type="pogoDsl:StringVectorType"/> - <status abstract="false" inherited="true" concrete="true"/> - </deviceProperties> - <commands name="GetVersionInfo" description="Array of version strings of all entities modelled by this device. 
(One level down only)
Each string in the array lists the version info for one entity
managed by this device. 
The first entry is version info for this TANGO Device itself.
The entities may be TANGO devices, or hardware LRUs or 
anything else this devices manages/models.
The intention with this command is that it can provide more 
detailed information than can be captured in the versionId 
and buildState attributes, if necessary.
In the minimal case the GetVersionInfo will contain only the 
versionId and buildState attributes of the next lower level
entities." execMethod="get_version_info" displayLevel="OPERATOR" polledPeriod="0"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description="[ name: EltTelState"> - <type xsi:type="pogoDsl:StringArrayType"/> - </argout> - <status abstract="false" inherited="true" concrete="true"/> - </commands> - <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> - <argin description="none"> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description="Device state"> - <type xsi:type="pogoDsl:StateType"/> - </argout> - <status abstract="true" inherited="true" concrete="true"/> - </commands> - <commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0"> - <argin description="none"> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description="Device status"> - <type xsi:type="pogoDsl:ConstStringType"/> - </argout> - <status abstract="true" inherited="true" concrete="true"/> - </commands> - <commands name="RunGroupCommand" description="Runs the specified command on the specified group and returns
the results." execMethod="run_group_command" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> - <argin description="JSON encoded dict with this format
{``group``: str, # name of existing group
 ``command``: str, # name of command to run
 ``arg_type``: str, # data type of command input argument
 ``arg_value``: str, # value for command input argument
 ``forward``: bool # True if command should be forwarded to all subgroups (default)
}"> - <type xsi:type="pogoDsl:StringType"/> - </argin> - <argout description="Return value from command on the group, as a JSON encoded string.
This will be a list of dicts of the form 
[ 
{``device_name``: str, # TANGO device name
 ``argout``: <value>, # return value from command (type depends on command)
 ``failed``: bool # True if command failed
},
{ ... },
 ... ]"> - <type xsi:type="pogoDsl:StringType"/> - </argout> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - </commands> - <commands name="Reset" description="Reset device to its default state" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="false" inherited="true" concrete="true"/> - </commands> - <commands name="On" description="Command to turn ON the device" execMethod="on" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - </commands> - <commands name="Stop" description="Command to stop the device" execMethod="stop" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argout> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - </commands> - <attributes name="obsState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> - <dataType xsi:type="pogoDsl:EnumType"/> - <dataReadyEvent fire="false" libCheckCriteria="true"/> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <properties description="Observing State" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - <enumLabels>IDLE</enumLabels> - <enumLabels>CONFIGURING</enumLabels> - <enumLabels>READY</enumLabels> - <enumLabels>SCANNING</enumLabels> - <enumLabels>PAUSED</enumLabels> - <enumLabels>ABORTED</enumLabels> - <enumLabels>FAULT</enumLabels> - </attributes> - <attributes name="obsMode" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> - <dataType xsi:type="pogoDsl:EnumType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> - <dataReadyEvent fire="false" libCheckCriteria="true"/> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <properties description="Observing Mode" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - <enumLabels>IDLE</enumLabels> - <enumLabels>IMAGING</enumLabels> - <enumLabels>PULSAR-SEARCH</enumLabels> - <enumLabels>PULSAR-TIMING</enumLabels> - <enumLabels>DYNAMIC-SPECTRUM</enumLabels> - <enumLabels>TRANSIENT-SEARCH</enumLabels> - <enumLabels>VLBI</enumLabels> - <enumLabels>CALIBRATION</enumLabels> - </attributes> - <attributes name="configurationProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> - <dataType xsi:type="pogoDsl:UShortType"/> - <dataReadyEvent fire="false" libCheckCriteria="true"/> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <properties description="Percentage configuration progress" label="" unit="%" standardUnit="" displayUnit="" format="" maxValue="100" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="configurationDelayExpected" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> - <dataType xsi:type="pogoDsl:UShortType"/> - <dataReadyEvent fire="false" libCheckCriteria="true"/> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <properties description="Configuration delay expected in seconds" label="" unit="seconds" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="buildState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="60000" maxX="" maxY="" allocReadMember="true"> - <dataType xsi:type="pogoDsl:StringType"/> - <status abstract="false" inherited="true" concrete="true"/> - <properties description="Build state of this device" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="versionId" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="60000" maxX="" maxY="" allocReadMember="true"> - <dataType xsi:type="pogoDsl:StringType"/> - <status abstract="false" inherited="true" concrete="true"/> - <properties description="Build state of this device" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="loggingLevel" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true"> - <dataType xsi:type="pogoDsl:EnumType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> - <status abstract="false" inherited="true" concrete="true"/> - <properties description="Current logging level for this device - initialises to LoggingLevelDefault on startup" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="healthState" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true"> - <dataType xsi:type="pogoDsl:EnumType"/> - <status abstract="false" inherited="true" concrete="true"/> - <properties description="The health state reported for this device. It interprets the current device condition 
and condition of all managed devices to set this. Most possibly an aggregate attribute." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="adminMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" allocReadMember="true"> - <dataType xsi:type="pogoDsl:EnumType"/> - <status abstract="false" inherited="true" concrete="true"/> - <properties description="The admin mode reported for this device. It may interpret the current device condition 
and condition of all managed devices to set this. Most possibly an aggregate attribute." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="controlMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" allocReadMember="true"> - <dataType xsi:type="pogoDsl:EnumType"/> - <status abstract="false" inherited="true" concrete="true"/> - <properties description="The control mode of the device. REMOTE, LOCAL
TANGO Device accepts only from a ‘local’ client and ignores commands and queries received from TM
or any other ‘remote’ clients. The Local clients has to release LOCAL control before REMOTE clients
can take control again." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="simulationMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" allocReadMember="true"> - <dataType xsi:type="pogoDsl:EnumType"/> - <status abstract="false" inherited="true" concrete="true"/> - <properties description="Reports the simulation mode of the device. Some devices may implement both modes,
while others will have simulators that set simulationMode to True while the real
devices always set simulationMode to False." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="testMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" allocReadMember="true"> - <dataType xsi:type="pogoDsl:EnumType"/> - <status abstract="false" inherited="true" concrete="true"/> - <properties description="The test mode of the device. 
Either no test mode (empty string) or an indication of the test mode." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <attributes name="loggingTargets" attType="Spectrum" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="3" maxY="" allocReadMember="true" isDynamic="false"> - <dataType xsi:type="pogoDsl:StringType"/> - <changeEvent fire="false" libCheckCriteria="false"/> - <archiveEvent fire="false" libCheckCriteria="false"/> - <dataReadyEvent fire="false" libCheckCriteria="true"/> - <status abstract="false" inherited="true" concrete="true"/> - <properties description="Logging targets for this device, excluding ska_logging defaults - 
initialises to LoggingTargetsDefault on startup" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> - <states name="ON" description="This state could have been called OK or OPERATIONAL. It means that the device is in its operational state. (E.g. the power supply is giving its nominal current, th motor is ON and ready to move, the instrument is operating). This state is modified by the Attribute alarm checking of the DeviceImpl:dev_state method. i.e. if the State is ON and one attribute has its quality factor to ATTR_WARNING or ATTR_ALARM, then the State is modified to ALARM."> - <status abstract="false" inherited="true" concrete="true"/> - </states> - <states name="OFF" description="The device is in normal condition but is not active. E.g. the power supply main circuit breaker is open; the RF transmitter has no power etc..."> - <status abstract="false" inherited="true" concrete="true"/> - </states> - <states name="FAULT" description="The device has a major failure that prevents it to work. For instance, A power supply has stopped due to over temperature A motor cannot move because it has fault conditions. Usually we cannot get out from this state without an intervention on the hardware or a reset command."> - <status abstract="false" inherited="true" concrete="true"/> - </states> - <states name="INIT" description="This state is reserved to the starting phase of the device server. It means that the software is not fully operational and that the user must wait"> - <status abstract="false" inherited="true" concrete="true"/> - </states> - <states name="ALARM" description="ALARM - The device is operating but
at least one of the attributes is out of range. It can be linked to alarm conditions set by attribute properties or a specific case. (E.g. temperature alarm on a stepper motor, end switch pressed on a stepper motor, up water level in a tank, etc....). In alarm, usually the device does its job, but the operator has to perform an action to avoid a bigger problem that may switch the state to FAULT."> - <status abstract="false" inherited="true" concrete="true"/> - </states> - <states name="UNKNOWN" description="The device cannot retrieve its state. It is the case when there is a communication problem to the hardware (network cut, broken cable etc...) It could also represent an incoherent situation"> - <status abstract="false" inherited="true" concrete="true"/> - </states> - <states name="STANDBY" description="Equates to LOW-POWER mode. This is the initial transition from INIT if the device supports a low-power mode. The device is not fully active but is ready to operate."> - <status abstract="false" inherited="true" concrete="true"/> - </states> - <states name="DISABLE" description="The device cannot be switched ON for an external reason. E.g. the power supply has its door open, the safety conditions are not satisfactory to allow the device to operate."> - <status abstract="false" inherited="true" concrete="true"/> - </states> - <preferences docHome="./doc_html" makefileHome="$(TANGO_HOME)"/> - <overlodedPollPeriodObject name="healthState" type="attribute" pollPeriod="0"/> - <overlodedPollPeriodObject name="adminMode" type="attribute" pollPeriod="0"/> - <overlodedPollPeriodObject name="controlMode" type="attribute" pollPeriod="0"/> - <overlodedPollPeriodObject name="simulationMode" type="attribute" pollPeriod="0"/> - <overlodedPollPeriodObject name="testMode" type="attribute" pollPeriod="0"/> - </classes> -</pogoDsl:PogoSystem> diff --git a/scripts/purge_xmi_tree.py b/scripts/purge_xmi_tree.py index 1ae88e5ef3d2a02743d2ffde0cceb5d79fbb603a..698f2b9cdf1212dce359bd0774c6acd7fe98b1c0 100755 --- a/scripts/purge_xmi_tree.py +++ b/scripts/purge_xmi_tree.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 """ Utility to purge orphaned elements from the XMI file tree. diff --git a/setup.cfg b/setup.cfg index a1866d77ee688730f57a302bc91ed0017ba99c77..b7420bf3b0879bdec0f0c66bff6966316bc211fd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,10 +3,18 @@ test=pytest [coverage:run] branch = True -source = skabase +source = ska.base [tool:pytest] -testpaths = skabase -addopts = --forked --verbose --json-report --json-report-file=htmlcov/report.json --cov-report term --cov-report html --cov-report xml --cov=skabase --junitxml=/build/reports/unit-tests.xml +testpaths = tests +addopts = --forked + --verbose + --json-report + --json-report-file=htmlcov/report.json + --cov-report term + --cov-report html + --cov-report xml + --cov=ska.base + --junitxml=/build/reports/unit-tests.xml console_output_style = progress junit_family = legacy diff --git a/setup.py b/setup.py index 2e6b65e08c281fc776c6981600af4391e0d3d814..4fa43b546c40887008c42c0325eefe3fe6633c8d 100644 --- a/setup.py +++ b/setup.py @@ -6,42 +6,50 @@ import sys import setuptools setup_dir = os.path.dirname(os.path.abspath(__file__)) -release_filename = os.path.join(setup_dir, 'skabase', 'release.py') +release_filename = os.path.join(setup_dir, "src", "ska", "base", "release.py") exec(open(release_filename).read()) # prevent unnecessary installation of pytest-runner -needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv) -pytest_runner = ['pytest-runner'] if needs_pytest else [] +needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv) +pytest_runner = ["pytest-runner"] if needs_pytest else [] setuptools.setup( - name=name, - description=description, - version=version, - author=author, - author_email=author_email, - license=license, - packages=setuptools.find_packages(), - include_package_data=True, - url='https://www.skatelescope.org/', - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: Other/Proprietary License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Scientific/Engineering :: Astronomy"], - platforms=["OS Independent"], - setup_requires=[] + pytest_runner, - install_requires=[ - "future", - "ska_logging >= 0.2.0" - ], - tests_require=[ - "pytest", - "coverage", - "pytest-json-report", - "pytest-forked", - ], - keywords="lmc base classes ska", - zip_safe=False) + name=name, + description=description, + version=version, + author=author, + author_email=author_email, + license=license, + packages=setuptools.find_packages(where="src"), + package_dir={"": "src"}, + include_package_data=True, + url="https://www.skatelescope.org/", + classifiers=[ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: Other/Proprietary License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Scientific/Engineering :: Astronomy", + ], + platforms=["OS Independent"], + setup_requires=[] + pytest_runner, + install_requires=["future", "ska_logging >= 0.2.0"], + tests_require=["pytest", "coverage", "pytest-json-report", "pytest-forked"], + entry_points={ + "console_scripts": [ + "SKAAlarmHandler=ska.base.alarm_handler_device:main", + "SKABaseDevice=ska.base.base_device:main", + "SKACapability=ska.base.capability_device:main", + "SKAExampleDevice=ska.base.example_device:main", + "SKALogger=ska.base.logger_device:main", + "SKAMaster=ska.base.master_device:main", + "SKAObsDevice=ska.base.obs_device:main", + "SKASubarray=ska.base.subarray_device:main", + "SKATelState=ska.base.tel_state_device:main", + ] + }, + keywords="lmc base classes ska", + zip_safe=False, +) diff --git a/src/ska/base/__init__.py b/src/ska/base/__init__.py index 0876b3881709c20edeec9862d2b5fcf518eb7f5d..4478f8e6a34147e695a30f5fac561273522b976d 100644 --- a/src/ska/base/__init__.py +++ b/src/ska/base/__init__.py @@ -1,10 +1,25 @@ -__all__ = ["auxiliary", - "SKAAlarmHandler", - "SKABaseDevice", - "SKACapability", - "SKALogger", - "SKAMaster", - "SKAObsDevice", - "SKASubarray", - "SKATelState" - ] +__all__ = ( + "control_model", + "SKAAlarmHandler", + "SKABaseDevice", + "SKACapability", + "SKALogger", + "SKAMaster", + "SKAObsDevice", + "SKASubarray", + "SKATelState" +) + +# Note: order of imports is important - start with lowest in the hierarchy + +# SKABaseDevice, and then classes that inherit from it +from .base_device import SKABaseDevice +from .alarm_handler_device import SKAAlarmHandler +from .logger_device import SKALogger +from .master_device import SKAMaster +from .tel_state_device import SKATelState + +# SKAObsDevice, and then classes that inherit from it +from .obs_device import SKAObsDevice +from .capability_device import SKACapability +from .subarray_device import SKASubarray diff --git a/src/ska/base/alarm_handler_device.py b/src/ska/base/alarm_handler_device.py index 3b99c198eaba67b89054a55da5cc06e726a51a9e..2a05b700db001bf509c84c16306d78f5067d096a 100644 --- a/src/ska/base/alarm_handler_device.py +++ b/src/ska/base/alarm_handler_device.py @@ -20,11 +20,8 @@ from tango import DebugIt from tango.server import run, attribute, command, device_property # SKA specific imports -from skabase import release -file_path = os.path.dirname(os.path.abspath(__file__)) -basedevice_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/SKABaseDevice" -sys.path.insert(0, basedevice_path) -from SKABaseDevice import SKABaseDevice +from . import SKABaseDevice, release + # PROTECTED REGION END # // SKAAlarmHandler.additionnal_import __all__ = ["SKAAlarmHandler", "main"] diff --git a/src/ska/base/base_device.py b/src/ska/base/base_device.py index 0bd64dc4c22115a3d01990a4482926005394afac..5b559197aadc09a14e64d266003a2365748ba0fe 100644 --- a/src/ska/base/base_device.py +++ b/src/ska/base/base_device.py @@ -27,21 +27,18 @@ from tango import DeviceProxy, DevFailed # SKA specific imports import ska_logging -from skabase import release -from skabase.control_model import ( +from . import release +from .control_model import ( AdminMode, ControlMode, HealthState, LoggingLevel, SimulationMode, TestMode ) -file_path = os.path.dirname(os.path.abspath(__file__)) -auxiliary_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/auxiliary" -sys.path.insert(0, auxiliary_path) - -from utils import (get_dp_command, - coerce_value, - get_groups_from_json, - get_tango_device_type_id) -from faults import (GroupDefinitionsError, - LoggingTargetError, - LoggingLevelError) + +from .utils import (get_dp_command, + coerce_value, + get_groups_from_json, + get_tango_device_type_id) +from .faults import (GroupDefinitionsError, + LoggingTargetError, + LoggingLevelError) LOG_FILE_SIZE = 1024 * 1024 # Log file size 1MB. @@ -177,7 +174,7 @@ __all__ = ["SKABaseDevice", "TangoLoggingLevel", "main"] class SKABaseDevice(Device): """ - A generic base device for SKA. + A generic base device for SKA. Update!! """ # PROTECTED REGION ID(SKABaseDevice.class_variable) ENABLED START # @@ -240,35 +237,6 @@ class SKABaseDevice(Device): self.error_stream = self.logger.error self.fatal_stream = self.logger.critical - def _parse_argin(self, argin, defaults=None, required=None): - """ - Parses the argument passed to it and returns them in a dictionary form. - - :param argin: The argument to parse - - :param defaults: - - :param required: - - :return: Dictionary containing passed arguments. - """ - args_dict = defaults.copy() if defaults else {} - try: - if argin: - args_dict.update(json.loads(argin)) - except ValueError as ex: - self.logger.fatal(str(ex), exc_info=True) - raise - - missing_args = [] - if required: - missing_args = set(required) - set(args_dict.keys()) - if missing_args: - msg = ("Missing arguments: {}" - .format(', '.join([str(m_arg) for m_arg in missing_args]))) - raise Exception(msg) - return args_dict - # PROTECTED REGION END # // SKABaseDevice.class_variable # ----------------- diff --git a/src/ska/base/capability_device.py b/src/ska/base/capability_device.py index aa03bdf4e7b77fdf333d86775c452d32ef251016..930905aaa781bf1ebd0b9a73fa67d8198a04e2fe 100644 --- a/src/ska/base/capability_device.py +++ b/src/ska/base/capability_device.py @@ -18,12 +18,7 @@ from tango import DebugIt from tango.server import run, attribute, command, device_property # SKA specific imports -from skabase import release - -file_path = os.path.dirname(os.path.abspath(__file__)) -obs_device_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/SKAObsDevice" -sys.path.insert(0, obs_device_path) -from SKAObsDevice import SKAObsDevice +from . import SKAObsDevice, release # PROTECTED REGION END # // SKACapability.additionnal_imports __all__ = ["SKACapability", "main"] diff --git a/src/ska/base/logger_device.py b/src/ska/base/logger_device.py index e91ba77df5d0c0fb7950ea2c9cc1f306aaea8bfc..9fc537c3d4de7d319579133592822b90318e8407 100644 --- a/src/ska/base/logger_device.py +++ b/src/ska/base/logger_device.py @@ -19,12 +19,8 @@ from tango import DebugIt, DeviceProxy, DevFailed from tango.server import run, command # SKA specific imports -from skabase import release -from skabase.control_model import LoggingLevel -file_path = os.path.dirname(os.path.abspath(__file__)) -basedevice_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/SKABaseDevice" -sys.path.insert(0, basedevice_path) -from SKABaseDevice import SKABaseDevice +from . import SKABaseDevice, release +from .control_model import LoggingLevel # PROTECTED REGION END # // SKALogger.additionnal_import __all__ = ["SKALogger", "main"] diff --git a/src/ska/base/master_device.py b/src/ska/base/master_device.py index 79f4a02d5006c7ed8e7623c21fca180acf710619..1b227c8a8026cd4cc7651c34944060cffeacd324 100644 --- a/src/ska/base/master_device.py +++ b/src/ska/base/master_device.py @@ -19,16 +19,8 @@ from tango import DebugIt from tango.server import run, attribute, command, device_property # SKA specific imports -from skabase import release - -file_path = os.path.dirname(os.path.abspath(__file__)) -basedevice_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/SKABaseDevice" -sys.path.insert(0, basedevice_path) -from SKABaseDevice import SKABaseDevice - -auxiliary_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/auxiliary" -sys.path.insert(0, auxiliary_path) -from utils import (validate_capability_types, validate_input_sizes, convert_dict_to_list) +from . import SKABaseDevice, release +from .utils import validate_capability_types, validate_input_sizes, convert_dict_to_list # PROTECTED REGION END # // SKAMaster.additionnal_imports diff --git a/src/ska/base/obs_device.py b/src/ska/base/obs_device.py index 46a21832d9a49d3df30f47c821e46e4646a87132..18f63d8997737156af3993a3696d22b6c2b7a57a 100644 --- a/src/ska/base/obs_device.py +++ b/src/ska/base/obs_device.py @@ -20,13 +20,8 @@ import sys from tango.server import run, attribute # SKA specific imports -from skabase import release -from skabase.control_model import ObsMode, ObsState - -file_path = os.path.dirname(os.path.abspath(__file__)) -basedevice_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/SKABaseDevice" -sys.path.insert(0, basedevice_path) -from SKABaseDevice import SKABaseDevice +from . import SKABaseDevice, release +from .control_model import ObsMode, ObsState # PROTECTED REGION END # // SKAObsDevice.additionnal_imports __all__ = ["SKAObsDevice", "main"] diff --git a/src/ska/base/release.py b/src/ska/base/release.py index b71601ed073f0298332158413a2f7a4563454e6d..6aa5bbccfe58a913ee3aeaaf176a6348f2bbe81f 100644 --- a/src/ska/base/release.py +++ b/src/ska/base/release.py @@ -7,7 +7,7 @@ """Release information for lmc-base-classes Python Package""" name = """lmcbaseclasses""" -version = "0.4.1" +version = "0.5.0" version_info = version.split(".") description = """A set of generic base devices for SKA Telescope.""" author = "SKA India and SARAO" diff --git a/src/ska/base/subarray_device.py b/src/ska/base/subarray_device.py index 3daca3472109a5a08757c1ede2bdfd295baf5e82..1b785c5833126318b97ac125fa986a6dc0ca0ac5 100644 --- a/src/ska/base/subarray_device.py +++ b/src/ska/base/subarray_device.py @@ -21,13 +21,8 @@ from tango.server import device_property from tango import Except, ErrSeverity, DevState # SKA specific imports -from skabase import release -from skabase.control_model import AdminMode, ObsState - -file_path = os.path.dirname(os.path.abspath(__file__)) -obs_device_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/SKAObsDevice" -sys.path.insert(0, obs_device_path) -from SKAObsDevice import SKAObsDevice +from . import SKAObsDevice, release +from .control_model import AdminMode, ObsState # PROTECTED REGION END # // SKASubarray.additionnal_imports __all__ = ["SKASubarray", "main"] diff --git a/src/ska/base/tel_state_device.py b/src/ska/base/tel_state_device.py index 1a2dd778b533f1516340bfe844a5dd94b563fc09..d9b3b0fd2cb2a60407d95b6d1870c08a23905771 100644 --- a/src/ska/base/tel_state_device.py +++ b/src/ska/base/tel_state_device.py @@ -17,12 +17,7 @@ import sys from tango.server import run, device_property # SKA specific imports -from skabase import release - -file_path = os.path.dirname(os.path.abspath(__file__)) -basedevice_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/SKABaseDevice" -sys.path.insert(0, basedevice_path) -from SKABaseDevice import SKABaseDevice +from . import SKABaseDevice, release # PROTECTED REGION END # // SKATelState.additionnal_imports __all__ = ["SKATelState", "main"] diff --git a/src/ska/base/utils.py b/src/ska/base/utils.py index 90e970e6ceb6b8a8c6c5b87e15502500a73a9090..7a5b93d1e002a8c92976ac4c343aceffc1ee8727 100644 --- a/src/ska/base/utils.py +++ b/src/ska/base/utils.py @@ -12,10 +12,9 @@ from datetime import datetime import tango from tango import (DeviceProxy, DbDatum, DbDevInfo, AttrQuality, AttrWriteType, Except, ErrSeverity) -from tango import DevState +from tango import DevState from contextlib import contextmanager -from faults import GroupDefinitionsError -from faults import SKABaseError +from .faults import GroupDefinitionsError, SKABaseError int_types = {tango._tango.CmdArgType.DevUShort, tango._tango.CmdArgType.DevLong, diff --git a/test-harness/Makefile b/test-harness/Makefile index 156398d266969611162d5a81be9b30dc594db490..dc149f5dcefcd509330e23b0cd17a3f430d6f586 100644 --- a/test-harness/Makefile +++ b/test-harness/Makefile @@ -36,7 +36,7 @@ test: lint: python3 -m pip install pylint2junit; \ mkdir -p /build/reports; \ - cd /app && pylint --output-format=parseable skabase | tee /build/code_analysis.stdout; \ - cd /app && pylint --output-format=pylint2junit.JunitReporter skabase > /build/reports/linting.xml; + cd /app && pylint --output-format=parseable ska.base | tee /build/code_analysis.stdout; \ + cd /app && pylint --output-format=pylint2junit.JunitReporter ska.base > /build/reports/linting.xml; .PHONY: all test lint diff --git a/tests/conftest.py b/tests/conftest.py index 77803c18849ddfc5fdeb468d65b9a1a4bdff8e5a..ce97603d5261dec15e1c2444afc6b1661b88c958 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,14 +1,9 @@ """ -A module defining a list of fixture functions that are shared across all the skabase -tests. +A module defining a list of fixtures that are shared across all ska.base tests. """ -import os -import time import importlib import pytest -from unittest import mock - from tango.test_context import DeviceTestContext @@ -40,20 +35,22 @@ def tango_context(request): }, } - fq_test_class_name = request.cls.__module__ - fq_test_class_name_details = fq_test_class_name.split(".") - # For future use - # package_name = fq_test_class_name_details[0] - # class_name = module_name = fq_test_class_name_details[1] - class_name = fq_test_class_name_details[1] - module = importlib.import_module(fq_test_class_name_details[1], fq_test_class_name_details[1]) - klass = getattr(module, class_name) - - tango_context = DeviceTestContext(klass, properties=test_properties.get(class_name)) + # This fixture is used to decorate classes like "TestSKABaseDevice" or + # "TestSKALogger". We drop the first "Test" from the string to get the + # class name of the device under test. + # Similarly, the test module is like "test_base_device.py". We drop the + # first "test_" to get the module name + test_class_name = request.cls.__name__ + class_name = test_class_name.split('Test', 1)[-1] + module = importlib.import_module("ska.base", class_name) + class_type = getattr(module, class_name) + + tango_context = DeviceTestContext(class_type, properties=test_properties.get(class_name)) tango_context.start() yield tango_context tango_context.stop() + @pytest.fixture(scope="function") def initialize_device(tango_context): """Re-initializes the device. @@ -64,23 +61,3 @@ def initialize_device(tango_context): Context to run a device without a database. """ yield tango_context.device.Init() - -@pytest.fixture(scope="class") -def setup_log_test_device(): - """ - Executes the SKA test device to test the logger class. - :return: None - """ - #TODO: Check if test device is registered in tango db. Register if required. Also check how to execute in docker environment. - # run test device - file_path = os.path.dirname(os.path.abspath(__file__)) - testdevice_path = os.path.abspath(os.path.join(file_path, os.curdir)) + "/SKAExampleDevice/SKAExampleDevice.py" - cmdline = 'python3 ' + testdevice_path + ' ' + '01 &' - os.system(cmdline) - time.sleep(3) - yield setup_log_test_device - - #tear down - cmdline = 'pkill -9 -f .' + testdevice_path + ' &' - os.system(cmdline) - diff --git a/tests/test_alarm_handler_device.py b/tests/test_alarm_handler_device.py index 535f61068113fb17eb3c9d494f5403a438607e89..e82e28c94bea73a4ec669696848032107d9af129 100644 --- a/tests/test_alarm_handler_device.py +++ b/tests/test_alarm_handler_device.py @@ -16,10 +16,6 @@ import os import re import pytest -# Path -path = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.insert(0, os.path.abspath(path)) - # PROTECTED REGION ID(SKAAlarmHandler.test_additional_imports) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_additional_imports # Device test case diff --git a/tests/test_base_device.py b/tests/test_base_device.py index 41f600a83caa705c469cac0893057f6b0ca6e6fa..2788d9a456db664302b2443cedf7f6d2d0123812 100644 --- a/tests/test_base_device.py +++ b/tests/test_base_device.py @@ -14,21 +14,14 @@ import os import re import pytest -# Imports -from skabase.SKABaseDevice import SKABaseDevice - -# Path -path = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.insert(0, os.path.abspath(path)) - # PROTECTED REGION ID(SKABaseDevice.test_additional_imports) ENABLED START # import logging from unittest import mock from tango import DevFailed, DevState -from skabase.control_model import ( +from ska.base.control_model import ( AdminMode, ControlMode, HealthState, LoggingLevel, SimulationMode, TestMode ) -from skabase.SKABaseDevice.SKABaseDevice import ( +from ska.base.base_device import ( LoggingUtils, LoggingTargetError, ) @@ -289,7 +282,7 @@ class TestSKABaseDevice(object): # PROTECTED REGION ID(SKABaseDevice.test_loggingTargets) ENABLED START # assert tango_context.device.loggingTargets == tuple() - with mock.patch("SKABaseDevice.LoggingUtils.create_logging_handler") as mocked_creator: + with mock.patch("ska.base.base_device.LoggingUtils.create_logging_handler") as mocked_creator: def null_creator(target): handler = logging.NullHandler() @@ -360,26 +353,3 @@ class TestSKABaseDevice(object): # PROTECTED REGION ID(SKABaseDevice.test_testMode) ENABLED START # assert tango_context.device.testMode == TestMode.NONE # PROTECTED REGION END # // SKABaseDevice.test_testMode - - # TODO: Fix this test case when "Error in get_name() of tango.DeviceImpl while using pytest" is resolved. - # def test_get_device_commands(self, tango_context): - # Test the get_device_commands method - # commands = SKABaseDevice.get_device_commands(SKABaseDevice) - #assert commands == [{'parameters': [], 'name': 'GetVersionInfo', 'component_type': 'nodb', 'component_id': 'skabasedevice'}, {'parameters': [], 'name': 'Init', 'component_type': 'nodb', 'component_id': 'skabasedevice'}, {'parameters': [], 'name': 'Reset', 'component_type': 'nodb', 'component_id': 'skabasedevice'}, {'parameters': [], 'name': 'State', 'component_type': 'nodb', 'component_id': 'skabasedevice'}, {'parameters': [], 'name': 'Status', 'component_type': 'nodb', 'component_id': 'skabasedevice'}] - - # TODO: Fix this test case when "Error in get_name() of tango.DeviceImpl while using pytest" is resolved. - # def test_get_device_attributes(self, tango_context): - # # Test the get_device_attributes method - # attributes = SKABaseDevice.get_device_attributes(SKABaseDevice) - # assert attributes == 1 - - def test__parse_argin(self, tango_context): - result = SKABaseDevice._parse_argin(SKABaseDevice, '{"class": "SKABaseDevice"}') - assert result == {'class': 'SKABaseDevice'} - - def test__parse_argin_with_required(self, tango_context): - SKABaseDevice._parse_argin( - SKABaseDevice, '{"class":"SKABaseDevice"}', required=['class']) - with pytest.raises(Exception): - SKABaseDevice._parse_argin( - SKABaseDevice, '{"class":"SKABaseDevice"}', required=['missing']) diff --git a/tests/test_capability_device.py b/tests/test_capability_device.py index 1dd2f62cd81997c12d3fc61c48f0b7ca72a0c8b0..1f75b9beab08dfe04be1ddabe2b8581cd2adac78 100644 --- a/tests/test_capability_device.py +++ b/tests/test_capability_device.py @@ -16,10 +16,6 @@ import os import re import pytest -# Path -path = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.insert(0, os.path.abspath(path)) - # PROTECTED REGION ID(SKACapability.test_additional_imports) ENABLED START # # PROTECTED REGION END # // SKACapability.test_additional_imports # Device test case diff --git a/tests/test_group.py b/tests/test_group.py deleted file mode 100644 index d5510028298ee1abc42a2ce9522da2aa18deba6a..0000000000000000000000000000000000000000 --- a/tests/test_group.py +++ /dev/null @@ -1,82 +0,0 @@ -# import tango -# from tango import DeviceProxy, AttrQuality, AttributeProxy -# from .base import DeviceServerBaseTest -# import json -# from time import sleep - -# class TestGroup(DeviceServerBaseTest): - # REQUIRED_DEVICE_SERVERS = ['Subarray_DS', 'Capability_DS'] - # - # @classmethod - # def add_devices(cls): - # cls.add_device('Subarray_DS', 'sub/1') - # cls.add_device('Capability_DS', 'cap/sub1cap1') - # cls.add_device('Capability_DS', 'cap/sub1cap2') - # cls.add_device('Device_DS', 'dev/sub1cap1dev1') - # cls.add_device('Device_DS', 'dev/sub1cap1dev2') - # cls.add_device('Device_DS', 'dev/sub1cap2dev1') - # - # @classmethod - # def remove_devices(cls): - # cls.remove_device('sub/1') - # cls.remove_device('cap/sub1cap1') - # cls.remove_device('cap/sub1cap2') - # cls.remove_device('dev/sub1cap1dev1') - # cls.remove_device('dev/sub1cap1dev2') - # cls.remove_device('dev/sub1cap2dev1') - - # def test_add_member(self): - # device_name = '%s/sub/1' % self.DOMAIN_NAME - # group_name = 'capabilities' - # # self.stop_device_server('Subarray_DS') - # # self.start_device_server('Subarray_DS') - # dp = DeviceProxy(device_name) - # dp.set_logging_level(5) - # member_device_name_1 = '%s/capability/sub1cap1' % self.DOMAIN_NAME - # data_1 = json.dumps({'group_name': group_name, 'device_name': member_device_name_1 }) - # dp.command_inout('add_member', data_1) - # self.assertTrue(member_device_name_1 in dp.get_property(group_name)[group_name]) - # - # member_device_name_2 = '%s/capability/sub1cap2' % self.DOMAIN_NAME - # data_2 = json.dumps({'group_name': group_name, 'device_name': member_device_name_2 }) - # dp.command_inout('add_member', data_2) - # - # items = dp.get_property(group_name)[group_name] - # self.assertTrue(member_device_name_2 in items) - # self.assertEqual(len(items), 2) - # dp.command_inout('remove_member', data_2) - # - # items = dp.get_property(group_name)[group_name] - # self.assertFalse(member_device_name_2 in items) - # self.assertEqual(len(items), 1) - # - # dp.command_inout('remove_member', data_1) - # self.assertFalse(member_device_name_1 in dp.get_property(group_name)[group_name]) - # - # def add_members(self, device_name, group_name, members=None): - # dp = DeviceProxy(device_name) - # for member in members: - # data = json.dumps({'group_name': group_name, 'device_name': member }) - # dp.command_inout('add_member', data) - # - # def test_alarm_propagation(self): - # device_name = '%s/sub1/1' % self.DOMAIN_NAME - # members_template = ['%s/capability/sub1cap1', '%s/capability/sub1cap2'] - # members = [member % self.DOMAIN_NAME for member in members_template] - # - # self.add_members(device_name, 'tiles', members) - # dp = DeviceProxy(device_name) - # self.assertNotEqual(dp.state(), AttrQuality.ATTR_ALARM) - # member_dp = DeviceProxy(members[0]) - # alarm_data = json.dumps({'name': 'an_attr', 'min_alarm': '20', 'max_alarm': '50'}) - # member_dp.command_inout('set_attribute_alarm', alarm_data) - # member_dp.an_attr = 10 - # attr = AttributeProxy(members[0] + '/an_attr') - # self.assertEqual(attr.read().quality, AttrQuality.ATTR_ALARM) - # self.assertEqual(member_dp.state(), tango._tango.DevState.ALARM) - # i = 0 - # while (dp.state() != tango._tango.DevState.ALARM) and i < 3: - # sleep(1) - # i+=1 - # - # self.assertEqual(dp.state(), tango._tango.DevState.ALARM) diff --git a/tests/test_logger_device.py b/tests/test_logger_device.py index 1e44f5224b02eefd31f2877038b2fd415215e662..cf794703480598836fed7a1a5708fdd3607fd8c6 100644 --- a/tests/test_logger_device.py +++ b/tests/test_logger_device.py @@ -19,12 +19,8 @@ from tango import DevState, DeviceProxy import tango -# Path -path = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.insert(0, os.path.abspath(path)) - # PROTECTED REGION ID(SKALogger.test_additional_imports) ENABLED START # -from skabase.control_model import ( +from ska.base.control_model import ( AdminMode, ControlMode, HealthState, LoggingLevel, SimulationMode, TestMode ) # PROTECTED REGION END # // SKALogger.test_additional_imports @@ -72,7 +68,7 @@ class TestSKALogger(object): @pytest.mark.parametrize("logging_level", [int(tango.LogLevel.LOG_ERROR)]) @pytest.mark.parametrize("logging_target", ["logger/test/1"]) # PROTECTED REGION END # // SKALogger.test_SetLoggingLevel_decorators - def test_SetLoggingLevel(self, tango_context, setup_log_test_device, + def test_SetLoggingLevel(self, tango_context, logging_level, logging_target): """Test for SetLoggingLevel""" # PROTECTED REGION ID(SKALogger.test_SetLoggingLevel) ENABLED START # diff --git a/tests/test_master_device.py b/tests/test_master_device.py index f55c628ad59002be09fdc5d51805b3068d79590c..a3c4584f291539d661e8fac7ad40a86878588ace 100644 --- a/tests/test_master_device.py +++ b/tests/test_master_device.py @@ -17,12 +17,8 @@ import re import pytest from tango import DevState -# Path -path = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.insert(0, os.path.abspath(path)) - # PROTECTED REGION ID(SKAMaster.test_additional_imports) ENABLED START # -from skabase.control_model import AdminMode, ControlMode, HealthState, SimulationMode, TestMode +from ska.base.control_model import AdminMode, ControlMode, HealthState, SimulationMode, TestMode # PROTECTED REGION END # // SKAMaster.test_additional_imports # Device test case # PROTECTED REGION ID(SKAMaster.test_SKAMaster_decorators) ENABLED START # diff --git a/tests/test_obs_device.py b/tests/test_obs_device.py index bb90cf4eb02f5182dcb5435a691a931358197ff1..2b36c09e45bd9fb6ad0f52c900703cea5e5c0f36 100644 --- a/tests/test_obs_device.py +++ b/tests/test_obs_device.py @@ -17,12 +17,8 @@ import re import pytest from tango import DevState -# Path -path = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.insert(0, os.path.abspath(path)) - # PROTECTED REGION ID(SKAObsDevice.test_additional_imports) ENABLED START # -from skabase.control_model import ( +from ska.base.control_model import ( AdminMode, ControlMode, HealthState, ObsMode, ObsState, SimulationMode, TestMode ) # PROTECTED REGION END # // SKAObsDevice.test_additional_imports diff --git a/tests/test_subarray_device.py b/tests/test_subarray_device.py index dc8d0c7372ed7dbdef199da8ea93f17bdaeab4e1..9376dabd29ee1e5af86917ef69cf41e16eacd05b 100644 --- a/tests/test_subarray_device.py +++ b/tests/test_subarray_device.py @@ -17,12 +17,8 @@ import re import pytest from tango import DevState, DevSource -# Path -path = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.insert(0, os.path.abspath(path)) - # PROTECTED REGION ID(SKASubarray.test_additional_imports) ENABLED START # -from skabase.control_model import ( +from ska.base.control_model import ( AdminMode, ControlMode, HealthState, ObsMode, ObsState, SimulationMode, TestMode ) # PROTECTED REGION END # // SKASubarray.test_additional_imports diff --git a/tests/test_tel_state_device.py b/tests/test_tel_state_device.py index dfdf95bad7c526f4a28bf12af34e5fadac4dcf53..5b696b0b0664aa55f99ec18478f5010870dfefd1 100644 --- a/tests/test_tel_state_device.py +++ b/tests/test_tel_state_device.py @@ -17,12 +17,8 @@ import re import pytest from tango import DevState -# Path -path = os.path.join(os.path.dirname(__file__), os.pardir) -sys.path.insert(0, os.path.abspath(path)) - # PROTECTED REGION ID(SKATelState.test_additional_imports) ENABLED START # -from skabase.control_model import AdminMode, ControlMode, HealthState, SimulationMode, TestMode +from ska.base.control_model import AdminMode, ControlMode, HealthState, SimulationMode, TestMode # PROTECTED REGION END # // SKATelState.test_additional_imports # Device test case # PROTECTED REGION ID(SKATelState.test_SKATelState_decorators) ENABLED START # diff --git a/tests/test_utils.py b/tests/test_utils.py index 5eb304e6ab1cab043e05b0dcb858b0b91e4719ae..c12e38fa537d54b8124b3fa0d74b6971e2b4cc71 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -2,7 +2,7 @@ import json import pytest -from skabase.auxiliary.utils import ( +from ska.base.utils import ( get_groups_from_json, get_tango_device_type_id, GroupDefinitionsError,