kodexa 7.0.12399293688__tar.gz → 7.4.412416544440__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 (49) hide show
  1. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/PKG-INFO +1 -1
  2. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/model.py +7 -4
  3. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/persistence.py +87 -27
  4. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/pyproject.toml +2 -2
  5. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/LICENSE +0 -0
  6. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/README.md +0 -0
  7. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/__init__.py +0 -0
  8. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/assistant/__init__.py +0 -0
  9. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/assistant/assistant.py +0 -0
  10. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/connectors/__init__.py +0 -0
  11. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/connectors/connectors.py +0 -0
  12. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/dataclasses/__init__.py +0 -0
  13. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/dataclasses/templates/llm_data_class.j2 +0 -0
  14. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/__init__.py +0 -0
  15. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/base.py +0 -0
  16. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/entities/__init__.py +0 -0
  17. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/entities/check_response.py +0 -0
  18. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/entities/product.py +0 -0
  19. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/entities/product_subscription.py +0 -0
  20. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/objects.py +0 -0
  21. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/model/utils.py +0 -0
  22. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/pipeline/__init__.py +0 -0
  23. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/pipeline/pipeline.py +0 -0
  24. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/platform/__init__.py +0 -0
  25. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/platform/client.py +0 -0
  26. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/platform/interaction.py +0 -0
  27. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/platform/kodexa.py +0 -0
  28. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/__init__.py +0 -0
  29. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/ast.py +0 -0
  30. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/core.py +0 -0
  31. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/lexrules.py +0 -0
  32. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/lextab.py +0 -0
  33. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/lextab.pyi +0 -0
  34. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/parserules.py +0 -0
  35. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/parserules.pyi +0 -0
  36. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/parsetab.py +0 -0
  37. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/selectors/parsetab.pyi +0 -0
  38. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/spatial/__init__.py +0 -0
  39. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/spatial/azure_models.py +0 -0
  40. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/spatial/bbox_common.py +0 -0
  41. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/spatial/table_form_common.py +0 -0
  42. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/steps/__init__.py +0 -0
  43. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/steps/common.py +0 -0
  44. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/testing/__init__.py +0 -0
  45. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/testing/test_components.py +0 -0
  46. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/testing/test_utils.py +0 -0
  47. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/training/__init__.py +0 -0
  48. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/training/train_utils.py +0 -0
  49. {kodexa-7.0.12399293688 → kodexa-7.4.412416544440}/kodexa/utils/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kodexa
3
- Version: 7.0.12399293688
3
+ Version: 7.4.412416544440
4
4
  Summary: Python SDK for the Kodexa Platform
5
5
  Author: Austin Redenbaugh
6
6
  Author-email: austin@kodexa.com
@@ -2443,11 +2443,14 @@ class Document(object):
2443
2443
  def get_exceptions(self) -> List[ContentException]:
2444
2444
  return self._persistence_layer.get_exceptions()
2445
2445
 
2446
- def get_external_data(self) -> dict:
2447
- return self._persistence_layer.get_external_data()
2446
+ def get_external_data(self, key="default") -> dict:
2447
+ return self._persistence_layer.get_external_data(key)
2448
2448
 
2449
- def set_external_data(self, external_data:dict):
2450
- return self._persistence_layer.set_external_data(external_data)
2449
+ def get_external_data_keys(self) -> list[str]:
2450
+ return self._persistence_layer.get_external_data_keys()
2451
+
2452
+ def set_external_data(self, external_data:dict, key="default"):
2453
+ return self._persistence_layer.set_external_data(external_data, key)
2451
2454
 
2452
2455
  def get_steps(self) -> list[ProcessingStep]:
2453
2456
  return self._persistence_layer.get_steps()
@@ -1156,22 +1156,6 @@ class SqliteDocumentPersistence(object):
1156
1156
 
1157
1157
  return content_nodes
1158
1158
 
