streamlit-octostar-utils 0.4.2.dev15__tar.gz → 0.4.2.dev16__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.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/PKG-INFO +1 -1
  2. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/pyproject.toml +1 -1
  3. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/celery.py +6 -3
  4. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/fastapi.py +13 -8
  5. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/nifi.py +5 -2
  6. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/LICENSE +0 -0
  7. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/README.md +0 -0
  8. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/__init__.py +0 -0
  9. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/__init__.py +0 -0
  10. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/contents.py +0 -0
  11. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parallelism.py +0 -0
  12. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/__init__.py +0 -0
  13. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/combine_fields.py +0 -0
  14. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/entities_parser.py +0 -0
  15. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/generics.py +0 -0
  16. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/info.py +0 -0
  17. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/linkchart_functions.py +0 -0
  18. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/matches.py +0 -0
  19. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/parameters.py +0 -0
  20. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/rules.py +0 -0
  21. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/api_crafter/parser/signals.py +0 -0
  22. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/core/__init__.py +0 -0
  23. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/core/dict.py +0 -0
  24. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/core/filetypes.py +0 -0
  25. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/core/threading/__init__.py +0 -0
  26. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/core/threading/key_queue.py +0 -0
  27. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/core/timestamp.py +0 -0
  28. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/nlp/__init__.py +0 -0
  29. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/nlp/custom_recognizers.py +0 -0
  30. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/nlp/language.py +0 -0
  31. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/nlp/ner.py +0 -0
  32. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/octostar/__init__.py +0 -0
  33. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/octostar/client.py +0 -0
  34. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/octostar/context.py +0 -0
  35. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/octostar/permissions.py +0 -0
  36. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/ontology/__init__.py +0 -0
  37. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/ontology/inheritance.py +0 -0
  38. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/ontology/relationships.py +0 -0
  39. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/ontology/validation.py +0 -0
  40. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/style/__init__.py +0 -0
  41. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/style/common.py +0 -0
  42. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/threading/__init__.py +0 -0
  43. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/threading/async_task_manager.py +0 -0
  44. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/streamlit_octostar_utils/threading/session_callback_manager.py +0 -0
  45. {streamlit_octostar_utils-0.4.2.dev15 → streamlit_octostar_utils-0.4.2.dev16}/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.4.2.dev15
3
+ Version: 0.4.2.dev16
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.4.2-dev.15"
8
+ version = "0.4.2-dev.16"
9
9
  description = ""
10
10
  license = "MIT"
11
11
  authors = ["Octostar"]
@@ -800,7 +800,7 @@ class FastAPICeleryTaskRoute(Route):
800
800
  or (state not in ["SUCCESS", "FAILURE", "RETRY", "REVOKED"])
801
801
  )
802
802
  if state in ["FAILURE", "RETRY", "REVOKED"]:
803
- error_response = DefaultErrorRoute.format_error(exc, debug=True).body.decode("utf-8")
803
+ error_response = DefaultErrorRoute.format_error(exc, internal=True).body.decode("utf-8")
804
804
  data = {
805
805
  "task_state": state,
806
806
  "task_id": task_id,
@@ -853,7 +853,8 @@ class CeleryErrorRoute(DefaultErrorRoute):
853
853
 
854
854
  def add_default_exceptions_handler(
855
855
  fs_app,
856
- debug=False,
856
+ internal=False,
857
+ internal_prefixes=None,
857
858
  excs_to_status_codes=None,
858
859
  silenced_excs=None,
859
860
  ):
@@ -869,4 +870,6 @@ class CeleryErrorRoute(DefaultErrorRoute):
869
870
  **(silenced_excs or {}),
870
871
  }
871
872
 
872
- super(CeleryErrorRoute, CeleryErrorRoute).add_default_exceptions_handler(fs_app, debug, status_codes, silenced)
873
+ super(CeleryErrorRoute, CeleryErrorRoute).add_default_exceptions_handler(
874
+ fs_app, internal, internal_prefixes, status_codes, silenced,
875
+ )
@@ -21,7 +21,6 @@ from octostar.client import make_client
21
21
 
22
22
  MAX_ERROR_MESSAGE_BYTES = 256
23
23
  MAX_ERROR_TRACEBACK_BYTES = 10240
24
- DEFAULT_PROCESSOR_SUFFIX = "main"
25
24
 
26
25
 
27
26
  class CommonParsers(object):
@@ -314,7 +313,7 @@ class DefaultErrorRoute:
314
313
  },
315
314
  }
316
315
 
317
- def format_error(exc, body=b"", debug=False, excs_to_status_codes=DEFAULT_STATUS_CODE_MAPPINGS):
316
+ def format_error(exc, body=b"", internal=False, excs_to_status_codes=DEFAULT_STATUS_CODE_MAPPINGS):
318
317
  """Generic Error Handler"""
319
318
  status_code = 500
320
319
  for exc_type, handler in excs_to_status_codes.items():
@@ -325,7 +324,7 @@ class DefaultErrorRoute:
325
324
  message = exc.message
326
325
  except:
327
326
  message = str(exc)
328
- if debug:
327
+ if internal:
329
328
  message += "\n" + str(body)
330
329
  if len(message) > MAX_ERROR_MESSAGE_BYTES:
331
330
  message = message[-MAX_ERROR_MESSAGE_BYTES:]
@@ -336,16 +335,18 @@ class DefaultErrorRoute:
336
335
  except:
337
336
  tcbk = None
338
337
  response_content = {"message": message, "status": "error"}
339
- if debug:
338
+ if internal:
339
+ response_content["exception_class"] = f"python.{type(exc).__module__}.{type(exc).__qualname__}"
340
340
  response_content["traceback"] = tcbk
341
341
  return JSONResponse(status_code=status_code, content=response_content)
342
342
 
343
- async def handle_error(body: bytes, exc: Exception, debug: bool, excs_to_status_codes: dict):
344
- return DefaultErrorRoute.format_error(exc, body, debug, excs_to_status_codes)
343
+ async def handle_error(body: bytes, exc: Exception, internal: bool, excs_to_status_codes: dict):
344
+ return DefaultErrorRoute.format_error(exc, body, internal, excs_to_status_codes)
345
345
 
346
346
  def add_default_exceptions_handler(
347
347
  fs_app,
348
- debug=False,
348
+ internal=False,
349
+ internal_prefixes=None,
349
350
  excs_to_status_codes=None,
350
351
  silenced_excs=None,
351
352
  ):
@@ -353,9 +354,13 @@ class DefaultErrorRoute:
353
354
  excs_to_status_codes = DefaultErrorRoute.DEFAULT_STATUS_CODE_MAPPINGS
354
355
  if silenced_excs is None:
355
356
  silenced_excs = DefaultErrorRoute.DEFAULT_SILENCED_EXCEPTIONS
357
+ internal_prefixes = tuple(internal_prefixes or [])
356
358
 
357
359
  async def _async_handle_error(request: Request, exc: Exception):
358
- return await DefaultErrorRoute.handle_error(b"", exc, debug, excs_to_status_codes)
360
+ is_internal = internal or (
361
+ internal_prefixes and request.url.path.startswith(internal_prefixes)
362
+ )
363
+ return await DefaultErrorRoute.handle_error(b"", exc, is_internal, excs_to_status_codes)
359
364
 
360
365
  # Added all three since FastAPI seems to intercept some exceptions before Exception
361
366
  fs_app.add_exception_handler(RequestValidationError, _async_handle_error)
@@ -385,9 +385,12 @@ class NifiContextManager(object):
385
385
  return [entity for entity in self.jsonify(self.out_entities)["content"]]
386
386
 
387
387
  def raise_exception(self, entity, exc):
388
- error_response = DefaultErrorRoute.format_error(exc)
388
+ error_response = DefaultErrorRoute.format_error(exc, internal=True)
389
+ error_body = json.loads(error_response.body)
389
390
  entity.request["exception"]["code"] = error_response.status_code
390
- entity.request["exception"]["body"] = json.loads(error_response.body)["message"]
391
+ entity.request["exception"]["body"] = error_body["message"]
392
+ entity.request["exception"]["exception_class"] = error_body.get("exception_class")
393
+ entity.request["exception"]["traceback"] = error_body.get("traceback")
391
394
  travel_dict(entity.request["nifi_attributes"], ["invokehttp", "response", "body"], "w")(
392
395
  entity.request["exception"]["body"]
393
396
  )