streamlit-octostar-utils 0.4.2.dev3__tar.gz → 0.4.2.dev4__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.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/PKG-INFO +1 -1
  2. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/pyproject.toml +1 -1
  3. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/nifi.py +94 -48
  4. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/LICENSE +0 -0
  5. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/README.md +0 -0
  6. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/__init__.py +0 -0
  7. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/__init__.py +0 -0
  8. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/celery.py +0 -0
  9. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/contents.py +0 -0
  10. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/fastapi.py +0 -0
  11. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parallelism.py +0 -0
  12. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/__init__.py +0 -0
  13. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/combine_fields.py +0 -0
  14. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/entities_parser.py +0 -0
  15. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/generics.py +0 -0
  16. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/info.py +0 -0
  17. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/linkchart_functions.py +0 -0
  18. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/matches.py +0 -0
  19. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/parameters.py +0 -0
  20. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/rules.py +0 -0
  21. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/api_crafter/parser/signals.py +0 -0
  22. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/core/__init__.py +0 -0
  23. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/core/dict.py +0 -0
  24. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/core/filetypes.py +0 -0
  25. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/core/threading/__init__.py +0 -0
  26. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/core/threading/key_queue.py +0 -0
  27. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/core/timestamp.py +0 -0
  28. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/nlp/__init__.py +0 -0
  29. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/nlp/custom_recognizers.py +0 -0
  30. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/nlp/language.py +0 -0
  31. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/nlp/ner.py +0 -0
  32. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/octostar/__init__.py +0 -0
  33. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/octostar/client.py +0 -0
  34. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/octostar/context.py +0 -0
  35. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/octostar/permissions.py +0 -0
  36. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/ontology/__init__.py +0 -0
  37. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/ontology/inheritance.py +0 -0
  38. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/ontology/relationships.py +0 -0
  39. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/ontology/validation.py +0 -0
  40. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/style/__init__.py +0 -0
  41. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/style/common.py +0 -0
  42. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/threading/__init__.py +0 -0
  43. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/threading/async_task_manager.py +0 -0
  44. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/streamlit_octostar_utils/threading/session_callback_manager.py +0 -0
  45. {streamlit_octostar_utils-0.4.2.dev3 → streamlit_octostar_utils-0.4.2.dev4}/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.4.2.dev3
3
+ Version: 0.4.2.dev4
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.4.2-dev.3"
8
+ version = "0.4.2-dev.4"
9
9
  description = ""
10
10
  license = "MIT"
11
11
  authors = ["Octostar"]
@@ -41,6 +41,8 @@ GENERIC_RELATIONSHIP = RelationshipName(name="related_to", type="mtm")
41
41
  FILE_RELATIONSHIP = RelationshipName(name="generator_of", type="mtm")
42
42
  TAG_RELATIONSHIP = RelationshipName(name="has_tag", type="mtm")
43
43
  FRAGMENT_RELATIONSHIP = RelationshipName(name="is_fragment_of", type="otm")
44
+ PREVIOUS_FRAGMENT_RELATIONSHIP = RelationshipName(name="has_previous_fragment", type="otm")
45
+ NEXT_FRAGMENT_RELATIONSHIP = RelationshipName(name="has_next_fragment", type="otm")
44
46
 
45
47
 
46
48
  class NifiProxyEntityModel(BaseModel):
@@ -951,6 +953,47 @@ class NifiEntity(object):
951
953
  self.children.append(child_entity_proxy)
952
954
  return child_entity_proxy
953
955
 
