dkg 8.0.12__tar.gz → 8.0.13__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 (82) hide show
  1. {dkg-8.0.12 → dkg-8.0.13}/PKG-INFO +1 -1
  2. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/knowledge_collection_tools.py +60 -21
  3. {dkg-8.0.12 → dkg-8.0.13}/pyproject.toml +1 -1
  4. {dkg-8.0.12 → dkg-8.0.13}/LICENSE +0 -0
  5. {dkg-8.0.12 → dkg-8.0.13}/NOTICE +0 -0
  6. {dkg-8.0.12 → dkg-8.0.13}/README.md +0 -0
  7. {dkg-8.0.12 → dkg-8.0.13}/dkg/__init__.py +0 -0
  8. {dkg-8.0.12 → dkg-8.0.13}/dkg/assertion.py +0 -0
  9. {dkg-8.0.12 → dkg-8.0.13}/dkg/clients/__init__.py +0 -0
  10. {dkg-8.0.12 → dkg-8.0.13}/dkg/clients/async_dkg.py +0 -0
  11. {dkg-8.0.12 → dkg-8.0.13}/dkg/clients/dkg.py +0 -0
  12. {dkg-8.0.12 → dkg-8.0.13}/dkg/constants.py +0 -0
  13. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/AskStorage.json +0 -0
  14. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/Chronos.json +0 -0
  15. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/Hub.json +0 -0
  16. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/IdentityStorage.json +0 -0
  17. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/KnowledgeCollection.json +0 -0
  18. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/KnowledgeCollectionStorage.json +0 -0
  19. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/Paranet.json +0 -0
  20. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/ParanetIncentivesPoolFactory.json +0 -0
  21. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/ParanetKnowledgeMinersRegistry.json +0 -0
  22. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/ParanetNeuroIncentivesPool.json +0 -0
  23. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/ParanetsRegistry.json +0 -0
  24. {dkg-8.0.12 → dkg-8.0.13}/dkg/data/interfaces/Token.json +0 -0
  25. {dkg-8.0.12 → dkg-8.0.13}/dkg/dataclasses.py +0 -0
  26. {dkg-8.0.12 → dkg-8.0.13}/dkg/exceptions.py +0 -0
  27. {dkg-8.0.12 → dkg-8.0.13}/dkg/managers/__init__.py +0 -0
  28. {dkg-8.0.12 → dkg-8.0.13}/dkg/managers/async_manager.py +0 -0
  29. {dkg-8.0.12 → dkg-8.0.13}/dkg/managers/manager.py +0 -0
  30. {dkg-8.0.12 → dkg-8.0.13}/dkg/method.py +0 -0
  31. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/__init__.py +0 -0
  32. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/asset/__init__.py +0 -0
  33. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/asset/asset.py +0 -0
  34. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/asset/async_asset.py +0 -0
  35. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/async_module.py +0 -0
  36. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/graph/__init__.py +0 -0
  37. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/graph/async_graph.py +0 -0
  38. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/graph/graph.py +0 -0
  39. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/module.py +0 -0
  40. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/network/__init__.py +0 -0
  41. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/network/network.py +0 -0
  42. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/node/__init__.py +0 -0
  43. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/node/async_node.py +0 -0
  44. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/node/node.py +0 -0
  45. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/paranet/__init__.py +0 -0
  46. {dkg-8.0.12 → dkg-8.0.13}/dkg/modules/paranet/paranet.py +0 -0
  47. {dkg-8.0.12 → dkg-8.0.13}/dkg/providers/__init__.py +0 -0
  48. {dkg-8.0.12 → dkg-8.0.13}/dkg/providers/blockchain/__init__.py +0 -0
  49. {dkg-8.0.12 → dkg-8.0.13}/dkg/providers/blockchain/async_blockchain.py +0 -0
  50. {dkg-8.0.12 → dkg-8.0.13}/dkg/providers/blockchain/base_blockchain.py +0 -0
  51. {dkg-8.0.12 → dkg-8.0.13}/dkg/providers/blockchain/blockchain.py +0 -0
  52. {dkg-8.0.12 → dkg-8.0.13}/dkg/providers/node/__init__.py +0 -0
  53. {dkg-8.0.12 → dkg-8.0.13}/dkg/providers/node/async_node_http.py +0 -0
  54. {dkg-8.0.12 → dkg-8.0.13}/dkg/providers/node/base_node_http.py +0 -0
  55. {dkg-8.0.12 → dkg-8.0.13}/dkg/providers/node/node_http.py +0 -0
  56. {dkg-8.0.12 → dkg-8.0.13}/dkg/services/__init__.py +0 -0
  57. {dkg-8.0.12 → dkg-8.0.13}/dkg/services/blockchain_services/__init__.py +0 -0
  58. {dkg-8.0.12 → dkg-8.0.13}/dkg/services/blockchain_services/async_blockchain_service.py +0 -0
  59. {dkg-8.0.12 → dkg-8.0.13}/dkg/services/blockchain_services/blockchain_service.py +0 -0
  60. {dkg-8.0.12 → dkg-8.0.13}/dkg/services/input_service.py +0 -0
  61. {dkg-8.0.12 → dkg-8.0.13}/dkg/services/node_services/__init__.py +0 -0
  62. {dkg-8.0.12 → dkg-8.0.13}/dkg/services/node_services/async_node_service.py +0 -0
  63. {dkg-8.0.12 → dkg-8.0.13}/dkg/services/node_services/node_service.py +0 -0
  64. {dkg-8.0.12 → dkg-8.0.13}/dkg/types/__init__.py +0 -0
  65. {dkg-8.0.12 → dkg-8.0.13}/dkg/types/blockchain.py +0 -0
  66. {dkg-8.0.12 → dkg-8.0.13}/dkg/types/dkg_node.py +0 -0
  67. {dkg-8.0.12 → dkg-8.0.13}/dkg/types/encoding.py +0 -0
  68. {dkg-8.0.12 → dkg-8.0.13}/dkg/types/evm.py +0 -0
  69. {dkg-8.0.12 → dkg-8.0.13}/dkg/types/general.py +0 -0
  70. {dkg-8.0.12 → dkg-8.0.13}/dkg/types/generics.py +0 -0
  71. {dkg-8.0.12 → dkg-8.0.13}/dkg/types/network.py +0 -0
  72. {dkg-8.0.12 → dkg-8.0.13}/dkg/types/rdf.py +0 -0
  73. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/__init__.py +0 -0
  74. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/blockchain_request.py +0 -0
  75. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/decorators.py +0 -0
  76. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/knowledge_asset_tools.py +0 -0
  77. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/merkle.py +0 -0
  78. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/metadata.py +0 -0
  79. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/node_request.py +0 -0
  80. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/rdf.py +0 -0
  81. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/string_transformations.py +0 -0
  82. {dkg-8.0.12 → dkg-8.0.13}/dkg/utils/ual.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dkg
