streamlit-octostar-utils 0.5.0.dev16__tar.gz → 0.5.0.dev18__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 (45) hide show
  1. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/PKG-INFO +1 -1
  2. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/pyproject.toml +1 -1
  3. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/celery.py +24 -3
  4. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/nifi.py +26 -10
  5. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/LICENSE +0 -0
  6. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/README.md +0 -0
  7. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/__init__.py +0 -0
  8. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/__init__.py +0 -0
  9. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/contents.py +0 -0
  10. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/fastapi.py +0 -0
  11. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parallelism.py +0 -0
  12. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/__init__.py +0 -0
  13. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/combine_fields.py +0 -0
  14. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/entities_parser.py +0 -0
  15. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/generics.py +0 -0
  16. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/info.py +0 -0
  17. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/linkchart_functions.py +0 -0
  18. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/matches.py +0 -0
  19. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/parameters.py +0 -0
  20. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/rules.py +0 -0
  21. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/api_crafter/parser/signals.py +0 -0
  22. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/core/__init__.py +0 -0
  23. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/core/dict.py +0 -0
  24. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/core/filetypes.py +0 -0
  25. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/core/threading/__init__.py +0 -0
  26. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/core/threading/key_queue.py +0 -0
  27. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/core/timestamp.py +0 -0
  28. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/nlp/__init__.py +0 -0
  29. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/nlp/custom_recognizers.py +0 -0
  30. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/nlp/language.py +0 -0
  31. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/nlp/ner.py +0 -0
  32. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/octostar/__init__.py +0 -0
  33. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/octostar/client.py +0 -0
  34. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/octostar/context.py +0 -0
  35. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/octostar/permissions.py +0 -0
  36. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/ontology/__init__.py +0 -0
  37. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/ontology/inheritance.py +0 -0
  38. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/ontology/relationships.py +0 -0
  39. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/ontology/validation.py +0 -0
  40. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/style/__init__.py +0 -0
  41. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/style/common.py +0 -0
  42. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/threading/__init__.py +0 -0
  43. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/threading/async_task_manager.py +0 -0
  44. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/threading/session_callback_manager.py +0 -0
  45. {streamlit_octostar_utils-0.5.0.dev16 → streamlit_octostar_utils-0.5.0.dev18}/streamlit_octostar_utils/threading/session_state_hot_swapper.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-octostar-utils
3
- Version: 0.5.0.dev16
3
+ Version: 0.5.0.dev18
4
4
  Summary:
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -5,7 +5,7 @@ include = '\.pyi?$'
5
5
 
6
6
  [tool.poetry]
7
7
  name = "streamlit-octostar-utils"
8
- version = "0.5.0-dev.16"
8
+ version = "0.5.0-dev.18"
9
9
  description = ""
10
10
  license = "MIT"
11
11
  authors = ["Octostar"]
@@ -891,6 +891,13 @@ class CeleryExecutor(object):
891
891
  self.get_thread_pool, _poll_task_state, self.app, task_id
892
892
  )
893
893
 
894
+ async def get_task_info(self, task_id):
895
+ def _get_info(celery_app, task_id):
896
+ return celery_app.AsyncResult(task_id).info
897
+ return await asyncio.get_running_loop().run_in_executor(
898
+ self.get_thread_pool, _get_info, self.app, task_id,
899
+ )
900
+
894
901
  async def get_task_result(self, task_id, remove=False):
895
902
  def _try_get_task_data(celery_app, task_id):
896
903
  async_result = celery_app.AsyncResult(task_id)
@@ -976,6 +983,11 @@ class FastAPICeleryTaskRoute(Route):
976
983
  path="/task/{task_id}",
977
984
  methods=["DELETE"],
978
985
  summary="Cancel a queued or running task.",
986
+ description=(
987
+ "Terminate a task by its ID. If the task is still queued "
988
+ "(AWAITING) it is revoked; if it is running (STARTED) the "
989
+ "worker process is interrupted."
990
+ ),
979
991
  status_code=200,
980
992
  responses=DefaultErrorRoute.error_responses,
981
993
  )
@@ -988,7 +1000,14 @@ class FastAPICeleryTaskRoute(Route):
988
1000
  self,
989
1001
  path="/task/{task_id}",
990
1002
  methods=["GET"],
991
- summary="Get task status (and result if available).",
1003
+ summary="Get task status, progress, and result.",
1004
+ description=(
1005
+ "Poll a running or completed task. Returns task_state "
1006
+ "(AWAITING, STARTED, SUCCESS, FAILURE, etc.), and when "
1007
+ "STARTED may include a 'progress' dict with task-specific "
1008
+ "metrics (e.g. nodes_done / nodes_total). When SUCCESS, "
1009
+ "the 'data' field contains the task result."
1010
+ ),
992
1011
  status_code=200,
