diff --git a/pom.xml b/pom.xml index b3cc11598d..614bccfa64 100644 --- a/pom.xml +++ b/pom.xml @@ -1396,7 +1396,6 @@ streampipes-wrapper-distributed streampipes-wrapper-flink streampipes-wrapper-kafka-streams - streampipes-wrapper-python streampipes-wrapper-siddhi streampipes-wrapper-standalone diff --git a/streampipes-wrapper-python/README.md b/streampipes-wrapper-python/README.md deleted file mode 100644 index 03e50b41cd..0000000000 --- a/streampipes-wrapper-python/README.md +++ /dev/null @@ -1,25 +0,0 @@ - - -## Apache StreamPipes Wrapper for Python - DEPRECATED - -StreamPipes effort to support Python is continued in [StreamPipes Python](https://github.com/apache/streampipes/tree/dev/streampipes-client-python): -- [Documentation](https://streampipes.apache.org/docs/docs/python/latest/) -- [Download from PyPi](https://pypi.org/project/streampipes/) - -Therefore this module is deprecated from version 0.92.0 on and will probably be remove in 0.93.0. \ No newline at end of file diff --git a/streampipes-wrapper-python/build-distribution.sh b/streampipes-wrapper-python/build-distribution.sh deleted file mode 100755 index 32075a78ff..0000000000 --- a/streampipes-wrapper-python/build-distribution.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -CURR_DIR=`pwd` -BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" - -########################### - -cd ${BASE_DIR} - -rm -fr dist - -docker run \ - -v "$BASE_DIR:/app" \ - --workdir /app \ - -i python:3.7-alpine \ - python3 setup.py sdist bdist_wheel - -rm -fr streampipes_python.egg-info -rm -fr build - -echo "Built Python SDK wheels and packages at ${BASE_DIR}/dist." - -cd ${CURR_DIR} \ No newline at end of file diff --git a/streampipes-wrapper-python/pom.xml b/streampipes-wrapper-python/pom.xml deleted file mode 100644 index 64fad8e3ce..0000000000 --- a/streampipes-wrapper-python/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - streampipes-parent - org.apache.streampipes - 0.93.0-SNAPSHOT - - 4.0.0 - streampipes-wrapper-python - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - checkstyle.config.base.path=${project.parent.basedir}/tools/maven - - - - - - \ No newline at end of file diff --git a/streampipes-wrapper-python/requirements.txt b/streampipes-wrapper-python/requirements.txt deleted file mode 100644 index 3686fb9ffd..0000000000 --- a/streampipes-wrapper-python/requirements.txt +++ /dev/null @@ -1,15 +0,0 @@ -waitress==2.1.2 -click==7.1.2 -confluent-kafka==1.4.2 -Flask==2.3.2 -Flask-Classful==0.14.2 -Flask-Negotiate==0.1.0 -idna==2.10 -itsdangerous==1.1.0 -Jinja2==2.11.3 -MarkupSafe==1.1.1 -python-consul==1.1.0 -requests==2.24.0 -six==1.15.0 -urllib3==1.26.5 -Werkzeug==2.2.3 diff --git a/streampipes-wrapper-python/setup.py b/streampipes-wrapper-python/setup.py deleted file mode 100644 index a94733311c..0000000000 --- a/streampipes-wrapper-python/setup.py +++ /dev/null @@ -1,57 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -"""""" - -from setuptools import setup, find_packages - -import io -import os - -this_directory = os.path.abspath(os.path.dirname(__file__)) -with io.open(os.path.join(this_directory, 'README.md'), 'r', encoding='utf-8') as f: - long_description = f.read() - -setup( - name='apache-streampipes-python', - version='0.68.0.dev1', - packages=find_packages(), - package_data={'streampipes': ['api/templates/*']}, - url='https://github.com/apache/incubator-streampipes', - license='https://www.apache.org/licenses/LICENSE-2.0', - license_files=["LICENSE", "NOTICE"], - author='Apache Software Foundation', - author_email='dev@streampipes.apache.org', - description='Apache StreamPipes Python Wrapper', - long_description=long_description, - long_description_content_type='text/markdown', - install_requires=[ - 'confluent-kafka==1.4.2', - 'Deprecated==1.2.13', - 'Flask==2.3.2', - 'flask-classful==0.14.2', - 'Flask-Negotiate==0.1.0', - 'waitress==2.1.2', - 'python-consul==1.1.0' - ], - tests_require=[], - python_requires='>=3.5', - classifiers=[ - 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7'] -) \ No newline at end of file diff --git a/streampipes-wrapper-python/streampipes/__init__.py b/streampipes-wrapper-python/streampipes/__init__.py deleted file mode 100644 index 0f71865aae..0000000000 --- a/streampipes-wrapper-python/streampipes/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -"""global logging""" - -import logging - -LOGGING_FORMAT = "%(asctime)s [%(levelname)s] %(name)s — [%(filename)s:%(lineno)s - %(funcName)s()] — %(message)s" -logging.basicConfig(level=logging.INFO, format=LOGGING_FORMAT) -logging.getLogger(__name__).addHandler(logging.NullHandler()) diff --git a/streampipes-wrapper-python/streampipes/api/__init__.py b/streampipes-wrapper-python/streampipes/api/__init__.py deleted file mode 100644 index ecb1860df8..0000000000 --- a/streampipes-wrapper-python/streampipes/api/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# \ No newline at end of file diff --git a/streampipes-wrapper-python/streampipes/api/resources/__init__.py b/streampipes-wrapper-python/streampipes/api/resources/__init__.py deleted file mode 100644 index cce3acad34..0000000000 --- a/streampipes-wrapper-python/streampipes/api/resources/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# diff --git a/streampipes-wrapper-python/streampipes/api/resources/base.py b/streampipes-wrapper-python/streampipes/api/resources/base.py deleted file mode 100644 index ebee17ec0a..0000000000 --- a/streampipes-wrapper-python/streampipes/api/resources/base.py +++ /dev/null @@ -1,129 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import abc -import os -from flask import jsonify, make_response, request -from flask_classful import FlaskView, route -from flask_negotiate import consumes - - -class Element(FlaskView): - __metaclass__ = abc.ABC - - @route('/', methods=['GET']) - def get_description(self, element_id: str): - # TODO: get element description - # TODO: get element from declarer - resp = {'element_id': element_id, 'description': 'dummy description'} - return make_response(jsonify(resp), 200) - - @route('//assets', methods=['GET']) - def get_assets(self, element_id: str): - # TODO: send zipped asset - resp = {'element_id': element_id, 'asset': 'dummy asset'} - return make_response(jsonify(resp), 200) - - @route('//assets/icon', methods=['GET']) - def get_assets_icon(self, element_id: str): - # TODO: return icon as byte array - resp = {'element_id': element_id, 'asset': 'dummy asset', 'icon': 'dummy icon'} - return make_response(jsonify(resp), 200) - - @route('//assets/documentation', methods=['GET']) - def get_assets_docs(self, element_id: str): - # TODO: return icon as byte array - resp = {'element_id': element_id, 'asset': 'dummy asset', 'docs': 'dummy docs'} - return make_response(jsonify(resp), 200) - - @abc.abstractmethod - def get_element_declarers(self): - raise NotImplementedError() - - def get_declarer_by_id(self, element_id: str): - return self.get_element_declarers().get(element_id=element_id) - - @classmethod - def _get_json_ld(cls): - pass - - @classmethod - def _make_grounding(cls): - pass - - @classmethod - def _make_icon_path(cls, element_id: str): - return cls._make_path(element_id, 'icon.png') - - @classmethod - def _make_documentation_path(cls, element_id: str): - return cls._make_path(element_id, 'documentation.md') - - @classmethod - def _make_path(cls, element_id: str, asset_appendix: str): - return element_id + '/' + asset_appendix - - -class InvocableElement(Element): - __metaclass__ = abc.ABC - - @route('/', methods=['POST']) - @consumes('application/json') - def invoke_runtime(self, element_id: str): - # TODO: parse invocation graph - # payload = request.json - print(request.json) - resp = {'element_id': element_id, 'status': 'sucess'} - return make_response(jsonify(resp), 200) - - @route('//configurations', methods=['POST']) - @consumes('application/json') - def fetch_configurations(self, element_id: str): - # payload = request.json - resp = {'element_id': element_id, 'config': 'sucess'} - return make_response(jsonify(resp), 200) - - @route('//output', methods=['POST']) - @consumes('application/json') - def fetch_output_configurations(self, element_id: str): - # payload = request.json - resp = {'element_id': element_id, 'output': 'sucess'} - return make_response(jsonify(resp), 200) - - @route('//', methods=['DELETE']) - def detach(self, element_id: str, running_instance_id: str): - resp = {'element_id': element_id, 'running_instance_id': running_instance_id} - return make_response(jsonify(resp), 200) - - @abc.abstractmethod - def get_element_declarers(self): - raise NotImplementedError() - - @abc.abstractmethod - def get_instance_id(self, uri: str, element_id: str): - raise NotImplementedError() - - @abc.abstractmethod - def get_extractor(self, graph): - raise NotImplementedError() - - @abc.abstractmethod - def create_grounding_debug_information(self, graph): - raise NotImplementedError() - - @staticmethod - def _is_debug(): - return True if os.getenv('SP_DEBUG') == 'true' else False diff --git a/streampipes-wrapper-python/streampipes/api/resources/dummy.py b/streampipes-wrapper-python/streampipes/api/resources/dummy.py deleted file mode 100644 index 598d91d45f..0000000000 --- a/streampipes-wrapper-python/streampipes/api/resources/dummy.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -from flask import request -from flask_classful import FlaskView, route -from streampipes.manager import ProcessorDispatcher - - -# TODO: Delete when finished -# will be deleted and is only necessary for interims working example still relying on Java -class DummyInterimsResource(FlaskView): - - @route('/invoke', methods=['POST']) - def start(self): - return ProcessorDispatcher.start(**request.get_json()) - - @route('/detach', methods=['POST']) - def stop(self): - return ProcessorDispatcher.stop(**request.get_json()) \ No newline at end of file diff --git a/streampipes-wrapper-python/streampipes/api/resources/processor.py b/streampipes-wrapper-python/streampipes/api/resources/processor.py deleted file mode 100644 index e3f5820a56..0000000000 --- a/streampipes-wrapper-python/streampipes/api/resources/processor.py +++ /dev/null @@ -1,34 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -from streampipes.api.resources.base import InvocableElement - - -# TODO: implement -class SepaElementResource(InvocableElement): - - def get_instance_id(self, uri: str, element_id: str): - pass - - def get_element_declarers(self): - pass - - def get_extractor(self, graph): - pass - - def create_grounding_debug_information(self, graph): - pass - diff --git a/streampipes-wrapper-python/streampipes/api/resources/welcome.py b/streampipes-wrapper-python/streampipes/api/resources/welcome.py deleted file mode 100644 index 381a0cd2c4..0000000000 --- a/streampipes-wrapper-python/streampipes/api/resources/welcome.py +++ /dev/null @@ -1,45 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -from flask import make_response, jsonify, request, render_template -from flask_classful import FlaskView, route -from flask_negotiate import produces - - -class WelcomeResource(FlaskView): - dummy_processors = [{ - 'name': 'Greeter Python', - 'uri': 'http://localhost:5000/sepa/org.apache.streampipes.python.processor.greeter', - 'description': 'Greeter Python Description' - }, - { - 'name': 'DoNothing Python', - 'uri': 'http://localhost:5000/sepa/org.apache.streampipes.python.processor.donothing', - 'description': 'Donothing Python Description' - }] - - @route('/', methods=['GET']) - @produces('application/json','text/html') - def welcome(self): - # TODO: get description of all declared semantic event processor agents (sepa) - # TODO: DeclarerSingleton().get_declarers() - if request.accept_mimetypes['text/html']: - return render_template('index.html', processors=self.dummy_processors) - - if request.accept_mimetypes['application/json']: - resp = {'success': True} - return make_response(jsonify(resp), 200) - diff --git a/streampipes-wrapper-python/streampipes/api/rest.py b/streampipes-wrapper-python/streampipes/api/rest.py deleted file mode 100644 index e092ef53ea..0000000000 --- a/streampipes-wrapper-python/streampipes/api/rest.py +++ /dev/null @@ -1,51 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -""" API endpoints """ -import threading - -from waitress import serve -from flask import Flask -from deprecated import deprecated - -from streampipes.api.resources.dummy import DummyInterimsResource -from streampipes.api.resources.processor import SepaElementResource -from streampipes.api.resources.welcome import WelcomeResource - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class PipelineElementApi(object): - _FLASK_CONFIG = { - 'DEBUG': False, - 'DEVELOPMENT': False - } - - def __init__(self): - self.app = Flask(__name__, instance_relative_config=False) - self.app.config.from_object(self._FLASK_CONFIG) - - with self.app.app_context(): - - # register resources - SepaElementResource.register(self.app, route_base='/', route_prefix='sepa') - WelcomeResource.register(self.app, route_base='/') - # TODO: delete when finished - DummyInterimsResource.register(self.app, route_base='/') - - def run(self, port: int): - print('serving API via waitress WSGI server ... http://{}:{}'.format('0.0.0.0', port)) - threading.Thread(target=serve, args=(self.app,), kwargs={'host': '0.0.0.0', 'port': int(port), '_quiet': True}).start() - diff --git a/streampipes-wrapper-python/streampipes/api/templates/index.html b/streampipes-wrapper-python/streampipes/api/templates/index.html deleted file mode 100644 index 4454426fb4..0000000000 --- a/streampipes-wrapper-python/streampipes/api/templates/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - StreamPipes Python - - - - - - - - -
-

