deltafi 1.1.16__py3-none-any.whl → 2.0rc1705013410531__py3-none-any.whl

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/action.py CHANGED
@@ -22,18 +22,15 @@ from typing import Any, List
22
22
  from deltafi.actiontype import ActionType
23
23
  from deltafi.genericmodel import GenericModel
24
24
  from deltafi.domain import Context, DeltaFileMessage
25
- from deltafi.input import DomainInput, EgressInput, EnrichInput, FormatInput, LoadInput, TransformInput, ValidateInput
25
+ from deltafi.input import EgressInput, TransformInput
26
26
  from deltafi.result import *
27
27
  from pydantic import BaseModel
28
28
 
29
29
 
30
30
  class Action(ABC):
31
- def __init__(self, action_type: ActionType, description: str, requires_domains: List[str],
32
- requires_enrichments: List[str], valid_result_types: tuple):
31
+ def __init__(self, action_type: ActionType, description: str, valid_result_types: tuple):
33
32
  self.action_type = action_type
34
33
  self.description = description
35
- self.requires_domains = requires_domains
36
- self.requires_enrichments = requires_enrichments
37
34
  self.valid_result_types = valid_result_types
38
35
  self.action_execution = None
39
36
 
@@ -81,25 +78,9 @@ class Action(ABC):
81
78
  f"but a {result.__class__.__name__} was returned")
82
79
 
83
80
 
84
- class DomainAction(Action, ABC):
85
- def __init__(self, description: str, requires_domains: List[str]):
86
- super().__init__(ActionType.DOMAIN, description, requires_domains, [], (DomainResult, ErrorResult))
87
-
88
- def build_input(self, context: Context, delta_file_message: DeltaFileMessage):
89
- return DomainInput(content=delta_file_message.content_list, metadata=delta_file_message.metadata,
90
- domains={domain.name: domain for domain in delta_file_message.domains})
91
-
92
- @abstractmethod
93
- def domain(self, context: Context, params: BaseModel, domain_input: DomainInput):
94
- pass
95
-
96
- def execute(self, context: Context, domain_input: DomainInput, params: BaseModel):
97
- return self.domain(context, params, domain_input)
98
-
99
-
100
81
  class EgressAction(Action, ABC):
101
82
  def __init__(self, description: str):
102
- super().__init__(ActionType.EGRESS, description, [], [], (EgressResult, ErrorResult, FilterResult))
83
+ super().__init__(ActionType.EGRESS, description, (EgressResult, ErrorResult, FilterResult))
103
84
 
104
85
  def build_input(self, context: Context, delta_file_message: DeltaFileMessage):
105
86
  return EgressInput(content=delta_file_message.content_list[0], metadata=delta_file_message.metadata)
@@ -112,81 +93,9 @@ class EgressAction(Action, ABC):
112
93
  return self.egress(context, params, egress_input)
113
94
 
114
95
 
115
- class EnrichAction(Action, ABC):
116
- def __init__(self, description: str, requires_domains: List[str], requires_enrichments: List[str]):
117
- super().__init__(ActionType.ENRICH, description, requires_domains, requires_enrichments,
118
- (EnrichResult, ErrorResult))
119
-
120
- def build_input(self, context: Context, delta_file_message: DeltaFileMessage):
121
- return EnrichInput(content=delta_file_message.content_list, metadata=delta_file_message.metadata,
122
- domains={domain.name: domain for domain in delta_file_message.domains},
123
- enrichments={domain.name: domain for domain in delta_file_message.enrichments})
124
-
125
- @abstractmethod
126
- def enrich(self, context: Context, params: BaseModel, enrich_input: EnrichInput):
127
- pass
128
-
129
- def execute(self, context: Context, enrich_input: EnrichInput, params: BaseModel):
130
- return self.enrich(context, params, enrich_input)
131
-
132
-
133
- class FormatAction(Action, ABC):
134
- def __init__(self, description: str, requires_domains: List[str], requires_enrichments: List[str]):
135
- super().__init__(ActionType.FORMAT, description, requires_domains, requires_enrichments,
136
- (FormatResult, FormatManyResult, ErrorResult, FilterResult))
137
-
138
- def build_input(self, context: Context, delta_file_message: DeltaFileMessage):
139
- return FormatInput(content=delta_file_message.content_list, metadata=delta_file_message.metadata,
140
- domains={domain.name: domain for domain in delta_file_message.domains},
141
- enrichments={domain.name: domain for domain in delta_file_message.enrichments})
142
-
143
- def collect(self, format_inputs: List[FormatInput]):
144
- all_content = []
145
- all_metadata = {}
146
- all_domains = {}
147
- all_enrichments = {}
148
- for format_input in format_inputs:
149
- all_content += format_input.content
150
- all_metadata.update(format_input.metadata)
151
- all_domains.update(format_input.domains)
152
- all_enrichments.update(format_input.enrichments)
153
- return FormatInput(content=all_content, metadata=all_metadata, domains=all_domains, enrichments=all_enrichments)
154
-
155
- @abstractmethod
156
- def format(self, context: Context, params: BaseModel, format_input: FormatInput):
157
- pass
158
-
159
- def execute(self, context: Context, format_input: FormatInput, params: BaseModel):
160
- return self.format(context, params, format_input)
161
-
162
-
163
- class LoadAction(Action, ABC):
164
- def __init__(self, description: str):
165
- super().__init__(ActionType.LOAD, description, [], [],
166
- (LoadResult, LoadManyResult, ErrorResult, FilterResult, ReinjectResult))
167
-
168
- def build_input(self, context: Context, delta_file_message: DeltaFileMessage):
169
- return LoadInput(content=delta_file_message.content_list, metadata=delta_file_message.metadata)
170
-
171
- def collect(self, load_inputs: List[LoadInput]):
172
- all_content = []
173
- all_metadata = {}
174
- for load_input in load_inputs:
175
- all_content += load_input.content
176
- all_metadata.update(load_input.metadata)
177
- return LoadInput(content=all_content, metadata=all_metadata)
178
-
179
- @abstractmethod
180
- def load(self, context: Context, params: BaseModel, load_input: LoadInput):
181
- pass
182
-
183
- def execute(self, context: Context, load_input: LoadInput, params: BaseModel):
184
- return self.load(context, params, load_input)
185
-
186
-
187
96
  class TimedIngressAction(Action, ABC):
188
97
  def __init__(self, description: str):
189
- super().__init__(ActionType.TIMED_INGRESS, description, [], [], (IngressResult, ErrorResult))
98
+ super().__init__(ActionType.TIMED_INGRESS, description, (IngressResult, ErrorResult))
190
99
 
191
100
  def build_input(self, context: Context, delta_file_message: DeltaFileMessage):
192
101
  return None
@@ -201,7 +110,7 @@ class TimedIngressAction(Action, ABC):
201
110
 
202
111
  class TransformAction(Action, ABC):
203
112
  def __init__(self, description: str):
204
- super().__init__(ActionType.TRANSFORM, description, [], [], (TransformResult, ErrorResult, FilterResult, ReinjectResult))
113
+ super().__init__(ActionType.TRANSFORM, description, (TransformResult, ErrorResult, FilterResult))
205
114
 
206
115
  def build_input(self, context: Context, delta_file_message: DeltaFileMessage):
207
116
  return TransformInput(content=delta_file_message.content_list, metadata=delta_file_message.metadata)
@@ -220,18 +129,3 @@ class TransformAction(Action, ABC):
220
129
 
221
130
  def execute(self, context: Context, transform_input: TransformInput, params: BaseModel):
222
131
  return self.transform(context, params, transform_input)
223
-
224
-
225
- class ValidateAction(Action, ABC):
226
- def __init__(self, description: str):
227
- super().__init__(ActionType.VALIDATE, description, [], [], (ValidateResult, ErrorResult, FilterResult))
228
-
229
- def build_input(self, context: Context, delta_file_message: DeltaFileMessage):
230
- return ValidateInput(content=delta_file_message.content_list[0], metadata=delta_file_message.metadata)
231
-
232
- @abstractmethod
233
- def validate(self, context: Context, params: BaseModel, validate_input: ValidateInput):
234
- pass
235
-
236
- def execute(self, context: Context, validate_input: ValidateInput, params: BaseModel):
237
- return self.validate(context, params, validate_input)
deltafi/actiontype.py CHANGED
@@ -22,11 +22,5 @@ from enum import Enum
22
22
  class ActionType(Enum):
23
23
  TIMED_INGRESS = "TIMED_INGRESS"
24
24
  TRANSFORM = "TRANSFORM"
25
- LOAD = "LOAD"
26
- DOMAIN = "DOMAIN"
27
- ENRICH = "ENRICH"
28
- FORMAT = "FORMAT"
29
- VALIDATE = "VALIDATE"
30
25
  EGRESS = "EGRESS"
31
- DELETE = "DELETE"
32
26
  UNKNOWN = "UNKNOWN"
deltafi/input.py CHANGED
@@ -17,172 +17,13 @@
17
17
  #
18
18
 
19
19
  from deltafi.domain import *
