From 10c8b39276442dcd0f145ed9f40f338beaf6a8c5 Mon Sep 17 00:00:00 2001 From: Jozef Volak Date: Fri, 10 Nov 2023 22:23:25 +0100 Subject: [PATCH] [influxdb] Update project path to frinx_worker/influxdb --- misc/python/influxdb/CHANGELOG.md | 5 +- misc/python/influxdb/frinx_worker/__init__.py | 89 ------------------- .../frinx_worker/influxdb/__init__.py | 85 ++++++++++++++++++ .../frinx_worker/{ => influxdb}/utils.py | 0 misc/python/influxdb/pyproject.toml | 4 +- 5 files changed, 91 insertions(+), 92 deletions(-) create mode 100644 misc/python/influxdb/frinx_worker/influxdb/__init__.py rename misc/python/influxdb/frinx_worker/{ => influxdb}/utils.py (100%) diff --git a/misc/python/influxdb/CHANGELOG.md b/misc/python/influxdb/CHANGELOG.md index dda1066..aead23d 100644 --- a/misc/python/influxdb/CHANGELOG.md +++ b/misc/python/influxdb/CHANGELOG.md @@ -1,2 +1,5 @@ # 1.0.0 -- Upgrade pydantic version to v2 \ No newline at end of file +- Upgrade pydantic version to v2 + +# 1.1.0 +- Fix project path to frinx_worker/influxdb \ No newline at end of file diff --git a/misc/python/influxdb/frinx_worker/__init__.py b/misc/python/influxdb/frinx_worker/__init__.py index aa15f39..e69de29 100644 --- a/misc/python/influxdb/frinx_worker/__init__.py +++ b/misc/python/influxdb/frinx_worker/__init__.py @@ -1,89 +0,0 @@ -from typing import Optional - -from frinx.common.type_aliases import DictAny -from frinx.common.type_aliases import ListAny -from frinx.common.type_aliases import ListStr -from frinx.common.worker.service import ServiceWorkersImpl -from frinx.common.worker.task_def import TaskDefinition -from frinx.common.worker.task_def import TaskExecutionProperties -from frinx.common.worker.task_def import TaskInput -from frinx.common.worker.task_def import TaskOutput -from frinx.common.worker.task_result import TaskResult -from frinx.common.worker.worker import WorkerImpl - -from . import utils - - -class Influx(ServiceWorkersImpl): - - class InfluxWriteData(WorkerImpl): - - class ExecutionProperties(TaskExecutionProperties): - transform_string_to_json_valid: bool = True - exclude_empty_inputs: bool = True - - class WorkerDefinition(TaskDefinition): - name: str = 'INFLUX_write_data' - description: str = 'Write data do InfluxDB' - labels: ListStr = ['INFLUX'] - timeout_seconds: int = 300 - - class WorkerInput(TaskInput): - org: str - token: str - bucket: str - measurement: str - tags: DictAny - fields: DictAny - - class WorkerOutput(TaskOutput): - pass - - def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: - return utils.influx_write_data(self, worker_input) - - class InfluxQueryData(WorkerImpl): - - class ExecutionProperties(TaskExecutionProperties): - transform_string_to_json_valid: bool = True - exclude_empty_inputs: bool = True - - class WorkerDefinition(TaskDefinition): - name: str = 'INFLUX_query_data' - description: str = 'Query data from InfluxDB' - labels: ListStr = ['INFLUX'] - timeout_seconds: int = 300 - - class WorkerInput(TaskInput): - org: str - token: str - query: str - format_data: Optional[ListStr] = None - - class WorkerOutput(TaskOutput): - data: ListAny - - def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: - return utils.influx_query_data(self, worker_input) - - class InfluxCreateBucket(WorkerImpl): - - class ExecutionProperties(TaskExecutionProperties): - exclude_empty_inputs: bool = True - - class WorkerDefinition(TaskDefinition): - name: str = 'INFLUX_create_bucket' - description: str = 'Create bucket for organization in InfluxDB' - labels: ListStr = ['INFLUX'] - timeout_seconds: int = 300 - - class WorkerInput(TaskInput): - org: str - token: str - bucket: str - - class WorkerOutput(TaskOutput): - pass - - def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: - return utils.influx_create_bucket(self, worker_input) diff --git a/misc/python/influxdb/frinx_worker/influxdb/__init__.py b/misc/python/influxdb/frinx_worker/influxdb/__init__.py new file mode 100644 index 0000000..eb1afe0 --- /dev/null +++ b/misc/python/influxdb/frinx_worker/influxdb/__init__.py @@ -0,0 +1,85 @@ +from typing import Optional + +from frinx.common.type_aliases import DictAny +from frinx.common.type_aliases import ListAny +from frinx.common.type_aliases import ListStr +from frinx.common.worker.service import ServiceWorkersImpl +from frinx.common.worker.task_def import TaskDefinition +from frinx.common.worker.task_def import TaskExecutionProperties +from frinx.common.worker.task_def import TaskInput +from frinx.common.worker.task_def import TaskOutput +from frinx.common.worker.task_result import TaskResult +from frinx.common.worker.worker import WorkerImpl + +from . import utils + + +class InfluxDB(ServiceWorkersImpl): + class InfluxWriteData(WorkerImpl): + class ExecutionProperties(TaskExecutionProperties): + transform_string_to_json_valid: bool = True + exclude_empty_inputs: bool = True + + class WorkerDefinition(TaskDefinition): + name: str = 'INFLUX_write_data' + description: str = 'Write data do InfluxDB' + labels: ListStr = ['INFLUX'] + timeout_seconds: int = 300 + + class WorkerInput(TaskInput): + org: str + token: str + bucket: str + measurement: str + tags: DictAny + fields: DictAny + + class WorkerOutput(TaskOutput): + pass + + def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: + return utils.influx_write_data(self, worker_input) + + class InfluxQueryData(WorkerImpl): + class ExecutionProperties(TaskExecutionProperties): + transform_string_to_json_valid: bool = True + exclude_empty_inputs: bool = True + + class WorkerDefinition(TaskDefinition): + name: str = 'INFLUX_query_data' + description: str = 'Query data from InfluxDB' + labels: ListStr = ['INFLUX'] + timeout_seconds: int = 300 + + class WorkerInput(TaskInput): + org: str + token: str + query: str + format_data: Optional[ListStr] = None + + class WorkerOutput(TaskOutput): + data: ListAny + + def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: + return utils.influx_query_data(self, worker_input) + + class InfluxCreateBucket(WorkerImpl): + class ExecutionProperties(TaskExecutionProperties): + exclude_empty_inputs: bool = True + + class WorkerDefinition(TaskDefinition): + name: str = 'INFLUX_create_bucket' + description: str = 'Create bucket for organization in InfluxDB' + labels: ListStr = ['INFLUX'] + timeout_seconds: int = 300 + + class WorkerInput(TaskInput): + org: str + token: str + bucket: str + + class WorkerOutput(TaskOutput): + pass + + def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: + return utils.influx_create_bucket(self, worker_input) diff --git a/misc/python/influxdb/frinx_worker/utils.py b/misc/python/influxdb/frinx_worker/influxdb/utils.py similarity index 100% rename from misc/python/influxdb/frinx_worker/utils.py rename to misc/python/influxdb/frinx_worker/influxdb/utils.py diff --git a/misc/python/influxdb/pyproject.toml b/misc/python/influxdb/pyproject.toml index 7d8be6e..1f1871b 100644 --- a/misc/python/influxdb/pyproject.toml +++ b/misc/python/influxdb/pyproject.toml @@ -20,9 +20,9 @@ packages = [{ include = "frinx_worker" }] name = "frinx-influxdb-worker" description = "Conductor InfluxDB worker for Frinx Machine" authors = ["Jozef Volak "] -version = "1.0.0" +version = "1.1.0" readme = ["README.md", "CHANGELOG.md"] -keywords = ["frinx-machine", "influx", "worker"] +keywords = ["frinx-machine", "influxdb", "worker"] license = "Apache 2.0" [project.urls]