streamlit-octostar-utils 0.5.0.dev6__tar.gz → 0.5.0.dev7__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.
Files changed (45) hide show
  1. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/PKG-INFO +1 -1
  2. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/pyproject.toml +1 -1
  3. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/nifi.py +47 -19
  4. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/LICENSE +0 -0
  5. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/README.md +0 -0
  6. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/__init__.py +0 -0
  7. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/__init__.py +0 -0
  8. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/celery.py +0 -0
  9. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/contents.py +0 -0
  10. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/fastapi.py +0 -0
  11. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parallelism.py +0 -0
  12. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/__init__.py +0 -0
  13. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/combine_fields.py +0 -0
  14. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/entities_parser.py +0 -0
  15. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/generics.py +0 -0
  16. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/info.py +0 -0
  17. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/linkchart_functions.py +0 -0
  18. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/matches.py +0 -0
  19. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/parameters.py +0 -0
  20. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/rules.py +0 -0
  21. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/api_crafter/parser/signals.py +0 -0
  22. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/core/__init__.py +0 -0
  23. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/core/dict.py +0 -0
  24. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/core/filetypes.py +0 -0
  25. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/core/threading/__init__.py +0 -0
  26. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/core/threading/key_queue.py +0 -0
  27. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/core/timestamp.py +0 -0
  28. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/nlp/__init__.py +0 -0
  29. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/nlp/custom_recognizers.py +0 -0
  30. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/nlp/language.py +0 -0
  31. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/nlp/ner.py +0 -0
  32. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/octostar/__init__.py +0 -0
  33. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/octostar/client.py +0 -0
  34. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/octostar/context.py +0 -0
  35. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/octostar/permissions.py +0 -0
  36. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/ontology/__init__.py +0 -0
  37. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/ontology/inheritance.py +0 -0
  38. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/ontology/relationships.py +0 -0
  39. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/ontology/validation.py +0 -0
  40. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/style/__init__.py +0 -0
  41. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/style/common.py +0 -0
  42. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/threading/__init__.py +0 -0
  43. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/threading/async_task_manager.py +0 -0
  44. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/threading/session_callback_manager.py +0 -0
  45. {streamlit_octostar_utils-0.5.0.dev6 → streamlit_octostar_utils-0.5.0.dev7}/streamlit_octostar_utils/threading/session_state_hot_swapper.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-octostar-utils
3
- Version: 0.5.0.dev6
3
+ Version: 0.5.0.dev7
4
4
  Summary:
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -5,7 +5,7 @@ include = '\.pyi?$'
5
5
 
6
6
  [tool.poetry]
7
7
  name = "streamlit-octostar-utils"
8
- version = "0.5.0-dev.6"
8
+ version = "0.5.0-dev.7"
9
9
  description = ""
10
10
  license = "MIT"
11
11
  authors = ["Octostar"]
@@ -45,6 +45,7 @@ TAG_RELATIONSHIP = RelationshipName(name="has_tag", type="mtm")
45
45
  FRAGMENT_RELATIONSHIP = RelationshipName(name="is_fragment_of", type="otm")
46
46
  PREVIOUS_FRAGMENT_RELATIONSHIP = RelationshipName(name="has_previous_fragment", type="otm")
47
47
  NEXT_FRAGMENT_RELATIONSHIP = RelationshipName(name="has_next_fragment", type="otm")
48
+ SOURCE_FRAGMENT_ENTITY_RELATIONSHIP = RelationshipName(name="is_child_fragment_of", type="otm")
48
49
  OS_RESERVED_FIELDS = [
49
50
  "os_entity_uid", "entity_id", "entity_type", "os_concept",
50
51
  "entity_label", "os_created_at", "os_created_by",
@@ -212,6 +213,7 @@ class NifiFragmenter(object):
212
213
  raise ValueError("Cannot have more than 100k entities for fragmentation")
213
214
  identifier = str(uuid.uuid4())
214
215
  root_uid = fragments[0].record["os_entity_uid"]
216
+ root_type = fragments[0].record["os_concept"]
215
217
  for i, entity in enumerate(fragments):
216
218
  travel_dict(entity.request["nifi_attributes"], fragmenter_keylist.split("."), "w")(
217
219
  {"identifier": identifier, "count": count, "index": i}
@@ -225,7 +227,7 @@ class NifiFragmenter(object):
225
227
  "fragments_stack"
226
228
  ]
227
229
  travel_dict(entity.request["config"]["fragment"], fragmenter_keylist.split("."), "w")(
228
- {"identifier": identifier, "count": count, "index": i, "root_uid": root_uid}
230
+ {"identifier": identifier, "count": count, "index": i, "root_uid": root_uid, "root_type": root_type}
229
231
  )
230
232
 
231
233
  def push_defragment_strategy(fragment, defragmenter_config):
@@ -424,30 +426,34 @@ class NifiFragmenter(object):
424
426
  )
425
427
 
426
428
  @staticmethod
427
- def resolve_source_entity_uid(entity, fragment_root_source=None) -> str:
428
- """Resolve the source_entity_uid to use for child fragments.
429
+ def resolve_source_entity(entity, fragment_root_source=None) -> tuple:
430
+ """Resolve the source entity (recursive originator) for child fragments.
429
431
 
430
432
  When fragment_root_source is set (a fragment name or stack index),
431
- the UID is looked up via entity.get_fragment_root_uid() -- this is
432
- necessary when the current entity is a clone that may not be persisted.
433
- Otherwise falls back to the entity's own UID.
433
+ the root is looked up via entity.get_fragment_root(). When it is
434
+ None and the entity is already fragmented, the oldest fragmentation
435
+ level's root is used (the original non-fragment ancestor). Otherwise
436
+ falls back to the entity itself.
434
437
 