20
- from deltafi.exception import MissingMetadataException, ExpectedContentException, MissingDomainException, \
21
- MissingEnrichmentException
22
-
23
-
24
- class DomainInput(NamedTuple):
25
- content: List[Content]
26
- metadata: Dict[str, str]
27
- domains: Dict[str, Domain]
28
-
29
- def has_content(self) -> bool:
30
- return len(self.content) > 0
31
-
32
- def content_at(self, index: int) -> Content:
33
- if len(self.content) < index + 1:
34
- raise ExpectedContentException(index, len(self.content))
35
- return self.content[index]
36
-
37
- def first_content(self):
38
- return self.content_at(0)
39
-
40
- def get_metadata(self, key: str):
41
- if key in self.metadata:
42
- return self.metadata[key]
43
- else:
44
- raise MissingMetadataException(key)
45
-
46
- def get_metadata_or_else(self, key: str, default: str) -> str:
47
- if key in self.metadata:
48
- return self.metadata[key]
49
- else:
50
- return default
51
-
52
- def has_domain(self, name: str) -> bool:
53
- return name in self.domains
54
-
55
- def domain(self, name: str) -> Domain:
56
- if not self.has_domain(name):
57
- raise MissingDomainException(name)
58
- return self.domains[name]
59
-
20
+ from deltafi.exception import MissingMetadataException, ExpectedContentException
60
21
 
61
22
  class EgressInput(NamedTuple):
62
23
  content: Content
63
24
  metadata: dict
64
25
 
65
26
 
66
- class EnrichInput(NamedTuple):
67
- content: List[Content]
68
- metadata: dict
69
- domains: Dict[str, Domain]
70
- enrichments: Dict[str, Domain]
71
-
72
- def has_content(self) -> bool:
73
- return len(self.content) > 0
74
-
75
- def content_at(self, index: int) -> Content:
76
- if len(self.content) < index + 1:
77
- raise ExpectedContentException(index, len(self.content))
78
- return self.content[index]
79
-
80
- def first_content(self):
81
- return self.content_at(0)
82
-
83
- def get_metadata(self, key: str):
84
- if key in self.metadata:
85
- return self.metadata[key]
86
- else:
87
- raise MissingMetadataException(key)
88
-
89
- def get_metadata_or_else(self, key: str, default: str) -> str:
90
- if key in self.metadata:
91
- return self.metadata[key]
92
- else:
93
- return default
94
-
95
- def has_domain(self, name: str) -> bool:
96
- return name in self.domains
97
-
98
- def domain(self, name: str) -> Domain:
99
- if not self.has_domain(name):
100
- raise MissingDomainException(name)
101
- return self.domains[name]
102
-
103
- def has_enrichment(self, name: str) -> bool:
104
- return name in self.enrichments
105
-
106
- def enrichment(self, name: str) -> Domain:
107
- if not self.has_enrichment(name):
108
- raise MissingEnrichmentException(name)
109
- return self.enrichments[name]
110
-
111
-
112
- class FormatInput(NamedTuple):
113
- content: List[Content]
114
- metadata: dict
115
- domains: Dict[str, Domain]
116
- enrichments: Dict[str, Domain]
117
-
118
- def has_content(self) -> bool:
119
- return len(self.content) > 0
120
-
121
- def content_at(self, index: int) -> Content:
122
- if len(self.content) < index + 1:
123
- raise ExpectedContentException(index, len(self.content))
124
- return self.content[index]
125
-
126
- def first_content(self):
127
- return self.content_at(0)
128
-
129
- def get_metadata(self, key: str):
130
- if key in self.metadata:
131
- return self.metadata[key]
132
- else:
133
- raise MissingMetadataException(key)
134
-
135
- def get_metadata_or_else(self, key: str, default: str) -> str:
136
- if key in self.metadata:
137
- return self.metadata[key]
138
- else:
139
- return default
140
-
141
- def has_domain(self, name: str) -> bool:
142
- return name in self.domains
143
-
144
- def domain(self, name: str) -> Domain:
145
- if not self.has_domain(name):
146
- raise MissingDomainException(name)
147
- return self.domains[name]
148
-
149
- def has_enrichment(self, name: str) -> bool:
150
- return name in self.enrichments
151
-
152
- def enrichment(self, name: str) -> Domain:
153
- if not self.has_enrichment(name):
154
- raise MissingEnrichmentException(name)
155
- return self.enrichments[name]
156
-
157
-
158
- class LoadInput(NamedTuple):
159
- content: List[Content]
160
- metadata: dict
161
-
162
- def has_content(self) -> bool:
163
- return len(self.content) > 0
164
-
165
- def content_at(self, index: int) -> Content:
166
- if len(self.content) < index + 1:
167
- raise ExpectedContentException(index, len(self.content))
168
- return self.content[index]
169
-
170
- def first_content(self):
171
- return self.content_at(0)
172
-
173
- def get_metadata(self, key: str):
174
- if key in self.metadata:
175
- return self.metadata[key]
176
- else:
177
- raise MissingMetadataException(key)
178
-
179
- def get_metadata_or_else(self, key: str, default: str) -> str:
180
- if key in self.metadata:
181
- return self.metadata[key]
182
- else:
183
- return default
184
-
185
-
186
27
  class TransformInput(NamedTuple):
187
28
  content: List[Content]
188
29
  metadata: dict
@@ -209,8 +50,3 @@ class TransformInput(NamedTuple):
209
50
  return self.metadata[key]
210
51
  else:
211
52
  return default
212
-
213
-
214
- class ValidateInput(NamedTuple):
215
- content: Content
216
- metadata: dict
deltafi/plugin.py CHANGED
@@ -165,8 +165,6 @@ class Plugin(object):
165
165
  'name': self.action_name(action),
166
166
  'description': action.description,
167
167
  'type': action.action_type.name,
168
- 'requiresDomains': action.requires_domains,
169
- 'requiresEnrichments': action.requires_enrichments,
170
168
  'schema': action.param_class().model_json_schema()
171
169
  }
172
170
 
deltafi/result.py CHANGED
@@ -46,21 +46,6 @@ class Result:
46
46
  self.metrics.append(metric)
47
47
 
48
48
 
49
- class DomainResult(Result):
50
- def __init__(self, context: Context):
51
- super().__init__('domain', 'DOMAIN', context)
52
- self.annotations = {}
53
-
54
- def annotate(self, key: str, value: str):
55
- self.annotations[key] = value
56
- return self
57
-
58
- def response(self):
59
- return {
60
- 'annotations': self.annotations
61
- }
62
-
63
-
64
49
  class EgressResult(Result):
65
50
  def __init__(self, context: Context, destination: str, bytes_egressed: int):
66
51
  super().__init__(None, 'EGRESS', context)
@@ -71,31 +56,6 @@ class EgressResult(Result):
71
56
  return None
72
57
 
73
58
 
74
- class EnrichResult(Result):
75
- def __init__(self, context: Context):
76
- super().__init__('enrich', 'ENRICH', context)
77
- self.enrichments = []
78
- self.annotations = {}
79
-
80
- def enrich(self, name: str, value: str, media_type: str):
81
- self.enrichments.append({
82
- 'name': name,
83
- 'value': value,
84
- 'mediaType': media_type
85
- })
86
- return self
87
-
88
- def annotate(self, key: str, value: str):
89
- self.annotations[key] = value
90
- return self
91
-
92
- def response(self):
93
- return {
94
- 'enrichments': self.enrichments,
95
- 'annotations': self.annotations
96
- }
97
-
98
-
99
59
  class ErrorResult(Result):
100
60
  def __init__(self, context: Context, error_cause: str, error_context: str):
101
61
  super().__init__('error', 'ERROR', context)
@@ -134,80 +94,6 @@ class FilterResult(Result):
134
94
  }
135
95
 
136
96
 
137
- class FormatResult(Result):
138
- def __init__(self, context: Context):
139
- super().__init__('format', 'FORMAT', context)
140
- self.content = None
141
- self.delete_metadata_keys = []
142
- self.metadata = {}
143
-
144
- def set_metadata(self, metadata: dict):
145
- self.metadata = metadata
146
- return self
147
-
148
- def add_metadata(self, key: str, value: str):
149
- self.metadata[key] = value
150
- return self
151
-
152
- def delete_metadata_key(self, key: str):
153
- self.delete_metadata_keys.append(key)
154
- return self
155
-
156
- def set_content(self, content: Content):
157
- self.content = content
158
- return self
159
-
160
- def save_string_content(self, string_data: str, name: str, media_type: str):
161
- segment = self.context.content_service.put_str(self.context.did, string_data)
162
- self.content = Content(name=name, segments=[segment], media_type=media_type,
163
- content_service=self.context.content_service)
164
- return self
165
-
166
- def save_byte_content(self, byte_data: bytes, name: str, media_type: str):
167
- segment = self.context.content_service.put_bytes(self.context.did, byte_data)
168
- self.content = Content(name=name, segments=[segment], media_type=media_type,
169
- content_service=self.context.content_service)
170
- return self
171
-
172
- def response(self):
173
- return {
174
- 'content': self.content.json(),
175
- 'metadata': self.metadata,
176
- 'deleteMetadataKeys': self.delete_metadata_keys
177
- }
178
-
179
-
180
- class ChildFormatResult:
181
- def __init__(self, format_result: FormatResult = None):
182
- self._did = str(uuid.uuid4())
183
- self.format_result = format_result
184
-
185
- @property
186
- def did(self):
187
- return self._did
188
-
189
- def response(self):
190
- res = self.format_result.response()
191
- res["did"] = self._did
192
- return res
193
-
194
-
195
- class FormatManyResult(Result):
196
- def __init__(self, context: Context):
197
- super().__init__('formatMany', 'FORMAT_MANY', context)
198
- self.format_results = []
199
-
200
- def add_format_result(self, format_result):
201
- if isinstance(format_result, ChildFormatResult):
202
- self.format_results.append(format_result)
203
- else:
204
- self.format_results.append(ChildFormatResult(format_result))
205
- return self
206
-
207
- def response(self):
208
- return [format_result.response() for format_result in self.format_results]
209
-
210
-
211
97
  class IngressResultItem:
212
98
  def __init__(self, context: Context, filename: str):
213
99
  self.context = context
@@ -288,129 +174,6 @@ class IngressResult(Result):
288
174
  }
289
175
 
290
176
 
291
- class LoadResult(Result):
292
- def __init__(self, context: Context):
293
- super().__init__('load', 'LOAD', context)
294
- self.content = []
295
- self.metadata = {}
296
- self.domains = []
297
- self.annotations = {}
298
- self.delete_metadata_keys = []
299
-
300
- # content can be a single Content or a List[Content]
301
- def add_content(self, content):
302
- if content:
303
- if type(content) == list:
304
- self.content.extend(content)
305
- else:
306
- self.content.append(content)
307
-
308
- return self
309
-
310
- def save_string_content(self, string_data: str, name: str, media_type: str):
311
- segment = self.context.content_service.put_str(self.context.did, string_data)
312
- self.content.append(
313
- Content(name=name, segments=[segment], media_type=media_type, content_service=self.context.content_service))
314
- return self
315
-
316
- def save_byte_content(self, byte_data: bytes, name: str, media_type: str):
317
- segment = self.context.content_service.put_bytes(self.context.did, byte_data)
318
- self.content.append(
319
- Content(name=name, segments=[segment], media_type=media_type, content_service=self.context.content_service))
320
- return self
321
-
322
- def set_metadata(self, metadata: dict):
323
- self.metadata = metadata
324
- return self
325
-
326
- def add_metadata(self, key: str, value: str):
327
- self.metadata[key] = value
328
- return self
329
-
330
- def add_domain(self, name: str, value: str, media_type: str):
331
- self.domains.append({
332
- 'name': name,
333
- 'value': value,
334
- 'mediaType': media_type})
335
- return self
336
-
337
- def annotate(self, key: str, value: str):
338
- self.annotations[key] = value
339
- return self
340
-
341
- def delete_metadata_key(self, key: str):
342
- self.delete_metadata_keys.append(key)
343
- return self
344
-
345
- def response(self):
346
- return {
347
- 'domains': self.domains,
348
- 'content': [content.json() for content in self.content],
349
- 'metadata': self.metadata,
350
- 'annotations': self.annotations,
351
- 'deleteMetadataKeys': self.delete_metadata_keys
352
- }
353
-
354
-
355
- class ChildLoadResult:
356
- def __init__(self, load_result: LoadResult = None):
357
- self._did = str(uuid.uuid4())
358
- self.load_result = load_result
359
-
360
- @property
361
- def did(self):
362
- return self._did
363
-
364
- def response(self):
365
- res = self.load_result.response()
366
- res["did"] = self._did
367
- return res
368
-
369
-
370
- class LoadManyResult(Result):
371
- def __init__(self, context: Context):
372
- super().__init__('loadMany', 'LOAD_MANY', context)
373
- self.load_results = []
374
-
375
- def add_load_result(self, load_result):
376
- if isinstance(load_result, ChildLoadResult):
377
- self.load_results.append(load_result)
378
- else:
379
- self.load_results.append(ChildLoadResult(load_result))
380
- return self
381
-
382
- def response(self):
383
- return [load_result.response() for load_result in self.load_results]
384
-
385
-
386
- class ReinjectResult(Result):
387
- class ReinjectChild:
388
- def __init__(self, filename: str, flow: str, content: List[Content], metadata: Dict[str, str]):
389
- self.filename = filename
390
- self.flow = flow
391
- self.content = content
392
- self.metadata = metadata
393
-
394
- def json(self):
395
- return {
396
- 'filename': self.filename,
397
- 'flow': self.flow,
398
- 'metadata': self.metadata,
399
- 'content': [content.json() for content in self.content]
400
- }
401
-
402
- def __init__(self, context: Context):
403
- super().__init__('reinject', 'REINJECT', context)
404
- self.children = []
405
-
406
- def add_child(self, filename: str, flow: str, content: List[Content], metadata: Dict[str, str]):
407
- child = ReinjectResult.ReinjectChild(filename, flow, content, metadata)
408
- self.children.append(child)
409
-
410
- def response(self):
411
- return [child.json() for child in self.children]
412
-
413
-
414
177
  class TransformResult(Result):
