streamlit-octostar-utils 0.1.7a7__tar.gz → 0.1.7a9__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 (43) hide show
  1. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/PKG-INFO +1 -1
  2. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/pyproject.toml +1 -1
  3. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/celery.py +24 -16
  4. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/fastapi.py +30 -19
  5. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/LICENSE +0 -0
  6. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/README.md +0 -0
  7. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/__init__.py +0 -0
  8. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/__init__.py +0 -0
  9. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/nifi.py +0 -0
  10. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/__init__.py +0 -0
  11. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/combine_fields.py +0 -0
  12. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/entities_parser.py +0 -0
  13. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/generics.py +0 -0
  14. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/info.py +0 -0
  15. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/linkchart_functions.py +0 -0
  16. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/matches.py +0 -0
  17. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/parameters.py +0 -0
  18. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/rules.py +0 -0
  19. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/api_crafter/parser/signals.py +0 -0
  20. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/core/__init__.py +0 -0
  21. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/core/dict.py +0 -0
  22. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/core/filetypes.py +0 -0
  23. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/core/threading/__init__.py +0 -0
  24. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/core/threading/key_queue.py +0 -0
  25. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/core/timestamp.py +0 -0
  26. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/hello.py +0 -0
  27. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/nlp/__init__.py +0 -0
  28. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/nlp/language.py +0 -0
  29. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/nlp/ner.py +0 -0
  30. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/octostar/__init__.py +0 -0
  31. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/octostar/client.py +0 -0
  32. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/octostar/context.py +0 -0
  33. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/octostar/permissions.py +0 -0
  34. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/ontology/__init__.py +0 -0
  35. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/ontology/expand_entities.py +0 -0
  36. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/ontology/inheritance.py +0 -0
  37. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/ontology/validation.py +0 -0
  38. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/style/__init__.py +0 -0
  39. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/style/common.py +0 -0
  40. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/threading/__init__.py +0 -0
  41. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/threading/async_task_manager.py +0 -0
  42. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/threading/session_callback_manager.py +0 -0
  43. {streamlit_octostar_utils-0.1.7a7 → streamlit_octostar_utils-0.1.7a9}/streamlit_octostar_utils/threading/session_state_hot_swapper.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: streamlit-octostar-utils
3
- Version: 0.1.7a7
3
+ Version: 0.1.7a9
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Octostar
@@ -5,7 +5,7 @@ include = '\.pyi?$'
5
5
 
6
6
  [tool.poetry]
7
7
  name = "streamlit-octostar-utils"
8
- version = "0.1.7a7"
8
+ version = "0.1.7a9"
9
9
  description = ""
10
10
  license = "MIT"
11
11
  authors = ["Octostar"]
@@ -492,9 +492,11 @@ class CeleryExecutor(object):
492
492
  kwargs,
493
493
  task_id,
494
494
  )
495
+
495
496
  await asyncio.get_running_loop().run_in_executor(
496
497
  self.set_thread_pool, _send_task, task_fn, task_id, options
497
498
  )
499
+
498
500
  except asyncio.CancelledError:
499
501
  logger.info(f"Cancelling task {task_id} due to disconnect!")
500
502
  await self.terminate_task(task_id)
@@ -683,20 +685,26 @@ class CeleryErrorRoute(DefaultErrorRoute):
683
685
  DEFAULT_SILENCED_EXCEPTIONS = {CeleryExecutor.QueueFullException: lambda exc: True}
684
686
 
685
687
  def add_default_exceptions_handler(
686
- fs_app,
687
- debug=False,
688
- excs_to_status_codes=None,
689
- silenced_excs=None,
690
- log_filter=None,
688
+ fs_app,
689
+ debug=False,
690
+ excs_to_status_codes=None,
691
+ silenced_excs=None,
691
692
  ):