956
+ def _add_child_attachable(
957
+ self,
958
+ os_workspace,
959
+ filename,
960
+ filetype,
961
+ file: Union[Contents, bytes],
962
+ fields={},
963
+ relationship: RelationshipName = FILE_RELATIONSHIP,
964
+ os_entity_uid=None,
965
+ os_relationship_uid=None,
966
+ os_entity_type=FILE_ENTITY_NAME,
967
+ ):
968
+ child_entity, child_rel = self.add_child_entity(
969
+ os_workspace,
970
+ os_entity_type,
971
+ {
972
+ **fields,
973
+ "os_item_name": filename,
974
+ "os_item_content_type": filetype,
975
+ "os_has_attachment": True,
976
+ },
977
+ relationship,
978
+ os_entity_uid,
979
+ os_relationship_uid,
980
+ )
981
+ if isinstance(file, Contents):
982
+ child_entity._contents = file
983
+ else:
984
+ temp_filename = f"tmp_{child_entity.record['os_entity_uid']}"
985
+ temp_contents = TemporaryAttachmentContents(
986
+ entity_type=os_entity_type,
987
+ filetype=filetype,
988
+ filename=temp_filename,
989
+ client=self.context.client,
990
+ initial_data=file,
991
+ )
992
+ temp_contents.flush()
993
+ child_entity._contents = temp_contents
994
+ child_entity.request["contents_pointer"] = child_entity._contents.to_locator()
995
+ return child_entity, child_rel
996
+
954
997
  def add_mtm_relationship(
955
998
  self,
956
999
  os_entity_uid_from,
@@ -1002,29 +1045,19 @@ class NifiEntity(object):
1002
1045
  relationship: RelationshipName = GENERIC_RELATIONSHIP,
1003
1046
  os_entity_uid=None,
1004
1047
  os_relationship_uid=None,
1048
+ relationship_fields={},
1005
1049
  ):
1006
1050
  child_entity = self._add_entity(os_workspace, entity_type, fields, os_entity_uid)
1007
- if relationship.type == "mtm":
1008
- child_rel = self.add_mtm_relationship(
1009
- self.record["os_entity_uid"],
1010
- self.record["os_concept"],
1011
- child_entity.record["os_entity_uid"],
1012
- child_entity.record["os_concept"],
1013
- relationship.name,
1014
- os_workspace,
1015
- {},
1016
- os_relationship_uid,
1017
- )
1018
- elif relationship.type == "otm":
1019
- child_rel = self.add_otm_relationship(
1020
- self.record["os_entity_uid"],
1021
- self.record["os_concept"],
1022
- child_entity.record["os_entity_uid"],
1023
- child_entity.record["os_concept"],
1024
- relationship.name,
1025
- )
1026
- else:
1027
- raise ValueError(f"relationship.type is invalid! {relationship.type}")
1051
+ child_rel = self._add_relationship(
1052
+ os_workspace,
1053
+ self.record["os_entity_uid"],
1054
+ self.record["os_concept"],
1055
+ child_entity.record["os_entity_uid"],
1056
+ child_entity.record["os_concept"],
1057
+ relationship,
1058
+ relationship_fields,
1059
+ os_relationship_uid,
1060
+ )
1028
1061
  return child_entity, child_rel
1029
1062
 
1030
1063
  def add_child_file(
@@ -1040,40 +1073,30 @@ class NifiEntity(object):
1040
1073
  os_relationship_uid=None,
1041
1074
  os_entity_type=FILE_ENTITY_NAME,
1042
1075
  ):