993
1012
  responses=DefaultErrorRoute.error_responses,
994
1013
  )
@@ -1018,10 +1037,12 @@ class FastAPICeleryTaskRoute(Route):
1018
1037
  data = {"task_state": "UNKNOWN", "task_id": task_id}
1019
1038
  elif state in ["AWAITING", "STARTED"]:
1020
1039
  data = {"task_state": state, "task_id": task_id}
1040
+ if state == "STARTED":
1041
+ info = await self.celery_executor.get_task_info(task_id)
1042
+ if info and isinstance(info, dict):
1043
+ data["progress"] = info
1021
1044
  elif state == "SUCCESS":
1022
1045
  data = {"task_state": state, "task_id": task_id, "data": result}
1023
- elif state == "STARTED":
1024
- data = {"task_status": state, "task_id": task_id}
1025
1046
  else:
1026
1047
  raise ValueError(f"Unknown task state {state}!")
1027
1048
  return CommonModels.DataResponseModel(data=data)
@@ -1446,6 +1446,7 @@ class NifiEntity(object):
1446
1446
  source_entity_relationship=SOURCE_FRAGMENT_ENTITY_RELATIONSHIP,
1447
1447
  ):
1448
1448
  fields = {
1449
+ **{k: v for k, v in self.record if k.startswith("fragment") and v is not None},
1449
1450
  **fields,
1450
1451
  "os_parent_uid": self.record["os_entity_uid"],
1451
1452
  "source_entity_uid": source_entity_uid,
@@ -1525,7 +1526,12 @@ class NifiRoute(Route):
1525
1526
  self.endpoints[op.strip("/")] = nifi_task
1526
1527
 
1527
1528
  def define_routes(self):
1528
- @Route.route(self, path="/task-state/{task_id}")
1529
+ @Route.route(
1530
+ self,
1531
+ path="/task-state/{task_id}",
1532
+ summary="Get NiFi task state.",
1533
+ description="Return the current state of a task as a plain string (e.g. AWAITING, STARTED, SUCCESS).",
1534
+ )
1529
1535
  async def get_task_status(task_id: str) -> JSONResponse:
1530
1536
  try:
1531
1537
  task_status = await self.tasks_routes.get_task(task_id, pop=False)
@@ -1534,7 +1540,12 @@ class NifiRoute(Route):
1534
1540
  raise ValueError(f"Could not fetch task state for task id {task_id}!\n{e}")
1535
1541
  return JSONResponse(task_status)
1536
1542
 
1537
- @Route.route(self, path="/task-result/{task_id}")
1543
+ @Route.route(
1544
+ self,
1545
+ path="/task-result/{task_id}",
1546
+ summary="Get NiFi task result.",
1547
+ description="Return the result payload of a completed task and remove it from the backend.",
1548
+ )
1538
1549
  async def get_task_result(task_id: str) -> JSONResponse:
1539
1550
  try:
1540
1551
  return_data = await self.tasks_routes.get_task(task_id, pop=True)
@@ -1543,15 +1554,20 @@ class NifiRoute(Route):
1543
1554
  raise ValueError(f"Could not fetch task result for task id {task_id}\n{e}!")
1544
1555
  return JSONResponse(return_data)
1545
1556
 
1546
- @Route.route(self, path="/{op}", methods=["POST"])
1557
+ @Route.route(
1558
+ self,
1559
+ path="/{op}",
1560
+ methods=["POST"],
1561
+ summary="Submit a NiFi processing task.",
1562
+ description=(
1563
+ "Entry point for NiFi requests. The 'op' path parameter "
1564
+ "selects the processing route (e.g. extract-text, summarize). "
1565
+ "The body is a list of entities in NiFi format. Query "
1566
+ "parameters are read from the entity config at "
1567
+ "'request.config.<<processor_name>>.<<route_name>>.<<suffix_name>>'."
1568
+ ),
1569
+ )
1547
1570
  async def send_task(op: str, request: Request) -> str:
1548
- """
1549
- Any request coming from Nifi should enter from here.
1550
- Note that:
1551
- - The **op** parameter should be any of the other endpoints, including path parameters
1552
- - The body parameters should be a list of entities in Nifi format, which also replace form parameters
1553
- - The query parameters should be set in the 'request.config.<<processor_name>>.<<route_name>>.<<suffix_name>>' entry of the entities
1554
- """
1555
1571
  path_params = []
1556
1572
  op = op.split("/")
1557
1573
  if len(op) > 1: