Skip to content
Snippets Groups Projects
Commit 14ff4f1b authored by Anton Joubert's avatar Anton Joubert
Browse files

Merge branch 'move-obsdevice-vars-to-init_device' into 'master'

Move ObsDevice vars to init device (and fix Docker build)

See merge request ska-telescope/lmc-base-classes!14
parents 4cddb0f9 5d3ced38
No related branches found
No related tags found
No related merge requests found
...@@ -26,11 +26,6 @@ stages: ...@@ -26,11 +26,6 @@ stages:
- pages - pages
- release - release
.install_pip: &install_pip |-
apt-get -y update && apt-get install -yq curl python3-distutils
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py
clean shell runner: clean shell runner:
stage: .pre stage: .pre
tags: tags:
...@@ -44,7 +39,7 @@ build wheel for publication: # Executed on a tag ...@@ -44,7 +39,7 @@ build wheel for publication: # Executed on a tag
tags: tags:
- docker-executor - docker-executor
script: script:
- python setup.py egg_info -b+$CI_COMMIT_SHORT_SHA sdist bdist_wheel - python3 setup.py egg_info -b+$CI_COMMIT_SHORT_SHA sdist bdist_wheel
only: only:
- tags - tags
artifacts: artifacts:
...@@ -56,7 +51,7 @@ build wheel for development: # Executed on a commit ...@@ -56,7 +51,7 @@ build wheel for development: # Executed on a commit
tags: tags:
- docker-executor - docker-executor
script: script:
- python setup.py egg_info -b+dev.$CI_COMMIT_SHORT_SHA sdist bdist_wheel - python3 setup.py egg_info -b+dev.$CI_COMMIT_SHORT_SHA sdist bdist_wheel
except: except:
- tags - tags
artifacts: artifacts:
...@@ -68,12 +63,11 @@ unit tests: ...@@ -68,12 +63,11 @@ unit tests:
image: nexus.engageska-portugal.pt/ska-docker/tango-builder:latest image: nexus.engageska-portugal.pt/ska-docker/tango-builder:latest
before_script: before_script:
- docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY_HOST - docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY_HOST
- *install_pip
tags: tags:
- docker-executor - docker-executor
script: script:
- echo $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) - echo $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA)
- pip3 install -U $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple - python3 -m pip install -U $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple
- make test - make test
- scripts/validate-metadata.sh - scripts/validate-metadata.sh
artifacts: artifacts:
...@@ -85,12 +79,11 @@ linting: ...@@ -85,12 +79,11 @@ linting:
image: nexus.engageska-portugal.pt/ska-docker/tango-builder:latest image: nexus.engageska-portugal.pt/ska-docker/tango-builder:latest
before_script: before_script:
- docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY_HOST - docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY_HOST
- *install_pip
tags: tags:
- docker-executor - docker-executor
script: script:
- echo $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) - echo $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA)
- pip3 install -U $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple - python3 -m pip install -U $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple
- make lint - make lint
artifacts: artifacts:
paths: paths:
...@@ -106,7 +99,7 @@ publish to nexus: ...@@ -106,7 +99,7 @@ publish to nexus:
script: script:
# check metadata requirements # check metadata requirements
- scripts/validate-metadata.sh - scripts/validate-metadata.sh
- pip install twine - python3 -m pip install twine
- twine upload --repository-url $PYPI_REPOSITORY_URL dist/* - twine upload --repository-url $PYPI_REPOSITORY_URL dist/*
only: only:
variables: variables:
......
release=0.4.0 release=0.4.1
tag=lmcbaseclasses-0.4.0 tag=lmcbaseclasses-0.4.1
# Use SKA python image as base image # Use SKA python image as base image
FROM nexus.engageska-portugal.pt/ska-docker/ska-python-buildenv:latest AS buildenv FROM nexus.engageska-portugal.pt/ska-docker/ska-python-buildenv:9.3.1 AS buildenv
FROM nexus.engageska-portugal.pt/ska-docker/ska-python-runtime:latest AS runtime FROM nexus.engageska-portugal.pt/ska-docker/ska-python-runtime:9.3.1 AS runtime
# create ipython profile to so that itango doesn't fail if ipython hasn't run yet # create ipython profile to so that itango doesn't fail if ipython hasn't run yet
RUN ipython profile create RUN ipython profile create
# A temporary workaround until system team can investigate why 'pipenv install -e .' doesn't work # Note: working dir is `/app` which will have a copy of our repo
RUN pip install -e . --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple RUN python3 -m pip install -e . --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple
CMD ["/venv/bin/python", "/app/skabase/SKABaseDevice/SKABaseDevice.py"] CMD ["python3", "/app/skabase/SKABaseDevice/SKABaseDevice.py"]
...@@ -25,6 +25,12 @@ The lmc-base-classe repository contains set of eight classes as mentioned in SKA ...@@ -25,6 +25,12 @@ The lmc-base-classe repository contains set of eight classes as mentioned in SKA
## Version History ## Version History
#### 0.4.1
- Fix lost properties when re-initialising test device (remove `get_name` mock).
- Fix Sphinx doc building.
- Move `ObsDevice` variable initialisation from `__init__` to `init_device`.
- Run scripts with `python3` instead of `python` and update pip usage.
#### 0.4.0 #### 0.4.0
- Changed all `DevEnum` attributes to use Python `enum.IntEnum` classes. These can be imported from the - Changed all `DevEnum` attributes to use Python `enum.IntEnum` classes. These can be imported from the
new `control_model` namespace, e.g., `skabase.control_model import AdminMode`. new `control_model` namespace, e.g., `skabase.control_model import AdminMode`.
...@@ -94,7 +100,7 @@ The requirements for testing are: ...@@ -94,7 +100,7 @@ The requirements for testing are:
### Installation steps ### Installation steps
1. Clone the repository on local machine. 1. Clone the repository on local machine.
2. Navigate to the root directory of the repository from terminal 2. Navigate to the root directory of the repository from terminal
3. Run 'pip3 install . --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple' 3. Run 'python3 -m pip install . --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple'
## Testing ## Testing
The LMC base classes can be tested locally my invoking *make CI_JOB_ID=some_id test* command. The LMC base classes can be tested locally my invoking *make CI_JOB_ID=some_id test* command.
......
...@@ -2,37 +2,37 @@ ...@@ -2,37 +2,37 @@
# PACKAGE METADATA # PACKAGE METADATA
# ---------------- # ----------------
if [[ $(python setup.py --name) == "UNKNOWN" ]] ; then if [[ $(python3 setup.py --name) == "UNKNOWN" ]] ; then
echo "[error] metadata: name missing" echo "[error] metadata: name missing"
exit 2 exit 2
fi fi
if [[ $(python setup.py --version) == "0.0.0" ]] ; then if [[ $(python3 setup.py --version) == "0.0.0" ]] ; then
echo "[error] metadata: version missing" echo "[error] metadata: version missing"
exit 2 exit 2
fi fi
if ! python setup.py --version | grep -q -E '^([0-9]+)\.([0-9]+)\.([0-9]+)$' ; then if ! python3 setup.py --version | grep -q -E '^([0-9]+)\.([0-9]+)\.([0-9]+)$' ; then
echo "[error] metadata: version is not according to versioning standards" echo "[error] metadata: version is not according to versioning standards"
exit 2 exit 2
fi fi
if [[ $(python setup.py --url) == "UNKNOWN" ]] ; then if [[ $(python3 setup.py --url) == "UNKNOWN" ]] ; then
echo "[error] metadata: url missing" echo "[error] metadata: url missing"
exit 2 exit 2
fi fi
if [[ $(python setup.py --license) == "UNKNOWN" ]] ; then if [[ $(python3 setup.py --license) == "UNKNOWN" ]] ; then
echo "[error] metadata: license missing" echo "[error] metadata: license missing"
exit 2 exit 2
fi fi
if [[ $(python setup.py --description) == "UNKNOWN" ]] ; then if [[ $(python3 setup.py --description) == "UNKNOWN" ]] ; then
echo "[error] metadata: description missing" echo "[error] metadata: description missing"
exit 2 exit 2
fi fi
if ! [[ $(python setup.py --classifiers) ]] ; then if ! [[ $(python3 setup.py --classifiers) ]] ; then
echo "[error] metadata: classifiers missing" echo "[error] metadata: classifiers missing"
exit 2 exit 2
fi fi
...@@ -42,8 +42,8 @@ echo "[info] metadata: all required tags present" ...@@ -42,8 +42,8 @@ echo "[info] metadata: all required tags present"
# CONFIRM TAG VERSION # CONFIRM TAG VERSION
# ------------------- # -------------------
if [ -n "$CI_COMMIT_TAG" ]; then if [ -n "$CI_COMMIT_TAG" ]; then
if [[ $(python setup.py --version) != $CI_COMMIT_TAG ]] ; then if [[ $(python3 setup.py --version) != $CI_COMMIT_TAG ]] ; then
echo "[error] metadata: python package version [$(python setup.py --version)] differs from git tag version [$CI_COMMIT_TAG]" echo "[error] metadata: python package version [$(python3 setup.py --version)] differs from git tag version [$CI_COMMIT_TAG]"
exit 2 exit 2
fi fi
fi fi
...@@ -22,10 +22,6 @@ setuptools.setup( ...@@ -22,10 +22,6 @@ setuptools.setup(
license=license, license=license,
packages=setuptools.find_packages(), packages=setuptools.find_packages(),
include_package_data=True, include_package_data=True,
scripts=["scripts/gen_csv_info.py",
"scripts/purge_xmi_tree.py",
"scripts/elt_ctl.py",
],
url='https://www.skatelescope.org/', url='https://www.skatelescope.org/',
classifiers=[ classifiers=[
"Development Status :: 3 - Alpha", "Development Status :: 3 - Alpha",
...@@ -41,5 +37,11 @@ setuptools.setup( ...@@ -41,5 +37,11 @@ setuptools.setup(
"future", "future",
"ska_logging >= 0.2.0" "ska_logging >= 0.2.0"
], ],
tests_require=[
"pytest",
"coverage",
"pytest-json-report",
"pytest-forked",
],
keywords="lmc base classes ska", keywords="lmc base classes ska",
zip_safe=False) zip_safe=False)
...@@ -623,14 +623,14 @@ class SKABaseDevice(Device): ...@@ -623,14 +623,14 @@ class SKABaseDevice(Device):
# Commands # Commands
# -------- # --------
@command(dtype_out=('str',), doc_out="[ name: EltTelState ]",) @command(dtype_out=('str',), doc_out="Version strings",)
@DebugIt() @DebugIt()
def GetVersionInfo(self): def GetVersionInfo(self):
# PROTECTED REGION ID(SKABaseDevice.GetVersionInfo) ENABLED START # # PROTECTED REGION ID(SKABaseDevice.GetVersionInfo) ENABLED START #
""" """
Returns the version information of the device. Returns the version information of the device.
:return: Version version details of the device. :return: Version details of the device.
""" """
return ['{}, {}'.format(self.__class__.__name__, self.read_buildState())] return ['{}, {}'.format(self.__class__.__name__, self.read_buildState())]
# PROTECTED REGION END # // SKABaseDevice.GetVersionInfo # PROTECTED REGION END # // SKABaseDevice.GetVersionInfo
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<argin description=""> <argin description="">
<type xsi:type="pogoDsl:VoidType"/> <type xsi:type="pogoDsl:VoidType"/>
</argin> </argin>
<argout description="[ name: EltTelState ]"> <argout description="Version strings">
<type xsi:type="pogoDsl:StringArrayType"/> <type xsi:type="pogoDsl:StringArrayType"/>
</argout> </argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
......
...@@ -37,18 +37,6 @@ class SKAObsDevice(SKABaseDevice): ...@@ -37,18 +37,6 @@ class SKAObsDevice(SKABaseDevice):
A generic base device for Observations for SKA. A generic base device for Observations for SKA.
""" """
# PROTECTED REGION ID(SKAObsDevice.class_variable) ENABLED START # # PROTECTED REGION ID(SKAObsDevice.class_variable) ENABLED START #
def __init__(self, *args, **kwargs):
super(SKAObsDevice, self).__init__(*args, **kwargs)
self._build_state = '{}, {}, {}'.format(release.name, release.version,
release.description)
self._version_id = release.version
# Initialize attribute values.
self._obs_state = ObsState.IDLE
self._obs_mode = ObsMode.IDLE
self._config_progress = 0
self._config_delay_expected = 0
# PROTECTED REGION END # // SKAObsDevice.class_variable # PROTECTED REGION END # // SKAObsDevice.class_variable
# ----------------- # -----------------
...@@ -92,6 +80,14 @@ class SKAObsDevice(SKABaseDevice): ...@@ -92,6 +80,14 @@ class SKAObsDevice(SKABaseDevice):
def init_device(self): def init_device(self):
SKABaseDevice.init_device(self) SKABaseDevice.init_device(self)
# PROTECTED REGION ID(SKAObsDevice.init_device) ENABLED START # # PROTECTED REGION ID(SKAObsDevice.init_device) ENABLED START #
self._build_state = '{}, {}, {}'.format(release.name, release.version,
release.description)
self._version_id = release.version
# Initialize attribute values.
self._obs_state = ObsState.IDLE
self._obs_mode = ObsMode.IDLE
self._config_progress = 0
self._config_delay_expected = 0
# PROTECTED REGION END # // SKAObsDevice.init_device # PROTECTED REGION END # // SKAObsDevice.init_device
def always_executed_hook(self): def always_executed_hook(self):
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"""Release information for lmc-base-classes Python Package""" """Release information for lmc-base-classes Python Package"""
name = """lmcbaseclasses""" name = """lmcbaseclasses"""
version = "0.4.0" version = "0.4.1"
version_info = version.split(".") version_info = version.split(".")
description = """A set of generic base devices for SKA Telescope.""" description = """A set of generic base devices for SKA Telescope."""
author = "SKA India and SARAO" author = "SKA India and SARAO"
......
...@@ -34,7 +34,7 @@ test: ...@@ -34,7 +34,7 @@ test:
# FIXME: Add pylint2junit to the tango-builder:latest image so that we don't need to install it here. # FIXME: Add pylint2junit to the tango-builder:latest image so that we don't need to install it here.
# FIXME: Missing functionality in pylint2junit prevents converting from parseable to xml. Once it's implemented there is no need to run linting twice. # FIXME: Missing functionality in pylint2junit prevents converting from parseable to xml. Once it's implemented there is no need to run linting twice.
lint: lint:
pip3 install pylint2junit; \ python3 -m pip install pylint2junit; \
mkdir -p /build/reports; \ mkdir -p /build/reports; \
cd /app && pylint --output-format=parseable skabase | tee /build/code_analysis.stdout; \ cd /app && pylint --output-format=parseable skabase | tee /build/code_analysis.stdout; \
cd /app && pylint --output-format=pylint2junit.JunitReporter skabase > /build/reports/linting.xml; cd /app && pylint --output-format=pylint2junit.JunitReporter skabase > /build/reports/linting.xml;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment