From 3f701fbb2e0df0b545989548a635e5aa238aa827 Mon Sep 17 00:00:00 2001 From: Johan Venter <aventer@ska.ac.za> Date: Tue, 16 Feb 2021 08:08:29 +0000 Subject: [PATCH] SAR-190 Change more lmc-base-classes references to ska_lmcbase Also: - fix draw state machine imports - fix sphinx doc generation - add label metadata to Docker image - include repo renaming --- .make/Makefile.mk | 4 +- .release | 4 +- Dockerfile | 12 ++ Makefile | 16 +-- README.md | 34 +++--- docs/Makefile | 8 +- docs/source/Commands.rst | 2 +- docs/source/Control_Model.rst | 4 +- docs/source/CspSubElementMaster.rst | 6 +- docs/source/CspSubElementObsDevice.rst | 16 +-- docs/source/CspSubElementSubarray.rst | 8 +- docs/source/SKAAlarmHandler.rst | 6 +- docs/source/SKABaseDevice.rst | 8 +- docs/source/SKACapability.rst | 6 +- docs/source/SKALogger.rst | 6 +- docs/source/SKAMaster.rst | 6 +- docs/source/SKAObsDevice.rst | 6 +- docs/source/SKASubarray.rst | 6 +- docs/source/SKATelState.rst | 6 +- docs/source/State_Machine.rst | 16 +-- docs/source/conf.py | 46 ++++---- docs/source/draw_state_machines.py | 6 +- docs/source/index.rst | 6 +- pogo/CspSubElementMaster.xmi | 4 +- pogo/CspSubElementObsDevice.xmi | 4 +- pogo/CspSubElementSubarray.xmi | 4 +- pogo/SKAAlarmHandler.xmi | 2 +- pogo/SKABaseDevice.xmi | 2 +- pogo/SKACapability.xmi | 2 +- pogo/SKALogger.xmi | 2 +- pogo/SKAMaster.xmi | 2 +- pogo/SKAObsDevice.xmi | 2 +- pogo/SKASubarray.xmi | 2 +- pogo/SKATelState.xmi | 2 +- setup.cfg | 4 +- setup.py | 32 +++--- src/{ska/base => ska_tango_base}/__init__.py | 0 .../alarm_handler_device.py | 9 +- .../base => ska_tango_base}/base_device.py | 38 ++++--- .../capability_device.py | 6 +- src/{ska/base => ska_tango_base}/commands.py | 3 +- .../base => ska_tango_base}/control_model.py | 0 .../csp_subelement_master.py | 62 +++++----- .../csp_subelement_obsdevice.py | 57 +++++----- .../csp_subelement_state_machine.py | 0 .../csp_subelement_subarray.py | 44 ++++---- src/{ska/base => ska_tango_base}/faults.py | 0 .../base => ska_tango_base}/logger_device.py | 10 +- .../base => ska_tango_base}/master_device.py | 12 +- .../base => ska_tango_base}/obs_device.py | 20 ++-- src/{ska/base => ska_tango_base}/release.py | 8 +- .../base => ska_tango_base}/state_machine.py | 0 .../subarray_device.py | 12 +- .../tel_state_device.py | 2 +- src/{ska/base => ska_tango_base}/utils.py | 2 +- tests/conftest.py | 19 ++-- tests/test_alarm_handler_device.py | 4 +- tests/test_base_device.py | 106 +++++++++--------- tests/test_capability_device.py | 2 +- tests/test_csp_subelement_master.py | 18 +-- ...est_csp_subelement_obsdev_state_machine.py | 6 +- tests/test_csp_subelement_obsdevice.py | 25 +++-- tests/test_csp_subelement_subarray.py | 23 ++-- tests/test_logger_device.py | 10 +- tests/test_master_device.py | 8 +- tests/test_obs_device.py | 10 +- tests/test_state_machines.py | 4 +- tests/test_subarray_device.py | 12 +- tests/test_tel_state_device.py | 8 +- tests/test_utils.py | 18 +-- 70 files changed, 461 insertions(+), 399 deletions(-) rename src/{ska/base => ska_tango_base}/__init__.py (100%) rename src/{ska/base => ska_tango_base}/alarm_handler_device.py (99%) rename src/{ska/base => ska_tango_base}/base_device.py (98%) rename src/{ska/base => ska_tango_base}/capability_device.py (98%) rename src/{ska/base => ska_tango_base}/commands.py (99%) rename src/{ska/base => ska_tango_base}/control_model.py (100%) rename src/{ska/base => ska_tango_base}/csp_subelement_master.py (95%) rename src/{ska/base => ska_tango_base}/csp_subelement_obsdevice.py (97%) rename src/{ska/base => ska_tango_base}/csp_subelement_state_machine.py (100%) rename src/{ska/base => ska_tango_base}/csp_subelement_subarray.py (98%) rename src/{ska/base => ska_tango_base}/faults.py (100%) rename src/{ska/base => ska_tango_base}/logger_device.py (94%) rename src/{ska/base => ska_tango_base}/master_device.py (96%) rename src/{ska/base => ska_tango_base}/obs_device.py (95%) rename src/{ska/base => ska_tango_base}/release.py (68%) rename src/{ska/base => ska_tango_base}/state_machine.py (100%) rename src/{ska/base => ska_tango_base}/subarray_device.py (99%) rename src/{ska/base => ska_tango_base}/tel_state_device.py (97%) rename src/{ska/base => ska_tango_base}/utils.py (99%) diff --git a/.make/Makefile.mk b/.make/Makefile.mk index abb279b9..54d3ebda 100644 --- a/.make/Makefile.mk +++ b/.make/Makefile.mk @@ -26,7 +26,7 @@ ifeq ($(strip $(DOCKER_REGISTRY_HOST)),) endif ifeq ($(strip $(DOCKER_REGISTRY_USER)),) - DOCKER_REGISTRY_USER = tango-example + DOCKER_REGISTRY_USER = ska-telescope endif IMAGE=$(DOCKER_REGISTRY_HOST)/$(DOCKER_REGISTRY_USER)/$(NAME) @@ -53,7 +53,7 @@ pre-push: post-push: docker-build: .release - docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) $(DOCKER_BUILD_CONTEXT) -f $(DOCKER_FILE_PATH) --build-arg DOCKER_REGISTRY_HOST=$(DOCKER_REGISTRY_HOST) --build-arg DOCKER_REGISTRY_USER=$(DOCKER_REGISTRY_USER) + docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) $(DOCKER_BUILD_CONTEXT) -f $(DOCKER_FILE_PATH) --build-arg DOCKER_REGISTRY_HOST=$(DOCKER_REGISTRY_HOST) --build-arg DOCKER_REGISTRY_USER=$(DOCKER_REGISTRY_USER) --build-arg IMAGE_VERSION=$(VERSION) @DOCKER_MAJOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f1) ; \ DOCKER_MINOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f2) ; \ if [ $$DOCKER_MAJOR -eq 1 ] && [ $$DOCKER_MINOR -lt 10 ] ; then \ diff --git a/.release b/.release index add7c927..a6c96a3a 100644 --- a/.release +++ b/.release @@ -1,2 +1,2 @@ -release=0.8.1 -tag=lmcbaseclasses-0.8.1 +release=0.9.0 +tag=ska_tango_base-0.9.0 diff --git a/Dockerfile b/Dockerfile index a32879ad..0195ae70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,18 @@ FROM nexus.engageska-portugal.pt/ska-docker/ska-python-buildenv:9.3.3.1 AS buildenv FROM nexus.engageska-portugal.pt/ska-docker/ska-python-runtime:9.3.3.1 AS runtime +ARG IMAGE_VERSION=0.0.1 + +LABEL \ + author="SKA India and SARAO and CSIRO and INAF" \ + description="A set of generic base devices for SKA Telescope" \ + license="BSD-3-Clause" \ + registry="nexus.engageska-portugal.pt/ska-telescope/ska_tango_base" \ + vendor="SKA Telescope" \ + org.skatelescope.team="NCRA, Karoo, MCCS, CREAM" \ + org.skatelescope.version="${IMAGE_VERSION}" \ + org.skatelescope.website="https://gitlab.com/ska-telescope/ska-tango-base/" + # create ipython profile to so that itango doesn't fail if ipython hasn't run yet RUN ipython profile create diff --git a/Makefile b/Makefile index d7b5177d..b69e60e0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# Project makefile for a LMC Base Classes project. You should normally only need to modify +# Project makefile for a SKA Tango Base project. You should normally only need to modify # DOCKER_REGISTRY_USER and PROJECT below. # Use bash shell with pipefail option enabled so that the return status of a @@ -13,10 +13,10 @@ SHELL = /bin/bash # the Docker tag for this project. The definition below inherits the standard # value for DOCKER_REGISTRY_HOST (=rnexus.engageska-portugal.pt) and overwrites # DOCKER_REGISTRY_USER and PROJECT to give a final Docker tag of -# nexus.engageska-portugal.pt/tango-example/dishmaster +# nexus.engageska-portugal.pt/ska-telescope/ska_tango_base # -DOCKER_REGISTRY_USER:=tango-example -PROJECT = lmcbaseclasses +DOCKER_REGISTRY_USER:=ska-telescope +PROJECT = ska_tango_base IMAGE_FOR_DIAGRAMS = nexus.engageska-portugal.pt/ska-docker/ska-python-buildenv:9.3.3.1 # # include makefile to pick up the standard Make targets, e.g., 'make build' @@ -27,16 +27,16 @@ include .make/Makefile.mk .DEFAULT_GOAL := help -test: ## test lmcbaseclasses Python code +test: ## test ska_tango_base Python code mkdir -p build/reports python3 setup.py test | tee build/setup_py_test.stdout -lint: ## lint lmcbaseclasses Python code +lint: ## lint ska_tango_base Python code python3 -m pip install -U pylint==2.4.4 python3 -m pip install pylint2junit mkdir -p build/reports - pylint --output-format=parseable src/ska | tee build/code_analysis.stdout - pylint --output-format=pylint2junit.JunitReporter src/ska > build/reports/linting.xml + pylint --output-format=parseable src/ska_tango_base | tee build/code_analysis.stdout + pylint --output-format=pylint2junit.JunitReporter src/ska_tango_base > build/reports/linting.xml test-in-docker: build ## Build the docker image and run tests inside it. @docker run --rm $(IMAGE):$(VERSION) make test diff --git a/README.md b/README.md index 29374a59..2969f1d7 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# lmc-base-classes +# SKA Tango Base Classes and Utilities -[](https://developerskatelescopeorg.readthedocs.io/projects/lmc-base-classes/en/latest/?badge=latest) +[](https://developerskatelescopeorg.readthedocs.io/projects/ska-tango-base/en/latest/?badge=latest) ## About -A shared repository for the Local Monitoring and Control (LMC) Base Classes. The goal is to create a Software Development Kit for the Control System of the [Square Kilometre Array](http://skatelescope.org/) (SKA) radio telescope project. The Telescope Manager provides the Central Control System and each _Element_ provides a Local Control System that all work together as the Control System for the instrument. In the SKA case _Elements_ are subsystems such as the Central Signal Processor (CSP), Science Data Processor (SDP), Dishes (DSH), Low-Frequency Apperture Array (LFAA) etc. Control is implement using the distributed control system, [TANGO](http://www.tango-controls.org), which is accessed from Python using the [PyTango](https://github.com/tango-controls/pytango) package. +A shared repository for the Local Monitoring and Control (LMC) Tango Base Classes. The goal is to create a Software Development Kit for the Control System of the [Square Kilometre Array](http://skatelescope.org/) (SKA) radio telescope project. The Telescope Manager provides the Central Control System and each _Element_ provides a Local Control System that all work together as the Control System for the instrument. In the SKA case _Elements_ are subsystems such as the Central Signal Processor (CSP), Science Data Processor (SDP), Dishes (DSH), Low-Frequency Apperture Array (LFAA) etc. Control is implement using the distributed control system, [TANGO](http://www.tango-controls.org), which is accessed from Python using the [PyTango](https://gitlab.com/tango-controls/pytango) package. Early work in this repo was done as part of the LMC Base Classes Evolutionary Prototype (LEvPro) project, under the INDO-SA collaboration program. -The lmc-base-classe repository contains set of eight classes as mentioned in SKA Control systems guidelines. Following is the list of base classes +The ska-tango-base repository includes a set of eight classes as mentioned in SKA Control systems guidelines. Following is the list of base classes - SKABaseDevice: This is generic class that includes common attributes, commands and properties that are required for any SKA tango device. - SKACapability: This is generic base class for any element to provide common functionality of a capability of an SKA device. - SKAAlarmHandler: This is the generic class meant to handle the alarms and alerts. @@ -25,6 +25,12 @@ The lmc-base-classe repository contains set of eight classes as mentioned in SKA ## Version History +#### 0.9.0 +- Breaking change: Package rename + - Installable package name changed from `lmcbaseclasses` to `ska_tango_base`. + - Package import `ska.base` has been changed to `ska_tango_base`. For example, instead of + `from ska.base import SKABaseDevice` use `from ska_tango_base import SKABaseDevice`. + #### 0.8.1 - Fix broken docs @@ -125,13 +131,13 @@ than only EMPTY obsState. No change to usage. #### 0.5.0 -- Breaking change: Major restructuring of the package to simplify imports and reduce confusion. +- 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`. + class, just use `from ska.base import SKABaseDevice`. - Instead of `skabase.control_model` use `ska.base.control_model`. - The `SKATestDevice` was removed. Note that this class was only intended - for internal use in lmc-base-classes and is no longer needed. + for internal use and is no longer needed. - Removed unused scripts and modules. - Removed `TangoLoggingLevel` which was deprecated in 0.4.0. Use `ska.base.control_model.LoggingLevel` instead. @@ -214,9 +220,9 @@ The requirements for testing are: 3. Run 'python3 -m pip install . --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple' ## Testing -The LMC base classes can be tested locally my invoking *make CI_JOB_ID=some_id test* command. -This invokes a chain of commands from the makefile which builds the lmc base classes -python package, creates a docker image with lmc base classes, instantiates separate +The project can be tested locally my invoking *make CI_JOB_ID=some_id test* command. +This invokes a chain of commands from the makefile which builds the project's +python package, creates a docker image with the project, instantiates separate container for each of the base class and runs unit test cases of each class. Additionally, code analysis is also done and code coverage report is prepared. After testing is done, the containers are taken down. @@ -429,7 +435,7 @@ to the Tango Logging Service: ### Where are the logs from the admin device (dserver)? -PyTango is wrapper around the C++ Tango library, and the admin device is implemented in C++. +PyTango is wrapper around the C++ Tango library, and the admin device is implemented in C++. The admin device does not inherit from the SKABaseDevice and we cannot override its behaviour from the Python layer. Its logs can only be seen by configuring the TLS appropriately. @@ -472,10 +478,10 @@ In future, it would be useful to override the property with the command line opt ### PyCharm The Docker integration is recommended. For development, use the -`nexus.engageska-portugal.pt/tango-example/lmcbaseclasses:latest` image +`nexus.engageska-portugal.pt/ska-telescope/ska_tango_base:latest` image as the Python Interpreter for the project. Note that if `make` is run with targets like `build`, `up`, or `test`, that image will be -rebuilt by Docker using the local code, and tagged as `latest`. +rebuilt by Docker using the local code, and tagged as `latest`. As this project uses a `src` [folder structure](https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure), so under _Preferences > Project Structure_, the `src` folder needs to be marked as "Sources". That will @@ -484,7 +490,7 @@ When adding Run/Debug configurations, make sure "Add content roots to PYTHONPATH "Add source roots to PYTHONPATH" are checked. ## Docs -- Online: [Read The Docs](https://developerskatelescopeorg.readthedocs.io/projects/lmc-base-classes/en/latest) +- Online: [Read The Docs](https://developerskatelescopeorg.readthedocs.io/projects/ska-tango-base/en/latest) - SKA Control System guidelines: [Google docs folder](https://drive.google.com/drive/folders/0B8fhAW5QnZQWQ2ZlcjhVS0NmRms) - Old LEvPro work area: [Google docs folder](https://drive.google.com/drive/folders/0B8fhAW5QnZQWVHVFVGVXT2Via28) diff --git a/docs/Makefile b/docs/Makefile index 71639970..5f44cc48 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -85,17 +85,17 @@ qthelp: @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/LMCBaseClasses.qhcp" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/SKA_TangoBase.qhcp" @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/LMCBaseClasses.qhc" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/SKA_TangoBase.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/LMCBaseClasses" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/LMCBaseClasses" + @echo "# mkdir -p $$HOME/.local/share/devhelp/SKA_TangoBase" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/SKA_TangoBase" @echo "# devhelp" epub: diff --git a/docs/source/Commands.rst b/docs/source/Commands.rst index 63c5d710..1da962ae 100644 --- a/docs/source/Commands.rst +++ b/docs/source/Commands.rst @@ -5,7 +5,7 @@ SKA Commands .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.commands +.. automodule:: ska_tango_base.commands :members: :undoc-members: diff --git a/docs/source/Control_Model.rst b/docs/source/Control_Model.rst index 94563102..a0add5fb 100644 --- a/docs/source/Control_Model.rst +++ b/docs/source/Control_Model.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -9,7 +9,7 @@ SKA Control Model .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.control_model +.. automodule:: ska_tango_base.control_model :members: :undoc-members: diff --git a/docs/source/CspSubElementMaster.rst b/docs/source/CspSubElementMaster.rst index 1d3c55e1..1c88c268 100644 --- a/docs/source/CspSubElementMaster.rst +++ b/docs/source/CspSubElementMaster.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -10,7 +10,7 @@ This module implements a general Master device for a CSP Sub-element. .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.csp_subelement_master -.. autoclass:: ska.base.CspSubElementMaster +.. automodule:: ska_tango_base.csp_subelement_master +.. autoclass:: ska_tango_base.CspSubElementMaster :members: :undoc-members: diff --git a/docs/source/CspSubElementObsDevice.rst b/docs/source/CspSubElementObsDevice.rst index 56fbca37..b17da7d3 100644 --- a/docs/source/CspSubElementObsDevice.rst +++ b/docs/source/CspSubElementObsDevice.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -13,8 +13,8 @@ SKA CSP Sub-element ObsDevice .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.csp_subelement_obsdevice -.. autoclass:: ska.base.CspSubElementObsDevice +.. automodule:: ska_tango_base.csp_subelement_obsdevice +.. autoclass:: ska_tango_base.CspSubElementObsDevice :members: :undoc-members: @@ -27,9 +27,9 @@ Here it is reported the list of the *instance attributes*. |br| The scan ID is passed as argument of the *Scan* command. |br| The attribute value is reported via TANGO attribute *scanID*. -* ``_sdp_addresses``: a python dictionary with the SDP destination addresses for the output +* ``_sdp_addresses``: a python dictionary with the SDP destination addresses for the output products. |br| - Depending on the sub-element (CBF, PSS, PST) this attribute can specify more than one destination address, + Depending on the sub-element (CBF, PSS, PST) this attribute can specify more than one destination address, as for example in CBF sub-element. |br| The SDP destination addresses are specified at configuration. An SDP address specifies the MAC address, IP address and port of the endpoint. |br| @@ -44,7 +44,7 @@ Here it is reported the list of the *instance attributes*. |br| } The value of this attribute is reported via the TANGO *sdpDestionationAddresses* attribute. - + .. note:: Not all the Sub-element observing devices are connected to the SDP (for example Mid VCCs). @@ -53,12 +53,12 @@ Here it is reported the list of the *instance attributes*. |br| * ``_sdp_links_capacity``: this attribute records the capacity in GB/s of the SDP link. -* ``_config_id``: it stores the unique identificator associated to a JSON scan configuration. |br| +* ``_config_id``: it stores the unique identificator associated to a JSON scan configuration. |br| The value of this attribute is reported via the TANGO attriute *configID*. * ``_last_scan_configuration``: this attribute stores the last configuration successully programmed. |br| The value is reported via the TANGO attribute *lastScanConfiguration*. -* ``_health_failure_msg``: +* ``_health_failure_msg``: The value is reported via the TANGO attribute *healthFailureMesssage*. diff --git a/docs/source/CspSubElementSubarray.rst b/docs/source/CspSubElementSubarray.rst index 3eeacf60..ee08f12a 100644 --- a/docs/source/CspSubElementSubarray.rst +++ b/docs/source/CspSubElementSubarray.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -6,14 +6,14 @@ SKA CSP Sub-element Subarray ============================================ This module implements a generic Subarray device for a CSP Sub-element. -The scope of this module is to provide a uniform access to a CSP Sub-element +The scope of this module is to provide a uniform access to a CSP Sub-element subarray from the CSP.LMC side. .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.csp_subelement_subarray -.. autoclass:: ska.base.CspSubElementSubarray +.. automodule:: ska_tango_base.csp_subelement_subarray +.. autoclass:: ska_tango_base.CspSubElementSubarray :members: :undoc-members: diff --git a/docs/source/SKAAlarmHandler.rst b/docs/source/SKAAlarmHandler.rst index 9b0297fb..fd8f8548 100644 --- a/docs/source/SKAAlarmHandler.rst +++ b/docs/source/SKAAlarmHandler.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -9,7 +9,7 @@ SKA AlarmHandler .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.alarm_handler_device -.. autoclass:: ska.base.SKAAlarmHandler +.. automodule:: ska_tango_base.alarm_handler_device +.. autoclass:: ska_tango_base.SKAAlarmHandler :members: :undoc-members: diff --git a/docs/source/SKABaseDevice.rst b/docs/source/SKABaseDevice.rst index 49deb8eb..2d3e2576 100644 --- a/docs/source/SKABaseDevice.rst +++ b/docs/source/SKABaseDevice.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -9,12 +9,12 @@ SKA BaseDevice .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.base_device +.. automodule:: ska_tango_base.base_device -.. autoclass:: ska.base.DeviceStateModel +.. autoclass:: ska_tango_base.DeviceStateModel :members: :undoc-members: -.. autoclass:: ska.base.SKABaseDevice +.. autoclass:: ska_tango_base.SKABaseDevice :members: :undoc-members: diff --git a/docs/source/SKACapability.rst b/docs/source/SKACapability.rst index f749103f..91ba5dad 100644 --- a/docs/source/SKACapability.rst +++ b/docs/source/SKACapability.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -9,7 +9,7 @@ SKA Capability .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.capability_device -.. autoclass:: ska.base.SKACapability +.. automodule:: ska_tango_base.capability_device +.. autoclass:: ska_tango_base.SKACapability :members: :undoc-members: diff --git a/docs/source/SKALogger.rst b/docs/source/SKALogger.rst index 98415a32..2f628ef1 100644 --- a/docs/source/SKALogger.rst +++ b/docs/source/SKALogger.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -9,7 +9,7 @@ SKA Logger .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.logger_device -.. autoclass:: ska.base.SKALogger +.. automodule:: ska_tango_base.logger_device +.. autoclass:: ska_tango_base.SKALogger :members: :undoc-members: diff --git a/docs/source/SKAMaster.rst b/docs/source/SKAMaster.rst index 3788821b..3356684f 100644 --- a/docs/source/SKAMaster.rst +++ b/docs/source/SKAMaster.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -9,7 +9,7 @@ SKA Master .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.master_device -.. autoclass:: ska.base.SKAMaster +.. automodule:: ska_tango_base.master_device +.. autoclass:: ska_tango_base.SKAMaster :members: :undoc-members: diff --git a/docs/source/SKAObsDevice.rst b/docs/source/SKAObsDevice.rst index 013c6af9..89166e8c 100644 --- a/docs/source/SKAObsDevice.rst +++ b/docs/source/SKAObsDevice.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -9,7 +9,7 @@ SKA ObsDevice .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.obs_device -.. autoclass:: ska.base.SKAObsDevice +.. automodule:: ska_tango_base.obs_device +.. autoclass:: ska_tango_base.SKAObsDevice :members: :undoc-members: diff --git a/docs/source/SKASubarray.rst b/docs/source/SKASubarray.rst index 4db79893..29c354be 100644 --- a/docs/source/SKASubarray.rst +++ b/docs/source/SKASubarray.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -9,7 +9,7 @@ SKA Subarray .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.subarray_device -.. autoclass:: ska.base.SKASubarray +.. automodule:: ska_tango_base.subarray_device +.. autoclass:: ska_tango_base.SKASubarray :members: :undoc-members: diff --git a/docs/source/SKATelState.rst b/docs/source/SKATelState.rst index acd145f9..fac3623c 100644 --- a/docs/source/SKATelState.rst +++ b/docs/source/SKATelState.rst @@ -1,4 +1,4 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -9,7 +9,7 @@ SKA TelState .. toctree:: :maxdepth: 2 -.. automodule:: ska.base.tel_state_device -.. autoclass:: ska.base.SKATelState +.. automodule:: ska_tango_base.tel_state_device +.. autoclass:: ska_tango_base.SKATelState :members: :undoc-members: diff --git a/docs/source/State_Machine.rst b/docs/source/State_Machine.rst index 66329a11..4b57eacd 100644 --- a/docs/source/State_Machine.rst +++ b/docs/source/State_Machine.rst @@ -99,7 +99,7 @@ state state machine by * three extra states: INIT_ADMIN, FAULT_ADMIN and DISABLED_ADMIN * two extra transition triggers: "admin_on" and "admin_off", which allow for transition between INIT and INIT_ADMIN; FAULT and FAULT_ADMIN; and - DISABLE and DISABLE_ADMIN. + DISABLE and DISABLE_ADMIN. This implementation minimises the coupling between admin mode and operational state, allowing the two machines to be conceptualised almost @@ -133,7 +133,7 @@ observations (currently only subarray devices). :width: 80% :alt: Diagram of the observation state machine, as decided and published in ADR-8. - + Diagram of the observation state machine, as decided and published in ADR-8. @@ -142,7 +142,7 @@ observations (currently only subarray devices). :width: 80% :alt: Diagram of the observation state machine, automatically generated from the implementation - + Diagram of the observation state machine, automatically generated from the implementation. The equivalance of this diagram to the diagram previous demonstrates that the machine has been implemented in @@ -153,14 +153,14 @@ CSP SubElement ObsDevice state machine This state machine is implemented for the CSP SubElement devices, different from the subarrays, that manage observations. -Compared to the SKA Observation State Machine, it implements a smaller number +Compared to the SKA Observation State Machine, it implements a smaller number of states, number that can be further descreased depending on the necessities of the different sub-elements. The implemented states for the current state machine are: * IDLE: this is the observing state after the device intialization. -* CONFIGURING: transitional state to report the device configuration is in progress. +* CONFIGURING: transitional state to report the device configuration is in progress. *Need to understand if this state is really required by the observing devices of any CSP sub-element.* * READY: the device is configured and is ready to perform observations @@ -168,7 +168,7 @@ The implemented states for the current state machine are: * ABORTING: the device is processing an abort. Need to understand if this state is really required by the observing devices of any CSP sub-element. -* ABORTED: the device has completed the abort request. +* ABORTED: the device has completed the abort request. * FAULT: the device has experienced an error from which it can be recovered only via manual intervention invoking a reset command that force the device to the base state (IDLE). @@ -184,7 +184,7 @@ The implemented states for the current state machine are: API --- -.. automodule:: ska.base.state_machine +.. automodule:: ska_tango_base.state_machine :members: :undoc-members: @@ -197,7 +197,7 @@ API .. autoclass:: ObservationStateMachine :members: -.. automodule:: ska.base.csp_subelement_state_machine +.. automodule:: ska_tango_base.csp_subelement_state_machine :members: :undoc-members: diff --git a/docs/source/conf.py b/docs/source/conf.py index ed9da827..a60425d9 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# LMC Base Classes documentation build configuration file, created by +# SKA Tango Base documentation build configuration file, created by # sphinx-quickstart on Fri Jan 11 10:03:42 2019. # # This file is execfile()d with the current directory set to its @@ -26,22 +26,22 @@ # 'future', 'future.utils', 'logging', 'logging.handlers'] # sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) +from unittest.mock import Mock as MagicMock +import os +import sys autodoc_mock_imports = ['PyTango', 'tango', 'tango.server', 'run', 'command', - 'future', 'future.utils', 'transitions', + 'future', 'future.utils', 'transitions', 'ska', 'ska.logging', 'ska.logging.configuration', 'numpy' - ] - -import sys -import os + ] -from unittest.mock import Mock as MagicMock class Mock(MagicMock): @classmethod def __getattr__(cls, name): return MagicMock() + # Mock tango modules MOCK_MODULES = ['logging', 'logging.handlers'] sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) @@ -78,7 +78,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'LMC Base Classes' +project = u'SKA Tango Base' copyright = u'2019, NCRA India and SARAO' # The version info for the project you're documenting, acts as replacement for @@ -86,11 +86,13 @@ copyright = u'2019, NCRA India and SARAO' # built documents. # + def get_release_version(): - release_filename = os.path.join("..", "..", "src", "ska", "base", "release.py") + release_filename = os.path.join("..", "..", "src", "ska_tango_base", "release.py") exec(open(release_filename).read()) return locals()["version"] + release_version = get_release_version() # The short X.Y version. @@ -222,28 +224,28 @@ html_static_path = ['_static'] #html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'LMCBaseClassesdoc' +htmlhelp_basename = 'SKA_TangoBasedoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'LMCBaseClasses.tex', u'LMC Base Classes Documentation', - u'NCRA India', 'manual'), + ('index', 'SKA_TangoBase.tex', u'SKA Tango Base Documentation', + u'NCRA India', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -272,7 +274,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'lmcbaseclasses', u'LMC Base Classes Documentation', + ('index', 'ska_tango_base', u'SKA Tango Base Documentation', [u'NCRA India'], 1) ] @@ -286,9 +288,9 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'LMCBaseClasses', u'LMC Base Classes Documentation', - u'NCRA India', 'LMCBaseClasses', 'One line description of project.', - 'Miscellaneous'), + ('index', 'SKA_TangoBase', u'SKA Tango Base Documentation', + u'NCRA India', 'SKA_TangoBase', 'One line description of project.', + 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. diff --git a/docs/source/draw_state_machines.py b/docs/source/draw_state_machines.py index 6e02afa4..16c66978 100644 --- a/docs/source/draw_state_machines.py +++ b/docs/source/draw_state_machines.py @@ -2,9 +2,9 @@ This module draws diagrams of the state machines. Usage: - ~/ska-src/lmc-base-classes$ docker run --rm -ti -v $PWD:/app continuumio/miniconda3 bash + ~/ska-src/ska-tango-base$ docker run --rm -ti -v $PWD:/app continuumio/miniconda3 bash - (base) root@293f3b699c9b:/opt/project/src/ska/base# history + (base) root@293f3b699c9b:# $ conda install --yes pygraphviz $ pip install transitions $ apt-get update && apt-get install gsfonts @@ -21,7 +21,7 @@ from unittest import mock from transitions.extensions import GraphMachine # local import, so we can run this without installing the whole package -sys.path.append("../../src/ska/base") +sys.path.append("../../src/ska_tango_base") import state_machine import csp_subelement_state_machine diff --git a/docs/source/index.rst b/docs/source/index.rst index fcff7dc5..b82d7f1f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,10 +1,10 @@ -.. LMC Base Classes documentation master file, created by +.. SKA Tango Base documentation master file, created by sphinx-quickstart on Fri Jan 11 10:03:42 2019. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to LMC Base Classes documentation! -============================================ +Welcome to SKA Tango Base documentation! +======================================== .. toctree:: :caption: Table of Contents diff --git a/pogo/CspSubElementMaster.xmi b/pogo/CspSubElementMaster.xmi index 6813d24a..d92b0cbe 100644 --- a/pogo/CspSubElementMaster.xmi +++ b/pogo/CspSubElementMaster.xmi @@ -1,10 +1,10 @@ <?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="CspSubElementMaster" pogoRevision="9.6"> - <description description="Master device for SKA CSP Subelement." title="CspSubElementMaster" sourcePath="/home/toor/ska-git/lmc-base-classes/pogo" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="BSD3" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="Master device for SKA CSP Subelement." title="CspSubElementMaster" sourcePath="/home/toor/ska-git/ska-tango-base/pogo" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="BSD3" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKABaseDevice" sourcePath="./"/> - <inheritances classname="SKAMaster" sourcePath="/home/toor/ska-git/lmc-base-classes/pogo"/> + <inheritances classname="SKAMaster" sourcePath="/home/toor/ska-git/ska-tango-base/pogo"/> <identification contact="at inaf.it - elisabetta.giani" author="elisabetta.giani" emailDomain="inaf.it" 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/CspSubElementObsDevice.xmi b/pogo/CspSubElementObsDevice.xmi index d3274912..6c2ed17b 100644 --- a/pogo/CspSubElementObsDevice.xmi +++ b/pogo/CspSubElementObsDevice.xmi @@ -1,10 +1,10 @@ <?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="CspSubElementObsDevice" pogoRevision="9.6"> - <description description="General observing device for SKA CSP Subelement." title="CspSubElementObsDevice" sourcePath="/home/toor/tmp/lmc-base-classes/pogo" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="BSD3" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="General observing device for SKA CSP Subelement." title="CspSubElementObsDevice" sourcePath="/home/toor/tmp/ska-tango-base/pogo" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="BSD3" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKABaseDevice" sourcePath="./"/> - <inheritances classname="SKAObsDevice" sourcePath="/home/toor/ska-git/lmc-base-classes/pogo"/> + <inheritances classname="SKAObsDevice" sourcePath="/home/toor/ska-git/ska-tango-base/pogo"/> <identification contact="at inaf.it - elisabetta.giani" author="elisabetta.giani" emailDomain="inaf.it" 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/CspSubElementSubarray.xmi b/pogo/CspSubElementSubarray.xmi index f12f30e0..6702ae7f 100644 --- a/pogo/CspSubElementSubarray.xmi +++ b/pogo/CspSubElementSubarray.xmi @@ -1,10 +1,10 @@ <?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="CspSubElementSubarray" pogoRevision="9.6"> - <description description="Subarray device for SKA CSP SubElement" title="CspSubElementSubarray" sourcePath="/home/toor/ska-git/lmc-base-classes/pogo" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="BSD3" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="Subarray device for SKA CSP SubElement" title="CspSubElementSubarray" sourcePath="/home/toor/ska-git/ska-tango-base/pogo" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="BSD3" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKAObsDevice" sourcePath="./"/> - <inheritances classname="SKASubarray" sourcePath="/home/toor/ska-git/lmc-base-classes/pogo"/> + <inheritances classname="SKASubarray" sourcePath="/home/toor/ska-git/ska-tango-base/pogo"/> <identification contact="at inaf.it - elisabetta.giani" author="elisabetta.giani" emailDomain="inaf.it" 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/SKAAlarmHandler.xmi b/pogo/SKAAlarmHandler.xmi index 78984bcc..e8ae4591 100644 --- a/pogo/SKAAlarmHandler.xmi +++ b/pogo/SKAAlarmHandler.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="SKAAlarmHandler" pogoRevision="9.6"> - <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"> + <description description="A generic base device for Alarms for SKA." title="SKAAlarmHandler" sourcePath="/home/tango/src/ska-tango-base/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="./"/> <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"/> diff --git a/pogo/SKABaseDevice.xmi b/pogo/SKABaseDevice.xmi index 22f06e55..892b1adb 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/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"> + <description description="A generic base device for SKA." title="SKABASE" sourcePath="/home/tango/src/ska-tango-base/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 f2f78caa..30b58884 100644 --- a/pogo/SKACapability.xmi +++ b/pogo/SKACapability.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="SKACapability" pogoRevision="9.6"> - <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"> + <description description="Subarray handling device" title="SKACapability" sourcePath="/home/tango/src/ska-tango-base/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="./"/> <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=""/> diff --git a/pogo/SKALogger.xmi b/pogo/SKALogger.xmi index 54a9a28b..bad006a3 100644 --- a/pogo/SKALogger.xmi +++ b/pogo/SKALogger.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="SKALogger" pogoRevision="9.6"> - <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="false" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="A generic base device for Logging for SKA." title="SKALogger" sourcePath="/home/tango/src/ska-tango-base/pogo" 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="./"/> <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"/> diff --git a/pogo/SKAMaster.xmi b/pogo/SKAMaster.xmi index 14a44e17..4c56c65e 100644 --- a/pogo/SKAMaster.xmi +++ b/pogo/SKAMaster.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="SKAMaster" pogoRevision="9.6"> - <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"> + <description description="A master test" title="SKAMaster" sourcePath="/home/tango/src/ska-tango-base/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="./"/> <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=""/> diff --git a/pogo/SKAObsDevice.xmi b/pogo/SKAObsDevice.xmi index 913619b0..438d21f3 100644 --- a/pogo/SKAObsDevice.xmi +++ b/pogo/SKAObsDevice.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="SKAObsDevice" pogoRevision="9.6"> - <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"> + <description description="A generic base device for Observations for SKA." title="SKAObsDevice" sourcePath="/home/tango/src/ska-tango-base/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="./"/> <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"/> diff --git a/pogo/SKASubarray.xmi b/pogo/SKASubarray.xmi index 63f592de..88fb3f4b 100644 --- a/pogo/SKASubarray.xmi +++ b/pogo/SKASubarray.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="SKASubarray" pogoRevision="9.6"> - <description description="SubArray handling device" title="SKASubarray" sourcePath="/home/tango/src/lmc-base-classes/pogo" language="PythonHL" filestogenerate="XMI file" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="SubArray handling device" title="SKASubarray" sourcePath="/home/tango/src/ska-tango-base/pogo" language="PythonHL" filestogenerate="XMI file" license="none" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <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=""/> diff --git a/pogo/SKATelState.xmi b/pogo/SKATelState.xmi index 5307aa9c..24d9fc0e 100644 --- a/pogo/SKATelState.xmi +++ b/pogo/SKATelState.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="SKATelState" pogoRevision="9.6"> - <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"> + <description description="A generic base device for Telescope State for SKA." title="SKATelState" sourcePath="/home/tango/src/ska-tango-base/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="./"/> <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"/> diff --git a/setup.cfg b/setup.cfg index bd9d7702..df7dadc2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ test=pytest [coverage:run] branch = True -source = ska.base +source = ska_tango_base [tool:pytest] testpaths = tests @@ -14,7 +14,7 @@ addopts = --forked --cov-report term --cov-report html --cov-report xml:build/reports/code-coverage.xml - --cov=ska.base + --cov=ska_tango_base --junitxml=build/reports/unit-tests.xml console_output_style = progress junit_family = legacy diff --git a/setup.py b/setup.py index a172135c..6de91a0b 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ import sys import setuptools setup_dir = os.path.dirname(os.path.abspath(__file__)) -release_filename = os.path.join(setup_dir, "src", "ska", "base", "release.py") +release_filename = os.path.join(setup_dir, "src", "ska_tango_base", "release.py") exec(open(release_filename).read()) # prevent unnecessary installation of pytest-runner @@ -20,7 +20,7 @@ setuptools.setup( author=author, author_email=author_email, license=license, - packages=setuptools.find_namespace_packages(where="src", include=["ska.*"]), + packages=setuptools.find_packages("src"), package_dir={"": "src"}, include_package_data=True, url="https://www.skatelescope.org/", @@ -35,24 +35,24 @@ setuptools.setup( ], platforms=["OS Independent"], setup_requires=[] + pytest_runner, - install_requires=["future", "transitions", "ska_logging >= 0.3.0"], + install_requires=["future", "transitions", "ska_logging >= 0.3.0, < 0.4.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", - "CspSubelementMaster=ska.base.csp_subelement_master:main", - "CspSubelementObsDevice=ska.base.csp_subelement_obsdevice:main", - "CspSubelementSubarray=ska.base.csp_subelement_subarray:main", + "SKAAlarmHandler=ska_tango_base.alarm_handler_device:main", + "SKABaseDevice=ska_tango_base.base_device:main", + "SKACapability=ska_tango_base.capability_device:main", + "SKAExampleDevice=ska_tango_base.example_device:main", + "SKALogger=ska_tango_base.logger_device:main", + "SKAMaster=ska_tango_base.master_device:main", + "SKAObsDevice=ska_tango_base.obs_device:main", + "SKASubarray=ska_tango_base.subarray_device:main", + "SKATelState=ska_tango_base.tel_state_device:main", + "CspSubelementMaster=ska_tango_base.csp_subelement_master:main", + "CspSubelementObsDevice=ska_tango_base.csp_subelement_obsdevice:main", + "CspSubelementSubarray=ska_tango_base.csp_subelement_subarray:main", ] }, - keywords="lmc base classes ska", + keywords="tango lmc base classes ska", zip_safe=False, ) diff --git a/src/ska/base/__init__.py b/src/ska_tango_base/__init__.py similarity index 100% rename from src/ska/base/__init__.py rename to src/ska_tango_base/__init__.py diff --git a/src/ska/base/alarm_handler_device.py b/src/ska_tango_base/alarm_handler_device.py similarity index 99% rename from src/ska/base/alarm_handler_device.py rename to src/ska_tango_base/alarm_handler_device.py index 848c4793..10c8c881 100644 --- a/src/ska/base/alarm_handler_device.py +++ b/src/ska_tango_base/alarm_handler_device.py @@ -17,8 +17,8 @@ from tango import DebugIt from tango.server import run, attribute, command, device_property # SKA specific imports -from ska.base import SKABaseDevice -from ska.base.commands import BaseCommand +from ska_tango_base import SKABaseDevice +from ska_tango_base.commands import BaseCommand # PROTECTED REGION END # // SKAAlarmHandler.additionnal_import @@ -200,6 +200,7 @@ class SKAAlarmHandler(SKABaseDevice): """ A class for the SKAAlarmHandler's GetAlarmRule() command. """ + def do(self, argin): """ Stateless hook for SKAAlarmHandler GetAlarmRule() command. @@ -213,6 +214,7 @@ class SKAAlarmHandler(SKABaseDevice): """ A class for the SKAAlarmHandler's GetAlarmData() command. """ + def do(self, argin): """ Stateless hook for SKAAlarmHandler GetAlarmData() command. @@ -227,6 +229,7 @@ class SKAAlarmHandler(SKABaseDevice): A class for the SKAAlarmHandler's GetAlarmAdditionalInfo() command. """ + def do(self, argin): """ Stateless hook for SKAAlarmHandler GetAlarmAdditionalInfo() @@ -241,6 +244,7 @@ class SKAAlarmHandler(SKABaseDevice): """ A class for the SKAAlarmHandler's GetAlarmStats() command. """ + def do(self): """ Stateless hook for SKAAlarmHandler GetAlarmStats() command. @@ -254,6 +258,7 @@ class SKAAlarmHandler(SKABaseDevice): """ A class for the SKAAlarmHandler's GetAlertStats() command. """ + def do(self): """ Stateless hook for SKAAlarmHandler GetAlertStats() command. diff --git a/src/ska/base/base_device.py b/src/ska_tango_base/base_device.py similarity index 98% rename from src/ska/base/base_device.py rename to src/ska_tango_base/base_device.py index 12538e94..39432f3d 100644 --- a/src/ska/base/base_device.py +++ b/src/ska_tango_base/base_device.py @@ -29,19 +29,19 @@ from tango.server import run, Device, attribute, command, device_property # SKA specific imports import ska.logging as ska_logging -from ska.base import release -from ska.base.commands import ( +from ska_tango_base import release +from ska_tango_base.commands import ( ActionCommand, BaseCommand, ResultCode ) -from ska.base.control_model import ( +from ska_tango_base.control_model import ( AdminMode, ControlMode, SimulationMode, TestMode, HealthState, LoggingLevel ) -from ska.base.faults import StateModelError -from ska.base.state_machine import OperationStateMachine, AdminModeStateMachine +from ska_tango_base.faults import StateModelError +from ska_tango_base.state_machine import OperationStateMachine, AdminModeStateMachine -from ska.base.utils import get_groups_from_json, for_testing_only -from ska.base.faults import GroupDefinitionsError, LoggingTargetError, LoggingLevelError +from ska_tango_base.utils import get_groups_from_json, for_testing_only +from ska_tango_base.faults import GroupDefinitionsError, LoggingTargetError, LoggingLevelError LOG_FILE_SIZE = 1024 * 1024 # Log file size 1MB. @@ -54,8 +54,8 @@ class _Log4TangoLoggingLevel(enum.IntEnum): via PyTango, so we hard code it here in the interim. Source: - https://github.com/tango-controls/cppTango/blob/ - 4feffd7c8e24b51c9597a40b9ef9982dd6e99cdf/log4tango/include/log4tango/Level.hh#L86-L93 + https://gitlab.com/tango-controls/cppTango/blob/ + 4feffd7c8e24b51c9597a40b9ef9982dd6e99cdf/log4tango/include/log4tango/Level.hh#L86-93 """ OFF = 100 @@ -135,7 +135,7 @@ class LoggingUtils: def sanitise_logging_targets(targets, device_name): """Validate and return logging targets '<type>::<name>' strings. - :param targets: + :param targets: List of candidate logging target strings, like '<type>[::<name>]' Empty and whitespace-only strings are ignored. Can also be None. @@ -225,7 +225,8 @@ class LoggingUtils: elif parsed.scheme in ["udp", "tcp"]: if not parsed.hostname: raise LoggingTargetError( - "Invalid syslog URL - could not extract hostname from '{}'".format(url) + "Invalid syslog URL - could not extract hostname from '{}'".format( + url) ) try: port = int(parsed.port) @@ -239,7 +240,8 @@ class LoggingUtils: socktype = socket.SOCK_DGRAM if parsed.scheme == "udp" else socket.SOCK_STREAM else: raise LoggingTargetError( - "Invalid syslog URL - expected file, udp or tcp protocol scheme in '{}'".format(url) + "Invalid syslog URL - expected file, udp or tcp protocol scheme in '{}'".format( + url) ) return address, socktype @@ -279,7 +281,8 @@ class LoggingUtils: if tango_logger: handler = TangoLoggingServiceHandler(tango_logger) else: - raise LoggingTargetError("Missing tango_logger instance for 'tango' target type") + raise LoggingTargetError( + "Missing tango_logger instance for 'tango' target type") else: raise LoggingTargetError( "Invalid target type requested: '{}' in '{}'".format(target_type, target)) @@ -529,7 +532,7 @@ class DeviceStateModel: :param op_state: the target operational state (optional) :type op_state: :py:class:`tango.DevState` :param admin_mode: the target admin mode (optional) - :type admin_mode: :py:class:`~ska.base.control_model.AdminMode` + :type admin_mode: :py:class:`~ska_tango_base.control_model.AdminMode` """ if admin_mode is None: admin_mode = self._admin_mode_state_machine.state @@ -649,6 +652,7 @@ class SKABaseDevice(Device): class EnsureTagsFilter(logging.Filter): """Ensure all records have a "tags" field - empty string, if not provided.""" + def filter(self, record): if not hasattr(record, "tags"): record.tags = "" @@ -804,7 +808,7 @@ class SKABaseDevice(Device): callback :param admin_mode: the new admin_mode value - :type admin_mode: :py:class:`~ska.base.control_model.AdminMode` + :type admin_mode: :py:class:`~ska_tango_base.control_model.AdminMode` """ self.push_change_event("adminMode", admin_mode) self.push_archive_event("adminMode", admin_mode) @@ -1057,7 +1061,7 @@ class SKABaseDevice(Device): Sets Admin Mode of the device. :param value: Admin Mode of the device. - :type value: :py:class:`~ska.base.control_model.AdminMode` + :type value: :py:class:`~ska_tango_base.control_model.AdminMode` :raises ValueError: for unknown adminMode """ @@ -1143,6 +1147,7 @@ class SKABaseDevice(Device): """ A class for the SKABaseDevice's Reset() command. """ + def do(self): """ Stateless hook for device GetVersionInfo() command. @@ -1175,6 +1180,7 @@ class SKABaseDevice(Device): """ A class for the SKABaseDevice's Reset() command. """ + def __init__(self, target, state_model, logger=None): """ Create a new ResetCommand diff --git a/src/ska/base/capability_device.py b/src/ska_tango_base/capability_device.py similarity index 98% rename from src/ska/base/capability_device.py rename to src/ska_tango_base/capability_device.py index dedbb54f..5c7dba6a 100644 --- a/src/ska/base/capability_device.py +++ b/src/ska_tango_base/capability_device.py @@ -14,8 +14,8 @@ from tango import DebugIt from tango.server import run, attribute, command, device_property # SKA specific imports -from ska.base import SKAObsDevice -from ska.base.commands import ResponseCommand, ResultCode +from ska_tango_base import SKAObsDevice +from ska_tango_base.commands import ResponseCommand, ResultCode # PROTECTED REGION END # // SKACapability.additionnal_imports __all__ = ["SKACapability", "main"] @@ -25,6 +25,7 @@ class SKACapability(SKAObsDevice): """ A Subarray handling device. It exposes the instances of configured capabilities. """ + def init_command_objects(self): """ Sets up the command objects @@ -152,6 +153,7 @@ class SKACapability(SKAObsDevice): """ A class for the SKALoggerDevice's SetLoggingLevel() command. """ + def do(self, argin): """ Stateless hook for ConfigureInstances()) command diff --git a/src/ska/base/commands.py b/src/ska_tango_base/commands.py similarity index 99% rename from src/ska/base/commands.py rename to src/ska_tango_base/commands.py index e326c62c..8d414a69 100644 --- a/src/ska/base/commands.py +++ b/src/ska_tango_base/commands.py @@ -4,7 +4,7 @@ ResultCode enum. """ import enum import logging -from ska.base.faults import CommandError, ResultCodeError, StateModelError +from ska_tango_base.faults import CommandError, ResultCodeError, StateModelError module_logger = logging.getLogger(__name__) @@ -222,6 +222,7 @@ class ActionCommand(ResponseCommand): running, sends an action to that state model, thus driving device state. """ + def __init__( self, target, state_model, action_hook, start_action=False, logger=None ): diff --git a/src/ska/base/control_model.py b/src/ska_tango_base/control_model.py similarity index 100% rename from src/ska/base/control_model.py rename to src/ska_tango_base/control_model.py diff --git a/src/ska/base/csp_subelement_master.py b/src/ska_tango_base/csp_subelement_master.py similarity index 95% rename from src/ska/base/csp_subelement_master.py rename to src/ska_tango_base/csp_subelement_master.py index 6764cf64..ddd9fe3e 100644 --- a/src/ska/base/csp_subelement_master.py +++ b/src/ska_tango_base/csp_subelement_master.py @@ -21,10 +21,10 @@ from tango.server import run, attribute, command, device_property # SKA specific imports -from ska.base import SKAMaster -from ska.base.commands import ResultCode, ResponseCommand -from ska.base.control_model import AdminMode -from ska.base.faults import CommandError +from ska_tango_base import SKAMaster +from ska_tango_base.commands import ResultCode, ResponseCommand +from ska_tango_base.control_model import AdminMode +from ska_tango_base.faults import CommandError # PROTECTED REGION END # // CspSubElementMaster.additionnal_import __all__ = ["CspSubElementMaster", "main"] @@ -180,7 +180,6 @@ class CspSubElementMaster(SKAMaster): doc="The command execution measured duration (in sec).", ) - # --------------- # General methods # --------------- @@ -203,7 +202,7 @@ class CspSubElementMaster(SKAMaster): self.register_command_object( "ReInitDevices", self.ReInitDevicesCommand(*device_args) ) - + class InitCommand(SKAMaster.InitCommand): """ A class for the CspSubElementMaster's init_device() "command". @@ -234,7 +233,7 @@ class CspSubElementMaster(SKAMaster): # values: the expected maximum duration in sec. device._cmd_maximum_duration = defaultdict(float) - # _cmd_measure_duration: command execution's measured duration (msec.) + # _cmd_measure_duration: command execution's measured duration (msec.) # implemented as a default dictionary: # keys: the command name in lower case(on, off, standby,..) # values: the measured execution time (sec.) @@ -402,6 +401,7 @@ class CspSubElementMaster(SKAMaster): """ A class for the CspSubElementMaster's LoadFirmware command. """ + def do(self, argin): """ Stateless hook for device LoadFirmware() command. @@ -420,17 +420,17 @@ class CspSubElementMaster(SKAMaster): to be executed. The master device has to be in OFF/MAINTENACE to process the LoadFirmware command. - - :raises: ``CommandError`` if command not allowed + + :raises: ``CommandError`` if command not allowed :return: ``True`` if the command is allowed. :rtype: boolean """ if (self.state_model.op_state == tango.DevState.OFF and self.state_model.admin_mode == AdminMode.MAINTENANCE): return True - msg = "{} not allowed in {}/{}".format (self.name, - self.state_model.op_state, - AdminMode(self.state_model.admin_mode).name) + msg = "{} not allowed in {}/{}".format(self.name, + self.state_model.op_state, + AdminMode(self.state_model.admin_mode).name) raise CommandError(msg) class PowerOnDevicesCommand(ResponseCommand): @@ -455,8 +455,8 @@ class CspSubElementMaster(SKAMaster): Check if the command is in the proper state to be executed. The master device has to be in ON to process the PowerOnDevices command. - - : raises: ``CommandError`` if command not allowed + + : raises: ``CommandError`` if command not allowed : return: ``True`` if the command is allowed. : rtype: boolean """ @@ -488,8 +488,8 @@ class CspSubElementMaster(SKAMaster): Check if the command is in the proper state to be executed. The master device has to be in ON to process the PowerOffDevices command. - - : raises: ``CommandError`` if command not allowed + + : raises: ``CommandError`` if command not allowed : return: ``True`` if the command is allowed. : rtype: boolean """ @@ -515,18 +515,18 @@ class CspSubElementMaster(SKAMaster): """ message = "ReInitDevices command completed OK" return (ResultCode.OK, message) - + def check_allowed(self): """ Check if the command is in the proper state to be executed. The master device has to be in ON to process the ReInitDevices command. - - : raises: ``CommandError`` if command not allowed + + : raises: ``CommandError`` if command not allowed : return: ``True`` if the command is allowed. : rtype: boolean """ - if self.state_model.op_state == tango.DevState.ON: + if self.state_model.op_state == tango.DevState.ON: return True msg = "{} not allowed in {}".format(self.name, self.state_model.op_state) @@ -534,7 +534,7 @@ class CspSubElementMaster(SKAMaster): def is_LoadFirmware_allowed(self): """ - Check if the LoadFirmware command is allowed in the current + Check if the LoadFirmware command is allowed in the current state. :raises: ``CommandError`` if command not allowed @@ -555,16 +555,16 @@ class CspSubElementMaster(SKAMaster): def LoadFirmware(self, argin): # PROTECTED REGION ID(CspSubElementMaster.LoadFirmware) ENABLED START # """ - Deploy new versions of software and firmware and trigger - a restart so that a Component initializes using a newly + Deploy new versions of software and firmware and trigger + a restart so that a Component initializes using a newly deployed version. :param argin: A list of three strings: - - The file name or a pointer to the filename specified as URL. + - The file name or a pointer to the filename specified as URL. - the list of components that use software or firmware package (file), - checksum or signing - Ex: ['file://firmware.txt','test/dev/1, test/dev/2, test/dev/3', - '918698a7fea3fa9da5996db001d33628'] + Ex: ['file://firmware.txt','test/dev/1, test/dev/2, test/dev/3', + '918698a7fea3fa9da5996db001d33628'] :type argin: 'DevVarStringArray' :return: A tuple containing a return code and a string message indicating status. The message is for @@ -578,7 +578,7 @@ class CspSubElementMaster(SKAMaster): def is_PowerOnDevices_allowed(self): """ - Check if the PowerOnDevice command is allowed in the current + Check if the PowerOnDevice command is allowed in the current state. :raises ``tango.DevFailed`` if command not allowed @@ -615,7 +615,7 @@ class CspSubElementMaster(SKAMaster): def is_PowerOffDevices_allowed(self): """ - Check if the PowerOffDevices command is allowed in the current + Check if the PowerOffDevices command is allowed in the current state. :raises: ``tango.DevFailed`` if command not allowed @@ -653,7 +653,7 @@ class CspSubElementMaster(SKAMaster): def is_ReInitDevices_allowed(self): """ - Check if the ReInitDevices command is allowed in the current + Check if the ReInitDevices command is allowed in the current state. :raises: ``tango.DevFailed`` if command not allowed @@ -674,8 +674,8 @@ class CspSubElementMaster(SKAMaster): # PROTECTED REGION ID(CspSubElementMaster.ReInitDevices) ENABLED START # """ Reinitialize the devices passed in the input argument. - The exact functionality may vary for different devices - and sub-systems, each TANGO Device/Server should define + The exact functionality may vary for different devices + and sub-systems, each TANGO Device/Server should define what does ReInitDevices means. Ex: ReInitDevices FPGA -> reset diff --git a/src/ska/base/csp_subelement_obsdevice.py b/src/ska_tango_base/csp_subelement_obsdevice.py similarity index 97% rename from src/ska/base/csp_subelement_obsdevice.py rename to src/ska_tango_base/csp_subelement_obsdevice.py index fca4b4b9..c378502c 100644 --- a/src/ska/base/csp_subelement_obsdevice.py +++ b/src/ska_tango_base/csp_subelement_obsdevice.py @@ -14,20 +14,21 @@ import warnings import numpy as np from json.decoder import JSONDecodeError -# Tango imports +# Tango imports import tango from tango import DebugIt, DevState, AttrWriteType from tango.server import run, attribute, command, device_property # SKA specific imports -from ska.base import SKAObsDevice, ObsDeviceStateModel -from ska.base.commands import ResultCode, ActionCommand -from ska.base.control_model import ObsState -from ska.base.faults import CommandError -from ska.base.csp_subelement_state_machine import CspSubElementObsDeviceStateMachine +from ska_tango_base import SKAObsDevice, ObsDeviceStateModel +from ska_tango_base.commands import ResultCode, ActionCommand +from ska_tango_base.control_model import ObsState +from ska_tango_base.faults import CommandError +from ska_tango_base.csp_subelement_state_machine import CspSubElementObsDeviceStateMachine __all__ = ["CspSubElementObsDevice", "CspSubElementObsDeviceStateModel", "main"] + class CspSubElementObsDeviceStateModel(ObsDeviceStateModel): """ Implements the state model for the CspSubElementObsDevice. @@ -75,7 +76,7 @@ class CspSubElementObsDeviceStateModel(ObsDeviceStateModel): "obs_reset_succeeded": ("reset_succeeded", None), "obs_reset_failed": ("reset_failed", None), "fatal_error": ("fatal_error", None), - } + } super().__init__( action_breakdown, CspSubElementObsDeviceStateMachine, @@ -85,6 +86,7 @@ class CspSubElementObsDeviceStateModel(ObsDeviceStateModel): obs_state_callback=obs_state_callback, ) + class CspSubElementObsDevice(SKAObsDevice): """ General observing device for SKA CSP Subelement. @@ -163,7 +165,6 @@ class CspSubElementObsDevice(SKAObsDevice): doc="Message providing info about device health failure.", ) - # --------------- # General methods # --------------- @@ -203,7 +204,7 @@ class CspSubElementObsDevice(SKAObsDevice): self.register_command_object( "ObsReset", self.ObsResetCommand(*device_args) ) - + class InitCommand(SKAObsDevice.InitCommand): """ A class for the CspSubElementObsDevice's init_device() "command". @@ -224,10 +225,10 @@ class CspSubElementObsDevice(SKAObsDevice): device._obs_state = ObsState.IDLE device._scan_id = 0 - device._sdp_addresses = {"outputHost":[], "outputMac": [], "outputPort":[]} + device._sdp_addresses = {"outputHost": [], "outputMac": [], "outputPort": []} # a sub-element obsdevice can have more than one link to the SDP # (for ex. Mid.CBF FSP) - device._sdp_links_active = [False,] + device._sdp_links_active = [False, ] device._sdp_links_capacity = 0. device._config_id = '' @@ -259,7 +260,7 @@ class CspSubElementObsDevice(SKAObsDevice): def read_scanID(self): # PROTECTED REGION ID(CspSubElementObsDevice.scanID_read) ENABLED START # """Return the scanID attribute.""" - return self._scan_id + return self._scan_id # PROTECTED REGION END # // CspSubElementObsDevice.scanID_read def read_configurationID(self): @@ -304,16 +305,15 @@ class CspSubElementObsDevice(SKAObsDevice): return self._health_failure_msg # PROTECTED REGION END # // CspSubElementObsDevice.healthFailureMessage_read - # -------- # Commands # -------- - - + class ConfigureScanCommand(ActionCommand): """ A class for the CspSubElementObsDevices's ConfigureScan command. """ + def __init__(self, target, state_model, logger=None): """ Constructor for ConfigureScanCommand @@ -346,7 +346,7 @@ class CspSubElementObsDevice(SKAObsDevice): message indicating status. The message is for information purpose only. :rtype: (ResultCode, str) - :raises: ``CommandError`` if the configuration data validation fails. + :raises: ``CommandError`` if the configuration data validation fails. """ device = self.target # validate the input args @@ -363,20 +363,21 @@ class CspSubElementObsDevice(SKAObsDevice): :param argin: The JSON formatted string with configuration for the device. :type argin: 'DevString' - :return: A tuple containing a return code and a string message. + :return: A tuple containing a return code and a string message. :rtype: (ResultCode, str) """ device = self.target - try: + try: configuration_dict = json.loads(argin) device._config_id = configuration_dict['id'] # call the method to validate the data sent with # the configuration, as needed. return (ResultCode.OK, "ConfigureScan arguments validation successfull") - except (KeyError, JSONDecodeError) as err: + except (KeyError, JSONDecodeError) as err: msg = "Validate configuration failed with error:{}".format(err) except Exception as other_errs: - msg = "Validate configuration failed with unknown error:{}".format(other_errs) + msg = "Validate configuration failed with unknown error:{}".format( + other_errs) self.logger.error(msg) return (ResultCode.FAILED, msg) @@ -384,6 +385,7 @@ class CspSubElementObsDevice(SKAObsDevice): """ A class for the CspSubElementObsDevices's Scan command. """ + def __init__(self, target, state_model, logger=None): """ Constructor for ScanCommand @@ -437,15 +439,16 @@ class CspSubElementObsDevice(SKAObsDevice): :rtype: (ResultCode, str) """ if not argin.isdigit(): - msg = f"Input argument '{argin}' is not an integer" + msg = f"Input argument '{argin}' is not an integer" self.logger.error(msg) return (ResultCode.FAILED, msg) return (ResultCode.OK, "Scan arguments validation successfull") - + class EndScanCommand(ActionCommand): """ A class for the CspSubElementObsDevices's EndScan command. """ + def __init__(self, target, state_model, logger=None): """ Constructor for EndScanCommand @@ -477,11 +480,12 @@ class CspSubElementObsDevice(SKAObsDevice): :rtype: (ResultCode, str) """ return (ResultCode.OK, "EndScan command completed OK") - + class GoToIdleCommand(ActionCommand): """ A class for the CspSubElementObsDevices's GoToIdle command. """ + def __init__(self, target, state_model, logger=None): """ Constructor for GoToIdle Command. @@ -520,11 +524,12 @@ class CspSubElementObsDevice(SKAObsDevice): device._scan_id = 0 device._last_scan_configuration = '' return (ResultCode.OK, "GoToIdle command completed OK") - + class ObsResetCommand(ActionCommand): """ A class for the CspSubElementObsDevices's ObsReset command. """ + def __init__(self, target, state_model, logger=None): """ Constructor for ObsReset Command. @@ -558,12 +563,12 @@ class CspSubElementObsDevice(SKAObsDevice): message = "ObsReset command completed OK" self.logger.info(message) return (ResultCode.OK, message) - class AbortCommand(ActionCommand): """ A class for the CspSubElementObsDevices's Abort command. """ + def __init__(self, target, state_model, logger=None): """ Constructor for Abort Command. @@ -595,7 +600,7 @@ class CspSubElementObsDevice(SKAObsDevice): :rtype: (ResultCode, str) """ return (ResultCode.OK, "Abort command completed OK") - + @command( dtype_in='DevString', doc_in="JSON formatted string with the scan configuration.", diff --git a/src/ska/base/csp_subelement_state_machine.py b/src/ska_tango_base/csp_subelement_state_machine.py similarity index 100% rename from src/ska/base/csp_subelement_state_machine.py rename to src/ska_tango_base/csp_subelement_state_machine.py diff --git a/src/ska/base/csp_subelement_subarray.py b/src/ska_tango_base/csp_subelement_subarray.py similarity index 98% rename from src/ska/base/csp_subelement_subarray.py rename to src/ska_tango_base/csp_subelement_subarray.py index e34dc1e9..a9c1fb00 100644 --- a/src/ska/base/csp_subelement_subarray.py +++ b/src/ska_tango_base/csp_subelement_subarray.py @@ -26,9 +26,9 @@ from tango import AttrQuality, DispLevel, DevState from tango import AttrWriteType, PipeWriteType # SKA import -from ska.base import SKASubarray -from ska.base.commands import ResultCode, ActionCommand -from ska.base.control_model import ObsState +from ska_tango_base import SKASubarray +from ska_tango_base.commands import ResultCode, ActionCommand +from ska_tango_base.control_model import ObsState # Additional import # PROTECTED REGION END # // CspSubElementSubarray.additionnal_import @@ -94,7 +94,7 @@ class CspSubElementSubarray(SKASubarray): label="listOfDevicesCompletedTasks", doc="JSON formatted string reporting for each task/command the list of devices\nthat completed successfully the task.\nEx.\n{``cmd1``: [``device1``, ``device2``], ``cmd2``: [``device2``, ``device3``]}", ) - + configureScanMeasuredDuration = attribute( dtype='DevFloat', label="configureScanMeasuredDuration", @@ -137,7 +137,6 @@ class CspSubElementSubarray(SKASubarray): doc="Flag reporting AssignResources command timeout expiration.", ) - releaseResourcesMaximumDuration = attribute( dtype='DevFloat', access=AttrWriteType.READ_WRITE, @@ -183,7 +182,7 @@ class CspSubElementSubarray(SKASubarray): self.register_command_object( "GoToIdle", self.GoToIdleCommand(*device_args) ) - + class InitCommand(SKASubarray.InitCommand): """ A class for the CspSubElementObsDevice's init_device() "command". @@ -203,38 +202,38 @@ class CspSubElementSubarray(SKASubarray): device = self.target device._scan_id = 0 - device._sdp_addresses = {"outputHost":[], "outputMac": [], "outputPort":[]} - device._sdp_links_active = [False,] + device._sdp_addresses = {"outputHost": [], "outputMac": [], "outputPort": []} + device._sdp_links_active = [False, ] device._sdp_output_data_rate = 0. device._config_id = '' device._last_scan_configuration = '' - + # _list_of_devices_completed_task: for each task/command reports # the list of the devices that successfully completed the task. # Implemented as a defualt dictionary: # keys: the command name in lower case (configurescan, assignresources, etc.) # values: the list of devices' FQDN device._list_of_devices_completed_task = defaultdict(list) - + # _cmd_progress: command execution's progress percentage # implemented as a default dictionary: # keys: the command name in lower case(configurescan,..) # values: the progress percentage (default 0) device._cmd_progress = defaultdict(int) - + # _cmd_maximun_duration: command execution's expected maximum duration (sec.) # implemented as a default dictionary: # keys: the command name in lower case(configurescan, assignresources,..) # values: the expected maximum duration in sec. device._cmd_maximum_duration = defaultdict(float) - # _cmd_measure_duration: command execution's measured duration (sec.) + # _cmd_measure_duration: command execution's measured duration (sec.) # implemented as a default dictionary: # keys: the command name in lower case(configurescan, assignresources,..) # values: the measured execution time (sec.) device._cmd_measured_duration = defaultdict(float) - + # _timeout_expired: boolean flag to signal timeout during command execution. # To check and reset before a command execution. # keys: the command name in lower case(configurescan, assignresources,..) @@ -247,7 +246,6 @@ class CspSubElementSubarray(SKASubarray): device.set_archive_event('assignResourcesTimeoutExpiredFlag', True, True) device.set_change_event('releaseResourcesTimeoutExpiredFlag', True, True) device.set_archive_event('releaseResourcesTimeoutExpiredFlag', True, True) - message = "CspSubElementSubarray Init command completed OK" device.logger.info(message) @@ -267,7 +265,7 @@ class CspSubElementSubarray(SKASubarray): """ # PROTECTED REGION ID(CspSubElementSubarray.delete_device) ENABLED START # # PROTECTED REGION END # // CspSubElementSubarray.delete_device - + # ------------------ # Attributes methods # ------------------ @@ -313,7 +311,7 @@ class CspSubElementSubarray(SKASubarray): """Return the configureScanMeasuredDuration attribute.""" return self._cmd_measured_duration['configurescan'] # PROTECTED REGION END # // CspSubElementSubarray.configureScanMeasuredDuration_read - + def read_configureScanTimeoutExpiredFlag(self): # PROTECTED REGION ID(CspSubElementSubarray.configureScanTimeoutExpiredFlag_read) ENABLED START # """Return the configureScanTimeoutExpiredFlag attribute.""" @@ -380,7 +378,7 @@ class CspSubElementSubarray(SKASubarray): """Return the releaseResourcesProgress attribute.""" return self._cmd_progress['releaseresources'] # PROTECTED REGION END # // CspSubElementSubarray.releaseResourcesProgress_read - + def read_releaseResourcesTimeoutExpiredFlag(self): # PROTECTED REGION ID(CspSubElementSubarray.releaseResourcesTimeoutExpiredFlag_read) ENABLED START # """Return the releaseResourcesTimeoutExpiredFlag attribute.""" @@ -401,6 +399,7 @@ class CspSubElementSubarray(SKASubarray): """ A class for the CspSubElementObsDevices's ConfigureScan command. """ + def __init__(self, target, state_model, logger=None): """ Constructor for ConfigureScanCommand @@ -451,22 +450,23 @@ class CspSubElementSubarray(SKASubarray): :rtype: (ResultCode, str) """ device = self.target - try: + try: configuration_dict = json.loads(argin) device._config_id = configuration_dict['id'] return (ResultCode.OK, "Configuration validated with success") except (KeyError, JSONDecodeError) as err: msg = "Validate configuration failed with error:{}".format(err) except Exception as other_errs: - msg = "Validate configuration failed with unknown error:{}".format(other_errs) + msg = "Validate configuration failed with unknown error:{}".format( + other_errs) self.logger.error(msg) return (ResultCode.FAILED, msg) - class GoToIdleCommand(ActionCommand): """ A class for the CspSubElementObsDevices's GoToIdle command. """ + def __init__(self, target, state_model, logger=None): """ Constructor for GoToIdle Command. @@ -502,7 +502,7 @@ class CspSubElementSubarray(SKASubarray): device._config_id = '' device._scan_id = 0 return (ResultCode.OK, "GoToIdle command completed OK") - + @command( dtype_in='DevString', doc_in="A Json-encoded string with the scan configuration.", @@ -520,7 +520,7 @@ class CspSubElementSubarray(SKASubarray): :type argin: 'DevString' :return: - A tuple containing a return code and a string message indicating status. + A tuple containing a return code and a string message indicating status. The message is for information purpose only. :rtype: (ResultCode, str) """ diff --git a/src/ska/base/faults.py b/src/ska_tango_base/faults.py similarity index 100% rename from src/ska/base/faults.py rename to src/ska_tango_base/faults.py diff --git a/src/ska/base/logger_device.py b/src/ska_tango_base/logger_device.py similarity index 94% rename from src/ska/base/logger_device.py rename to src/ska_tango_base/logger_device.py index 39a57048..17166b97 100644 --- a/src/ska/base/logger_device.py +++ b/src/ska_tango_base/logger_device.py @@ -16,9 +16,9 @@ from tango import DebugIt, DeviceProxy, DevFailed from tango.server import run, command # SKA specific imports -from ska.base import SKABaseDevice -from ska.base.commands import ResponseCommand, ResultCode -from ska.base.control_model import LoggingLevel +from ska_tango_base import SKABaseDevice +from ska_tango_base.commands import ResponseCommand, ResultCode +from ska_tango_base.control_model import LoggingLevel # PROTECTED REGION END # // SKALogger.additionnal_import __all__ = ["SKALogger", "main"] @@ -73,6 +73,7 @@ class SKALogger(SKABaseDevice): """ A class for the SKALoggerDevice's SetLoggingLevel() command. """ + def __init__(self, target, state_model, logger=None): """ Constructor for SetLoggingLevelCommand @@ -111,7 +112,8 @@ class SKALogger(SKABaseDevice): dev_proxy = DeviceProxy(device) dev_proxy.loggingLevel = new_level except DevFailed: - self.logger.exception("Failed to set logging level %s for %s", level, device) + self.logger.exception( + "Failed to set logging level %s for %s", level, device) message = "SetLoggingLevel command completed OK" self.logger.info(message) diff --git a/src/ska/base/master_device.py b/src/ska_tango_base/master_device.py similarity index 96% rename from src/ska/base/master_device.py rename to src/ska_tango_base/master_device.py index a8e0c93a..224f99ee 100644 --- a/src/ska/base/master_device.py +++ b/src/ska_tango_base/master_device.py @@ -15,9 +15,9 @@ from tango import DebugIt from tango.server import run, attribute, command, device_property # SKA specific imports -from ska.base import SKABaseDevice -from ska.base.commands import BaseCommand, ResultCode -from ska.base.utils import validate_capability_types, validate_input_sizes, convert_dict_to_list +from ska_tango_base import SKABaseDevice +from ska_tango_base.commands import BaseCommand, ResultCode +from ska_tango_base.utils import validate_capability_types, validate_input_sizes, convert_dict_to_list # PROTECTED REGION END # // SKAMaster.additionnal_imports @@ -29,6 +29,7 @@ class SKAMaster(SKABaseDevice): """ Master device """ + def init_command_objects(self): """ Sets up the command objects @@ -45,6 +46,7 @@ class SKAMaster(SKABaseDevice): """ A class for the SKAMaster's init_device() "command". """ + def do(self): """ Stateless hook for device initialisation. @@ -68,7 +70,8 @@ class SKAMaster(SKABaseDevice): if device.MaxCapabilities: for max_capability in device.MaxCapabilities: capability_type, max_capability_instances = max_capability.split(":") - device._max_capabilities[capability_type] = int(max_capability_instances) + device._max_capabilities[capability_type] = int( + max_capability_instances) device._available_capabilities = device._max_capabilities.copy() message = "SKAMaster Init command completed OK" @@ -189,6 +192,7 @@ class SKAMaster(SKABaseDevice): """ A class for the SKAMaster's IsCapabilityAchievable() command. """ + def do(self, argin): """ Stateless hook for device IsCapabilityAchievable() command. diff --git a/src/ska/base/obs_device.py b/src/ska_tango_base/obs_device.py similarity index 95% rename from src/ska/base/obs_device.py rename to src/ska_tango_base/obs_device.py index 0b881a27..d936d3bb 100644 --- a/src/ska/base/obs_device.py +++ b/src/ska_tango_base/obs_device.py @@ -20,15 +20,16 @@ from tango import DevState from tango.server import run, attribute # SKA specific imports -from ska.base import SKABaseDevice, DeviceStateModel -from ska.base.commands import ResultCode -from ska.base.control_model import ObsMode, ObsState -from ska.base.faults import StateModelError -from ska.base.utils import for_testing_only +from ska_tango_base import SKABaseDevice, DeviceStateModel +from ska_tango_base.commands import ResultCode +from ska_tango_base.control_model import ObsMode, ObsState +from ska_tango_base.faults import StateModelError +from ska_tango_base.utils import for_testing_only # PROTECTED REGION END # // SKAObsDevice.additionnal_imports __all__ = ["SKAObsDevice", "ObsDeviceStateModel", "main"] + class ObsDeviceStateModel(DeviceStateModel): """ Base class for ObsDevice state models @@ -51,7 +52,7 @@ class ObsDeviceStateModel(DeviceStateModel): :type action_breakdown: dictionary defining actions to be performed on the observation state machine and,as needed, on the device state machine. :param obs_machine_class - :type obs_machine_class: state machine for the observing state of a + :type obs_machine_class: state machine for the observing state of a SKAObsDevice class device. :param logger: the logger to be used by this state model. :type logger: a logger that implements the standard library @@ -214,9 +215,9 @@ class ObsDeviceStateModel(DeviceStateModel): :param op_state: the target operational state (optional) :type op_state: :py:class:`tango.DevState` :param admin_mode: the target admin mode (optional) - :type admin_mode: :py:class:`~ska.base.control_model.AdminMode` + :type admin_mode: :py:class:`~ska_tango_base.control_model.AdminMode` :param obs_state: the target observation state (optional) - :type obs_state: :py:class:`~ska.base.control_model.ObsState` + :type obs_state: :py:class:`~ska_tango_base.control_model.ObsState` """ if obs_state is not None: getattr(self._observation_state_machine, f"to_{obs_state.name}")() @@ -231,6 +232,7 @@ class SKAObsDevice(SKABaseDevice): """ A class for the SKAObsDevice's init_device() "command". """ + def do(self): """ Stateless hook for device initialisation. @@ -300,7 +302,7 @@ class SKAObsDevice(SKABaseDevice): callback :param obs_state: the new obs_state value - :type admin_mode: :py:class:`~ska.base.control_model.ObsState` + :type admin_mode: :py:class:`~ska_tango_base.control_model.ObsState` """ self._obs_state = obs_state self.push_change_event("obsState", obs_state) diff --git a/src/ska/base/release.py b/src/ska_tango_base/release.py similarity index 68% rename from src/ska/base/release.py rename to src/ska_tango_base/release.py index b6f0cc87..19bbf98a 100644 --- a/src/ska/base/release.py +++ b/src/ska_tango_base/release.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- # -# This file is part of the SKA LMC Base Classes project +# This file is part of the SKA Tango Base project # # # -"""Release information for lmc-base-classes Python Package""" +"""Release information for ska_tango_base Python Package""" -name = """lmcbaseclasses""" -version = "0.8.1" +name = """ska_tango_base""" +version = "0.9.0" version_info = version.split(".") description = """A set of generic base devices for SKA Telescope.""" author = "SKA India and SARAO and CSIRO and INAF" diff --git a/src/ska/base/state_machine.py b/src/ska_tango_base/state_machine.py similarity index 100% rename from src/ska/base/state_machine.py rename to src/ska_tango_base/state_machine.py diff --git a/src/ska/base/subarray_device.py b/src/ska_tango_base/subarray_device.py similarity index 99% rename from src/ska/base/subarray_device.py rename to src/ska_tango_base/subarray_device.py index 30f7f65a..2119d27d 100644 --- a/src/ska/base/subarray_device.py +++ b/src/ska_tango_base/subarray_device.py @@ -19,12 +19,12 @@ from tango.server import run, attribute, command from tango.server import device_property # SKA specific imports -from ska.base import SKAObsDevice, ObsDeviceStateModel -from ska.base.commands import ActionCommand, ResultCode -from ska.base.control_model import AdminMode, ObsState -from ska.base.faults import CapabilityValidationError, StateModelError -from ska.base.state_machine import ObservationStateMachine -from ska.base.utils import for_testing_only +from ska_tango_base import SKAObsDevice, ObsDeviceStateModel +from ska_tango_base.commands import ActionCommand, ResultCode +from ska_tango_base.control_model import AdminMode, ObsState +from ska_tango_base.faults import CapabilityValidationError, StateModelError +from ska_tango_base.state_machine import ObservationStateMachine +from ska_tango_base.utils import for_testing_only # PROTECTED REGION END # // SKASubarray.additionnal_imports diff --git a/src/ska/base/tel_state_device.py b/src/ska_tango_base/tel_state_device.py similarity index 97% rename from src/ska/base/tel_state_device.py rename to src/ska_tango_base/tel_state_device.py index c040e37e..98cb6551 100644 --- a/src/ska/base/tel_state_device.py +++ b/src/ska_tango_base/tel_state_device.py @@ -14,7 +14,7 @@ A generic base device for Telescope State for SKA. from tango.server import run, device_property # SKA specific imports -from ska.base import SKABaseDevice +from ska_tango_base import SKABaseDevice # PROTECTED REGION END # // SKATelState.additionnal_imports __all__ = ["SKATelState", "main"] diff --git a/src/ska/base/utils.py b/src/ska_tango_base/utils.py similarity index 99% rename from src/ska/base/utils.py rename to src/ska_tango_base/utils.py index c5fd8408..d33b6fa6 100644 --- a/src/ska/base/utils.py +++ b/src/ska_tango_base/utils.py @@ -16,7 +16,7 @@ from tango import (DeviceProxy, DbDatum, DbDevInfo, AttrQuality, AttrWriteType, Except, ErrSeverity) from tango import DevState from contextlib import contextmanager -from ska.base.faults import GroupDefinitionsError, SKABaseError +from ska_tango_base.faults import GroupDefinitionsError, SKABaseError int_types = {tango._tango.CmdArgType.DevUShort, tango._tango.CmdArgType.DevLong, diff --git a/tests/conftest.py b/tests/conftest.py index eb37d95f..ca3efd3a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,5 @@ """ -A module defining a list of fixtures that are shared across all ska.base tests. +A module defining a list of fixtures that are shared across all ska_tango_base tests. """ from collections import defaultdict import importlib @@ -12,8 +12,8 @@ from transitions import MachineError from tango import DevState, EventType from tango.test_context import DeviceTestContext -from ska.base.control_model import AdminMode, ObsState -from ska.base.faults import StateModelError +from ska_tango_base.control_model import AdminMode, ObsState +from ska_tango_base.faults import StateModelError def pytest_configure(config): @@ -45,7 +45,8 @@ def pytest_generate_tests(metafunc): expected = defaultdict(lambda: None) for transition in spec["transitions"]: triggers.add(transition["trigger"]) - expected[(transition["from"], transition["trigger"])] = states[transition["to"]] + expected[(transition["from"], transition["trigger"]) + ] = states[transition["to"]] test_cases = list(itertools.product(sorted(states), sorted(triggers))) test_ids = [f"{state}-{trigger}" for (state, trigger) in test_cases] @@ -332,6 +333,7 @@ def load_data(name): with open(f"tests/data/{name}.json", "r") as json_file: return json.load(json_file) + def load_state_machine_spec(name): """ Loads a state machine specification by name. @@ -352,6 +354,7 @@ def load_state_machine_spec(name): state_spec["obs_state"] = ObsState[state_spec["obs_state"]] return machine_spec + @pytest.fixture(scope="class") def tango_context(request): """Creates and returns a TANGO DeviceTestContext object. @@ -394,10 +397,11 @@ def tango_context(request): # 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) + module = importlib.import_module("ska_tango_base", class_name) class_type = getattr(module, class_name) - tango_context = DeviceTestContext(class_type, properties=test_properties.get(class_name)) + tango_context = DeviceTestContext( + class_type, properties=test_properties.get(class_name)) tango_context.start() yield tango_context tango_context.stop() @@ -502,7 +506,8 @@ def tango_change_event_helper(tango_context): """ if event_data.err: error = event_data.errors[0] - self._errors.append("Event callback error: [%s] %s" % (error.reason, error.desc)) + self._errors.append( + "Event callback error: [%s] %s" % (error.reason, error.desc)) else: self._values_queue.put(event_data.attr_value.value) diff --git a/tests/test_alarm_handler_device.py b/tests/test_alarm_handler_device.py index b97224d7..9675262b 100644 --- a/tests/test_alarm_handler_device.py +++ b/tests/test_alarm_handler_device.py @@ -90,7 +90,7 @@ class TestSKAAlarmHandler(object): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r'SKAAlarmHandler, lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'SKAAlarmHandler, ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope.') versionInfo = tango_context.device.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None @@ -142,7 +142,7 @@ class TestSKAAlarmHandler(object): """Test for buildState""" # PROTECTED REGION ID(SKAAlarmHandler.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert (re.match(buildPattern, tango_context.device.buildState)) is not None # PROTECTED REGION END # // SKAAlarmHandler.test_buildState diff --git a/tests/test_base_device.py b/tests/test_base_device.py index c0d1b3ee..a2601401 100644 --- a/tests/test_base_device.py +++ b/tests/test_base_device.py @@ -19,12 +19,12 @@ import tango from unittest import mock from tango import DevFailed, DevState -from ska.base import SKABaseDevice -from ska.base.commands import ResultCode -from ska.base.control_model import ( +from ska_tango_base import SKABaseDevice +from ska_tango_base.commands import ResultCode +from ska_tango_base.control_model import ( AdminMode, ControlMode, HealthState, LoggingLevel, SimulationMode, TestMode ) -from ska.base.base_device import ( +from ska_tango_base.base_device import ( _Log4TangoLoggingLevel, _PYTHON_TO_TANGO_LOGGING_LEVEL, LoggingUtils, @@ -32,7 +32,7 @@ from ska.base.base_device import ( DeviceStateModel, TangoLoggingServiceHandler, ) -from ska.base.faults import CommandError +from ska_tango_base.faults import CommandError from .conftest import load_state_machine_spec, ModelStateMachineTester @@ -52,12 +52,12 @@ class TestTangoLoggingServiceHandler: return TangoLoggingServiceHandler(self.tango_logger) @pytest.fixture(params=[ - logging.DEBUG, - logging.INFO, - logging.WARN, - logging.ERROR, - logging.CRITICAL, - ]) + logging.DEBUG, + logging.INFO, + logging.WARN, + logging.ERROR, + logging.CRITICAL, + ]) def python_log_level(self, request): return request.param @@ -73,7 +73,8 @@ class TestTangoLoggingServiceHandler: def test_emit_message_is_formatted(self, tls_handler): # arrange - record = logging.LogRecord('test', logging.INFO, '', 1, 'message %s', ('param',), None) + record = logging.LogRecord('test', logging.INFO, '', 1, + 'message %s', ('param',), None) def format_stub(log_record): return "LOG: " + log_record.getMessage() @@ -113,36 +114,36 @@ class TestTangoLoggingServiceHandler: class TestLoggingUtils: @pytest.fixture(params=[ - (None, []), - ([""], []), - ([" \n\t "], []), - (["console"], ["console::cout"]), - (["console::"], ["console::cout"]), - (["console::cout"], ["console::cout"]), - (["console::anything"], ["console::anything"]), - (["file"], ["file::my_dev_name.log"]), - (["file::"], ["file::my_dev_name.log"]), - (["file::/tmp/dummy"], ["file::/tmp/dummy"]), - (["syslog::some/path"], ["syslog::some/path"]), - (["syslog::file://some/path"], ["syslog::file://some/path"]), - (["syslog::protocol://somehost:1234"], ["syslog::protocol://somehost:1234"]), - (["tango"], ["tango::logger"]), - (["tango::"], ["tango::logger"]), - (["tango::logger"], ["tango::logger"]), - (["tango::anything"], ["tango::anything"]), - (["console", "file"], ["console::cout", "file::my_dev_name.log"]), - ]) + (None, []), + ([""], []), + ([" \n\t "], []), + (["console"], ["console::cout"]), + (["console::"], ["console::cout"]), + (["console::cout"], ["console::cout"]), + (["console::anything"], ["console::anything"]), + (["file"], ["file::my_dev_name.log"]), + (["file::"], ["file::my_dev_name.log"]), + (["file::/tmp/dummy"], ["file::/tmp/dummy"]), + (["syslog::some/path"], ["syslog::some/path"]), + (["syslog::file://some/path"], ["syslog::file://some/path"]), + (["syslog::protocol://somehost:1234"], ["syslog::protocol://somehost:1234"]), + (["tango"], ["tango::logger"]), + (["tango::"], ["tango::logger"]), + (["tango::logger"], ["tango::logger"]), + (["tango::anything"], ["tango::anything"]), + (["console", "file"], ["console::cout", "file::my_dev_name.log"]), + ]) def good_logging_targets(self, request): targets_in, expected = request.param dev_name = "my/dev/name" return targets_in, dev_name, expected @pytest.fixture(params=[ - ["invalid"], - ["invalid", "console"], - ["invalid::type"], - ["syslog"], - ]) + ["invalid"], + ["invalid", "console"], + ["invalid::type"], + ["syslog"], + ]) def bad_logging_targets(self, request): targets_in = request.param dev_name = "my/dev/name" @@ -159,14 +160,15 @@ class TestLoggingUtils: LoggingUtils.sanitise_logging_targets(targets_in, dev_name) @pytest.fixture(params=[ - ("deprecated/path", ["deprecated/path", None]), - ("file:///abs/path", ["/abs/path", None]), - ("file://relative/path", ["relative/path", None]), - ("file://some/spaced%20path", ["some/spaced path", None]), - ("udp://somehost.domain:1234", [("somehost.domain", 1234), socket.SOCK_DGRAM]), - ("udp://127.0.0.1:1234", [("127.0.0.1", 1234), socket.SOCK_DGRAM]), - ("tcp://somehost:1234", [("somehost", 1234), socket.SOCK_STREAM]), - ("tcp://127.0.0.1:1234", [("127.0.0.1", 1234), socket.SOCK_STREAM]), + ("deprecated/path", ["deprecated/path", None]), + ("file:///abs/path", ["/abs/path", None]), + ("file://relative/path", ["relative/path", None]), + ("file://some/spaced%20path", ["some/spaced path", None]), + ("udp://somehost.domain:1234", + [("somehost.domain", 1234), socket.SOCK_DGRAM]), + ("udp://127.0.0.1:1234", [("127.0.0.1", 1234), socket.SOCK_DGRAM]), + ("tcp://somehost:1234", [("somehost", 1234), socket.SOCK_STREAM]), + ("tcp://127.0.0.1:1234", [("127.0.0.1", 1234), socket.SOCK_STREAM]), ]) def good_syslog_url(self, request): url, (expected_address, expected_socktype) = request.param @@ -193,7 +195,8 @@ class TestLoggingUtils: def test_get_syslog_address_and_socktype_success(self, good_syslog_url): url, (expected_address, expected_socktype) = good_syslog_url - actual_address, actual_socktype = LoggingUtils.get_syslog_address_and_socktype(url) + actual_address, actual_socktype = LoggingUtils.get_syslog_address_and_socktype( + url) assert actual_address == expected_address assert actual_socktype == expected_socktype @@ -201,7 +204,7 @@ class TestLoggingUtils: with pytest.raises(LoggingTargetError): LoggingUtils.get_syslog_address_and_socktype(bad_syslog_url) - @mock.patch('ska.base.base_device.TangoLoggingServiceHandler') + @mock.patch('ska_tango_base.base_device.TangoLoggingServiceHandler') @mock.patch('logging.handlers.SysLogHandler') @mock.patch('logging.handlers.RotatingFileHandler') @mock.patch('logging.StreamHandler') @@ -338,7 +341,7 @@ def device_state_model(): @pytest.mark.state_machine_tester(load_state_machine_spec("device_state_machine")) class TestDeviceStateModel(ModelStateMachineTester): """ - This class contains the test suite for the ska.base.SKABaseDevice class. + This class contains the test suite for the ska_tango_base.SKABaseDevice class. """ @pytest.fixture @@ -376,7 +379,7 @@ class TestSKABaseDevice(object): 'SkaLevel': '4', 'GroupDefinitions': '', 'LoggingTargetsDefault': '' - } + } @classmethod def mocking(cls): @@ -422,7 +425,7 @@ class TestSKABaseDevice(object): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKABaseDevice.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r'SKABaseDevice, lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'SKABaseDevice, ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope.') versionInfo = tango_context.device.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None @@ -505,7 +508,7 @@ class TestSKABaseDevice(object): """Test for buildState""" # PROTECTED REGION ID(SKABaseDevice.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert (re.match(buildPattern, tango_context.device.buildState)) is not None # PROTECTED REGION END # // SKABaseDevice.test_buildState @@ -544,7 +547,7 @@ class TestSKABaseDevice(object): assert tango_context.device.loggingTargets == ("tango::logger", ) with mock.patch( - "ska.base.base_device.LoggingUtils.create_logging_handler" + "ska_tango_base.base_device.LoggingUtils.create_logging_handler" ) as mocked_creator: def null_creator(target, tango_logger): @@ -646,6 +649,7 @@ class TestSKABaseDevice(object): assert tango_context.device.testMode == TestMode.NONE # PROTECTED REGION END # // SKABaseDevice.test_testMode + class TestSKABaseDevice_commands: """ This class contains tests of SKASubarray commands diff --git a/tests/test_capability_device.py b/tests/test_capability_device.py index a837f553..6c982093 100644 --- a/tests/test_capability_device.py +++ b/tests/test_capability_device.py @@ -88,7 +88,7 @@ class TestSKACapability(object): """Test for buildState""" # PROTECTED REGION ID(SKACapability.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert (re.match(buildPattern, tango_context.device.buildState)) is not None # PROTECTED REGION END # // SKACapability.test_buildState diff --git a/tests/test_csp_subelement_master.py b/tests/test_csp_subelement_master.py index be648a7b..6ffaf7ea 100644 --- a/tests/test_csp_subelement_master.py +++ b/tests/test_csp_subelement_master.py @@ -16,10 +16,10 @@ from tango import DevState, DevFailed from tango.test_context import MultiDeviceTestContext # PROTECTED REGION ID(CspSubelementMaster.test_additional_imports) ENABLED START # -from ska.base import SKAMaster, CspSubElementMaster -from ska.base.commands import ResultCode -from ska.base.faults import CommandError -from ska.base.control_model import ( +from ska_tango_base import SKAMaster, CspSubElementMaster +from ska_tango_base.commands import ResultCode +from ska_tango_base.faults import CommandError +from ska_tango_base.control_model import ( AdminMode, ControlMode, HealthState, SimulationMode, TestMode ) # PROTECTED REGION END # // CspSubElementMaster.test_additional_imports @@ -37,7 +37,7 @@ class TestCspSubElementMaster(object): 'GroupDefinitions': '', 'PowerDelayStandbyOn': 1.5, 'PowerDelayStandbyOff': 1.0, - } + } @classmethod def mocking(cls): @@ -75,7 +75,7 @@ class TestCspSubElementMaster(object): """Test for GetVersionInfo""" # PROTECTED REGION ID(CspSubelementMaster.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r'CspSubElementMaster, lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'CspSubElementMaster, ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope.') versionInfo = tango_context.device.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None @@ -86,7 +86,7 @@ class TestCspSubElementMaster(object): """Test for buildState""" # PROTECTED REGION ID(CspSubelementMaster.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert (re.match(buildPattern, tango_context.device.buildState)) is not None # PROTECTED REGION END # // CspSubelementMaster.test_buildState @@ -267,7 +267,7 @@ class TestCspSubElementMaster(object): # PROTECTED REGION ID(CspSubelementMaster.test_LoadFirmware) ENABLED START # # After initialization the device is in the right state (OFF/MAINTENANCE) to # execute the command. - assert tango_context.device.LoadFirmware(['file', 'test/dev/b','918698a7fea3']) == [ + assert tango_context.device.LoadFirmware(['file', 'test/dev/b', '918698a7fea3']) == [ [ResultCode.OK], ["LoadFirmware command completed OK"] ] # PROTECTED REGION END # // CspSubelementMaster.test_LoadFirmware @@ -283,7 +283,7 @@ class TestCspSubElementMaster(object): tango_context.device.Off() tango_context.device.On() with pytest.raises(DevFailed) as df: - tango_context.device.LoadFirmware(['file', 'test/dev/b','918698a7fea3']) + tango_context.device.LoadFirmware(['file', 'test/dev/b', '918698a7fea3']) assert "LoadFirmwareCommand not allowed" in str(df.value.args[0].desc) # PROTECTED REGION END # // CspSubelementMaster.test_LoadFirmware_when_in_wrong_state diff --git a/tests/test_csp_subelement_obsdev_state_machine.py b/tests/test_csp_subelement_obsdev_state_machine.py index 894aeb22..77df307c 100644 --- a/tests/test_csp_subelement_obsdev_state_machine.py +++ b/tests/test_csp_subelement_obsdev_state_machine.py @@ -1,10 +1,10 @@ """ -Module to test the transitions of a CSP SubElement ObsDevice -(ska.base.csp_subelement_obsdev_state_machine module). +Module to test the transitions of a CSP SubElement ObsDevice +(ska_tango_base.csp_subelement_obsdev_state_machine module). """ import pytest -from ska.base.csp_subelement_state_machine import ( +from ska_tango_base.csp_subelement_state_machine import ( CspSubElementObsDeviceStateMachine, ) from .conftest import load_state_machine_spec, TransitionsStateMachineTester diff --git a/tests/test_csp_subelement_obsdevice.py b/tests/test_csp_subelement_obsdevice.py index 66d88277..971a7f44 100644 --- a/tests/test_csp_subelement_obsdevice.py +++ b/tests/test_csp_subelement_obsdevice.py @@ -19,9 +19,9 @@ from tango import DevState, DevFailed from tango.test_context import MultiDeviceTestContext # PROTECTED REGION ID(CspSubelementObsDevice.test_additional_imports) ENABLED START # -from ska.base import SKAObsDevice, CspSubElementObsDevice, CspSubElementObsDeviceStateModel -from ska.base.commands import ResultCode -from ska.base.control_model import ( +from ska_tango_base import SKAObsDevice, CspSubElementObsDevice, CspSubElementObsDeviceStateModel +from ska_tango_base.commands import ResultCode +from ska_tango_base.control_model import ( ObsState, AdminMode, ControlMode, HealthState, SimulationMode, TestMode ) from .conftest import load_state_machine_spec, ModelStateMachineTester @@ -39,6 +39,7 @@ def csp_subelement_obsdevice_state_model(): """ yield CspSubElementObsDeviceStateModel(logging.getLogger()) + @pytest.mark.state_machine_tester(load_state_machine_spec("csp_subelement_obsdevice_state_machine")) class TestCspSubElementObsDeviceStateModel(ModelStateMachineTester): """ @@ -68,6 +69,7 @@ class TestCspSubElementObsDeviceStateModel(ModelStateMachineTester): assert machine.op_state == state["op_state"] assert machine.obs_state == state["obs_state"] + class TestCspSubElementObsDevice(object): """Test case for CSP SubElement ObsDevice class.""" @@ -76,7 +78,7 @@ class TestCspSubElementObsDevice(object): 'LoggingTargetsDefault': '', 'GroupDefinitions': '', 'DeviceID': 11, - } + } # PROTECTED REGION ID(CspSubelementObsDevice.test_State_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_State_decorators @@ -100,7 +102,7 @@ class TestCspSubElementObsDevice(object): """Test for GetVersionInfo""" # PROTECTED REGION ID(CspSubelementObsDevice.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r'CspSubElementObsDevice, lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'CspSubElementObsDevice, ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope.') versionInfo = tango_context.device.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None @@ -112,7 +114,7 @@ class TestCspSubElementObsDevice(object): """Test for buildState""" # PROTECTED REGION ID(CspSubelementObsDevice.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert (re.match(buildPattern, tango_context.device.buildState)) is not None # PROTECTED REGION END # // CspSubelementObsDevice.test_buildState @@ -198,7 +200,7 @@ class TestCspSubElementObsDevice(object): # PROTECTED REGION ID(CspSubelementObsDevice.test_sdpLinkActive) ENABLED START # actual = tango_context.device.sdpLinkActive n_links = len(actual) - expected = [ False for i in range(0, n_links)] + expected = [False for i in range(0, n_links)] assert all([a == b for a, b in zip(actual, expected)]) # PROTECTED REGION END # // CspSubelementObsDevice.test_sdpLinkActive @@ -240,7 +242,8 @@ class TestCspSubElementObsDevice(object): # The device in in OFF/IDLE state, not valid to invoke ConfigureScan. with pytest.raises(DevFailed) as df: tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') - assert "Error executing command ConfigureScanCommand" in str(df.value.args[0].desc) + assert "Error executing command ConfigureScanCommand" in str( + df.value.args[0].desc) # PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_when_in_wrong_state # PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_decorators) ENABLED START # @@ -275,7 +278,8 @@ class TestCspSubElementObsDevice(object): tango_context.device.On() obs_state_callback = tango_change_event_helper.subscribe("obsState") tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') - obs_state_callback.assert_calls([ObsState.IDLE,ObsState.CONFIGURING, ObsState.READY]) + obs_state_callback.assert_calls( + [ObsState.IDLE, ObsState.CONFIGURING, ObsState.READY]) tango_context.device.GoToIdle() obs_state_callback.assert_call(ObsState.IDLE) assert tango_context.device.scanID == 0 @@ -394,7 +398,8 @@ class TestCspSubElementObsDevice(object): tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') obs_state_callback = tango_change_event_helper.subscribe("obsState") tango_context.device.Abort() - obs_state_callback.assert_calls([ObsState.READY, ObsState.ABORTING, ObsState.ABORTED]) + obs_state_callback.assert_calls( + [ObsState.READY, ObsState.ABORTING, ObsState.ABORTED]) # PROTECTED REGION END # // CspSubelementObsDevice.test_Abort # PROTECTED REGION ID(CspSubelementObsDevice.test_Abort_when_in_wrong_state_decorators) ENABLED START # diff --git a/tests/test_csp_subelement_subarray.py b/tests/test_csp_subelement_subarray.py index 6ee89588..1418a888 100644 --- a/tests/test_csp_subelement_subarray.py +++ b/tests/test_csp_subelement_subarray.py @@ -18,10 +18,10 @@ import json from tango import DevState, DevFailed # PROTECTED REGION ID(CspSubelementSubarray.test_additional_imports) ENABLED START # -from ska.base import SKASubarray, CspSubElementSubarray -from ska.base.commands import ResultCode -from ska.base.faults import StateModelError -from ska.base.control_model import ( +from ska_tango_base import SKASubarray, CspSubElementSubarray +from ska_tango_base.commands import ResultCode +from ska_tango_base.faults import StateModelError +from ska_tango_base.control_model import ( ObsState, AdminMode, ControlMode, HealthState, SimulationMode, TestMode ) from .conftest import load_state_machine_spec, StateMachineTester @@ -39,7 +39,7 @@ class TestCspSubElementSubarray(object): 'SkaLevel': '4', 'LoggingTargetsDefault': '', 'GroupDefinitions': '', - } + } @classmethod def mocking(cls): @@ -78,7 +78,7 @@ class TestCspSubElementSubarray(object): """Test for GetVersionInfo""" # PROTECTED REGION ID(CspSubelementSubarray.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r'CspSubElementSubarray, lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'CspSubElementSubarray, ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope.') versionInfo = tango_context.device.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None @@ -89,7 +89,7 @@ class TestCspSubElementSubarray(object): """Test for buildState""" # PROTECTED REGION ID(CspSubelementSubarray.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert (re.match(buildPattern, tango_context.device.buildState)) is not None # PROTECTED REGION END # // CspSubelementSubarray.test_buildState @@ -168,7 +168,7 @@ class TestCspSubElementSubarray(object): # PROTECTED REGION ID(CspSubelementSubarray.test_sdpLinkActive) ENABLED START # actual = tango_context.device.sdpLinkActive n_links = len(actual) - expected = [ False for i in range(0, n_links)] + expected = [False for i in range(0, n_links)] assert all([a == b for a, b in zip(actual, expected)]) # PROTECTED REGION END # // CspSubelementSubarray.test_sdpLinkActive @@ -293,7 +293,7 @@ class TestCspSubElementSubarray(object): obs_state_callback = tango_change_event_helper.subscribe("obsState") scan_configuration = '{"id":"sbi-mvp01-20200325-00002"}' tango_context.device.command_inout(command_alias, (scan_configuration)) - obs_state_callback.assert_calls([ObsState.IDLE,ObsState.CONFIGURING]) + obs_state_callback.assert_calls([ObsState.IDLE, ObsState.CONFIGURING]) assert tango_context.device.configurationID == "sbi-mvp01-20200325-00002" assert tango_context.device.lastScanConfiguration == scan_configuration # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan @@ -311,7 +311,7 @@ class TestCspSubElementSubarray(object): # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_with_wrong_configId_key_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan_with_wrong_configId_key_decorators def test_ConfigureScan_with_wrong_configId_key(self, tango_context): - """Test for ConfigureScan when json configuration specifies a wrong key for + """Test for ConfigureScan when json configuration specifies a wrong key for configuration ID """ # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_with_wrong_configId_key) ENABLED START # @@ -344,7 +344,8 @@ class TestCspSubElementSubarray(object): tango_context.device.AssignResources('{"example": [1,2,3]}') obs_state_callback = tango_change_event_helper.subscribe("obsState") tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') - obs_state_callback.assert_calls([ObsState.IDLE,ObsState.CONFIGURING, ObsState.READY]) + obs_state_callback.assert_calls( + [ObsState.IDLE, ObsState.CONFIGURING, ObsState.READY]) tango_context.device.command_inout(command_alias) obs_state_callback.assert_call(ObsState.IDLE) assert tango_context.device.scanID == 0 diff --git a/tests/test_logger_device.py b/tests/test_logger_device.py index 1bc03dbd..25692aff 100644 --- a/tests/test_logger_device.py +++ b/tests/test_logger_device.py @@ -12,12 +12,12 @@ import re import pytest from tango import DevState from tango.test_context import MultiDeviceTestContext -from ska.base.logger_device import SKALogger -from ska.base.subarray_device import SKASubarray +from ska_tango_base.logger_device import SKALogger +from ska_tango_base.subarray_device import SKASubarray import tango # PROTECTED REGION ID(SKALogger.test_additional_imports) ENABLED START # -from ska.base.control_model import ( +from ska_tango_base.control_model import ( AdminMode, ControlMode, HealthState, @@ -76,7 +76,7 @@ class TestSKALogger(object): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKALogger.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r"SKALogger, lmcbaseclasses, [0-9].[0-9].[0-9], " + r"SKALogger, ska_tango_base, [0-9].[0-9].[0-9], " r"A set of generic base devices for SKA Telescope." ) versionInfo = tango_context.device.GetVersionInfo() @@ -89,7 +89,7 @@ class TestSKALogger(object): """Test for buildState""" # PROTECTED REGION ID(SKALogger.test_buildState) ENABLED START # buildPattern = re.compile( - r"lmcbaseclasses, [0-9].[0-9].[0-9], " + r"ska_tango_base, [0-9].[0-9].[0-9], " r"A set of generic base devices for SKA Telescope" ) assert (re.match(buildPattern, tango_context.device.buildState)) is not None diff --git a/tests/test_master_device.py b/tests/test_master_device.py index c775e4b9..30e3b7cf 100644 --- a/tests/test_master_device.py +++ b/tests/test_master_device.py @@ -13,7 +13,7 @@ import pytest from tango import DevState # PROTECTED REGION ID(SKAMaster.test_additional_imports) ENABLED START # -from ska.base.control_model import AdminMode, ControlMode, HealthState, SimulationMode, TestMode +from ska_tango_base.control_model import AdminMode, ControlMode, HealthState, SimulationMode, TestMode # PROTECTED REGION END # // SKAMaster.test_additional_imports @@ -31,7 +31,7 @@ class TestSKAMaster(object): 'NrSubarrays': '16', 'CapabilityTypes': '', 'MaxCapabilities': 'BAND1:1' - } + } @classmethod def mocking(cls): @@ -69,7 +69,7 @@ class TestSKAMaster(object): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKAMaster.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r'SKAMaster, lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'SKAMaster, ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope.') versionInfo = tango_context.device.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None @@ -129,7 +129,7 @@ class TestSKAMaster(object): """Test for buildState""" # PROTECTED REGION ID(SKAMaster.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert ( re.match(buildPattern, tango_context.device.buildState) diff --git a/tests/test_obs_device.py b/tests/test_obs_device.py index 0043ed07..d6d8cbfa 100644 --- a/tests/test_obs_device.py +++ b/tests/test_obs_device.py @@ -16,8 +16,8 @@ from tango import DevState from tango.test_context import MultiDeviceTestContext # PROTECTED REGION ID(SKAObsDevice.test_additional_imports) ENABLED START # -from ska.base import SKABaseDevice, SKAObsDevice -from ska.base.control_model import ( +from ska_tango_base import SKABaseDevice, SKAObsDevice +from ska_tango_base.control_model import ( AdminMode, ControlMode, HealthState, ObsMode, ObsState, SimulationMode, TestMode ) # PROTECTED REGION END # // SKAObsDevice.test_additional_imports @@ -34,7 +34,7 @@ class TestSKAObsDevice(object): 'SkaLevel': '4', 'LoggingTargetsDefault': '', 'GroupDefinitions': '', - } + } @classmethod def mocking(cls): @@ -72,7 +72,7 @@ class TestSKAObsDevice(object): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKAObsDevice.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r'SKAObsDevice, lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'SKAObsDevice, ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope.') versionInfo = tango_context.device.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None @@ -121,7 +121,7 @@ class TestSKAObsDevice(object): """Test for buildState""" # PROTECTED REGION ID(SKAObsDevice.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert (re.match(buildPattern, tango_context.device.buildState)) is not None # PROTECTED REGION END # // SKAObsDevice.test_buildState diff --git a/tests/test_state_machines.py b/tests/test_state_machines.py index dfa9208f..8eaa2aee 100644 --- a/tests/test_state_machines.py +++ b/tests/test_state_machines.py @@ -1,9 +1,9 @@ """ -This module contains the tests for the ska.base.state_machine module. +This module contains the tests for the ska_tango_base.state_machine module. """ import pytest -from ska.base.state_machine import ( +from ska_tango_base.state_machine import ( AdminModeStateMachine, OperationStateMachine, ObservationStateMachine, diff --git a/tests/test_subarray_device.py b/tests/test_subarray_device.py index 6411c2ba..9c817363 100644 --- a/tests/test_subarray_device.py +++ b/tests/test_subarray_device.py @@ -15,9 +15,9 @@ import pytest from tango import DevState, DevFailed # PROTECTED REGION ID(SKASubarray.test_additional_imports) ENABLED START # -from ska.base import SKASubarray, SKASubarrayResourceManager, SKASubarrayStateModel -from ska.base.commands import ResultCode -from ska.base.control_model import ( +from ska_tango_base import SKASubarray, SKASubarrayResourceManager, SKASubarrayStateModel +from ska_tango_base.commands import ResultCode +from ska_tango_base.control_model import ( AdminMode, ControlMode, HealthState, @@ -26,7 +26,7 @@ from ska.base.control_model import ( SimulationMode, TestMode, ) -from ska.base.faults import CommandError +from ska_tango_base.faults import CommandError from .conftest import load_state_machine_spec, ModelStateMachineTester @@ -146,7 +146,7 @@ class TestSKASubarray: """Test for GetVersionInfo""" # PROTECTED REGION ID(SKASubarray.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r'SKASubarray, lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'SKASubarray, ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope.') versionInfo = tango_context.device.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None @@ -359,7 +359,7 @@ class TestSKASubarray: """Test for buildState""" # PROTECTED REGION ID(SKASubarray.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert (re.match(buildPattern, tango_context.device.buildState)) is not None # PROTECTED REGION END # // SKASubarray.test_buildState diff --git a/tests/test_tel_state_device.py b/tests/test_tel_state_device.py index a5c5361f..0e3b719c 100644 --- a/tests/test_tel_state_device.py +++ b/tests/test_tel_state_device.py @@ -13,7 +13,7 @@ import pytest from tango import DevState # PROTECTED REGION ID(SKATelState.test_additional_imports) ENABLED START # -from ska.base.control_model import AdminMode, ControlMode, HealthState, SimulationMode, TestMode +from ska_tango_base.control_model import AdminMode, ControlMode, HealthState, SimulationMode, TestMode # PROTECTED REGION END # // SKATelState.test_additional_imports @@ -28,7 +28,7 @@ class TestSKATelState(object): 'SkaLevel': '4', 'GroupDefinitions': '', 'LoggingTargetsDefault': '', - } + } @classmethod def mocking(cls): @@ -66,7 +66,7 @@ class TestSKATelState(object): """Test for GetVersionInfo""" # PROTECTED REGION ID(SKATelState.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - r'SKATelState, lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'SKATelState, ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope.') versionInfo = tango_context.device.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None @@ -78,7 +78,7 @@ class TestSKATelState(object): """Test for buildState""" # PROTECTED REGION ID(SKATelState.test_buildState) ENABLED START # buildPattern = re.compile( - r'lmcbaseclasses, [0-9].[0-9].[0-9], ' + r'ska_tango_base, [0-9].[0-9].[0-9], ' r'A set of generic base devices for SKA Telescope') assert (re.match(buildPattern, tango_context.device.buildState)) is not None # PROTECTED REGION END # // SKATelState.test_buildState diff --git a/tests/test_utils.py b/tests/test_utils.py index f4048127..fecd8fd4 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,7 +3,7 @@ from contextlib import nullcontext import json import pytest -from ska.base.utils import ( +from ska_tango_base.utils import ( get_groups_from_json, get_tango_device_type_id, GroupDefinitionsError, @@ -34,14 +34,14 @@ TEST_GROUPS = { 'subgroups': [ {'group_name': 'racks', 'subgroups': [ - {'group_name': 'rackA', - 'devices': ['dc1/server/1', 'dc1/server/2', - 'dc1/switch/A', 'dc1/pdu/rackA']}, - {'group_name': 'rackB', - 'devices': ['dc1/server/3', 'dc1/server/4', - 'dc1/switch/B', 'dc1/pdu/rackB'], - 'subgroups': []}, - ]}, + {'group_name': 'rackA', + 'devices': ['dc1/server/1', 'dc1/server/2', + 'dc1/switch/A', 'dc1/pdu/rackA']}, + {'group_name': 'rackB', + 'devices': ['dc1/server/3', 'dc1/server/4', + 'dc1/switch/B', 'dc1/pdu/rackB'], + 'subgroups': []}, + ]}, ] }, -- GitLab