deltafi 2.0rc1725920935509__py3-none-any.whl → 2.0rc1727460733389__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/__init__.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
deltafi/action.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
deltafi/actiontype.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
deltafi/domain.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -293,6 +293,12 @@ class Content:
293
293
  """
294
294
  self.segments.extend(other_content.segments)
295
295
 
296
+ def get_segment_names(self):
297
+ segment_names = {}
298
+ for seg in self.segments:
299
+ segment_names[seg.id()] = seg
300
+ return segment_names
301
+
296
302
  def __eq__(self, other):
297
303
  if isinstance(other, Content):
298
304
  return (self.name == other.name and
deltafi/exception.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
deltafi/genericmodel.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
deltafi/input.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
deltafi/logger.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
deltafi/metric.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
deltafi/plugin.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -32,13 +32,12 @@ from pathlib import Path
32
32
  from typing import List
33
33
 
34
34
  import requests
35
-
36
35
  from deltafi.action import Action, Join
37
36
  from deltafi.actioneventqueue import ActionEventQueue
38
37
  from deltafi.domain import Event, ActionExecution
39
38
  from deltafi.exception import ExpectedContentException, MissingMetadataException
40
39
  from deltafi.logger import get_logger
41
- from deltafi.result import ErrorResult
40
+ from deltafi.result import ErrorResult, IngressResult, TransformResult, TransformResults
42
41
  from deltafi.storage import ContentService
43
42
 
44
43
 
@@ -268,8 +267,7 @@ class Plugin(object):
268
267
  'start': start_time,
269
268
  'stop': stop_time,
270
269
  'type': result.result_type,
271
- 'metrics': [metric.json() for metric in result.metrics],
272
- 'savedContent': [content.json() for content in event.context.saved_content]
270
+ 'metrics': [metric.json() for metric in result.metrics]
273
271
  }
274
272
  if result.result_key is not None:
275
273
  response[result.result_key] = result.response()
@@ -309,6 +307,8 @@ class Plugin(object):
309
307
  response = Plugin.to_response(
310
308
  event, start_time, time.time(), result)
311
309
 
310
+ Plugin.orphaned_content_check(action_logger, event.context, result, response)
311
+
312
312
  topic = 'dgs'
313
313
  if event.return_address:
314
314
  topic += f"-{event.return_address}"
@@ -316,3 +316,42 @@ class Plugin(object):
316
316
  except BaseException as e:
317
317
  action_logger.error(f"Unexpected {type(e)} error: {str(e)}\n{traceback.format_exc()}")
318
318
  time.sleep(1)
319
+
320
+ @staticmethod
321
+ def orphaned_content_check(logger, context, result, response):
322
+ if len(context.saved_content) > 0:
323
+ to_delete = Plugin.find_unused_content(context.saved_content, result)
324
+ if len(to_delete) > 0:
325
+ errors = context.content_service.delete_all(to_delete)
326
+ for e in errors:
327
+ logger.error(f"Unable to delete object(s), {e}")
328
+ logger.warning(
329
+ f"Deleted {len(to_delete)} unused content entries for did {context.did} due to a {response['type']} event by {response['actionName']}")
330
+
331
+ @staticmethod
332
+ def find_unused_content(saved_content, result):
333
+ segments_in_use = Plugin.used_segment_names(result)
334
+ saved_segments = Plugin.get_segment_names(saved_content)
335
+ to_delete = []
336
+ for key, value in saved_segments.items():
337
+ if key not in segments_in_use:
338
+ to_delete.append(value)
339
+ return to_delete
340
+
341
+ @staticmethod
342
+ def used_segment_names(result):
343
+ segment_names = {}
344
+ if isinstance(result, TransformResult):
345
+ segment_names.update(result.get_segment_names())
346
+ elif isinstance(result, TransformResults):
347
+ segment_names.update(result.get_segment_names())
348
+ elif isinstance(result, IngressResult):
349
+ segment_names.update(result.get_segment_names())
350
+ return segment_names
351
+
352
+ @staticmethod
353
+ def get_segment_names(content_list):
354
+ segment_names = {}
355
+ for content in content_list:
356
+ segment_names.update(content.get_segment_names())
357
+ return segment_names
deltafi/result.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -139,6 +139,12 @@ class IngressResultItem:
139
139
  self.metadata[key] = value
140
140
  return self
141
141
 
142
+ def get_segment_names(self):
143
+ segment_names = {}
144
+ for c in self.content:
145
+ segment_names.update(c.get_segment_names())
146
+ return segment_names
147
+
142
148
  def response(self):
143
149
  return {
144
150
  'did': self._did,
@@ -167,6 +173,12 @@ class IngressResult(Result):
167
173
  self.ingress_result_items.append(ingress_result_item)
168
174
  return self
169
175
 
176
+ def get_segment_names(self):
177
+ segment_names = {}
178
+ for ingress_item in self.ingress_result_items:
179
+ segment_names.update(ingress_item.get_segment_names())
180
+ return segment_names
181
+
170
182
  def response(self):
171
183
  return {
172
184
  'memo': self.memo,
@@ -225,6 +237,12 @@ class TransformResult(Result):
225
237
  self.delete_metadata_keys.append(key)
226
238
  return self
227
239
 
240
+ def get_segment_names(self):
241
+ segment_names = {}
242
+ for c in self.content:
243
+ segment_names.update(c.get_segment_names())
244
+ return segment_names
245
+
228
246
  def json(self):
229
247
  return {
230
248
  'content': [content.json() for content in self.content],
@@ -241,6 +259,9 @@ class NamedTransformResult(NamedTuple):
241
259
  result: TransformResult
242
260
  name: str
243
261
 
262
+ def get_segment_names(self):
263
+ return self.result.get_segment_names()
264
+
244
265
  def json(self):
245
266
  j = self.result.json()
246
267
  if self.name is not None:
@@ -257,6 +278,12 @@ class TransformResults(Result):
257
278
  self.named_results.append(NamedTransformResult(result, name))
258
279
  return self
259
280
 
281
+ def get_segment_names(self):
282
+ segment_names = {}
283
+ for named_result in self.named_results:
284
+ segment_names.update(named_result.get_segment_names())
285
+ return segment_names
286
+
260
287
  def response(self):
261
288
  transform_events = []
262
289
  for named_result in self.named_results:
deltafi/storage.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ from typing import List, NamedTuple
22
22
  from urllib.parse import urlparse
23
23
 
24
24
  import minio
25
+ from minio.deleteobjects import DeleteObject
25
26
 
26
27
  BUCKET = 'storage'
27
28
 
@@ -86,3 +87,7 @@ class ContentService:
86
87
 
87
88
  def put_str(self, did, string_data):
88
89
  return self.put_bytes(did, string_data.encode('utf-8'))
90
+
91
+ def delete_all(self, segments: List[Segment]):
92
+ delete_objects = [DeleteObject(seg.id()) for seg in segments]
93
+ return self.minio_client.remove_objects(BUCKET, delete_objects)
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DeltaFi - Data transformation and enrichment platform
3
3
  #
4
- # Copyright 2021-2023 DeltaFi Contributors <deltafi@deltafi.org>
4
+ # Copyright 2021-2024 DeltaFi Contributors <deltafi@deltafi.org>
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: deltafi
3
- Version: 2.0rc1725920935509
3
+ Version: 2.0rc1727460733389
4
4
  Summary: SDK for DeltaFi plugins and actions
5
5
  License: Apache License, Version 2.0
6
6
  Keywords: deltafi
@@ -0,0 +1,23 @@
1
+ deltafi/__init__.py,sha256=sSGWjpvzcCzgLywoEg55z_0satt0g_LPTwNIWtylgF4,709
2
+ deltafi/action.py,sha256=Myc4RTYHLag6hXYd1pHZl3aguDPTrJ0MWN8x9nWG4Sw,5755
3
+ deltafi/actioneventqueue.py,sha256=_05aDeqVpUbGWG3jFf0AalOsVfAvOTn0oBxjpQIQxIs,2847
4
+ deltafi/actiontype.py,sha256=CpVI0wk9C-eu44e0jYvqBzE6yIX_zfRrW5RCf4ohu4Y,913
5
+ deltafi/domain.py,sha256=1nUjpOF48UlytGKHep-lAy06U9RIe0H_dSeDJMsajng,12266
6
+ deltafi/exception.py,sha256=LNNFqc_lA89I-RvnVsbTQ2vnWQ9WZXdQqLwiXwNgc_w,943
7
+ deltafi/genericmodel.py,sha256=WU8zfqEO_n84CZ0KpH9FhgTsL9jyU0EXSuhL0IdLWFw,1152
8
+ deltafi/input.py,sha256=ydAhuw68N9qMeacc9YE4U79zRqxWiinZNkm1AxoFBEk,1656
9
+ deltafi/logger.py,sha256=4ahVx6E3TIZBTcvteaBeYXeAjk1oRR7vHkOienmtx4U,2141
10
+ deltafi/metric.py,sha256=s68b1xNG9UPcpOB-nlTT-SntskJEUCpoKz1gTMRFgHc,967
11
+ deltafi/plugin.py,sha256=20uXIB3XhaQAefBwKV-Mh7s4-sx9iWm9A_xLXbermeU,14374
12
+ deltafi/result.py,sha256=s5jIoCa_deYHyl0T3lXLOcEVTROE2_U_7AQ2n4USgdI,9234
13
+ deltafi/storage.py,sha256=vCE29Yzk5s7ub4O1PdaxXBKPBQy4OHs7j46z3O5MezE,2979
14
+ deltafi/test_kit/__init__.py,sha256=sSGWjpvzcCzgLywoEg55z_0satt0g_LPTwNIWtylgF4,709
15
+ deltafi/test_kit/assertions.py,sha256=MdUXENLn0aDvknMtsnSAb-DwvpzXlMkaYQ6-RRkWG8s,1378
16
+ deltafi/test_kit/compare_helpers.py,sha256=qRINvCQqBUaalT1DG2oz2egSkUjiSOfqKF5U7WyeT_g,12957
17
+ deltafi/test_kit/constants.py,sha256=Suygx9CEob2Skw4UyzzMCibQ8hRhGHC_d_Xab8AJMFE,833
18
+ deltafi/test_kit/egress.py,sha256=53SBeJJmphDl-jZdqkC1dKYWZ4ATWlzY02TUt0Sj1zs,1899
19
+ deltafi/test_kit/framework.py,sha256=w0vdG3sTGYFrd1cQN6r4H5ioXhjRfABJBGs6ZbNBEo0,15184
20
+ deltafi/test_kit/transform.py,sha256=bnV6kcOkuShi_9uCtzkWcgz-wMejnI9Q2_MbyVm_A7U,4085
21
+ deltafi-2.0rc1727460733389.dist-info/METADATA,sha256=9_YeyYlsaZ2DQqd8LV-Uv-t3dBLs9x-nHgzua9pVD14,1446
22
+ deltafi-2.0rc1727460733389.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
23
+ deltafi-2.0rc1727460733389.dist-info/RECORD,,
@@ -1,23 +0,0 @@
1
- deltafi/__init__.py,sha256=qv6y7PpBG0ekTN9EuD9Lj8JYOLVqZA6tvHwgjplncAM,709
2
- deltafi/action.py,sha256=ejORyFe1cFCC04fdNt1VPWHqhNqZGjpLeD9tTQAYs1w,5755
3
- deltafi/actioneventqueue.py,sha256=mCRE1PFXy_KvaeezTeMze5N400CO1V06zEF8FFD6xZk,2847
4
- deltafi/actiontype.py,sha256=V7JbTgHQIaWQ2N36pG-XV7kAXhq8qvj954z71iHw_wI,913
5
- deltafi/domain.py,sha256=kuw0zwC2eMlJcksR5IU5_zJecU23RuUWwY26ks8hQp4,12100
6
- deltafi/exception.py,sha256=Z8LwxxTiTyuG3v7FAsjfz6cAqRAJFKK2q_2TbEDrIJE,943
7
- deltafi/genericmodel.py,sha256=LBIhU1rLU4HjoD8ooMfpbEhcRkrTIeGXCP1-0palKic,1152
8
- deltafi/input.py,sha256=2qQcOWqz7lOXZIZipTz5XtcGESpjdnUAsZ7b9YqHw7M,1656
9
- deltafi/logger.py,sha256=b6vTKSJjfXfzJIKB7bLrefIvlaIQAxWkeDJYzT1EXes,2141
10
- deltafi/metric.py,sha256=eIDjZQVO53KuAFoEtjLNFwqMrp_7BC0Td9GLD1tb6sE,967
11
- deltafi/plugin.py,sha256=oPopncj41OZ5EGzB2DfTaZEZwrIYOM3W8uSfCTq27RA,12679
12
- deltafi/result.py,sha256=353nPN4tSLskhf9ClJiGM2cy8vVMrjRaxsbzjmu8ONA,8382
13
- deltafi/storage.py,sha256=toq58EPZgzj2TfDF-YpFUmRnsWSjACA0KQAZzkM04xU,2740
14
- deltafi/test_kit/__init__.py,sha256=qv6y7PpBG0ekTN9EuD9Lj8JYOLVqZA6tvHwgjplncAM,709
15
- deltafi/test_kit/assertions.py,sha256=2eahqmbedhnHXMguiJHdaV-6sx4_jvCbxH4HSzx6PV8,1378
16
- deltafi/test_kit/compare_helpers.py,sha256=Q0e14q4XQ4rlMUbPt3aMHThAXHFRXlue3-M4oAayyJE,12957
17
- deltafi/test_kit/constants.py,sha256=epz0OS-qILcc8t7iIs5B3m2-wvZx8FpYpyb19ZsImbI,833
18
- deltafi/test_kit/egress.py,sha256=nF7YYak-_X35m7h2rSIcju86IJBf8cVaFHs7xw7-_b8,1899
19
- deltafi/test_kit/framework.py,sha256=hHJHyfx5yfBtixLdZGjqbjLdgvZ2idItunOOwQk_35c,15184
20
- deltafi/test_kit/transform.py,sha256=q9zQdZswTKwU5Om8E9Lwg0G5JI8LEXuRZjT9oam-Zoo,4085
21
- deltafi-2.0rc1725920935509.dist-info/METADATA,sha256=mEOhAUWSGCUgMx7UfwO0z6K7AT7vFelnlhF-ZA3Djs4,1446
22
- deltafi-2.0rc1725920935509.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
23
- deltafi-2.0rc1725920935509.dist-info/RECORD,,