streamlit-octostar-utils 0.1.7a10__py3-none-any.whl → 0.1.7a11__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-0.1.7a10.dist-info → streamlit_octostar_utils-0.1.7a11.dist-info}/METADATA +1 -1
- {streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.1.7a11.dist-info}/RECORD +5 -5
- {streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.1.7a11.dist-info}/LICENSE +0 -0
- {streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.1.7a11.dist-info}/WHEEL +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:
|
{streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.1.7a11.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
|
@@ -37,7 +37,7 @@ streamlit_octostar_utils/threading/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzp
|
|
37
37
|
streamlit_octostar_utils/threading/async_task_manager.py,sha256=q7N6YZwUvIYMzkSHmsJNheNVCv93c03H6Hyg9uH8pvk,4747
|
38
38
|
streamlit_octostar_utils/threading/session_callback_manager.py,sha256=LvZVP4g6tvKtYmI13f2j1sX_7hm61Groqp5xJine9_k,3973
|
39
39
|
streamlit_octostar_utils/threading/session_state_hot_swapper.py,sha256=6eeCQI6A42hp4DmW2NQw2rbeR-k9N8DhfBKQdN_fbLU,811
|
40
|
-
streamlit_octostar_utils-0.1.
|
41
|
-
streamlit_octostar_utils-0.1.
|
42
|
-
streamlit_octostar_utils-0.1.
|
43
|
-
streamlit_octostar_utils-0.1.
|
40
|
+
streamlit_octostar_utils-0.1.7a11.dist-info/LICENSE,sha256=dkwVPyV03fPHHtERnF6RnvRXcll__tud9gWca1RcgnQ,1073
|
41
|
+
streamlit_octostar_utils-0.1.7a11.dist-info/METADATA,sha256=sh4TvXiQ_9cxohuhsa_MuY8kcqGJZ2GnVBNCVRXpbpc,2268
|
42
|
+
streamlit_octostar_utils-0.1.7a11.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
43
|
+
streamlit_octostar_utils-0.1.7a11.dist-info/RECORD,,
|
{streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.1.7a11.dist-info}/LICENSE
RENAMED
File without changes
|
{streamlit_octostar_utils-0.1.7a10.dist-info → streamlit_octostar_utils-0.1.7a11.dist-info}/WHEEL
RENAMED
File without changes
|