1159
- def __ensure_ed_table_exists(self):
1160
- """
1161
- Ensure the 'ed' table exists in the database.
1162
- Creates the table if it does not exist.
1163
- """
1164
- self.cursor.execute("""
1165
- CREATE TABLE IF NOT EXISTS ed (
1166
- obj BLOB
1167
- )
1168
- """)
1169
-
1170
- # Check if the table has any rows, if not, insert an initial empty row
1171
- result = self.cursor.execute("SELECT COUNT(*) FROM ed").fetchone()
1172
- if result[0] == 0:
1173
- self.cursor.execute("INSERT INTO ed (obj) VALUES (?)", [sqlite3.Binary(msgpack.packb({}))])
1174
-
1175
1159
  def __ensure_validations_table_exists(self):
1176
1160
  """
1177
1161
  Ensure the 'validations' table exists in the database.
@@ -1213,31 +1197,98 @@ class SqliteDocumentPersistence(object):
1213
1197
  return [DocumentTaxonValidation.model_validate(v) for v in msgpack.unpackb(result[0])]
1214
1198
  return []
1215
1199
 
1216
- def set_external_data(self, external_data: dict):
1200
+ def set_external_data(self, external_data: dict, key: str = "default"):
1217
1201
  """
1218
- Sets the external data for the document.
1202
+ Sets the external data for the document for a specific key.
1219
1203
 
1220
1204
  Args:
1221
1205
  external_data (dict): The external data to store, must be JSON serializable.
1206
+ key (str): The key to store the data under, defaults to "default"
1222
1207
  """
1223
1208
  self.__ensure_ed_table_exists()
1224
1209
  serialized_data = sqlite3.Binary(msgpack.packb(external_data))
1225
- self.cursor.execute("UPDATE ed SET obj = ? WHERE rowid = 1", [serialized_data])
1210
+ self.cursor.execute("DELETE FROM ed WHERE key = ?", [key])
1211
+ self.cursor.execute("INSERT INTO ed (key, obj) VALUES (?, ?)", [key, serialized_data])
1226
1212
  self.connection.commit()
1227
1213
 
1228
- def get_external_data(self) -> dict:
1214
+ def get_external_data(self, key: str = "default") -> dict:
1229
1215
  """
1230
- Gets the external data associated with this document.
1216
+ Gets the external data associated with this document for a specific key.
1217
+
1218
+ Args:
1219
+ key (str): The key to retrieve data for, defaults to "default"
1231
1220
 
1232
1221
  Returns:
1233
- dict: The external data stored in the ed table.
1222
+ dict: The external data stored in the ed table for the given key.
1234
1223
  """
1235
1224
  self.__ensure_ed_table_exists()
1236
- result = self.cursor.execute("SELECT obj FROM ed WHERE rowid = 1").fetchone()
1225
+ result = self.cursor.execute("SELECT obj FROM ed WHERE key = ?", [key]).fetchone()
1237
1226
  if result and result[0]:
1238
1227
  return msgpack.unpackb(result[0])
1239
1228
  return {}
1240
1229
 
1230
+ def get_external_data_keys(self) -> List[str]:
1231
+ """
1232
+ Gets all keys under which external data is stored.
1233
+
1234
+ Returns:
1235
+ List[str]: A list of all keys that have external data stored.
1236
+ """
1237
+ self.__ensure_ed_table_exists()
1238
+ results = self.cursor.execute("SELECT key FROM ed").fetchall()
1239
+ return [row[0] for row in results]
1240
+
1241
+ def __ensure_ed_table_exists(self):
1242
+ """
1243
+ Ensure the 'ed' table exists in the database.
1244
+ Creates the table if it does not exist.
1245
+ """
1246
+ # First check if the old table exists and has key column
1247
+ old_table = self.cursor.execute("""
1248
+ SELECT name FROM sqlite_master
1249
+ WHERE type='table' AND name='ed'
1250
+ """).fetchone()
1251
+
1252
+ if old_table:
1253
+ # Check if table has key column
1254
+ table_info = self.cursor.execute("PRAGMA table_info(ed)").fetchall()
1255
+ has_key_column = any(col[1] == 'key' for col in table_info)
1256
+
1257
+ if not has_key_column:
1258
+ # Get the old data and drop the table
1259
+ data = self.cursor.execute("SELECT obj FROM ed").fetchone()
1260
+ self.cursor.execute("DROP TABLE ed")
1261
+
1262
+ # Create new table with key column
1263
+ self.cursor.execute("""
1264
+ CREATE TABLE ed (
1265
+ key TEXT PRIMARY KEY,
1266
+ obj BLOB
1267
+ )
1268
+ """)
1269
+
1270
+ # If there was data in the old table, insert it with default key
1271
+ if data:
1272
+ self.cursor.execute("INSERT INTO ed (key, obj) VALUES (?, ?)",
1273
+ ["default", data[0]])
1274
+ else:
1275
+ # Table exists and has key column - do nothing
1276
+ return
1277
+ else:
1278
+ # Create new table if it doesn't exist
1279
+ self.cursor.execute("""
1280
+ CREATE TABLE IF NOT EXISTS ed (
1281
+ key TEXT PRIMARY KEY,
1282
+ obj BLOB
1283
+ )
1284
+ """)
1285
+
1286
+ # Check if default key exists, if not insert empty data
1287
+ result = self.cursor.execute("SELECT COUNT(*) FROM ed WHERE key = 'default'").fetchone()
1288
+ if result[0] == 0:
1289
+ self.cursor.execute("INSERT INTO ed (key, obj) VALUES (?, ?)",
1290
+ ["default", sqlite3.Binary(msgpack.packb({}))])
1291
+
1241
1292
  def __ensure_steps_table_exists(self):
1242
1293
  """