3
- Version: 8.0.12
3
+ Version: 8.0.13
4
4
  Summary: Python library for interacting with the OriginTrail Decentralized Knowledge Graph
5
5
  License: Apache-2.0
6
6
  Author: Uladzislau Hubar
@@ -6,6 +6,7 @@ from dkg.types import JSONLD, NQuads
6
6
  from pyld import jsonld
7
7
  from dkg.constants import DEFAULT_RDF_FORMAT, DEFAULT_CANON_ALGORITHM, ESCAPE_MAP
8
8
  from rdflib import Graph, BNode, URIRef, Literal as RDFLiteral
9
+ from rdflib.exceptions import ParserError as RDFParserError
9
10
  from uuid import uuid4
10
11
  from web3 import Web3
11
12
  import math
@@ -154,29 +155,26 @@ def generate_missing_ids_for_blank_nodes(nquads_list: list[str] | None) -> list[
154
155
 
155
156
  return term # Return IRIs or Literals unchanged
156
157
 
157
- # Create a temporary graph for parsing individual quads
158
- result = []
159
-
160
- # Process each N-Quad string individually to maintain order
161
- for nquad in nquads_list:
162
- if not nquad.strip():
163
- continue
158
+ all_nquads = "\n".join(nquad for nquad in nquads_list if nquad.strip())
164
159
 
165
- # Parse single N-Quad
166
- g = Graph()
167
- g.parse(data=nquad, format="nquads")
160
+ # Create a single Dataset
161
+ g = Graph()
162
+ try:
163
+ g.parse(data=all_nquads, format="nt")
164
+ except RDFParserError:
165
+ raise UnsupportedJSONLD(nquads_list)
168
166
 
169
- # Get the triple and replace blank nodes
170
- for s, p, o in g:
171
- updated_quad = (
172
- replace_blank_node(s),
173
- replace_blank_node(p),
174
- replace_blank_node(o),
175
- )
176
- # Format as N-Quad string
177
- result.append(
178
- f"{updated_quad[0].n3()} {updated_quad[1].n3()} {updated_quad[2].n3()} ."
179
- )
167
+ # Process all quads
168
+ result = []
169
+ for s, p, o in g:
170
+ updated_quad = (
171
+ replace_blank_node(s),
172
+ replace_blank_node(p),
173
+ replace_blank_node(o),
174
+ )
175
+ result.append(
176
+ f"{updated_quad[0].n3()} {updated_quad[1].n3()} {updated_quad[2].n3()} ."
177
+ )
180
178
 
181
179
  return result
182
180
 
@@ -266,3 +264,44 @@ def escape_literal_dict(obj):
266
264
  return escape_literal_string(s=obj)
267
265
  else:
268
266
  return obj
267
+
268
+
269
+ # Used when JSON-LD parsing fails due to quads being passed instead of triples
270
+ class UnsupportedJSONLD(Exception):
271
+ def __init__(self, nquads_list):
272
+ self.nquads_list = nquads_list
273
+ self.message = f"""
274
+ Unsupported JSON-LD input detected
275
+
276
+ After parsing the JSON-LD input, the parser detected creation of new named graphs.
277
+ The DKG does not support custom named graphs.
278
+
279
+ Problematic Quads:
280
+
281
+ {self.find_problematic_quads()}
282
+
283
+ Full Parsed N-Quads Array:
284
+
285
+ {self.format_nquads_list()}
286
+
287
+ """
288
+ super().__init__(self.message)
289
+
290
+ def __str__(self):
291
+ return f"{self.__class__.__name__}: {self.message}"
292
+
293
+ def format_nquads_list(self):
294
+ return "\n".join(nquad.strip() for nquad in self.nquads_list)
295
+
296
+ def find_problematic_quads(self):
297
+ problematic = []
298
+ g = Graph()
299
+ for quad in self.nquads_list:
300
+ if not quad.strip():
301
+ continue
302
+ try:
303
+ g.parse(data=quad, format="nt")
304
+ except RDFParserError:
305
+ problematic.append(quad)
306
+
307
+ return "\n".join(f"{i + 1}. {quad}" for i, quad in enumerate(problematic))
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dkg"
3
- version = "8.0.12"
3
+ version = "8.0.13"
4
4
  description = "Python library for interacting with the OriginTrail Decentralized Knowledge Graph"
5
5
  authors = ["Uladzislau Hubar <hubar.uladzislau@gmail.com>, Zvonimir Sculac <zvonimir.sculac@origin-trail.com>"]
6
6
  license = "Apache-2.0"
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
File without changes
File without changes
File without changes