415
178
  def __init__(self, context: Context):
416
179
  super().__init__('transform', 'TRANSFORM', context)
@@ -464,11 +227,3 @@ class TransformResult(Result):
464
227
  'annotations': self.annotations,
465
228
  'deleteMetadataKeys': self.delete_metadata_keys
466
229
  }
467
-
468
-
469
- class ValidateResult(Result):
470
- def __init__(self, context: Context):
471
- super().__init__(None, 'VALIDATE', context)
472
-
473
- def response(self):
474
- return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: deltafi
3
- Version: 1.1.16
3
+ Version: 2.0rc1705013410531
4
4
  Summary: SDK for DeltaFi plugins and actions
5
5
  License: Apache License, Version 2.0
6
6
  Keywords: deltafi
@@ -1,24 +1,22 @@
1
1
  deltafi/__init__.py,sha256=qv6y7PpBG0ekTN9EuD9Lj8JYOLVqZA6tvHwgjplncAM,709
2
- deltafi/action.py,sha256=TM8HwfC12GgfHMBWPmO88N7J9xvwGO8BMwxKTNqwg9A,10498
2
+ deltafi/action.py,sha256=cjnRsmBNCSCosFipIS_UXMHKC5MRITVSdc6MIeYUyL4,5305
3
3
  deltafi/actioneventqueue.py,sha256=mCRE1PFXy_KvaeezTeMze5N400CO1V06zEF8FFD6xZk,2847
4
- deltafi/actiontype.py,sha256=SgCxs5Kn_6BuzuKDk5h93ZLtfdbzV0sWLcEaaB0mqlU,997
4
+ deltafi/actiontype.py,sha256=6OoZNEMcreD5f_QaGhTu8MEYLr3CalzcNu9XuFx40zg,865
5
5
  deltafi/domain.py,sha256=M97_n6KsMmIxCh3h622jNj1n6c5iMEAOn-SFH36oLis,12161
6
6
  deltafi/exception.py,sha256=qQ2TY2QPtMU9t5RH8jmFo_cX98AJ-zOFWP_Wfm5U6qQ,1149
7
7
  deltafi/genericmodel.py,sha256=8VXWgFMjIwG4o3rkcLOa3bQH0Nf-T1Kw621QtMw-4q0,1090
8
- deltafi/input.py,sha256=DuY280ZglZxEUkhjTtyr0g9Ohu2drn16UVhASH244nA,6290
8
+ deltafi/input.py,sha256=2qQcOWqz7lOXZIZipTz5XtcGESpjdnUAsZ7b9YqHw7M,1656
9
9
  deltafi/logger.py,sha256=q76R_Gn8BfcASH3Zy0V82m5ot34bjTnSELyKbjhvx3E,2136
10
10
  deltafi/metric.py,sha256=eIDjZQVO53KuAFoEtjLNFwqMrp_7BC0Td9GLD1tb6sE,967
11
- deltafi/plugin.py,sha256=GkDq9oc5O0QYUZ7CdYcP1f9zRT38ufvzudZ4addHVS8,13076
12
- deltafi/result.py,sha256=KkFKewPxcP8_Slp0D2COJ43h5_fF5Vti9ocWtp8pjpc,14911
11
+ deltafi/plugin.py,sha256=LTkAII2ur6BFylxnp80slzximkDyKr5bvHEzczR9C4U,12956
12
+ deltafi/result.py,sha256=2r3BKNQntlMpFXZtYOm7skoLzBocDRBwtRP3oRkGrfc,7330
13
13
  deltafi/storage.py,sha256=toq58EPZgzj2TfDF-YpFUmRnsWSjACA0KQAZzkM04xU,2740
14
14
  deltafi/test_kit/__init__.py,sha256=qv6y7PpBG0ekTN9EuD9Lj8JYOLVqZA6tvHwgjplncAM,709
15
15
  deltafi/test_kit/assertions.py,sha256=2eahqmbedhnHXMguiJHdaV-6sx4_jvCbxH4HSzx6PV8,1378
16
16
  deltafi/test_kit/compare_helpers.py,sha256=Oi07zsq7jlpAHxqjwHsea84acC3lAL3ooG0VC42lLAc,1581