This is a developer-oriented view. Navigate to 'Install Pipeline Elements' in the - StreamPipes UI to import the elements shown here. -

- {% for processor in processors %} -

{{ processor.name }}

-

URI: {{ processor.uri }}

-

Description: {{ processor.description }}

- {% endfor %} -
- - \ No newline at end of file diff --git a/streampipes-wrapper-python/streampipes/base/__init__.py b/streampipes-wrapper-python/streampipes/base/__init__.py deleted file mode 100644 index cce3acad34..0000000000 --- a/streampipes-wrapper-python/streampipes/base/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# diff --git a/streampipes-wrapper-python/streampipes/base/banner.py b/streampipes-wrapper-python/streampipes/base/banner.py deleted file mode 100644 index 5bb8e7538d..0000000000 --- a/streampipes-wrapper-python/streampipes/base/banner.py +++ /dev/null @@ -1,26 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -"""banner""" - -banner = """\ - _______ __ ______ __ -| __| |_.----.-----.---.-.--------.| __ \__|.-----.-----.-----. -|__ | _| _| -__| _ | || __/ || _ | -__|__ --| -|_______|____|__| |_____|___._|__|__|__||___| |__|| __|_____|_____| - |__| -** StreamPipes Pipeline Element Container for Python ** - """ diff --git a/streampipes-wrapper-python/streampipes/core.py b/streampipes-wrapper-python/streampipes/core.py deleted file mode 100644 index a6c8f010dc..0000000000 --- a/streampipes-wrapper-python/streampipes/core.py +++ /dev/null @@ -1,164 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -"""contains relevant base classes""" -import abc -import json -import logging -import threading -from confluent_kafka.admin import AdminClient -from confluent_kafka import Producer, Consumer - -from deprecated import deprecated - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class EventProcessor(object): - __metaclass__ = abc.ABC - - _DEFAULT_KAFKA_CONSUMER_CONFIG = { - 'bootstrap.servers': 'kafka:9092', - 'enable.auto.commit': True, - 'auto.commit.interval.ms': 10000, - 'session.timeout.ms': 30000, - 'fetch.max.bytes': 5000012, - 'auto.offset.reset': 'latest', - } - - _DEFAULT_KAFKA_PRODUCER_CONFIG = { - 'bootstrap.servers': 'kafka:9092', - 'acks': 'all', - 'retries': 0, - 'linger.ms': 20, - } - - def __init__(self, **kwargs): - """initialize EventProcessor with Kafka Prodcuer and Consumer""" - self.logger = logging.getLogger(__name__) - - self._input_topics = kwargs.get('input_topics') - self._output_topics = kwargs.get('output_topics') - self._invocation_id = kwargs.get('invocation_id') - self._bootstrap_servers = kwargs.get('bootstrap_servers') - self.static_properties = kwargs.get('static_properties') - - self._running = False - self._threads = {} - - if self._bootstrap_servers is not None: - self._DEFAULT_KAFKA_CONSUMER_CONFIG['bootstrap.servers'] = self._bootstrap_servers - self._DEFAULT_KAFKA_PRODUCER_CONFIG['bootstrap.servers'] = self._bootstrap_servers - - self._DEFAULT_KAFKA_CONSUMER_CONFIG['group.id'] = 'streampipes_python_' + self._invocation_id - - self._producer = Producer(self._DEFAULT_KAFKA_PRODUCER_CONFIG) - self._consumer = Consumer(self._DEFAULT_KAFKA_CONSUMER_CONFIG) - #self._create_topic(topic=self._output_topics, conf=self._DEFAULT_KAFKA_PRODUCER_CONFIG) - - self.on_invocation() - - def init(self): - self.logger.info('start processor {}'.format(self.invocation_id)) - thread = threading.Thread(target=self._consume, name=self.invocation_id) - thread.start() - self._threads['kafka'] = thread - - def active_threads(self): - return self._threads - - @property - def invocation_id(self): - return self._invocation_id - - def __del__(self): - pass - - @abc.abstractmethod - def on_invocation(self): - """ on_invocation is called when processor is started """ - - @abc.abstractmethod - def on_event(self, event): - """ on_event receives kafka consumer messages """ - pass - - @abc.abstractmethod - def on_detach(self): - """ on_detach is called when processor is stopped """ - pass - - def _on_event(self, event): - result = self.on_event(event) - - if result is not None: - self._produce(result) - - def _consume(self): - """ retrieve events from kafka """ - self._consumer.subscribe(topics=[self._input_topics]) - self._running = True - - while self._running: - # fetch records from kafka and send to - msg = self._consumer.poll(timeout=1.0) - - if msg is None: - continue - elif msg.error(): - if msg.error().str() != "Broker: No more messages": - self.logger.error("Consumer error: {}".format(msg.error())) - continue - else: - try: - # json -> dict - event = json.loads(msg.value().decode('utf-8')) - if isinstance(event, int): - self.logger.info("Integer not allowed {}".format(event)) - continue - except ValueError as e: - self.logger.info("Not a valid json {}".format(e)) - continue - - self._on_event(event) - - def _produce(self, result): - """ send events to kafka """ - event = json.dumps(result).encode('utf-8') - try: - # dict -> json - self._producer.produce(self._output_topics, value=event) - except BufferError: - self._producer.poll(1) - - # def _create_topic(self, topic=None, conf=None): - # """ Create the topic if it doesn't exist """ - # admin = AdminClient(conf) - # fs = admin.create_topics([NewTopic(topic, num_partitions=1, replication_factor=1)]) - # f = fs[topic] - # try: - # f.result() - # except KafkaException as ex: - # if ex.args[0].code() == KafkaError.TOPIC_ALREADY_EXISTS: - # self.logger.warning("Topic {} already exists: continue".format(topic)) - # else: - # raise - - def stop(self): - self.logger.info('stop processor {}'.format(self.invocation_id)) - self._running = False - self._consumer.close() - self._producer.flush() - self.on_detach() diff --git a/streampipes-wrapper-python/streampipes/declarer.py b/streampipes-wrapper-python/streampipes/declarer.py deleted file mode 100644 index 3e548b69c1..0000000000 --- a/streampipes-wrapper-python/streampipes/declarer.py +++ /dev/null @@ -1,60 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -from depreacted import deprecated - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class Singleton(type): - _instances = {} - - def __call__(cls, *args, **kwargs): - if cls not in cls._instances: - cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) - return cls._instances[cls] - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class DeclarerSingleton(metaclass=Singleton): - - """ EventProcessorManager holds running processor instances """ - _processors = {} - - def __init__(self): - self.sepa_declarers = {} - self.supported_protocols = {} - self.supported_formats = {} - self.route = '/' - self.host = None - self.port = None - - @classmethod - def add(cls, processors=None): - """ holds dict with """ - cls._processors = processors - - @classmethod - def get_processor(cls, key): - return cls._processors[key] - - @classmethod - def get(cls): - return cls._processors - - def get_declarers(self): - return self.sepa_declarers - - def get_base_uri(self): - return 'http://' + self.host + ':' + self.port + self.route diff --git a/streampipes-wrapper-python/streampipes/instances.py b/streampipes-wrapper-python/streampipes/instances.py deleted file mode 100644 index 369e4e5582..0000000000 --- a/streampipes-wrapper-python/streampipes/instances.py +++ /dev/null @@ -1,49 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import abc -from deprecated import deprecated - -@deprecated(version='0.92' - '.0', reason="Please switch to StreamPipes Python (see README)") -class NamedStreamPipesEntity: - __metaclass__ = abc.ABC - - def get_description(self): - pass - -@deprecated(version='0.92' - '.0', reason="Please switch to StreamPipes Python (see README)") -class RunningInstances: - __metaclass__ = abc.ABC - - _running_instances = {} - - def add(self, instance_id, description, invocation): - self._running_instances[instance_id] = [description, invocation] - - def get_invocation(self, instance_id): - invocation = self._running_instances.get(instance_id)[1] - return invocation if invocation is not None else None - - def get_description(self, instance_id): - return self._running_instances.get(instance_id)[0] - - def remove(self, instance_id): - self._running_instances.pop(instance_id) - - def get_running_instances_count(self): - return len(self._running_instances) diff --git a/streampipes-wrapper-python/streampipes/manager.py b/streampipes-wrapper-python/streampipes/manager.py deleted file mode 100644 index 04b4acc31a..0000000000 --- a/streampipes-wrapper-python/streampipes/manager.py +++ /dev/null @@ -1,65 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -"""Manages processor life cycle""" -import logging -import abc -from deprectaed import deprecated -from streampipes.declarer import DeclarerSingleton - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class ProcessorDispatcher(object): - __metaclass__ = abc.ABC - - _running_instances = {} - - logger = logging.getLogger(__name__) - - @classmethod - def start(cls, **kwargs): - processor_id = kwargs.get('processor_id') - try: - processor = DeclarerSingleton().get_processor(processor_id)(**kwargs) - processor.init() - cls._running_instances[processor.invocation_id] = processor - - return {'status': 'success'} - - except KeyError: - err = "KeyError. processor_id not found" - cls.logger.info('{}: {}'.format(err, processor_id)) - return {'status': err} - - @classmethod - def stop(cls, **kwargs): - invocation_id = kwargs.get('invocation_id') - try: - processor = cls._running_instances[invocation_id] - active_threads = processor.active_threads() - processor.stop() - active_threads['kafka'].join() - - del processor - cls._running_instances.pop(invocation_id) - - return {'status': 'success'} - - except KeyError: - err = "KeyError. invocation_id not found" - cls.logger.info('{}: {}'.format(err,invocation_id)) - - return {'status': err} diff --git a/streampipes-wrapper-python/streampipes/model/__init__.py b/streampipes-wrapper-python/streampipes/model/__init__.py deleted file mode 100644 index cce3acad34..0000000000 --- a/streampipes-wrapper-python/streampipes/model/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# diff --git a/streampipes-wrapper-python/streampipes/model/base/__init__.py b/streampipes-wrapper-python/streampipes/model/base/__init__.py deleted file mode 100644 index 9ccada8996..0000000000 --- a/streampipes-wrapper-python/streampipes/model/base/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -''' DataProcessor Base ''' diff --git a/streampipes-wrapper-python/streampipes/model/base/abstract_streampipes_entity.py b/streampipes-wrapper-python/streampipes/model/base/abstract_streampipes_entity.py deleted file mode 100644 index 7e1645e88f..0000000000 --- a/streampipes-wrapper-python/streampipes/model/base/abstract_streampipes_entity.py +++ /dev/null @@ -1,23 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -from deprecated import deprecated - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class AbstractStreamPipesEntity: - def __init__(self): - pass diff --git a/streampipes-wrapper-python/streampipes/model/base/consumable_streampipes_entity.py b/streampipes-wrapper-python/streampipes/model/base/consumable_streampipes_entity.py deleted file mode 100644 index c0c2561865..0000000000 --- a/streampipes-wrapper-python/streampipes/model/base/consumable_streampipes_entity.py +++ /dev/null @@ -1,26 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import sys, os -from deprecated import deprecated -sys.path.append(os.path.abspath("streampipes-wrapper-python")) - -from streampipes.model.base.named_streampipes_Entity import NamedStreamPipesEntity - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class ConsumableStreamPipesEntity(NamedStreamPipesEntity): - pass diff --git a/streampipes-wrapper-python/streampipes/model/base/named_streampipes_entity.py b/streampipes-wrapper-python/streampipes/model/base/named_streampipes_entity.py deleted file mode 100644 index f0d5f9969e..0000000000 --- a/streampipes-wrapper-python/streampipes/model/base/named_streampipes_entity.py +++ /dev/null @@ -1,29 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import sys, os -from deprecated import deprecated -sys.path.append(os.path.abspath("streampipes-wrapper-python")) - -from streampipes.model.base.abstract_streampipes_entity import AbstractStreamPipesEntity - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class NamedStreamPipesEntity(AbstractStreamPipesEntity): - def __init__(self): - self.applicationLinks = [] - self.includedAssets = [] - self.includedLocales = [] diff --git a/streampipes-wrapper-python/streampipes/model/base/unnamed_streampipes_entity.py b/streampipes-wrapper-python/streampipes/model/base/unnamed_streampipes_entity.py deleted file mode 100644 index 7185763688..0000000000 --- a/streampipes-wrapper-python/streampipes/model/base/unnamed_streampipes_entity.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import sys, os -from deprecated import deprecated -sys.path.append(os.path.abspath("streampipes-wrapper-python")) - -from streampipes.model.base.abstract_streampipes_entity import AbstractStreamPipesEntity - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class UnnamedStreamPipesEntity(AbstractStreamPipesEntity): - - __serialVersionUID = 8051137255998890188 - def __init__(self): - pass - @classmethod - def with_elementId(elementId: str): - self.elementId = elementId diff --git a/streampipes-wrapper-python/streampipes/model/config_item.py b/streampipes-wrapper-python/streampipes/model/config_item.py deleted file mode 100644 index 0a535f1967..0000000000 --- a/streampipes-wrapper-python/streampipes/model/config_item.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import json -from deprecated import deprecated - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class ConfigItem(object): - def __init__(self): - self.value = None - self.value_type = None - self.description = None - self.configuration_scope = None - self.is_password = None - - def to_json(self): - d = {} - for k,v in self.__dict__.items(): - elements = k.split('_') - camel_case = elements[0] + ''.join(x.title() for x in elements[1:]) - d[camel_case] = v - - return json.dumps(d) diff --git a/streampipes-wrapper-python/streampipes/model/graph/__init__.py b/streampipes-wrapper-python/streampipes/model/graph/__init__.py deleted file mode 100644 index cce3acad34..0000000000 --- a/streampipes-wrapper-python/streampipes/model/graph/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# diff --git a/streampipes-wrapper-python/streampipes/model/graph/data_processor_description.py b/streampipes-wrapper-python/streampipes/model/graph/data_processor_description.py deleted file mode 100644 index f4d7afc0bb..0000000000 --- a/streampipes-wrapper-python/streampipes/model/graph/data_processor_description.py +++ /dev/null @@ -1,45 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import sys, os -from depreacated import deprecated -sys.path.append(os.path.abspath("streampipes-wrapper-python")) - -from streampipes.model.base.consumable_streampipes_entity import ConsumableStreamPipesEntity - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class DataProcessorDescription (ConsumableStreamPipesEntity): - __serialVersionUID = 3995767921861518597 - def __init__(self): - self.__set_PathName(pathName) - - def DataProcessorDescription(self, pathName, name, description, iconUrl): - super(pathName, name, description, iconUrl) - self.pathName = pathName - spDataStreams = [] - staticProperties = [] - - def DataProcessorDescription(self, pathName, name, description): - super(pathName, name, description, "") - self.pathName = pathName - spDataStreams = [] - staticProperties = [] - - def getPathName(): - return pathName - - def __set_PathName(pathName): - self.pathName = pathName diff --git a/streampipes-wrapper-python/streampipes/model/pipeline_element_config.py b/streampipes-wrapper-python/streampipes/model/pipeline_element_config.py deleted file mode 100644 index 3a989ff66b..0000000000 --- a/streampipes-wrapper-python/streampipes/model/pipeline_element_config.py +++ /dev/null @@ -1,98 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import os -from deprecated import deprecated -from streampipes.model.config_item import ConfigItem - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class Config(object): - def __init__(self, app_id: str) -> None: - if not app_id: - raise ValueError - - self.app_id = app_id - self.host: str = "" - self.port: int = 0 - self.service: str = "" - self.config_items = {} - - def register(self, type: str, env_key: str, default, description: str, configuration_scope=None, is_password=None): - if not type: - raise ValueError - if not env_key: - raise ValueError - if not default: - raise ValueError - - if type is 'host': - self.host = self._env_or_default(env_key, default) - elif type is 'port': - self.port = self._env_or_default(env_key, default) - elif type is 'service': - self.service = self._env_or_default(env_key, default) - - config_item = self._create_config_item(env_key, default, description, configuration_scope, is_password) - self.config_items[env_key] = config_item - - def _create_config_item(self, env_key: str, default, description: str, configuration_scope=None, is_password=None): - config_item = ConfigItem() - - if env_key is not None: - if os.getenv(env_key): - env_value = os.getenv(env_key) - config_item.value = env_value - config_item.value_type = self._check_default_type(env_value) - else: - config_item.value = default - config_item.value_type = self._check_default_type(default) - else: - config_item.value = default - config_item.value_type = self._check_default_type(default) - - config_item.description = description - - if configuration_scope is not None: - config_item.configuration_scope = configuration_scope - else: - # TODO: configuration_scope needed? Currently manually set - config_item.configuration_scope = 'CONTAINER_STARTUP_CONFIG' - - if is_password is not None: - config_item.is_password = is_password - else: - config_item.is_password = False - - return config_item - - @staticmethod - def _env_or_default(key, default): - if key is not None: - if os.getenv(key): - return os.getenv(key) - return default - - @staticmethod - def _check_default_type(value) -> str: - if isinstance(value, int): - return 'xs:integer' - elif isinstance(value, str): - return 'xs:string' - elif isinstance(value, bool): - return 'xs:boolean' - elif isinstance(value, float): - return 'xs:float' diff --git a/streampipes-wrapper-python/streampipes/model/staticproperty/__init__.py b/streampipes-wrapper-python/streampipes/model/staticproperty/__init__.py deleted file mode 100644 index 1b7226f85b..0000000000 --- a/streampipes-wrapper-python/streampipes/model/staticproperty/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -from .StaticProperty import StaticProperty diff --git a/streampipes-wrapper-python/streampipes/model/staticproperty/free_text_StaticProperty.py b/streampipes-wrapper-python/streampipes/model/staticproperty/free_text_StaticProperty.py deleted file mode 100644 index 35ef9b11ce..0000000000 --- a/streampipes-wrapper-python/streampipes/model/staticproperty/free_text_StaticProperty.py +++ /dev/null @@ -1,28 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import sys, os -from deprecated import deprecated -sys.path.append(os.path.abspath("streampipes-wrapper-python")) - -import streampipes.model.staticproperty.static_property - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class FreeTextStaticProperty(StaticProperty): - __serialVersionUID = 1 - def __init__(self): - pass diff --git a/streampipes-wrapper-python/streampipes/model/staticproperty/static_property.py b/streampipes-wrapper-python/streampipes/model/staticproperty/static_property.py deleted file mode 100644 index 50965571d0..0000000000 --- a/streampipes-wrapper-python/streampipes/model/staticproperty/static_property.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import sys, os -from deprecated import deprecated -sys.path.append(os.path.abspath("streampipes-wrapper-python")) - -from streampipes.model.base.unnamed_streampipes_entity import UnnamedStreamPipesEntity - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class StaticProperty(UnnamedStreamPipesEntity): - __serialVersionUID = 2509153122084646025 - - - def __init__(self): - self.__set_StaticPropertyType(staticPropertyType) - - def get_StaticPropertyType(self): - return staticPropertyType - - def __set_StaticPropertyType(self, staticPropertyType): - self.staticPropertyType = staticPropertyType diff --git a/streampipes-wrapper-python/streampipes/model/staticproperty/static_property_visitor.py b/streampipes-wrapper-python/streampipes/model/staticproperty/static_property_visitor.py deleted file mode 100644 index cce3acad34..0000000000 --- a/streampipes-wrapper-python/streampipes/model/staticproperty/static_property_visitor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# diff --git a/streampipes-wrapper-python/streampipes/submitter.py b/streampipes-wrapper-python/streampipes/submitter.py deleted file mode 100644 index ef75d4dbf3..0000000000 --- a/streampipes-wrapper-python/streampipes/submitter.py +++ /dev/null @@ -1,52 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -import abc -from deprecated import deprecated - -from streampipes.api.rest import PipelineElementApi -from streampipes.base.banner import banner -from streampipes.declarer import DeclarerSingleton -from streampipes.model.pipeline_element_config import Config -from streampipes.utils.register import ConsulUtils - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class StandaloneModelSubmitter(object): - __metaclass__ = abc.ABC - - @classmethod - def init(cls, config: Config): - # print banner - print(banner) - # add host to declarer singleton - DeclarerSingleton().host = config.host - DeclarerSingleton().port = config.port - # start api - PipelineElementApi().run(port=config.port) - # register pipeline element config and service - ConsulUtils().register_configs(config=config) - ConsulUtils().register_service(app_id=config.app_id, host=config.host, port=int(config.port)) - - # TODO: delete later - @classmethod - def init_debug(cls, config: Config): - # print banner - print(banner) - # add host to declarer singleton - DeclarerSingleton().host = config.host - DeclarerSingleton().port = config.port - # start api - PipelineElementApi().run(port=config.port) diff --git a/streampipes-wrapper-python/streampipes/utils/__init__.py b/streampipes-wrapper-python/streampipes/utils/__init__.py deleted file mode 100644 index ecb1860df8..0000000000 --- a/streampipes-wrapper-python/streampipes/utils/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# \ No newline at end of file diff --git a/streampipes-wrapper-python/streampipes/utils/register.py b/streampipes-wrapper-python/streampipes/utils/register.py deleted file mode 100644 index d76121eacf..0000000000 --- a/streampipes-wrapper-python/streampipes/utils/register.py +++ /dev/null @@ -1,73 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -"""""" -import os -import consul -from consul import Check -from deprecated import deprecated -from streampipes.model.pipeline_element_config import Config - - -@deprecated(version='0.92.0', reason="Please switch to StreamPipes Python (see README)") -class ConsulUtils(object): - _DEFAULT_CONSUL_CONFIG = { - 'CONSUL_HOST': 'consul', - 'CONSUL_PORT': 8500, - 'HEALTHCHECK_INTERVAL': '10s', - 'CONSUL_BASIC_ROUTE': 'sp/v1/' - } - - def __init__(self): - self.consul = self._consul() - - def register_service(self, app_id: str, host: str, port: int): - if not app_id: - raise ValueError - if not host: - raise ValueError - if not port: - raise ValueError - - self.consul.agent.service.register(name='pe', service_id=app_id, address=host, port=port, - tags=['pe', 'python', app_id], - check=Check.http( - url='http://' + host + ':' + str(port), - interval=self._DEFAULT_CONSUL_CONFIG['HEALTHCHECK_INTERVAL'], - header={"Accept": ["application/json"]} - )) - - def register_configs(self, config: Config): - for key, config_item in config.config_items.items(): - key_route = self._get_consul_key_route(config.app_id, key) - index, data = self.consul.kv.get(key_route) - # TODO: update existing keys? - if data is None: - self.consul.kv.put(key_route, config_item.to_json()) - - def _get_consul_key_route(self, app_id, key): - return self._DEFAULT_CONSUL_CONFIG['CONSUL_BASIC_ROUTE'] + app_id + '/' + key - - def _consul(self): - if os.getenv('CONSUL_LOCATION'): - return consul.Consul(host=os.getenv('CONSUL_LOCATION'), - port=self._DEFAULT_CONSUL_CONFIG['CONSUL_PORT']) - elif os.getenv('SP_DEBUG'): - return consul.Consul(host='localhost', - port=self._DEFAULT_CONSUL_CONFIG['CONSUL_PORT']) - else: - return consul.Consul(host=self._DEFAULT_CONSUL_CONFIG['CONSUL_HOST'], - port=self._DEFAULT_CONSUL_CONFIG['CONSUL_PORT'])