streamlit-octostar-utils 0.4.2.dev2__tar.gz → 0.4.2.dev3__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.
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/PKG-INFO +1 -1
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/pyproject.toml +1 -1
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/nifi.py +56 -43
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/LICENSE +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/README.md +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/celery.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/contents.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/fastapi.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parallelism.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/combine_fields.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/entities_parser.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/generics.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/info.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/linkchart_functions.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/matches.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/parameters.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/rules.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/api_crafter/parser/signals.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/core/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/core/dict.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/core/filetypes.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/core/threading/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/core/threading/key_queue.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/core/timestamp.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/nlp/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/nlp/custom_recognizers.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/nlp/language.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/nlp/ner.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/octostar/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/octostar/client.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/octostar/context.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/octostar/permissions.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/ontology/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/ontology/inheritance.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/ontology/relationships.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/ontology/validation.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/style/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/style/common.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/threading/__init__.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/threading/async_task_manager.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/threading/session_callback_manager.py +0 -0
- {streamlit_octostar_utils-0.4.2.dev2 → streamlit_octostar_utils-0.4.2.dev3}/streamlit_octostar_utils/threading/session_state_hot_swapper.py +0 -0
|
@@ -5,18 +5,16 @@ from contextlib import contextmanager
|
|
|
5
5
|
import json
|
|
6
6
|
import jwt
|
|
7
7
|
from typing import List, Union, Optional, Callable
|
|
8
|
-
import base64
|
|
9
8
|
from pydantic import BaseModel, ConfigDict, Field
|
|
10
9
|
import itertools
|
|
11
|
-
import asyncio
|
|
12
10
|
from enum import Enum
|
|
13
|
-
from typing import Dict, Any
|
|
11
|
+
from typing import Dict, Any, Literal
|
|
14
12
|
from datetime import datetime, timezone, timedelta
|
|
15
13
|
from fastapi import Request
|
|
16
14
|
from fastapi.responses import JSONResponse
|
|
17
15
|
from starlette.exceptions import HTTPException as StarletteHTTPException
|
|
18
16
|
|
|
19
|
-
from octostar.utils.workspace import
|
|
17
|
+
from octostar.utils.workspace import upsert_entities, write_file
|
|
20
18
|
from octostar.utils.ontology import fetch_ontology_data
|
|
21
19
|
from octostar.utils.workspace.permissions import get_permissions, PermissionLevel
|
|
22
20
|
from octostar.client import make_client
|
|
@@ -26,26 +24,23 @@ from ..core.dict import recursive_update_dict, travel_dict, jsondict_hash
|
|
|
26
24
|
from ..core.timestamp import now, string_to_datetime
|
|
27
25
|
from .fastapi import DefaultErrorRoute, Route
|
|
28
26
|
from ..ontology.inheritance import is_child_concept as is_child_concept_fn, get_label_keys
|
|
29
|
-
from .contents import Contents,
|
|
27
|
+
from .contents import Contents, WorkspaceAttachmentContents, TemporaryAttachmentContents, ContentsLocation
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class RelationshipName(BaseModel):
|
|
31
|
+
name: str
|
|
32
|
+
type: Literal["mtm", "otm"]
|
|
33
|
+
|
|
30
34
|
|
|
31
35
|
RELATIONSHIP_ENTITY_NAME = "os_relationship"
|
|
32
36
|
LOCAL_RELATIONSHIP_ENTITY_NAME = "os_workspace_relationship"
|
|
33
37
|
FILE_ENTITY_NAME = "os_file"
|
|
34
|
-
GENERIC_RELATIONSHIP_NAME = "related_to"
|
|
35
|
-
FILE_RELATIONSHIP_NAME = "generator_of"
|
|
36
|
-
TAG_RELATIONSHIP_NAME = "has_tag"
|
|
37
38
|
TAG_ENTITY_NAME = "os_tag"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if loop.is_running():
|
|
44
|
-
return asyncio.ensure_future(coro)
|
|
45
|
-
else:
|
|
46
|
-
return asyncio.run(coro)
|
|
47
|
-
except RuntimeError:
|
|
48
|
-
return asyncio.run(coro)
|
|
39
|
+
FRAGMENT_ENTITY_NAME = "os_fragment"
|
|
40
|
+
GENERIC_RELATIONSHIP = RelationshipName(name="related_to", type="mtm")
|
|
41
|
+
FILE_RELATIONSHIP = RelationshipName(name="generator_of", type="mtm")
|
|
42
|
+
TAG_RELATIONSHIP = RelationshipName(name="has_tag", type="mtm")
|
|
43
|
+
FRAGMENT_RELATIONSHIP = RelationshipName(name="is_fragment_of", type="otm")
|
|
49
44
|
|
|
50
45
|
|
|
51
46
|
class NifiProxyEntityModel(BaseModel):
|
|
@@ -397,10 +392,6 @@ class NifiContextManager(object):
|
|
|
397
392
|
|
|
398
393
|
@contextmanager
|
|
399
394
|
def reindex_lock(self, entities: List[Union[dict, "NifiEntity"]], timeout: int = 7200):
|
|
400
|
-
"""Lock entities to prevent reindexing during processing.
|
|
401
|
-
|
|
402
|
-
Sets do_not_reindex_at to a future time on entry, resets on exit.
|
|
403
|
-
"""
|
|
404
395
|
if not entities:
|
|
405
396
|
yield
|
|
406
397
|
return
|
|
@@ -579,8 +570,7 @@ class NifiContextManager(object):
|
|
|
579
570
|
target["os_workspace"],
|
|
580
571
|
target["os_concept"],
|
|
581
572
|
target,
|
|
582
|
-
|
|
583
|
-
os_relationship_type=rel_type,
|
|
573
|
+
relationship=RelationshipName(name=rel["os_relationship_name"], type=rel_type),
|
|
584
574
|
)
|
|
585
575
|
child_entity.record = {**child_entity.record, **target}
|
|
586
576
|
child_entity.record["entity_id"] = child_entity.record[
|
|
@@ -974,7 +964,7 @@ class NifiEntity(object):
|
|
|
974
964
|
):
|
|
975
965
|
return self._add_entity(
|
|
976
966
|
os_relationship_workspace,
|
|
977
|
-
|
|
967
|
+
LOCAL_RELATIONSHIP_ENTITY_NAME,
|
|
978
968
|
{
|
|
979
969
|
**relationship_fields,
|
|
980
970
|
"os_entity_uid_from": os_entity_uid_from,
|
|
@@ -1009,33 +999,32 @@ class NifiEntity(object):
|
|
|
1009
999
|
os_workspace,
|
|
1010
1000
|
entity_type,
|
|
1011
1001
|
fields,
|
|
1012
|
-
|
|
1013
|
-
os_relationship_type="mtm",
|
|
1002
|
+
relationship: RelationshipName = GENERIC_RELATIONSHIP,
|
|
1014
1003
|
os_entity_uid=None,
|
|
1015
1004
|
os_relationship_uid=None,
|
|
1016
1005
|
):
|
|
1017
1006
|
child_entity = self._add_entity(os_workspace, entity_type, fields, os_entity_uid)
|
|
1018
|
-
if
|
|
1007
|
+
if relationship.type == "mtm":
|
|
1019
1008
|
child_rel = self.add_mtm_relationship(
|
|
1020
1009
|
self.record["os_entity_uid"],
|
|
1021
1010
|
self.record["os_concept"],
|
|
1022
1011
|
child_entity.record["os_entity_uid"],
|
|
1023
1012
|
child_entity.record["os_concept"],
|
|
1024
|
-
|
|
1013
|
+
relationship.name,
|
|
1025
1014
|
os_workspace,
|
|
1026
1015
|
{},
|
|
1027
1016
|
os_relationship_uid,
|
|
1028
1017
|
)
|
|
1029
|
-
elif
|
|
1018
|
+
elif relationship.type == "otm":
|
|
1030
1019
|
child_rel = self.add_otm_relationship(
|
|
1031
1020
|
self.record["os_entity_uid"],
|
|
1032
1021
|
self.record["os_concept"],
|
|
1033
1022
|
child_entity.record["os_entity_uid"],
|
|
1034
1023
|
child_entity.record["os_concept"],
|
|
1035
|
-
|
|
1024
|
+
relationship.name,
|
|
1036
1025
|
)
|
|
1037
1026
|
else:
|
|
1038
|
-
raise ValueError(f"
|
|
1027
|
+
raise ValueError(f"relationship.type is invalid! {relationship.type}")
|
|
1039
1028
|
return child_entity, child_rel
|
|
1040
1029
|
|
|
1041
1030
|
def add_child_file(
|
|
@@ -1046,14 +1035,14 @@ class NifiEntity(object):
|
|
|
1046
1035
|
filetype,
|
|
1047
1036
|
file: Union[Contents, bytes],
|
|
1048
1037
|
fields={},
|
|
1049
|
-
|
|
1050
|
-
os_relationship_type="mtm",
|
|
1038
|
+
relationship: RelationshipName = FILE_RELATIONSHIP,
|
|
1051
1039
|
os_entity_uid=None,
|
|
1052
1040
|
os_relationship_uid=None,
|
|
1041
|
+
os_entity_type=FILE_ENTITY_NAME,
|
|
1053
1042
|
):
|
|
1054
1043
|
child_entity, child_rel = self.add_child_entity(
|
|
1055
1044
|
os_workspace,
|
|
1056
|
-
|
|
1045
|
+
os_entity_type,
|
|
1057
1046
|
{
|
|
1058
1047
|
**fields,
|
|
1059
1048
|
"os_item_name": filename,
|
|
@@ -1061,8 +1050,7 @@ class NifiEntity(object):
|
|
|
1061
1050
|
"os_has_attachment": True,
|
|
1062
1051
|
"os_parent_folder": os_parent_folder,
|
|
1063
1052
|
},
|
|
1064
|
-
|
|
1065
|
-
os_relationship_type,
|
|
1053
|
+
relationship,
|
|
1066
1054
|
os_entity_uid,
|
|
1067
1055
|
os_relationship_uid,
|
|
1068
1056
|
)
|
|
@@ -1071,7 +1059,7 @@ class NifiEntity(object):
|
|
|
1071
1059
|
else:
|
|
1072
1060
|
temp_filename = f"tmp_{child_entity.record['os_entity_uid']}"
|
|
1073
1061
|
temp_contents = TemporaryAttachmentContents(
|
|
1074
|
-
entity_type=
|
|
1062
|
+
entity_type=os_entity_type,
|
|
1075
1063
|
filetype=filetype,
|
|
1076
1064
|
filename=temp_filename,
|
|
1077
1065
|
client=self.context.client,
|
|
@@ -1082,13 +1070,38 @@ class NifiEntity(object):
|
|
|
1082
1070
|
child_entity.request["contents_pointer"] = child_entity._contents.to_locator()
|
|
1083
1071
|
return child_entity, child_rel
|
|
1084
1072
|
|
|
1073
|
+
def add_child_fragment(
|
|
1074
|
+
self,
|
|
1075
|
+
os_workspace,
|
|
1076
|
+
os_parent_folder,
|
|
1077
|
+
filename,
|
|
1078
|
+
filetype,
|
|
1079
|
+
file: Union[Contents, bytes],
|
|
1080
|
+
fields={},
|
|
1081
|
+
relationship: RelationshipName = FRAGMENT_RELATIONSHIP,
|
|
1082
|
+
os_entity_uid=None,
|
|
1083
|
+
os_relationship_uid=None,
|
|
1084
|
+
os_entity_type=FRAGMENT_ENTITY_NAME,
|
|
1085
|
+
):
|
|
1086
|
+
return self.add_child_file(
|
|
1087
|
+
os_workspace,
|
|
1088
|
+
os_parent_folder,
|
|
1089
|
+
filename,
|
|
1090
|
+
filetype,
|
|
1091
|
+
file,
|
|
1092
|
+
fields,
|
|
1093
|
+
relationship,
|
|
1094
|
+
os_entity_uid,
|
|
1095
|
+
os_relationship_uid,
|
|
1096
|
+
os_entity_type,
|
|
1097
|
+
)
|
|
1098
|
+
|
|
1085
1099
|
def add_tag(self, os_workspace, name, group, order, color, fields={}):
|
|
1086
1100
|
return self.add_child_entity(
|
|
1087
1101
|
os_workspace,
|
|
1088
|
-
|
|
1089
|
-
{**fields,"name": name, "group": group, "order": order, "color": color},
|
|
1090
|
-
|
|
1091
|
-
"mtm",
|
|
1102
|
+
TAG_ENTITY_NAME,
|
|
1103
|
+
{**fields, "name": name, "group": group, "order": order, "color": color},
|
|
1104
|
+
TAG_RELATIONSHIP,
|
|
1092
1105
|
)
|
|
1093
1106
|
|
|
1094
1107
|
def add_annotations(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|