Fix the dataformat generation failure due to Demeter's metadata change. At the same maintain its backward compatibility with Acumos Clio.
Issue-ID: DCAEGEN2-2825
Signed-off-by: shabs2020 <shabnam.sultana@highstreet-technologies.com>
Change-Id: I0f665415d1b3c94e774eec5a56c8df598d222cd3
Signed-off-by: shabs2020 <shabnam.sultana@highstreet-technologies.com>
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+## [1.0.6] - 6/04/2021
+ * Adapt DCAE adapter to work with Acumos Demeter's metadata structure change
## [1.0.5] - 5/05/2021
* Enhance adapter to also work behind proxy.
## [1.0.4] - 1/07/2021
# org.onap.dcae
# =============================================================================
# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# we use a dict because multiple methods may reuse names
needed_formats = {}
for method in meta["methods"]:
- needed_formats[meta["methods"][method]["input"]] = 1
- needed_formats[meta["methods"][method]["output"]] = 1
+ needed_formats[utils.validate_format(meta, method, "input")] = 1
+ needed_formats[utils.validate_format(meta, method, "output")] = 1
return list(needed_formats.keys())
# org.onap.dcae
# =============================================================================
# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
pstype = "message_router"
for method in meta["methods"]:
- df_in_name = meta["methods"][method]["input"]
+ df_in_name = utils.validate_format(meta, method, "input")
subscriber = {
"config_key": "{0}_subscriber".format(method),
"format": df_in_name,
spec["streams"]["subscribes"].append(subscriber)
- df_out_name = meta["methods"][method]["output"]
+ df_out_name = utils.validate_format(meta, method, "output")
publisher = {
"config_key": "{0}_publisher".format(method),
# org.onap.dcae
# =============================================================================
# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
def get_metadata(model_repo_path, model_name):
# for now, assume it's called "metadata.json"
return json.loads(open("{0}/{1}/metadata.json".format(model_repo_path, model_name), "r").read())
+
+
+def validate_format(meta, method, type):
+ """
+ Method to check for the metadata structure of the Acumos Model
+ due to change in tree structure of the input and output with Acumos-Demeter's release
+ Solution for Issue id: DCAEGEN2-2825
+ """
+ try:
+ df_name = meta["methods"][method][type]["name"]
+
+ except TypeError:
+ df_name = meta["methods"][method][type]
+ return df_name
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.dcaegen2.platform.adapter</groupId>
<artifactId>dcaegen2-platform-adapter-acumos</artifactId>
- <version>1.0.5-SNAPSHOT</version>
+ <version>1.0.6-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.sources>.</sonar.sources>
setup(
name="aoconversion",
- version="1.0.5-SNAPSHOT",
+ version="1.0.6-SNAPSHOT",
packages=find_packages(exclude=["tests.*", "tests"]),
author="Tommy Carpenter, Andrew Gauld",
author_email="tommy@research.att.com, agauld@att.com",
--- /dev/null
+{
+ "schema": "acumos.schema.model:0.6.0",
+ "runtime": {
+ "name": "python",
+ "version": "3.7.9",
+ "dependencies": {
+ "pip": {
+ "indexes": [
+ ],
+ "requirements": [
+ {
+ "name": "dill",
+ "version": "0.3.3"
+ },
+ {
+ "name": "scikit-learn",
+ "version": "0.23.2"
+ },
+ {
+ "name": "numpy",
+ "version": "1.19.2"
+ },
+ {
+ "name": "acumos",
+ "version": "0.9.7"
+ }
+ ]
+ },
+ "conda": {
+ "channels": [
+ ],
+ "requirements": [
+ ]
+ }
+ }
+ },
+ "name": "example-model",
+ "methods": {
+ "Numbers": {
+ "input": {
+ "name": "NumbersIn",
+ "media_type": [
+ "application/vnd.google.protobuf"
+ ],
+ "metadata": {
+ },
+ "description": ""
+ },
+ "output": {
+ "name": "NumbersOut",
+ "media_type": [
+ "application/vnd.google.protobuf"
+ ],
+ "metadata": {
+ },
+ "description": ""
+ },
+ "description": ""
+ }
+ }
+}
--- /dev/null
+# ============LICENSE_START====================================================
+# org.onap.dcae
+# =============================================================================
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END======================================================
+
+"""
+Test the compatibility of Adapter while reading metadata from both previous (upto Clio) Acumos releases
+and the new Demeter release.
+"""
+
+import aoconversion
+import testing_helpers
+
+
+def test_validate_format_Clio():
+ """
+ Given the metadata as per Acumos Clio's tree structure, check if the validate_json method
+ reads the correct input and output name
+ """
+ model_repo_path = testing_helpers.get_fixture_path('models')
+ model_name = 'example-model'
+ meta = aoconversion.utils.get_metadata(model_repo_path, model_name)
+
+ for method in meta["methods"]:
+ assert (aoconversion.utils.validate_format(meta, method, "input")) == "NumbersIn"
+ assert (aoconversion.utils.validate_format(meta, method, "output")) == "NumberOut"
+
+
+def test_validate_format_Demeter():
+ """
+ Given the metadata as per Acumos Clio's tree structure, check if the validate_json method
+ can also read the correct input and output name without fail
+ """
+ model_repo_path = testing_helpers.get_fixture_path('models')
+ model_name = 'example-model-demeter'
+ meta = aoconversion.utils.get_metadata(model_repo_path, model_name)
+
+ for method in meta["methods"]:
+ assert (aoconversion.utils.validate_format(meta, method, "input")) == "NumbersIn"
+ assert (aoconversion.utils.validate_format(meta, method, "output")) == "NumbersOut"