streamlit-octostar-utils 0.1.7a10__py3-none-any.whl → 0.2.0__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.
- streamlit_octostar_utils/api_crafter/parser/entities_parser.py +14 -51
- streamlit_octostar_utils/nlp/ner.py +0 -2
- streamlit_octostar_utils/octostar/client.py +8 -11
- streamlit_octostar_utils/octostar/permissions.py +1 -1
- {streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.2.0.dist-info}/METADATA +2 -2
- {streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.2.0.dist-info}/RECORD +8 -9
- {streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.2.0.dist-info}/WHEEL +1 -1
- streamlit_octostar_utils/hello.py +0 -2
- {streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.2.0.dist-info}/LICENSE +0 -0
@@ -67,26 +67,16 @@ InvalidErrorDict = dict
|
|
67
67
|
|
68
68
|
|
69
69
|
class EntitiesParser(object):
|
70
|
-
def __init__(self, parse_rulesets,
|
70
|
+
def __init__(self, parse_rulesets, ontology=None):
|
71
71
|
self.concepts = dict()
|
72
72
|
self.ruleset = dict()
|
73
|
-
self.ontology =
|
74
|
-
self.os_client = client
|
73
|
+
self.ontology = ontology
|
75
74
|
if not isinstance(parse_rulesets, list):
|
76
75
|
parse_rulesets = [parse_rulesets]
|
77
76
|
for parse_ruleset in parse_rulesets:
|
78
77
|
self.ruleset = parse_ruleset.load(self.ruleset, self)
|
79
78
|
self._reset_parsing_vars()
|
80
79
|
|
81
|
-
def _get_ontology(self):
|
82
|
-
if not self.ontology:
|
83
|
-
from octostar.utils.ontology import fetch_ontology_data
|
84
|
-
|
85
|
-
try:
|
86
|
-
self.ontology = fetch_ontology_data.sync(client=self.os_client)
|
87
|
-
except:
|
88
|
-
self.ontology = None
|
89
|
-
|
90
80
|
def _reset_parsing_vars(self):
|
91
81
|
self.curr_entries = list()
|
92
82
|
self.curr_entities = list()
|
@@ -131,13 +121,13 @@ class EntitiesParser(object):
|
|
131
121
|
def _cull_entities(self, entities, relationships):
|
132
122
|
removed_ids = list()
|
133
123
|
for entity in entities:
|
134
|
-
if "extra_fields" in entity.fields:
|
135
|
-
if not entity.fields["extra_fields"]:
|
136
|
-
del entity.fields["extra_fields"]
|
124
|
+
if "#extra_fields" in entity.fields:
|
125
|
+
if not entity.fields["#extra_fields"]:
|
126
|
+
del entity.fields["#extra_fields"]
|
137
127
|
else:
|
138
|
-
for extra_field in list(entity.fields["extra_fields"].keys()):
|
139
|
-
if not entity.fields["extra_fields"][extra_field]:
|
140
|
-
del entity.fields["extra_fields"][extra_field]
|
128
|
+
for extra_field in list(entity.fields["#extra_fields"].keys()):
|
129
|
+
if not entity.fields["#extra_fields"][extra_field]:
|
130
|
+
del entity.fields["#extra_fields"][extra_field]
|
141
131
|
for field in list(entity.fields.keys()):
|
142
132
|
if not entity.fields[field]:
|
143
133
|
del entity.fields[field]
|
@@ -248,11 +238,11 @@ class EntitiesParser(object):
|
|
248
238
|
if root_entity:
|
249
239
|
root_entity = root_entity[0]
|
250
240
|
unused_fields = dict()
|
251
|
-
if "extra_fields" not in root_entity.fields:
|
252
|
-
root_entity.fields["extra_fields"] = dict()
|
241
|
+
if "#extra_fields" not in root_entity.fields:
|
242
|
+
root_entity.fields["#extra_fields"] = dict()
|
253
243
|
unused_fields = _find_extra_fields_recursive(entry.value)
|
254
|
-
root_entity.fields["extra_fields"] = {
|
255
|
-
**root_entity.fields["extra_fields"],
|
244
|
+
root_entity.fields["#extra_fields"] = {
|
245
|
+
**root_entity.fields["#extra_fields"],
|
256
246
|
**unused_fields,
|
257
247
|
}
|
258
248
|
|
@@ -548,9 +538,8 @@ class EntitiesParser(object):
|
|
548
538
|
"""
|
549
539
|
|
550
540
|
def validate_and_format_entities(self, entities, relationships):
|
551
|
-
self._get_ontology()
|
552
541
|
if not self.ontology:
|
553
|
-
raise RuntimeError("
|
542
|
+
raise RuntimeError("No ontology provided for validation!")
|
554
543
|
ontology = self.ontology
|
555
544
|
from streamlit_octostar_utils.ontology.validation import (
|
556
545
|
validate_and_format_timbr_type,
|
@@ -571,7 +560,7 @@ class EntitiesParser(object):
|
|
571
560
|
entity_properties = [
|
572
561
|
k
|
573
562
|
for k in entity.fields.keys()
|
574
|
-
if not k.startswith("#")
|
563
|
+
if not k.startswith("#")
|
575
564
|
]
|
576
565
|
ontology_properties = {
|
577
566
|
e["property_name"]: e
|
@@ -665,32 +654,6 @@ class EntitiesParser(object):
|
|
665
654
|
if relationship.concept_to == id_from:
|
666
655
|
relationship.concept_to = id_to
|
667
656
|
|
668
|
-
def extra_fields_to_entities(self, source_entities, remove_fields_from_source=True):
|
669
|
-
new_entities = list()
|
670
|
-
new_relationships = list()
|
671
|
-
for entity in source_entities:
|
672
|
-
if (
|
673
|
-
entity.fields
|
674
|
-
and "extra_fields" in entity.fields
|
675
|
-
and entity.fields["extra_fields"]
|
676
|
-
):
|
677
|
-
new_entity = EntityInfo(
|
678
|
-
self._compute_deterministic_uuid(
|
679
|
-
entity.fields["extra_fields"], "json", False
|
680
|
-
),
|
681
|
-
"json",
|
682
|
-
entity.fields["extra_fields"],
|
683
|
-
)
|
684
|
-
if remove_fields_from_source:
|
685
|
-
del entity.fields["extra_fields"]
|
686
|
-
new_entities.append(new_entity)
|
687
|
-
new_relationships.append(
|
688
|
-
RelationshipInfo(
|
689
|
-
entity.unique_id, new_entity.unique_id, "has_unparsed_data"
|
690
|
-
)
|
691
|
-
)
|
692
|
-
return new_entities, new_relationships
|
693
|
-
|
694
657
|
def to_linkchart(self, entities, relationships, label_fn):
|
695
658
|
return_dict = {"records": list(), "relationships": list()}
|
696
659
|
for entity in entities:
|
@@ -163,7 +163,6 @@ def compute_ner(
|
|
163
163
|
entities += flair_entities
|
164
164
|
del flair_entities
|
165
165
|
|
166
|
-
print("Checking REGEXES")
|
167
166
|
# REGEX model
|
168
167
|
for label, regexes in REGEX_NER_MODELS.items():
|
169
168
|
if not isinstance(regexes, list):
|
@@ -183,7 +182,6 @@ def compute_ner(
|
|
183
182
|
min_score = min([min_score] + [e.score for e in regex_entities])
|
184
183
|
|
185
184
|
# SPACY model
|
186
|
-
print("CHECKING SPACY")
|
187
185
|
chunks = []
|
188
186
|
chunk_start_offsets = []
|
189
187
|
current_chunk = []
|
@@ -1,12 +1,10 @@
|
|
1
1
|
from octostar.client import make_client, UserContext, User
|
2
2
|
from functools import wraps
|
3
|
-
from
|
3
|
+
from octostar_streamlit.desktop import whoami
|
4
4
|
from streamlit.runtime.scriptrunner import get_script_run_ctx
|
5
5
|
import hashlib
|
6
6
|
import streamlit as st
|
7
7
|
import time
|
8
|
-
import base64
|
9
|
-
import json
|
10
8
|
|
11
9
|
|
12
10
|
def impersonating_running_user(**client_kwargs):
|
@@ -27,14 +25,13 @@ def as_running_user(force_refresh=False):
|
|
27
25
|
script_ctx = get_script_run_ctx()
|
28
26
|
current_time = time.time()
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
)
|
28
|
+
should_refresh = (
|
29
|
+
force_refresh
|
30
|
+
or script_ctx.script_requests is not session.get("prev_run")
|
31
|
+
or current_time > session.get("token_expiry", 0) - 300 # 5 minutes buffer
|
32
|
+
)
|
36
33
|
|
37
|
-
if not should_refresh
|
34
|
+
if not should_refresh and "prev_user" in session:
|
38
35
|
return UserContext(session["prev_user"])
|
39
36
|
|
40
37
|
running_user = whoami()
|
@@ -52,5 +49,5 @@ def as_running_user(force_refresh=False):
|
|
52
49
|
session["prev_user"] = user
|
53
50
|
session["token_expiry"] = user.jwt_expires_at
|
54
51
|
|
55
|
-
session["
|
52
|
+
session["prev_run"] = script_ctx.script_requests
|
56
53
|
return UserContext(session["prev_user"])
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import streamlit as st
|
2
2
|
|
3
|
-
from
|
3
|
+
from octostar_streamlit.desktop import get_open_workspace_ids
|
4
4
|
from octostar.utils.ontology import query_ontology
|
5
5
|
from octostar.utils.workspace.permissions import get_permissions, PermissionLevel
|
6
6
|
|
{streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.2.0.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: streamlit-octostar-utils
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary:
|
5
5
|
License: MIT
|
6
6
|
Author: Octostar
|
@@ -21,6 +21,7 @@ Requires-Dist: flair (==0.13.1) ; extra == "nlp"
|
|
21
21
|
Requires-Dist: iso639 (>=0.1.0) ; extra == "nlp"
|
22
22
|
Requires-Dist: nltk (>=3.8.0,<4.0.0) ; extra == "nlp"
|
23
23
|
Requires-Dist: numpy (>=1.20.0)
|
24
|
+
Requires-Dist: octostar-streamlit (>=0.1.25,<0.2.0)
|
24
25
|
Requires-Dist: pottery (>=3.0.0,<4.0.0)
|
25
26
|
Requires-Dist: py3langid (>=0.2.0,<0.3.0) ; extra == "nlp"
|
26
27
|
Requires-Dist: pydantic (>=2.6.4,<3.0.0)
|
@@ -33,7 +34,6 @@ Requires-Dist: sortedcontainers (>=2.0.0)
|
|
33
34
|
Requires-Dist: spacy (>=3.7.0,<4.0.0) ; extra == "nlp"
|
34
35
|
Requires-Dist: spacy-download (==1.1.0) ; extra == "nlp"
|
35
36
|
Requires-Dist: streamlit (>=1.33.0,<2.0.0)
|
36
|
-
Requires-Dist: streamlit-octostar-research (>=0.1.22,<0.2.0)
|
37
37
|
Requires-Dist: sumy (>=0.11.0,<1.0.0) ; extra == "nlp"
|
38
38
|
Description-Content-Type: text/markdown
|
39
39
|
|
{streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.2.0.dist-info}/RECORD
RENAMED
@@ -5,7 +5,7 @@ streamlit_octostar_utils/api_crafter/fastapi.py,sha256=2bktT5Mwjs9XixWcOqUKMoLM_
|
|
5
5
|
streamlit_octostar_utils/api_crafter/nifi.py,sha256=fQ5k9eZl2oSQZ2BexZYwKUiO05-FryUi7wnCd_56P9Y,44375
|
6
6
|
streamlit_octostar_utils/api_crafter/parser/__init__.py,sha256=YeYWF6sdQiCFV_RKNW2t9Vs6KJExE2pbXxWTe_DOayY,107
|
7
7
|
streamlit_octostar_utils/api_crafter/parser/combine_fields.py,sha256=ddc44xkajw8MU0peAX_263DL7rPXbTKbHUjpOhRgvyU,8790
|
8
|
-
streamlit_octostar_utils/api_crafter/parser/entities_parser.py,sha256=
|
8
|
+
streamlit_octostar_utils/api_crafter/parser/entities_parser.py,sha256=zOQoN-p1Gz6ZzxvoX4M1b4Fi3mfmQr5zaNUcp_8gCjw,30016
|
9
9
|
streamlit_octostar_utils/api_crafter/parser/generics.py,sha256=GefvTUWkqsICS_TdXA2p73_Uzh6041g88mWql3Fr9cY,1861
|
10
10
|
streamlit_octostar_utils/api_crafter/parser/info.py,sha256=L2cdtsmfIdFSkAnIXhGhQZG6YMZRtY1GgLXn-847avA,649
|
11
11
|
streamlit_octostar_utils/api_crafter/parser/linkchart_functions.py,sha256=WfHl-EfH4SWjpk8civS7HL11eIl4SAV5Dtwe8mTidrc,7163
|
@@ -19,14 +19,13 @@ streamlit_octostar_utils/core/filetypes.py,sha256=C4h4WDU8voMIdQETC3n1cd-CDgw9aN
|
|
19
19
|
streamlit_octostar_utils/core/threading/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
20
20
|
streamlit_octostar_utils/core/threading/key_queue.py,sha256=7CJpj0gvZMQd8eC5wKQi3Ak5SQQ4zQ1OPTs_OP_kD20,2255
|
21
21
|
streamlit_octostar_utils/core/timestamp.py,sha256=a3s4xfm1nctLzYsHOJxqoWIDTdbNY_yN1OByl8ahLc8,383
|
22
|
-
streamlit_octostar_utils/hello.py,sha256=JVeug8fnyYYf_qw6eeMDBrdqsSkiwnSHdPvb9puEGdA,69
|
23
22
|
streamlit_octostar_utils/nlp/__init__.py,sha256=BtlYDZK_xaEbc7Ju_7MznXbCVPZcdLn26xwR9qf_UhM,336
|
24
23
|
streamlit_octostar_utils/nlp/language.py,sha256=13f6kAALYjC3EclBzcyKPd4GlIeIR1mWPu3S6d-z814,549
|
25
|
-
streamlit_octostar_utils/nlp/ner.py,sha256=
|
24
|
+
streamlit_octostar_utils/nlp/ner.py,sha256=EAx4WNCH3jO9KQlK47hG3RMjnNpFadGl7CKfCQmSM7c,13326
|
26
25
|
streamlit_octostar_utils/octostar/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
27
|
-
streamlit_octostar_utils/octostar/client.py,sha256=
|
26
|
+
streamlit_octostar_utils/octostar/client.py,sha256=2oyU3ZJp4a7GxFM3qH5UVzu2KQm2kSSjzFlqG6t6G2Q,1696
|
28
27
|
streamlit_octostar_utils/octostar/context.py,sha256=TpucK48EbeVy4vDqKd9UULEtr1JOY-_4nBs-rXZzESw,212
|
29
|
-
streamlit_octostar_utils/octostar/permissions.py,sha256=
|
28
|
+
streamlit_octostar_utils/octostar/permissions.py,sha256=G5nZQLR-k-5_Xeto4nDTb32828Ga-SHm1mvSB9tz-t4,1565
|
30
29
|
streamlit_octostar_utils/ontology/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
31
30
|
streamlit_octostar_utils/ontology/expand_entities.py,sha256=bBt32Dnts3VSzu13QQtPyfYe05IRodD9WfnhNTiBg_w,22749
|
32
31
|
streamlit_octostar_utils/ontology/inheritance.py,sha256=oSd6xDAlmI7iYOv3VJ7t8CRN2zK7_Cln26YHS20qAqw,138
|
@@ -37,7 +36,7 @@ streamlit_octostar_utils/threading/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzp
|
|
37
36
|
streamlit_octostar_utils/threading/async_task_manager.py,sha256=q7N6YZwUvIYMzkSHmsJNheNVCv93c03H6Hyg9uH8pvk,4747
|
38
37
|
streamlit_octostar_utils/threading/session_callback_manager.py,sha256=LvZVP4g6tvKtYmI13f2j1sX_7hm61Groqp5xJine9_k,3973
|
39
38
|
streamlit_octostar_utils/threading/session_state_hot_swapper.py,sha256=6eeCQI6A42hp4DmW2NQw2rbeR-k9N8DhfBKQdN_fbLU,811
|
40
|
-
streamlit_octostar_utils-0.
|
41
|
-
streamlit_octostar_utils-0.
|
42
|
-
streamlit_octostar_utils-0.
|
43
|
-
streamlit_octostar_utils-0.
|
39
|
+
streamlit_octostar_utils-0.2.0.dist-info/LICENSE,sha256=dkwVPyV03fPHHtERnF6RnvRXcll__tud9gWca1RcgnQ,1073
|
40
|
+
streamlit_octostar_utils-0.2.0.dist-info/METADATA,sha256=CfGrV-aE4V02HSNDBHec34ngZR7tLSrAmCR0eyKKNRQ,2256
|
41
|
+
streamlit_octostar_utils-0.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
42
|
+
streamlit_octostar_utils-0.2.0.dist-info/RECORD,,
|
{streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.2.0.dist-info}/LICENSE
RENAMED
File without changes
|