deltafi 2.30.0__tar.gz → 2.30.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of deltafi might be problematic. Click here for more details.
- deltafi-2.30.1/.dockerignore +3 -0
- deltafi-2.30.1/.gitignore +2 -0
- deltafi-2.30.1/.python-version +1 -0
- deltafi-2.30.1/PKG-INFO +82 -0
- deltafi-2.30.1/README.md +47 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/result.py +1 -0
- deltafi-2.30.1/pyproject.toml +50 -0
- deltafi-2.30.1/pyproject.toml.template +50 -0
- deltafi-2.30.1/test/__init__.py +30 -0
- deltafi-2.30.1/test/helperutils.py +81 -0
- deltafi-2.30.1/test/plugin_data/flows/variables.yaml +6 -0
- deltafi-2.30.1/test/plugin_data/flows/variables.yml +8 -0
- deltafi-2.30.1/test/plugin_data/tests/f1.yaml +2 -0
- deltafi-2.30.1/test/plugin_data/tests/f2.yml +5 -0
- deltafi-2.30.1/test/plugin_data/tests/f3.txt +1 -0
- deltafi-2.30.1/test/plugin_data/tests/f4.json +4 -0
- deltafi-2.30.1/test/sample/__init__.py +19 -0
- deltafi-2.30.1/test/sample/actions.py +76 -0
- deltafi-2.30.1/test/test_actioneventqueue.py +69 -0
- deltafi-2.30.1/test/test_domain.py +165 -0
- deltafi-2.30.1/test/test_input.py +43 -0
- deltafi-2.30.1/test/test_kit/__init__.py +30 -0
- deltafi-2.30.1/test/test_kit/test_compare_helpers.py +300 -0
- deltafi-2.30.1/test/test_kit/test_testkit_egress.py +140 -0
- deltafi-2.30.1/test/test_kit/test_testkit_timed_ingress.py +159 -0
- deltafi-2.30.1/test/test_kit/test_testkit_transform.py +367 -0
- deltafi-2.30.1/test/test_plugin.py +235 -0
- deltafi-2.30.1/test/test_result.py +171 -0
- deltafi-2.30.1/test/test_storage.py +113 -0
- deltafi-2.30.1/test/test_transform_action.py +186 -0
- deltafi-2.30.1/uv.lock +552 -0
- deltafi-2.30.0/PKG-INFO +0 -38
- deltafi-2.30.0/README.md +0 -3
- deltafi-2.30.0/pyproject.toml +0 -48
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/__init__.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/action.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/actioneventqueue.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/actiontype.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/domain.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/exception.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/genericmodel.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/input.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/logger.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/metric.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/plugin.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/resultmessage.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/storage.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/test_kit/__init__.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/test_kit/assertions.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/test_kit/compare_helpers.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/test_kit/constants.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/test_kit/egress.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/test_kit/framework.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/test_kit/timed_ingress.py +0 -0
- {deltafi-2.30.0 → deltafi-2.30.1}/deltafi/test_kit/transform.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
deltafi-2.30.1/PKG-INFO
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deltafi
|
|
3
|
+
Version: 2.30.1
|
|
4
|
+
Summary: SDK for DeltaFi plugins and actions
|
|
5
|
+
Project-URL: Source Code, https://gitlab.com/deltafi/deltafi
|
|
6
|
+
Project-URL: Documentation, https://docs.deltafi.org/#/
|
|
7
|
+
Project-URL: Bug Reports, https://chat.deltafi.org/deltafi/channels/bug-reports
|
|
8
|
+
Author-email: DeltaFi <deltafi@systolic.com>
|
|
9
|
+
License: Apache License, Version 2.0
|
|
10
|
+
Keywords: deltafi
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Software Development
|
|
18
|
+
Requires-Python: >=3.13
|
|
19
|
+
Requires-Dist: deepdiff==6.7.1
|
|
20
|
+
Requires-Dist: json-logging==1.5.1
|
|
21
|
+
Requires-Dist: minio==7.2.15
|
|
22
|
+
Requires-Dist: pydantic==2.11.7
|
|
23
|
+
Requires-Dist: pyyaml==6.0.2
|
|
24
|
+
Requires-Dist: redis==6.2.0
|
|
25
|
+
Requires-Dist: requests==2.32.4
|
|
26
|
+
Requires-Dist: urllib3==2.5.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: mypy>=1.8.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
30
|
+
Provides-Extra: test
|
|
31
|
+
Requires-Dist: mockito==1.5.4; extra == 'test'
|
|
32
|
+
Requires-Dist: pytest-mock==3.14.1; extra == 'test'
|
|
33
|
+
Requires-Dist: pytest==8.4.1; extra == 'test'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# DeltaFi Action Kit
|
|
37
|
+
|
|
38
|
+
This project provides a Python implementation of the DeltaFi Action Kit. The DeltaFi Action Kit is a setup of modules which simplify the creation of a DeltaFi Plugin.
|
|
39
|
+
|
|
40
|
+
## Development Setup
|
|
41
|
+
|
|
42
|
+
This project uses [uv](https://github.com/astral-sh/uv) for dependency management and building. uv is a fast Python package installer and resolver.
|
|
43
|
+
|
|
44
|
+
### Prerequisites
|
|
45
|
+
|
|
46
|
+
- Python 3.13 or higher
|
|
47
|
+
- uv (will be installed automatically via the build process)
|
|
48
|
+
|
|
49
|
+
### Building and Testing
|
|
50
|
+
|
|
51
|
+
The project uses Gradle to orchestrate the build process with uv:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Build the project
|
|
55
|
+
./gradlew assemble
|
|
56
|
+
|
|
57
|
+
# Run tests
|
|
58
|
+
./gradlew test
|
|
59
|
+
|
|
60
|
+
# Clean build artifacts
|
|
61
|
+
./gradlew clean
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Manual Development
|
|
65
|
+
|
|
66
|
+
For manual development without Gradle:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cd src
|
|
70
|
+
|
|
71
|
+
# Install uv if not already installed
|
|
72
|
+
brew install uv || pip install uv
|
|
73
|
+
|
|
74
|
+
# Install dependencies
|
|
75
|
+
uv pip install -e .[test]
|
|
76
|
+
|
|
77
|
+
# Run tests
|
|
78
|
+
uv run pytest
|
|
79
|
+
|
|
80
|
+
# Build package
|
|
81
|
+
uv build
|
|
82
|
+
```
|
deltafi-2.30.1/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# DeltaFi Action Kit
|
|
2
|
+
|
|
3
|
+
This project provides a Python implementation of the DeltaFi Action Kit. The DeltaFi Action Kit is a setup of modules which simplify the creation of a DeltaFi Plugin.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
This project uses [uv](https://github.com/astral-sh/uv) for dependency management and building. uv is a fast Python package installer and resolver.
|
|
8
|
+
|
|
9
|
+
### Prerequisites
|
|
10
|
+
|
|
11
|
+
- Python 3.13 or higher
|
|
12
|
+
- uv (will be installed automatically via the build process)
|
|
13
|
+
|
|
14
|
+
### Building and Testing
|
|
15
|
+
|
|
16
|
+
The project uses Gradle to orchestrate the build process with uv:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Build the project
|
|
20
|
+
./gradlew assemble
|
|
21
|
+
|
|
22
|
+
# Run tests
|
|
23
|
+
./gradlew test
|
|
24
|
+
|
|
25
|
+
# Clean build artifacts
|
|
26
|
+
./gradlew clean
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Manual Development
|
|
30
|
+
|
|
31
|
+
For manual development without Gradle:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cd src
|
|
35
|
+
|
|
36
|
+
# Install uv if not already installed
|
|
37
|
+
brew install uv || pip install uv
|
|
38
|
+
|
|
39
|
+
# Install dependencies
|
|
40
|
+
uv pip install -e .[test]
|
|
41
|
+
|
|
42
|
+
# Run tests
|
|
43
|
+
uv run pytest
|
|
44
|
+
|
|
45
|
+
# Build package
|
|
46
|
+
uv build
|
|
47
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "deltafi"
|
|
3
|
+
version = "2.30.1"
|
|
4
|
+
description = "SDK for DeltaFi plugins and actions"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "DeltaFi", email = "deltafi@systolic.com"}
|
|
7
|
+
]
|
|
8
|
+
license = {text = "Apache License, Version 2.0"}
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["deltafi"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"License :: OSI Approved :: Apache Software License",
|
|
13
|
+
"Topic :: Software Development",
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.13"
|
|
19
|
+
]
|
|
20
|
+
requires-python = ">=3.13"
|
|
21
|
+
dependencies = [
|
|
22
|
+
"deepdiff==6.7.1",
|
|
23
|
+
"json-logging==1.5.1",
|
|
24
|
+
"minio==7.2.15",
|
|
25
|
+
"PyYAML==6.0.2",
|
|
26
|
+
"pydantic==2.11.7",
|
|
27
|
+
"redis==6.2.0",
|
|
28
|
+
"requests==2.32.4",
|
|
29
|
+
"urllib3==2.5.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
test = [
|
|
34
|
+
"pytest==8.4.1",
|
|
35
|
+
"pytest-mock==3.14.1",
|
|
36
|
+
"mockito==1.5.4",
|
|
37
|
+
]
|
|
38
|
+
dev = [
|
|
39
|
+
"ruff>=0.1.0",
|
|
40
|
+
"mypy>=1.8.0",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
"Source Code" = "https://gitlab.com/deltafi/deltafi"
|
|
45
|
+
Documentation = "https://docs.deltafi.org/#/"
|
|
46
|
+
"Bug Reports" = "https://chat.deltafi.org/deltafi/channels/bug-reports"
|
|
47
|
+
|
|
48
|
+
[build-system]
|
|
49
|
+
requires = ["hatchling"]
|
|
50
|
+
build-backend = "hatchling.build"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "deltafi"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
description = "SDK for DeltaFi plugins and actions"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "DeltaFi", email = "deltafi@systolic.com"}
|
|
7
|
+
]
|
|
8
|
+
license = {text = "Apache License, Version 2.0"}
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["deltafi"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"License :: OSI Approved :: Apache Software License",
|
|
13
|
+
"Topic :: Software Development",
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.13"
|
|
19
|
+
]
|
|
20
|
+
requires-python = ">=3.13"
|
|
21
|
+
dependencies = [
|
|
22
|
+
"deepdiff==6.7.1",
|
|
23
|
+
"json-logging==1.5.1",
|
|
24
|
+
"minio==7.2.15",
|
|
25
|
+
"PyYAML==6.0.2",
|
|
26
|
+
"pydantic==2.11.7",
|
|
27
|
+
"redis==6.2.0",
|
|
28
|
+
"requests==2.32.4",
|
|
29
|
+
"urllib3==2.5.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
test = [
|
|
34
|
+
"pytest==8.4.1",
|
|
35
|
+
"pytest-mock==3.14.1",
|
|
36
|
+
"mockito==1.5.4",
|
|
37
|
+
]
|
|
38
|
+
dev = [
|
|
39
|
+
"ruff>=0.1.0",
|
|
40
|
+
"mypy>=1.8.0",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
"Source Code" = "https://gitlab.com/deltafi/deltafi"
|
|
45
|
+
Documentation = "https://docs.deltafi.org/#/"
|
|
46
|
+
"Bug Reports" = "https://chat.deltafi.org/deltafi/channels/bug-reports"
|
|
47
|
+
|
|
48
|
+
[build-system]
|
|
49
|
+
requires = ["hatchling"]
|
|
50
|
+
build-backend = "hatchling.build"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#
|
|
2
|
+
# DeltaFi - Data transformation and enrichment platform
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2021-2025 DeltaFi Contributors <deltafi@deltafi.org>
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
import os
|
|
20
|
+
import sys
|
|
21
|
+
|
|
22
|
+
PROJECT_PATH = os.getcwd()
|
|
23
|
+
SOURCE_PATH = os.path.join(
|
|
24
|
+
PROJECT_PATH, "src"
|
|
25
|
+
)
|
|
26
|
+
sys.path.append(SOURCE_PATH)
|
|
27
|
+
TEST_PATH = os.path.join(
|
|
28
|
+
PROJECT_PATH, "src/test"
|
|
29
|
+
)
|
|
30
|
+
sys.path.append(TEST_PATH)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#
|
|
2
|
+
# DeltaFi - Data transformation and enrichment platform
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2021-2025 DeltaFi Contributors <deltafi@deltafi.org>
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
from deltafi.domain import Context, Event
|
|
20
|
+
from deltafi.storage import Segment
|
|
21
|
+
|
|
22
|
+
SEG_ID = "1"
|
|
23
|
+
TEST_DID = "123did"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def make_segment(seg_id):
|
|
27
|
+
return Segment(uuid=seg_id, offset=0, size=100, did=TEST_DID)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def make_context_dict():
|
|
31
|
+
return {
|
|
32
|
+
'did': TEST_DID,
|
|
33
|
+
'deltaFileName': 'FILENAME',
|
|
34
|
+
'dataSource': 'DATA_SOURCE',
|
|
35
|
+
'flowName': 'FLOW_NAME',
|
|
36
|
+
'flowId': 'FLOW_ID',
|
|
37
|
+
'actionName': 'ACTION_NAME',
|
|
38
|
+
'actionVersion': '1.0',
|
|
39
|
+
'hostname': 'HOSTNAME',
|
|
40
|
+
'systemName': 'SYSTEM_NAME'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def make_content_dict(name):
|
|
45
|
+
return {
|
|
46
|
+
'name': name,
|
|
47
|
+
'segments': [make_segment(SEG_ID).json()],
|
|
48
|
+
'mediaType': 'xml'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def make_delta_file_message_dict():
|
|
53
|
+
return {
|
|
54
|
+
'metadata': {'plKey1': 'valueA', 'plKey2': 'valueB'},
|
|
55
|
+
'contentList': [make_content_dict('CONTENT_NAME'), make_content_dict('CONTENT 2')]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def make_context():
|
|
60
|
+
return Context(did=TEST_DID,
|
|
61
|
+
delta_file_name='FILENAME',
|
|
62
|
+
data_source='DATA_SOURCE',
|
|
63
|
+
flow_name='FLOW_NAME',
|
|
64
|
+
flow_id='FLOW_ID',
|
|
65
|
+
action_name='ACTION_NAME',
|
|
66
|
+
action_version='1.0',
|
|
67
|
+
hostname='HOSTNAME',
|
|
68
|
+
system_name='SYSTEM_NAME',
|
|
69
|
+
content_service=None)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def make_event(content_service):
|
|
73
|
+
logger = None
|
|
74
|
+
event = Event.create({
|
|
75
|
+
'deltaFileMessages': [make_delta_file_message_dict()],
|
|
76
|
+
'actionContext': make_context_dict(),
|
|
77
|
+
'actionParams': {
|
|
78
|
+
"thing": "theThing"
|
|
79
|
+
}
|
|
80
|
+
}, content_service, logger)
|
|
81
|
+
return event
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This file will be ignored by _read_valid_files() due to its extension
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#
|
|
2
|
+
# DeltaFi - Data transformation and enrichment platform
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2021-2025 DeltaFi Contributors <deltafi@deltafi.org>
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#
|
|
2
|
+
# DeltaFi - Data transformation and enrichment platform
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2021-2025 DeltaFi Contributors <deltafi@deltafi.org>
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
from abc import abstractmethod
|
|
20
|
+
from typing import Dict, List
|
|
21
|
+
|
|
22
|
+
from deltafi.action import ActionOptions, DescriptionWithConditions, InputSpec, OutputSpec, TransformAction
|
|
23
|
+
from deltafi.domain import Context, Content
|
|
24
|
+
from deltafi.input import TransformInput
|
|
25
|
+
from deltafi.result import TransformResult
|
|
26
|
+
from deltafi.storage import ContentService
|
|
27
|
+
from mockito import mock
|
|
28
|
+
from pydantic import BaseModel, Field
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class SampleTransformParameters(BaseModel):
|
|
32
|
+
a_string: str = Field(description="this string parameter is required")
|
|
33
|
+
def_string: str = Field(default="default-val", description="str with default")
|
|
34
|
+
a_dict: dict[str, str] = Field(description="this dict parameter is required")
|
|
35
|
+
def_dict: Dict[str, str] = Field(default={"key1:" "val1"}, description="dict has default")
|
|
36
|
+
a_list: List[str] = Field(default=[], description="list with default")
|
|
37
|
+
a_bool: bool = Field(description="this boolean parameter is required")
|
|
38
|
+
def_int: int = Field(default=100, description="int with default")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class SampleTransformAction(TransformAction):
|
|
42
|
+
def __init__(self):
|
|
43
|
+
super().__init__('', ActionOptions(description='Transform action description',
|
|
44
|
+
input_spec=InputSpec(content_summary='The input content summary', metadata_summary='The input metadata summary'),
|
|
45
|
+
output_spec=OutputSpec(content_summary='The output content summary', metadata_summary='The output metadata summary', annotations_summary='The output annotations summary'),
|
|
46
|
+
filters=[DescriptionWithConditions('Filter 1', ['Condition A', 'Condition B']),
|
|
47
|
+
'Filter 2'],
|
|
48
|
+
errors=[DescriptionWithConditions('Error 1', ['Condition A', 'Condition B']),
|
|
49
|
+
'Error 2'],
|
|
50
|
+
notes=['Note 1', 'Note2'],
|
|
51
|
+
details='The details'))
|
|
52
|
+
|
|
53
|
+
def param_class(self):
|
|
54
|
+
return SampleTransformParameters
|
|
55
|
+
|
|
56
|
+
def transform(self, context: Context, params: SampleTransformParameters, transform_input: TransformInput):
|
|
57
|
+
return TransformResult(context).add_metadata('transformKey', 'transformValue') \
|
|
58
|
+
.add_content(Content(name='transformed content', segments=[], media_type='text/plain',
|
|
59
|
+
content_service=mock(ContentService)))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class SampleAbstractTransformAction(TransformAction):
|
|
63
|
+
def __init__(self):
|
|
64
|
+
super().__init__('Transform action description - ignored due to the abstract method')
|
|
65
|
+
|
|
66
|
+
def param_class(self):
|
|
67
|
+
return SampleTransformParameters
|
|
68
|
+
|
|
69
|
+
@abstractmethod
|
|
70
|
+
def extra_abstract_method(self):
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
def transform(self, context: Context, params: SampleTransformParameters, transform_input: TransformInput):
|
|
74
|
+
return TransformResult(context).add_metadata('transformKey', 'transformValue') \
|
|
75
|
+
.add_content(Content(name='transformed content', segments=[], media_type='text/plain',
|
|
76
|
+
content_service=mock(ContentService)))
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#
|
|
2
|
+
# DeltaFi - Data transformation and enrichment platform
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2021-2025 DeltaFi Contributors <deltafi@deltafi.org>
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
import time
|
|
20
|
+
|
|
21
|
+
import redis
|
|
22
|
+
from deltafi.actioneventqueue import ActionEventQueue
|
|
23
|
+
from mockito import when, mock, unstub
|
|
24
|
+
|
|
25
|
+
TEST_URL = "http://127.0.0.1:12345"
|
|
26
|
+
TEST_ACTION = "Action"
|
|
27
|
+
TEST_ITEM = "1234"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_action_event_queue_size():
|
|
31
|
+
unstub()
|
|
32
|
+
mock_pool = mock(redis.ConnectionPool)
|
|
33
|
+
mock_conn = mock(redis.Redis)
|
|
34
|
+
|
|
35
|
+
when(redis).ConnectionPool(...).thenReturn(mock_pool)
|
|
36
|
+
when(redis).Redis(connection_pool=mock_pool).thenReturn(mock_conn)
|
|
37
|
+
when(mock_conn).zcard(TEST_ACTION).thenReturn(1)
|
|
38
|
+
|
|
39
|
+
service = ActionEventQueue(TEST_URL, 5, "password", None)
|
|
40
|
+
assert service.size(TEST_ACTION) == 1
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_action_event_queue_put():
|
|
44
|
+
unstub()
|
|
45
|
+
mock_pool = mock(redis.ConnectionPool)
|
|
46
|
+
mock_conn = mock(redis.Redis)
|
|
47
|
+
|
|
48
|
+
when(redis).ConnectionPool(...).thenReturn(mock_pool)
|
|
49
|
+
when(redis).Redis(connection_pool=mock_pool).thenReturn(mock_conn)
|
|
50
|
+
when(time).time().thenReturn(1.6)
|
|
51
|
+
when(mock_conn).zadd(TEST_ACTION, {TEST_ITEM: 1600}, nx=True).thenReturn(1)
|
|
52
|
+
|
|
53
|
+
service = ActionEventQueue(TEST_URL, 5, "password", None)
|
|
54
|
+
assert service.put(TEST_ACTION, TEST_ITEM) == 1
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_action_event_queue_take():
|
|
58
|
+
unstub()
|
|
59
|
+
mock_pool = mock(redis.ConnectionPool)
|
|
60
|
+
mock_conn = mock(redis.Redis)
|
|
61
|
+
|
|
62
|
+
result_tuple = (TEST_ACTION, TEST_ITEM, 1600)
|
|
63
|
+
|
|
64
|
+
when(redis).ConnectionPool(...).thenReturn(mock_pool)
|
|
65
|
+
when(redis).Redis(connection_pool=mock_pool).thenReturn(mock_conn)
|
|
66
|
+
when(mock_conn).bzpopmin(TEST_ACTION, 0).thenReturn(result_tuple)
|
|
67
|
+
|
|
68
|
+
service = ActionEventQueue(TEST_URL, 5, "password", "some-pod")
|
|
69
|
+
assert service.take(TEST_ACTION) == TEST_ITEM
|