692
- if excs_to_status_codes is None:
693
- excs_to_status_codes = {
694
- **DefaultErrorRoute.DEFAULT_STATUS_CODE_MAPPINGS,
695
- **CeleryErrorRoute.DEFAULT_STATUS_CODE_MAPPINGS,
696
- }
697
- if silenced_excs is None:
698
- silenced_excs = {
699
- **DefaultErrorRoute.DEFAULT_SILENCED_EXCEPTIONS,
700
- **CeleryErrorRoute.DEFAULT_SILENCED_EXCEPTIONS,
701
- }
702
- DefaultErrorRoute.add_default_exceptions_handler(fs_app, debug, excs_to_status_codes)
693
+ extra_status = {CeleryExecutor.QueueFullException: lambda exc: 429}
694
+ extra_silence = {CeleryExecutor.QueueFullException: lambda exc: True}
695
+
696
+ status_codes = {
697
+ **DefaultErrorRoute.DEFAULT_STATUS_CODE_MAPPINGS,
698
+ **(excs_to_status_codes or {}),
699
+ **extra_status,
700
+ }
701
+
702
+ silenced = {
703
+ **DefaultErrorRoute.DEFAULT_SILENCED_EXCEPTIONS,
704
+ **(silenced_excs or {}),
705
+ **extra_silence,
706
+ }
707
+
708
+ super(CeleryErrorRoute, CeleryErrorRoute).add_default_exceptions_handler(
709
+ fs_app, debug, status_codes, silenced
710
+ )
@@ -241,20 +241,30 @@ class CommonModels(object):
241
241
  headers["Content-Disposition"] += f' filename="{filename}"'
242
242
  return StreamingResponse(zip_buffer, media_type="application/zip", headers=headers)
243
243
 
244
+
244
245
  class ErrorLogFilter(logging.Filter):
245
- def __init__(self, silenced_excs: dict):
246
+ def __init__(self, silenced_excs: dict[type, callable]):
246
247
  super().__init__()
247
248
  self.silenced_excs = silenced_excs
248
-
249
- def filter(self, record):
250
- exc_info = getattr(record, 'exc_info', None)
251
- if exc_info:
252
- if record.exc_info:
253
- exc_type, exc_value, exc_tb = record.exc_info
254
- if exc_value:
255
- for etype, cond in self.silenced_excs.items():
256
- if isinstance(exc_value, etype) and cond(exc_value):
257
- return False
249
+
250
+ def _silenced(self, exc_value) -> bool:
251
+ for etype, cond in self.silenced_excs.items():
252
+ if isinstance(exc_value, etype) and cond(exc_value):
253
+ return True
254
+ return False
255
+
256
+ def filter(self, record: logging.LogRecord) -> bool:
257
+ if record.exc_info:
258
+ exc_type, exc_value, _ = record.exc_info
259
+ if self._silenced(exc_value):
260
+ return False
261
+
262
+ msg = record.getMessage()
263
+ for etype in self.silenced_excs:
264
+ if etype.__name__ in msg:
265
+ if self.silenced_excs[etype](None):
266
+ return False
267
+
258
268
  return True
259
269
 
260
270
 
@@ -334,10 +344,10 @@ class DefaultErrorRoute:
334
344
  return DefaultErrorRoute.format_error(exc, body, debug, excs_to_status_codes)
335
345
 
336
346
  def add_default_exceptions_handler(
337
- fs_app,
338
- debug=False,
339
- excs_to_status_codes=None,
340
- silenced_excs=None,
347
+ fs_app,
348
+ debug=False,
349
+ excs_to_status_codes=None,
350
+ silenced_excs=None,
341
351
  ):
342
352
  if excs_to_status_codes is None:
343
353
  excs_to_status_codes = DefaultErrorRoute.DEFAULT_STATUS_CODE_MAPPINGS
@@ -351,11 +361,12 @@ class DefaultErrorRoute:
351
361
  fs_app.add_exception_handler(RequestValidationError, _async_handle_error)
352
362
  fs_app.add_exception_handler(StarletteHTTPException, _async_handle_error)
353
363
  fs_app.add_exception_handler(Exception, _async_handle_error)
354
-
364
+
355
365
  log_filter = ErrorLogFilter(silenced_excs)
356
- logging.getLogger("uvicorn.error").addFilter(log_filter)
357
- logging.getLogger("uvicorn").addFilter(log_filter)
358
- logging.getLogger("fastapi").addFilter(log_filter)
366
+ for name in ("uvicorn.error", "uvicorn.access", "fastapi", "uvicorn"):
367
+ logging.getLogger(name).addFilter(log_filter)
368
+
369
+ logging.getLogger().addFilter(log_filter)
359
370
 
360
371
  class RequestCancelledMiddleware:
361
372
  def __init__(self, app):