1243
1294
  Ensure the 'steps' table exists in the database.
@@ -1436,22 +1487,31 @@ class PersistenceManager(object):
1436
1487
  def get_validations(self) -> list[DocumentTaxonValidation]:
1437
1488
  return self._underlying_persistence.get_validations()
1438
1489
 
1439
- def get_external_data(self) -> dict:
1490
+ def get_external_data(self, key="default") -> dict:
1440
1491
  """
1441
1492
  Gets the external data object associated with this document
1442
1493
 
1443
1494
  :return: dict of the external data
1444
1495
  """
1445
- return self._underlying_persistence.get_external_data()
1496
+ return self._underlying_persistence.get_external_data(key)
1497
+
1498
+ def get_external_data_keys(self) -> List[str]:
1499
+ """
1500
+ Gets all keys under which external data is stored.
1501
+
1502
+ Returns:
1503
+ List[str]: A list of all keys that have external data stored.
1504
+ """
1505
+ return self._underlying_persistence.get_external_data_keys()
1446
1506
 
1447
- def set_external_data(self, external_data:dict):
1507
+ def set_external_data(self, external_data:dict, key="default"):
1448
1508
  """
1449
1509
  Sets the external data for this document
1450
1510
 
1451
1511
  :param external_data: dict representing the external data, must be JSON serializable
1452
1512
  :return:
1453
1513
  """
1454
- self._underlying_persistence.set_external_data(external_data)
1514
+ self._underlying_persistence.set_external_data(external_data, key)
1455
1515
 
1456
1516
  def get_nodes_by_type(self, node_type: str) -> List[ContentNode]:
1457
1517
  """
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "kodexa"
3
- version = "7.0.012399293688"
3
+ version = "7.4.412416544440"
4
4
  description = "Python SDK for the Kodexa Platform"
5
5
  authors = ["Austin Redenbaugh <austin@kodexa.com>", "Philip Dodds <philip@kodexa.com>", "Romar Cablao <rcablao@kodexa.com>", "Amadea Paula Dodds <amadeapaula@kodexa.com>"]
6
6
  readme = "README.md"
@@ -14,7 +14,7 @@ classifiers = [
14
14
  'Intended Audience :: Developers',
15
15
  'Topic :: Software Development :: Libraries',
16
16
  '''License :: OSI Approved :: Apache Software License''', # noqa
17
- 'Programming Language :: Python :: 3.10',
17
+ 'Programming Language :: Python :: 3.11',
18
18
  ]
19
19
 
20
20
  [tool.poetry.dependencies]