17
17
  deltafi/test_kit/constants.py,sha256=epz0OS-qILcc8t7iIs5B3m2-wvZx8FpYpyb19ZsImbI,833
18
- deltafi/test_kit/format.py,sha256=YkF8VGuDp6fOxria332zoQJarmmPaN6fTjTuumzyMLI,4071
19
18
  deltafi/test_kit/framework.py,sha256=R07AH4zxWXaJ3QNufGrtiOvdZrZKEoo2FtZLGmgAnRk,13062
20
- deltafi/test_kit/load.py,sha256=W8LRW1-NYHdjPB9UJ7kAAKblv883Ke39v4jewwbfm60,4855
21
19
  deltafi/test_kit/transform.py,sha256=x2TNTV39TmJQbVImm-sOfUlS_qaWcDRi5mfK4ZE0ONE,2608
22
- deltafi-1.1.16.dist-info/METADATA,sha256=Y3plfdN9TFiogOxnhxuUwM-IMyvypRfi5ryP-WLV9kM,1484
23
- deltafi-1.1.16.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
24
- deltafi-1.1.16.dist-info/RECORD,,
20
+ deltafi-2.0rc1705013410531.dist-info/METADATA,sha256=Qnqr2rCpU5PnXE1uJti_UH_Kiz2hVKqvsZHm1iA_BBg,1496
21
+ deltafi-2.0rc1705013410531.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
22
+ deltafi-2.0rc1705013410531.dist-info/RECORD,,
@@ -1,100 +0,0 @@
1
- #
2
- # DeltaFi - Data transformation and enrichment platform
3
- #
4
- # Copyright 2021-2023 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 typing import List
20
-
21
- from deltafi.result import FormatResult, FormatManyResult
22
-
23
- from .assertions import *
24
- from .framework import TestCaseBase, ActionTest
25
-
26
-
27
- class FormatTestCase(TestCaseBase):
28
- def __init__(self, fields: Dict):
29
- super().__init__(fields)
30
- self.metadata = {}
31
- self.delete_metadata_keys = []
32
- self.expected_format_many_result = []
33
-
34
- def expect_format_result(self, metadata: Dict, delete_metadata_keys: List[str]):
35
- self.expected_result_type = FormatResult
36
- self.metadata = metadata
37
- self.delete_metadata_keys = delete_metadata_keys
38
-
39
- def add_format_many_result(self, metadata: Dict, delete_metadata_keys: List):
40
- self.expected_result_type = FormatManyResult
41
- self.expected_format_many_result.append(
42
- {
43
- "metadata": metadata,
44
- "delete_metadata_keys": delete_metadata_keys
45
- }
46
- )
47
-
48
-
49
- class FormatActionTest(ActionTest):
50
- def __init__(self, package_name: str):
51
- """
52
- Provides structure for testing DeltaFi Format action
53
- Args:
54
- package_name: name of the actions package for finding resources
55
- """
56
- super().__init__(package_name)
57
-
58
- def format(self, test_case: FormatTestCase):
59
- if test_case.expected_result_type == FormatManyResult:
60
- self.expect_format_many_result(test_case)
61
- elif test_case.expected_result_type == FormatResult:
62
- self.expect_format_result(test_case)
63
- else:
64
- super().execute(test_case)
65
-
66
- def expect_format_result(self, test_case: FormatTestCase):
67
- result = super().run_and_check_result_type(test_case, FormatResult)
68
- self.assert_format_result(test_case, result)
69
-
70
- def expect_format_many_result(self, test_case: FormatTestCase):
71
- result = super().run_and_check_result_type(test_case, FormatManyResult)
72
- self.assert_format_many_result(test_case, result)
73
-
74
- def assert_format_result(self, test_case: FormatTestCase, result: FormatResult):
75
- # Check output
76
- if result.content is None:
77
- self.compare_all_output(test_case.compare_tool, [])
78
- else:
79
- self.compare_all_output(test_case.compare_tool, [result.content])
80
-
81
- # Check metadata
82
- assert_keys_and_values(test_case.metadata, result.metadata)
83
-
84
- # Check deleted metadata
85
- for key in test_case.delete_metadata_keys:
86
- assert_key_in(key, result.delete_metadata_keys)
87
-
88
- def assert_format_many_result(self, test_case: FormatTestCase, actual: FormatManyResult):
89
- assert_equal_len(test_case.expected_format_many_result, actual.format_results)
90
- for index, expected_child_result in enumerate(test_case.expected_format_many_result):
91
- actual_child = actual.format_results[index]
92
- self.compare_one_content(test_case.compare_tool,
93
- self.expected_outputs[index],
94
- actual_child.format_result.content,
95
- index)
96
-
97
- assert_keys_and_values(expected_child_result['metadata'],
98
- actual_child.format_result.metadata)
99
- for key in expected_child_result['delete_metadata_keys']:
100
- assert_key_in(key, actual_child.format_result.delete_metadata_keys)
deltafi/test_kit/load.py DELETED
@@ -1,122 +0,0 @@
1
- #
2
- # DeltaFi - Data transformation and enrichment platform
3
- #
4
- # Copyright 2021-2023 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 typing import List
20
-
21
- from deltafi.result import LoadResult, ReinjectResult
22
-
23
- from .assertions import *
24
- from .compare_helpers import GenericCompareHelper, CompareHelper
25
- from .framework import TestCaseBase, ActionTest, IOContent
26
-
27
-
28
- class LoadTestCase(TestCaseBase):
29
- def __init__(self, fields: Dict):
30
- super().__init__(fields)
31
- self.metadata = {}
32
- self.delete_metadata_keys = []
33
- self.annotations = {}
34
- self.domains = []
35
- self.domain_cmp_tool = GenericCompareHelper()
36
- self.children = []
37
-
38
- def set_domain_compare_tool(self, helper: CompareHelper):
39
- self.domain_cmp_tool = helper
40
-
41
- def expect_load_result(self, metadata: Dict, delete_metadata_keys: List[str], annotations: Dict, domains: List):
42
- self.expected_result_type = LoadResult
43
- self.metadata = metadata
44
- self.delete_metadata_keys = delete_metadata_keys
45
- self.annotations = annotations
46
- self.domains = domains
47
-
48
- def add_reinject_child(self, filename: str, flow: str, content: IOContent, metadata: Dict):
49
- self.expected_result_type = ReinjectResult
50
- self.children.append(
51
- {
52
- "filename": filename,
53
- "flow": flow,
54
- "content": content,
55
- "metadata": metadata
56
- }
57
- )
58
-
59
-
60
- class LoadActionTest(ActionTest):
61
- def __init__(self, package_name: str):
62
- """
63
- Provides structure for testing DeltaFi Load action
64
- Args:
65
- package_name: name of the actions package for finding resources
66
- """
67
- super().__init__(package_name)
68
-
69
- def load(self, test_case: LoadTestCase):
70
- if test_case.expected_result_type == ReinjectResult:
71
- self.expect_reinject_result(test_case)
72
- elif test_case.expected_result_type == LoadResult:
73
- self.expect_load_result(test_case)
74
- else:
75
- super().execute(test_case)
76
-
77
- def expect_load_result(self, test_case: LoadTestCase):
78
- result = super().run_and_check_result_type(test_case, LoadResult)
79
- self.assert_load_result(test_case, result)
80
-
81
- def expect_reinject_result(self, test_case: LoadTestCase):
82
- result = super().run_and_check_result_type(test_case, ReinjectResult)
83
- self.assert_reinject_result(test_case, result)
84
-
85
- def assert_load_result(self, test_case: LoadTestCase, result: LoadResult):
86
- # Check output
87
- self.compare_all_output(test_case.compare_tool, result.content)
88
-
89
- # Check metadata
90
- assert_keys_and_values(test_case.metadata, result.metadata)
91
-
92
- # Check deleted metadata
93
- for key in test_case.delete_metadata_keys:
94
- assert_key_in(key, result.delete_metadata_keys)
95
-
96
- # Check annotations
97
- assert_keys_and_values(test_case.annotations, result.annotations)
98
-
99
- # Check domains
100
- self.compare_domains(test_case.domain_cmp_tool, test_case.domains, result.domains)
101
-
102
- def assert_reinject_result(self, test_case: LoadTestCase, actual: ReinjectResult):
103
- assert_equal_len(test_case.children, actual.children)
104
- for index, expected in enumerate(test_case.children):
105
- reinject_child = actual.children[index]
106
- assert_equal(expected['filename'], reinject_child.filename)
107
- assert_equal(expected['flow'], reinject_child.flow)
108
- assert_keys_and_values(expected['metadata'], reinject_child.metadata)
109
-
110
- expected_value = expected['content']
111
- child_content = reinject_child.content[0]
112
- seg_id = child_content.segments[0].uuid
113
- actual_content = self.content_service.get_output(seg_id)
114
-
115
- if type(expected_value) == str:
116
- test_case.domain_cmp_tool.compare(expected_value, actual_content, f"RI_child[{index}]")
117
- elif type(expected_value) == IOContent:
118
- expected_data = self.load_file(expected_value)
119
- test_case.domain_cmp_tool.compare(expected_data, actual_content, f"RI_child[{index}]")
120
- else:
121
- raise ValueError(
122
- f"unknown expected_value type: {type(expected_value)}")