435
438
  Args:
436
439
  entity: A NifiEntity or NifiEntityProxy.
437
- fragment_root_source: None to use the entity's own UID, an int
440
+ fragment_root_source: None for automatic resolution, an int
438
441
  to index into the fragments stack, or a string fragmenter
439
442
  keylist name.
440
443
 
441
444
  Returns:
442
- The resolved source entity UID string.
445
+ (source_entity_uid, source_entity_type) tuple.
443
446
  """
444
- if fragment_root_source is None:
445
- return entity.record["os_entity_uid"]
446
- try:
447
- idx = int(fragment_root_source)
448
- return entity.get_fragment_root_uid(idx)
449
- except (ValueError, TypeError):
450
- return entity.get_fragment_root_uid(fragment_root_source)
447
+ if fragment_root_source is not None:
448
+ try:
449
+ idx = int(fragment_root_source)
450
+ return entity.get_fragment_root(idx)
451
+ except (ValueError, TypeError):
452
+ return entity.get_fragment_root(fragment_root_source)
453
+ stack = entity.request.get("config", {}).get("fragment", {}).get("fragments_stack", [])
454
+ if stack:
455
+ return entity.get_fragment_root(-1)
456
+ return (entity.record["os_entity_uid"], entity.record["os_concept"])
451
457
 
452
458
 
453
459
  class NifiEntityBatch(object):
@@ -1089,7 +1095,17 @@ class NifiEntity(object):
1089
1095
  )
1090
1096
  return NifiFragmenter.get_fragment_info(self, key).get("index", 0) == 0
1091
1097
 
1092
- def get_fragment_root_uid(self, fragment_name_or_idx) -> str:
1098
+ def get_fragment_root(self, fragment_name_or_idx) -> tuple:
1099
+ """Return (root_uid, root_type) for a given fragmentation level.
1100
+
1101
+ Args:
1102
+ fragment_name_or_idx: An int to index into fragments_stack
1103
+ (e.g. -1 for the oldest fragmentation), or a string
1104
+ fragmenter keylist name.
1105
+
1106
+ Returns:
1107
+ (root_uid, root_type) tuple for the root entity at that level.
1108
+ """
1093
1109
  fragment_config = self.request.get("config", {}).get("fragment", {})
1094
1110
  fragments_stack = fragment_config.get("fragments_stack", [])
1095
1111
  if isinstance(fragment_name_or_idx, int):
@@ -1114,7 +1130,10 @@ class NifiEntity(object):
1114
1130
  raise KeyError(
1115
1131
  f"No root_uid found in fragment config for '{fragment_key}'"
1116
1132
  )
1117
- return fragment_data["root_uid"]
1133
+ return (
1134
+ fragment_data["root_uid"],
1135
+ fragment_data.get("root_type", "os_fragment"),
1136
+ )
1118
1137
 
1119
1138
  def to_json(self):
1120
1139
  if self.drop_on_output:
@@ -1408,6 +1427,7 @@ class NifiEntity(object):
1408
1427
  self,
1409
1428
  os_workspace,
1410
1429
  source_entity_uid,
1430
+ source_entity_type,
1411
1431
  filename,
1412
1432
  filetype,
1413
1433
  file: Union[Contents, bytes],
@@ -1422,9 +1442,12 @@ class NifiEntity(object):
1422
1442
  next_fragment_uid=None,
1423
1443
  next_fragment_relationship_uid=None,
1424
1444
  next_fragment_relationship=NEXT_FRAGMENT_RELATIONSHIP,
1445
+ source_entity_relationship_uid=None,
1446
+ source_entity_relationship=SOURCE_FRAGMENT_ENTITY_RELATIONSHIP,
1425
1447
  ):
1426
1448
  fields = {
1427
1449
  **fields,
1450
+ "os_parent_uid": self.record["os_entity_uid"],
1428
1451
  "source_entity_uid": source_entity_uid,
1429
1452
  "previous_entity_uid": previous_fragment_uid,
1430
1453
  "next_entity_uid": next_fragment_uid,
@@ -1440,9 +1463,14 @@ class NifiEntity(object):
1440
1463
  os_relationship_uid,
1441
1464
  os_entity_type,
1442
1465
  )
1443
- prev_rel, next_rel = None, None
1444
1466
  fragment_uid = child_entity.record["os_entity_uid"]
1445
1467
  fragment_type = child_entity.record["os_concept"]
1468
+ source_rel = self._add_relationship(
1469
+ os_workspace, fragment_uid, fragment_type,
1470
+ source_entity_uid, source_entity_type,
1471
+ source_entity_relationship, {}, source_entity_relationship_uid,
1472
+ )
1473
+ prev_rel, next_rel = None, None
1446
1474
  if previous_fragment_uid:
1447
1475
  prev_rel = self._add_relationship(
1448
1476
  os_workspace, fragment_uid, fragment_type,
@@ -1455,7 +1483,7 @@ class NifiEntity(object):
1455
1483
  next_fragment_uid, os_entity_type,
1456
1484
  next_fragment_relationship, {}, next_fragment_relationship_uid,
1457
1485
  )
1458
- return child_entity, child_rel, prev_rel, next_rel
1486
+ return child_entity, child_rel, source_rel, prev_rel, next_rel
1459
1487
 
1460
1488
  def add_tag(self, os_workspace, name, group, order, color, fields={}):
1461
1489
  return self.add_child_entity(