1043
- child_entity, child_rel = self.add_child_entity(
1076
+ return self._add_child_attachable(
1044
1077
  os_workspace,
1045
- os_entity_type,
1046
- {
1047
- **fields,
1048
- "os_item_name": filename,
1049
- "os_item_content_type": filetype,
1050
- "os_has_attachment": True,
1051
- "os_parent_folder": os_parent_folder,
1052
- },
1078
+ filename,
1079
+ filetype,
1080
+ file,
1081
+ {**fields, "os_parent_folder": os_parent_folder},
1053
1082
  relationship,
1054
1083
  os_entity_uid,
1055
1084
  os_relationship_uid,
1085
+ os_entity_type
1056
1086
  )
1057
- if isinstance(file, Contents):
1058
- child_entity._contents = file
1087
+
1088
+ def _add_relationship(self, os_workspace, from_uid, from_type, to_uid, to_type, rel, relationship_fields={}, rel_uid=None):
1089
+ if rel.type == "mtm":
1090
+ return self.add_mtm_relationship(from_uid, from_type, to_uid, to_type, rel.name, os_workspace, relationship_fields, rel_uid)
1091
+ elif rel.type == "otm":
1092
+ return self.add_otm_relationship(from_uid, from_type, to_uid, to_type, rel.name)
1059
1093
  else:
1060
- temp_filename = f"tmp_{child_entity.record['os_entity_uid']}"
1061
- temp_contents = TemporaryAttachmentContents(
1062
- entity_type=os_entity_type,
1063
- filetype=filetype,
1064
- filename=temp_filename,
1065
- client=self.context.client,
1066
- initial_data=file,
1067
- )
1068
- temp_contents.flush()
1069
- child_entity._contents = temp_contents
1070
- child_entity.request["contents_pointer"] = child_entity._contents.to_locator()
1071
- return child_entity, child_rel
1094
+ raise ValueError(f"relationship.type is invalid! {rel.type}")
1072
1095
 
1073
1096
  def add_child_fragment(
1074
1097
  self,
1075
1098
  os_workspace,
1076
- os_parent_folder,
1099
+ source_entity_uid,
1077
1100
  filename,
1078
1101
  filetype,
1079
1102
  file: Union[Contents, bytes],
@@ -1082,19 +1105,42 @@ class NifiEntity(object):
1082
1105
  os_entity_uid=None,
1083
1106
  os_relationship_uid=None,
1084
1107
  os_entity_type=FRAGMENT_ENTITY_NAME,
1108
+ previous_fragment_uid=None,
1109
+ previous_fragment_relationship_uid=None,
1110
+ previous_fragment_relationship=PREVIOUS_FRAGMENT_RELATIONSHIP,
1111
+ next_fragment_uid=None,
1112
+ next_fragment_relationship_uid=None,
1113
+ next_fragment_relationship=NEXT_FRAGMENT_RELATIONSHIP,
1085
1114
  ):
1086
- return self.add_child_file(
1115
+ child_entity, child_rel = self._add_child_attachable(
1087
1116
  os_workspace,
1088
- os_parent_folder,
1089
1117
  filename,
1090
1118
  filetype,
1091
1119
  file,
1092
- fields,
1120
+ {**fields, "source_entity_uid": source_entity_uid},
1093
1121
  relationship,
1094
1122
  os_entity_uid,
1095
1123
  os_relationship_uid,
1096
1124
  os_entity_type,
1097
1125
  )
1126
+ prev_rel, next_rel = None, None
1127
+ fragment_uid = child_entity.record["os_entity_uid"]
1128
+ fragment_type = child_entity.record["os_concept"]
1129
+ if previous_fragment_uid:
1130
+ prev_rel = previous_fragment_relationship or PREVIOUS_FRAGMENT_RELATIONSHIP
1131
+ self._add_relationship(
1132
+ os_workspace, fragment_uid, fragment_type,
1133
+ previous_fragment_uid, os_entity_type,
1134
+ previous_fragment_relationship, {}, previous_fragment_relationship_uid,
1135
+ )
1136
+ if next_fragment_uid:
1137
+ next_rel = next_fragment_relationship or NEXT_FRAGMENT_RELATIONSHIP
1138
+ self._add_relationship(
1139
+ os_workspace, fragment_uid, fragment_type,
1140
+ next_fragment_uid, os_entity_type,
1141
+ next_fragment_relationship, {}, next_fragment_relationship_uid,
1142
+ )
1143
+ return child_entity, child_rel, prev_rel, next_rel
1098
1144
 
1099
1145
  def add_tag(self, os_workspace, name, group, order, color, fields={}):
1100
1146
  return self.add_child_entity(