perspective-python 5.6.0__tar.gz → 5.6.1__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 (122) hide show
  1. {perspective_python-5.6.0 → perspective_python-5.6.1}/Cargo.toml +3 -3
  2. {perspective_python-5.6.0 → perspective_python-5.6.1}/LICENSE_THIRDPARTY_cargo.yml +2 -2
  3. {perspective_python-5.6.0 → perspective_python-5.6.1}/PKG-INFO +2 -2
  4. {perspective_python-5.6.0 → perspective_python-5.6.1}/package.json +1 -1
  5. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/__init__.py +1 -1
  6. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/handlers/starlette.py +3 -4
  7. perspective_python-5.6.1/perspective/tests/virtual_servers/test_data_slice_lifetime.py +82 -0
  8. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/virtual_servers/test_duckdb.py +86 -21
  9. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/virtual_servers/test_polars.py +2 -1
  10. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/virtual_servers/test_postgres.py +4 -3
  11. perspective_python-5.6.1/perspective/tests/virtual_servers/test_session_close.py +139 -0
  12. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/virtual_servers/__init__.py +2 -1
  13. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/virtual_servers/clickhouse.py +5 -0
  14. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/virtual_servers/duckdb.py +14 -14
  15. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/virtual_servers/polars.py +5 -0
  16. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/virtual_servers/postgres.py +13 -1
  17. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/widget/static/perspective-anywidget.css +1 -1
  18. perspective_python-5.6.1/perspective/widget/static/perspective-anywidget.js +31 -0
  19. {perspective_python-5.6.0/perspective_python-5.6.0.data → perspective_python-5.6.1/perspective_python-5.6.1.data}/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/package.json +2 -2
  20. perspective_python-5.6.1/perspective_python-5.6.1.data/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/static/253.b4919408c843a0411cbe.js +1 -0
  21. perspective_python-5.6.0/perspective_python-5.6.0.data/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/static/523.504cd9ad7ebf4f99180b.js → perspective_python-5.6.1/perspective_python-5.6.1.data/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/static/523.b91ca71cb7f8d97d5967.js +1 -1
  22. perspective_python-5.6.0/perspective_python-5.6.0.data/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/static/remoteEntry.c86494bec5ee8ddb16b9.js → perspective_python-5.6.1/perspective_python-5.6.1.data/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/static/remoteEntry.0db86e18bb5781017a82.js +1 -1
  23. {perspective_python-5.6.0 → perspective_python-5.6.1}/pyproject.toml +2 -2
  24. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/server/virtual_server_sync.rs +80 -69
  25. perspective_python-5.6.0/perspective/widget/static/perspective-anywidget.js +0 -31
  26. perspective_python-5.6.0/perspective_python-5.6.0.data/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/static/253.c4440a69e8a14a73cf64.js +0 -1
  27. {perspective_python-5.6.0 → perspective_python-5.6.1}/LICENSE.md +0 -0
  28. {perspective_python-5.6.0 → perspective_python-5.6.1}/README.md +0 -0
  29. {perspective_python-5.6.0 → perspective_python-5.6.1}/build.rs +0 -0
  30. {perspective_python-5.6.0 → perspective_python-5.6.1}/docs/index.html +0 -0
  31. {perspective_python-5.6.0 → perspective_python-5.6.1}/docs/lib.md +0 -0
  32. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/handlers/__init__.py +0 -0
  33. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/handlers/aiohttp.py +0 -0
  34. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/handlers/tornado.py +0 -0
  35. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/templates/exported_widget.html.template +0 -0
  36. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/__init__.py +0 -0
  37. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/async/test_async_client.py +0 -0
  38. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/async/test_websocket_client.py +0 -0
  39. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/column_paths.py +0 -0
  40. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/conftest.py +0 -0
  41. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/core/__init__.py +0 -0
  42. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/core/test_async.py +0 -0
  43. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/multi_threaded/__init__.py +0 -0
  44. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/multi_threaded/test_derived_threaded.py +0 -0
  45. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/multi_threaded/test_multi_threaded.py +0 -0
  46. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/server/__init__.py +0 -0
  47. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/server/test_server.py +0 -0
  48. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/server/test_session.py +0 -0
  49. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/__init__.py +0 -0
  50. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/arrow/date32.arrow +0 -0
  51. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/arrow/date64.arrow +0 -0
  52. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/arrow/dict.arrow +0 -0
  53. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/arrow/dict_update.arrow +0 -0
  54. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/arrow/int_float_str.arrow +0 -0
  55. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/arrow/int_float_str_file.arrow +0 -0
  56. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/arrow/int_float_str_update.arrow +0 -0
  57. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/object_sequence.py +0 -0
  58. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_column_paths.py +0 -0
  59. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_delete.py +0 -0
  60. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_derived.py +0 -0
  61. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_exception.py +0 -0
  62. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_join.py +0 -0
  63. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_leaks.py +0 -0
  64. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_on_remove.py +0 -0
  65. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_ports.py +0 -0
  66. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_remove.py +0 -0
  67. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table.py +0 -0
  68. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_arrow.py +0 -0
  69. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_arrow_nested.py +0 -0
  70. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_datetime.py +0 -0
  71. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_infer.py +0 -0
  72. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_limit.py +0 -0
  73. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_numpy.py +0 -0
  74. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_page_to_disk.py +0 -0
  75. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_pandas.py +0 -0
  76. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_polars.py +0 -0
  77. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_table_view_table.py +0 -0
  78. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_to_arrow.py +0 -0
  79. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_to_arrow_lz4.py +0 -0
  80. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_to_arrow_zstd.py +0 -0
  81. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_to_format.py +0 -0
  82. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_to_polars.py +0 -0
  83. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_update.py +0 -0
  84. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_update_arrow.py +0 -0
  85. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_update_pandas.py +0 -0
  86. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_view.py +0 -0
  87. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/table/test_view_expression.py +0 -0
  88. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/test_dependencies.py +0 -0
  89. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/viewer/__init__.py +0 -0
  90. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/viewer/test_viewer.py +0 -0
  91. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/virtual_servers/__init__.py +0 -0
  92. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/virtual_servers/test_coerce_types.py +0 -0
  93. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/widget/__init__.py +0 -0
  94. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/widget/test_anywidget_smoke.py +0 -0
  95. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/widget/test_widget.py +0 -0
  96. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/widget/test_widget_html_export.py +0 -0
  97. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/tests/widget/test_widget_pandas.py +0 -0
  98. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/widget/__init__.py +0 -0
  99. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/widget/viewer/__init__.py +0 -0
  100. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/widget/viewer/viewer.py +0 -0
  101. {perspective_python-5.6.0 → perspective_python-5.6.1}/perspective/widget/viewer/viewer_traitlets.py +0 -0
  102. {perspective_python-5.6.0/perspective_python-5.6.0.data → perspective_python-5.6.1/perspective_python-5.6.1.data}/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/install.json +0 -0
  103. {perspective_python-5.6.0/perspective_python-5.6.0.data → perspective_python-5.6.1/perspective_python-5.6.1.data}/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/static/style.js +0 -0
  104. {perspective_python-5.6.0/perspective_python-5.6.0.data → perspective_python-5.6.1/perspective_python-5.6.1.data}/data/share/jupyter/labextensions/@perspective-dev/jupyterlab/static/third-party-licenses.json +0 -0
  105. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/client/client_async.rs +0 -0
  106. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/client/client_sync.rs +0 -0
  107. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/client/mod.rs +0 -0
  108. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/client/pandas.rs +0 -0
  109. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/client/polars.rs +0 -0
  110. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/client/proxy_session.rs +0 -0
  111. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/client/pyarrow.rs +0 -0
  112. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/client/table_data.rs +0 -0
  113. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/client/update_data.rs +0 -0
  114. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/lib.rs +0 -0
  115. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/py_async.rs +0 -0
  116. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/py_err.rs +0 -0
  117. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/server/generic_sql_model.rs +0 -0
  118. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/server/mod.rs +0 -0
  119. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/server/server_async.rs +0 -0
  120. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/server/server_sync.rs +0 -0
  121. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/server/session_async.rs +0 -0
  122. {perspective_python-5.6.0 → perspective_python-5.6.1}/src/server/session_sync.rs +0 -0
@@ -12,7 +12,7 @@
12
12
 
13
13
  [package]
14
14
  name = "perspective-python"
15
- version = "5.6.0"
15
+ version = "5.6.1"
16
16
  edition = "2024"
17
17
  description = "Interactive data grid, pivot table and charts for large, real-time and streaming datasets, with a Jupyter widget and WebSocket server."
18
18
  repository = "https://github.com/perspective-dev/perspective"
@@ -60,8 +60,8 @@ pyo3-build-config = "0.29.0"
60
60
  python-config-rs = "0.1.2"
61
61
 
62
62
  [dependencies]
63
- perspective-client = { version = "5.6.0" }
64
- perspective-server = { version = "5.6.0" }
63
+ perspective-client = { version = "5.6.1" }
64
+ perspective-server = { version = "5.6.1" }
65
65
  bytes = "1.10.1"
66
66
  chrono = "0.4"
67
67
  macro_rules_attribute = "0.2.2"
@@ -4980,14 +4980,14 @@ third_party_libraries:
4980
4980
 
4981
4981
  END OF TERMS AND CONDITIONS
4982
4982
  - package_name: perspective-client
4983
- package_version: 5.6.0
4983
+ package_version: 5.6.1
4984
4984
  repository: https://github.com/perspective-dev/perspective
4985
4985
  license: Apache-2.0
4986
4986
  licenses:
4987
4987
  - license: Apache-2.0
4988
4988
  text: "# Apache License\n\n_Version 2.0, January 2004_ \n_&lt;<http://www.apache.org/licenses/>&gt;_\n\n### Terms and Conditions for use, reproduction, and distribution\n\n#### 1. Definitions\n\n“License” shall mean the terms and conditions for use, reproduction, and\ndistribution as defined by Sections 1 through 9 of this document.\n\n“Licensor” shall mean the copyright owner or entity authorized by the copyright\nowner that is granting the License.\n\n“Legal Entity” shall mean the union of the acting entity and all other entities\nthat control, are controlled by, or are under common control with that entity.\nFor the purposes of this definition, “control” means **(i)** the power, direct or\nindirect, to cause the direction or management of such entity, whether by\ncontract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the\noutstanding shares, or **(iii)** beneficial ownership of such entity.\n\n“You” (or “Your”) shall mean an individual or Legal Entity exercising\npermissions granted by this License.\n\n“Source” form shall mean the preferred form for making modifications, including\nbut not limited to software source code, documentation source, and configuration\nfiles.\n\n“Object” form shall mean any form resulting from mechanical transformation or\ntranslation of a Source form, including but not limited to compiled object code,\ngenerated documentation, and conversions to other media types.\n\n“Work” shall mean the work of authorship, whether in Source or Object form, made\navailable under the License, as indicated by a copyright notice that is included\nin or attached to the work (an example is provided in the Appendix below).\n\n“Derivative Works” shall mean any work, whether in Source or Object form, that\nis based on (or derived from) the Work and for which the editorial revisions,\nannotations, elaborations, or other modifications represent, as a whole, an\noriginal work of authorship. For the purposes of this License, Derivative Works\nshall not include works that remain separable from, or merely link (or bind by\nname) to the interfaces of, the Work and Derivative Works thereof.\n\n“Contribution” shall mean any work of authorship, including the original version\nof the Work and any modifications or additions to that Work or Derivative Works\nthereof, that is intentionally submitted to Licensor for inclusion in the Work\nby the copyright owner or by an individual or Legal Entity authorized to submit\non behalf of the copyright owner. For the purposes of this definition,\n“submitted” means any form of electronic, verbal, or written communication sent\nto the Licensor or its representatives, including but not limited to\ncommunication on electronic mailing lists, source code control systems, and\nissue tracking systems that are managed by, or on behalf of, the Licensor for\nthe purpose of discussing and improving the Work, but excluding communication\nthat is conspicuously marked or otherwise designated in writing by the copyright\nowner as “Not a Contribution.”\n\n“Contributor” shall mean Licensor and any individual or Legal Entity on behalf\nof whom a Contribution has been received by Licensor and subsequently\nincorporated within the Work.\n\n#### 2. Grant of Copyright License\n\nSubject to the terms and conditions of this License, each Contributor hereby\ngrants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,\nirrevocable copyright license to reproduce, prepare Derivative Works of,\npublicly display, publicly perform, sublicense, and distribute the Work and such\nDerivative Works in Source or Object form.\n\n#### 3. Grant of Patent License\n\nSubject to the terms and conditions of this License, each Contributor hereby\ngrants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,\nirrevocable (except as stated in this section) patent license to make, have\nmade, use, offer to sell, sell, import, and otherwise transfer the Work, where\nsuch license applies only to those patent claims licensable by such Contributor\nthat are necessarily infringed by their Contribution(s) alone or by combination\nof their Contribution(s) with the Work to which such Contribution(s) was\nsubmitted. If You institute patent litigation against any entity (including a\ncross-claim or counterclaim in a lawsuit) alleging that the Work or a\nContribution incorporated within the Work constitutes direct or contributory\npatent infringement, then any patent licenses granted to You under this License\nfor that Work shall terminate as of the date such litigation is filed.\n\n#### 4. Redistribution\n\nYou may reproduce and distribute copies of the Work or Derivative Works thereof\nin any medium, with or without modifications, and in Source or Object form,\nprovided that You meet the following conditions:\n\n- **(a)** You must give any other recipients of the Work or Derivative Works a copy of\n this License; and\n- **(b)** You must cause any modified files to carry prominent notices stating that You\n changed the files; and\n- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,\n all copyright, patent, trademark, and attribution notices from the Source form\n of the Work, excluding those notices that do not pertain to any part of the\n Derivative Works; and\n- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any\n Derivative Works that You distribute must include a readable copy of the\n attribution notices contained within such NOTICE file, excluding those notices\n that do not pertain to any part of the Derivative Works, in at least one of the\n following places: within a NOTICE text file distributed as part of the\n Derivative Works; within the Source form or documentation, if provided along\n with the Derivative Works; or, within a display generated by the Derivative\n Works, if and wherever such third-party notices normally appear. The contents of\n the NOTICE file are for informational purposes only and do not modify the\n License. You may add Your own attribution notices within Derivative Works that\n You distribute, alongside or as an addendum to the NOTICE text from the Work,\n provided that such additional attribution notices cannot be construed as\n modifying the License.\n\nYou may add Your own copyright statement to Your modifications and may provide\nadditional or different license terms and conditions for use, reproduction, or\ndistribution of Your modifications, or for any such Derivative Works as a whole,\nprovided Your use, reproduction, and distribution of the Work otherwise complies\nwith the conditions stated in this License.\n\n#### 5. Submission of Contributions\n\nUnless You explicitly state otherwise, any Contribution intentionally submitted\nfor inclusion in the Work by You to the Licensor shall be under the terms and\nconditions of this License, without any additional terms or conditions.\nNotwithstanding the above, nothing herein shall supersede or modify the terms of\nany separate license agreement you may have executed with Licensor regarding\nsuch Contributions.\n\n#### 6. Trademarks\n\nThis License does not grant permission to use the trade names, trademarks,\nservice marks, or product names of the Licensor, except as required for\nreasonable and customary use in describing the origin of the Work and\nreproducing the content of the NOTICE file.\n\n#### 7. Disclaimer of Warranty\n\nUnless required by applicable law or agreed to in writing, Licensor provides the\nWork (and each Contributor provides its Contributions) on an “AS IS” BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,\nincluding, without limitation, any warranties or conditions of TITLE,\nNON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are\nsolely responsible for determining the appropriateness of using or\nredistributing the Work and assume any risks associated with Your exercise of\npermissions under this License.\n\n#### 8. Limitation of Liability\n\nIn no event and under no legal theory, whether in tort (including negligence),\ncontract, or otherwise, unless required by applicable law (such as deliberate\nand grossly negligent acts) or agreed to in writing, shall any Contributor be\nliable to You for damages, including any direct, indirect, special, incidental,\nor consequential damages of any character arising as a result of this License or\nout of the use or inability to use the Work (including but not limited to\ndamages for loss of goodwill, work stoppage, computer failure or malfunction, or\nany and all other commercial damages or losses), even if such Contributor has\nbeen advised of the possibility of such damages.\n\n#### 9. Accepting Warranty or Additional Liability\n\nWhile redistributing the Work or Derivative Works thereof, You may choose to\noffer, and charge a fee for, acceptance of support, warranty, indemnity, or\nother liability obligations and/or rights consistent with this License. However,\nin accepting such obligations, You may act only on Your own behalf and on Your\nsole responsibility, not on behalf of any other Contributor, and only if You\nagree to indemnify, defend, and hold each Contributor harmless for any liability\nincurred by, or claims asserted against, such Contributor by reason of your\naccepting any such warranty or additional liability.\n\n_END OF TERMS AND CONDITIONS_\n\n### APPENDIX: How to apply the Apache License to your work\n\nTo apply the Apache License to your work, attach the following boilerplate\nnotice, with the fields enclosed by brackets `[]` replaced with your own\nidentifying information. (Don't include the brackets!) The text should be\nenclosed in the appropriate comment syntax for the file format. We also\nrecommend that a file or class name and description of purpose be included on\nthe same “printed page” as the copyright notice for easier identification within\nthird-party archives.\n\n Copyright 2019 The Perspective Authors\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n"
4989
4989
  - package_name: perspective-server
4990
- package_version: 5.6.0
4990
+ package_version: 5.6.1
4991
4991
  repository: https://github.com/perspective-dev/perspective
4992
4992
  license: Apache-2.0
4993
4993
  licenses:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: perspective-python
3
- Version: 5.6.0
3
+ Version: 5.6.1
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: Intended Audience :: Financial and Insurance Industry
@@ -25,7 +25,7 @@ Classifier: Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt
25
25
  Requires-Dist: anywidget>=0.9 ; extra == 'jupyter'
26
26
  Requires-Dist: tornado>=5,<7 ; extra == 'tornado'
27
27
  Requires-Dist: aiohttp>=2,<4 ; extra == 'aiohttp'
28
- Requires-Dist: starlette<1 ; extra == 'starlette'
28
+ Requires-Dist: starlette<2 ; extra == 'starlette'
29
29
  Provides-Extra: jupyter
30
30
  Provides-Extra: tornado
31
31
  Provides-Extra: aiohttp
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perspective-dev/python",
3
- "version": "5.6.0",
3
+ "version": "5.6.1",
4
4
  "description": "",
5
5
  "private": true,
6
6
  "repository": {
@@ -10,7 +10,7 @@
10
10
  # ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
11
  # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
12
 
13
- __version__ = "5.6.0"
13
+ __version__ = "5.6.1"
14
14
  __all__ = [
15
15
  "_jupyter_labextension_paths",
16
16
  "Server",
@@ -53,11 +53,10 @@ class PerspectiveStarletteHandler(object):
53
53
  try:
54
54
  await self._websocket.accept()
55
55
  while True:
56
- message = await self._websocket.receive()
57
- self._websocket._raise_on_disconnect(message)
56
+ message = await self._websocket.receive_bytes()
58
57
  if self._executor is not None:
59
- self._executor.submit(self.session.handle_request, message["bytes"])
58
+ self._executor.submit(self.session.handle_request, message)
60
59
  else:
61
- self.session.handle_request(message["bytes"])
60
+ self.session.handle_request(message)
62
61
  finally:
63
62
  self.session.close()
@@ -0,0 +1,82 @@
1
+ # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2
+ # ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3
+ # ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4
+ # ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5
+ # ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6
+ # ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7
+ # ┃ Copyright (c) 2017, the Perspective Authors. ┃
8
+ # ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9
+ # ┃ This file is part of the Perspective library, distributed under the terms ┃
10
+ # ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
+ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
+
13
+ import pytest
14
+
15
+ import perspective
16
+ from perspective import Client
17
+ from perspective.virtual_servers import VirtualServerHandler
18
+
19
+
20
+ class IntegerHandler(VirtualServerHandler):
21
+ def __init__(self):
22
+ self.kept = []
23
+ self.errors = []
24
+
25
+ def get_hosted_tables(self):
26
+ return ["fixture"]
27
+
28
+ def table_schema(self, table_name):
29
+ return {"x": "integer"}
30
+
31
+ def table_size(self, table_name):
32
+ return 3
33
+
34
+ def table_make_view(self, table_name, view_name, config):
35
+ pass
36
+
37
+ def view_delete(self, view_name):
38
+ pass
39
+
40
+ def view_get_data(self, view_name, config, schema, viewport, data):
41
+ for i in range(3):
42
+ data.set_col("integer", "x", i, i)
43
+
44
+
45
+ class KeepingHandler(IntegerHandler):
46
+ def view_get_data(self, view_name, config, schema, viewport, data):
47
+ super().view_get_data(view_name, config, schema, viewport, data)
48
+ self.kept.append(data)
49
+
50
+
51
+ def make_client(handler):
52
+ server = perspective.VirtualServer(handler)
53
+ client = Client(
54
+ lambda msg: client.handle_response(server.handle_request(msg))
55
+ )
56
+ return client
57
+
58
+
59
+ def fetch(handler):
60
+ view = make_client(handler).open_table("fixture").view()
61
+ result = view.to_columns()
62
+ view.delete()
63
+ return result
64
+
65
+
66
+ class TestDataSliceLifetime:
67
+ def test_kept_slice_does_not_abort(self):
68
+ handler = KeepingHandler()
69
+ assert fetch(handler)["x"] == [0, 1, 2]
70
+ assert len(handler.kept) == 1
71
+
72
+ def test_kept_slice_raises_after_return(self):
73
+ handler = KeepingHandler()
74
+ fetch(handler)
75
+ with pytest.raises(ValueError, match="view_get_data"):
76
+ handler.kept[0].set_col("integer", "x", 0, 1)
77
+
78
+ def test_kept_slice_raises_on_from_arrow_ipc_after_return(self):
79
+ handler = KeepingHandler()
80
+ fetch(handler)
81
+ with pytest.raises(ValueError, match="view_get_data"):
82
+ handler.kept[0].from_arrow_ipc(b"")
@@ -87,6 +87,21 @@ def _load_coerce_types(db):
87
87
  """)
88
88
 
89
89
 
90
+
91
+ def approx_floats(value):
92
+ """`value` with every `float` in it compared approximately."""
93
+ if isinstance(value, float):
94
+ return pytest.approx(value)
95
+
96
+ if isinstance(value, list):
97
+ return [approx_floats(x) for x in value]
98
+
99
+ if isinstance(value, dict):
100
+ return {k: approx_floats(v) for k, v in value.items()}
101
+
102
+ return value
103
+
104
+
90
105
  @pytest.fixture(scope="module")
91
106
  def client():
92
107
  db = duckdb.connect()
@@ -106,7 +121,8 @@ def client():
106
121
 
107
122
  session = server.new_session(handle_response)
108
123
  c = Client(handle_request)
109
- return c
124
+ yield c
125
+ session.close()
110
126
 
111
127
 
112
128
  class TestDuckDBClient:
@@ -244,13 +260,13 @@ class TestDuckDBGroupBy:
244
260
  num_rows = view.num_rows()
245
261
  assert num_rows == 5
246
262
  json = view.to_json()
247
- assert json == [
263
+ assert json == approx_floats([
248
264
  {"__ROW_PATH__": [], "Sales": 2297200.860299955},
249
265
  {"__ROW_PATH__": ["Central"], "Sales": 501239.8908000005},
250
266
  {"__ROW_PATH__": ["East"], "Sales": 678781.2399999979},
251
267
  {"__ROW_PATH__": ["South"], "Sales": 391721.9050000003},
252
268
  {"__ROW_PATH__": ["West"], "Sales": 725457.8245000006},
253
- ]
269
+ ])
254
270
  view.delete()
255
271
 
256
272
  def test_multi_level_group_by(self, client):
@@ -261,7 +277,7 @@ class TestDuckDBGroupBy:
261
277
  aggregates={"Sales": "sum"},
262
278
  )
263
279
  json = view.to_json()
264
- assert json == [
280
+ assert json == approx_floats([
265
281
  {"__ROW_PATH__": [], "Sales": 2297200.860299955},
266
282
  {"__ROW_PATH__": ["Central"], "Sales": 501239.8908000005},
267
283
  {"__ROW_PATH__": ["Central", "Furniture"], "Sales": 163797.16380000004},
@@ -282,7 +298,7 @@ class TestDuckDBGroupBy:
282
298
  {"__ROW_PATH__": ["West", "Furniture"], "Sales": 252612.7435000003},
283
299
  {"__ROW_PATH__": ["West", "Office Supplies"], "Sales": 220853.24900000007},
284
300
  {"__ROW_PATH__": ["West", "Technology"], "Sales": 251991.83199999997},
285
- ]
301
+ ])
286
302
  view.delete()
287
303
 
288
304
  def test_group_by_with_count_aggregate(self, client):
@@ -310,12 +326,12 @@ class TestDuckDBGroupBy:
310
326
  aggregates={"Sales": "avg"},
311
327
  )
312
328
  json = view.to_json()
313
- assert json == [
329
+ assert json == approx_floats([
314
330
  {"__ROW_PATH__": [], "Sales": 229.8580008304938},
315
331
  {"__ROW_PATH__": ["Furniture"], "Sales": 349.83488698727007},
316
332
  {"__ROW_PATH__": ["Office Supplies"], "Sales": 119.32410089611732},
317
333
  {"__ROW_PATH__": ["Technology"], "Sales": 452.70927612344155},
318
- ]
334
+ ])
319
335
  view.delete()
320
336
 
321
337
  def test_group_by_with_min_aggregate(self, client):
@@ -372,7 +388,7 @@ class TestDuckDBSplitBy:
372
388
  ]
373
389
 
374
390
  json = view.to_json()
375
- assert json == [
391
+ assert json == approx_floats([
376
392
  {
377
393
  "__ROW_PATH__": [],
378
394
  "Central|Sales": 501239.8908000005,
@@ -401,7 +417,7 @@ class TestDuckDBSplitBy:
401
417
  "South|Sales": 148771.9079999999,
402
418
  "West|Sales": 251991.83199999997,
403
419
  },
404
- ]
420
+ ])
405
421
  view.delete()
406
422
 
407
423
  def test_split_by_without_group_by(self, client):
@@ -560,12 +576,12 @@ class TestDuckDBFilter:
560
576
  num_rows = view.num_rows()
561
577
  assert num_rows == 4
562
578
  json = view.to_json()
563
- assert json == [
579
+ assert json == approx_floats([
564
580
  {"__ROW_PATH__": [], "Sales": 725457.8245000006},
565
581
  {"__ROW_PATH__": ["Furniture"], "Sales": 252612.7435000003},
566
582
  {"__ROW_PATH__": ["Office Supplies"], "Sales": 220853.24900000007},
567
583
  {"__ROW_PATH__": ["Technology"], "Sales": 251991.83199999997},
568
- ]
584
+ ])
569
585
  view.delete()
570
586
 
571
587
 
@@ -611,13 +627,13 @@ class TestDuckDBSort:
611
627
  aggregates={"Sales": "sum"},
612
628
  )
613
629
  json = view.to_json()
614
- assert json == [
630
+ assert json == approx_floats([
615
631
  {"__ROW_PATH__": [], "Sales": 2297200.860299955},
616
632
  {"__ROW_PATH__": ["West"], "Sales": 725457.8245000006},
617
633
  {"__ROW_PATH__": ["East"], "Sales": 678781.2399999979},
618
634
  {"__ROW_PATH__": ["Central"], "Sales": 501239.8908000005},
619
635
  {"__ROW_PATH__": ["South"], "Sales": 391721.9050000003},
620
- ]
636
+ ])
621
637
  view.delete()
622
638
 
623
639
  def test_multi_column_sort(self, client):
@@ -639,6 +655,55 @@ class TestDuckDBSort:
639
655
  ]
640
656
  view.delete()
641
657
 
658
+ @pytest.mark.parametrize("split_by", [[], ["Segment"]])
659
+ def test_sort_with_multi_level_group_by(self, client, split_by):
660
+ table = client.open_table("memory.superstore")
661
+ view = table.view(
662
+ columns=["Sales"],
663
+ group_by=["Region", "Category"],
664
+ split_by=split_by,
665
+ sort=[["Sales", "desc"]],
666
+ aggregates={"Sales": "sum"},
667
+ )
668
+ paths = [row["__ROW_PATH__"] for row in view.to_json()]
669
+ assert paths == [[]] + [
670
+ path
671
+ for region, categories in MULTI_LEVEL_SORT_LEAVES.items()
672
+ for path in [[region]] + [[region, c] for c in categories]
673
+ ]
674
+ view.delete()
675
+
676
+ @pytest.mark.parametrize("split_by", [[], ["Segment"]])
677
+ def test_sort_with_multi_level_group_by_flat(self, client, split_by):
678
+ table = client.open_table("memory.superstore")
679
+ view = table.view(
680
+ columns=["Sales"],
681
+ group_by=["Region", "Category"],
682
+ split_by=split_by,
683
+ group_rollup_mode="flat",
684
+ sort=[["Sales", "desc"]],
685
+ aggregates={"Sales": "sum"},
686
+ )
687
+ paths = [
688
+ row["__ROW_PATH__"]
689
+ for row in view.to_json()
690
+ if len(row["__ROW_PATH__"]) == 2
691
+ ]
692
+ assert paths == [
693
+ [region, c]
694
+ for region, categories in MULTI_LEVEL_SORT_LEAVES.items()
695
+ for c in categories
696
+ ]
697
+ view.delete()
698
+
699
+
700
+ MULTI_LEVEL_SORT_LEAVES = {
701
+ "West": ["Furniture", "Technology", "Office Supplies"],
702
+ "East": ["Technology", "Furniture", "Office Supplies"],
703
+ "Central": ["Technology", "Office Supplies", "Furniture"],
704
+ "South": ["Technology", "Office Supplies", "Furniture"],
705
+ }
706
+
642
707
 
643
708
  DESCRIBE_CONFIGS = [
644
709
  dict(columns=["Sales", "Quantity", "Region"]),
@@ -783,13 +848,13 @@ class TestDuckDBExpressions:
783
848
  aggregates={"total": "sum"},
784
849
  )
785
850
  json = view.to_json()
786
- assert json == [
851
+ assert json == approx_floats([
787
852
  {"__ROW_PATH__": [], "total": 2583597.882000014},
788
853
  {"__ROW_PATH__": ["Central"], "total": 540946.2532999996},
789
854
  {"__ROW_PATH__": ["East"], "total": 770304.0199999991},
790
855
  {"__ROW_PATH__": ["South"], "total": 438471.33530000027},
791
856
  {"__ROW_PATH__": ["West"], "total": 833876.2733999988},
792
- ]
857
+ ])
793
858
  view.delete()
794
859
 
795
860
 
@@ -888,12 +953,12 @@ class TestDuckDBCombinedOperations:
888
953
  aggregates={"Sales": "sum"},
889
954
  )
890
955
  json = view.to_json()
891
- assert json == [
956
+ assert json == approx_floats([
892
957
  {"__ROW_PATH__": [], "Sales": 725457.8245000006},
893
958
  {"__ROW_PATH__": ["Furniture"], "Sales": 252612.7435000003},
894
959
  {"__ROW_PATH__": ["Technology"], "Sales": 251991.83199999997},
895
960
  {"__ROW_PATH__": ["Office Supplies"], "Sales": 220853.24900000007},
896
- ]
961
+ ])
897
962
  view.delete()
898
963
 
899
964
  def test_split_by_group_by_filter(self, client):
@@ -918,7 +983,7 @@ class TestDuckDBCombinedOperations:
918
983
  assert num_rows == 4
919
984
 
920
985
  json = view.to_json()
921
- assert json == [
986
+ assert json == approx_floats([
922
987
  {
923
988
  "__ROW_PATH__": [],
924
989
  "Central|Sales": 332883.0567999998,
@@ -947,7 +1012,7 @@ class TestDuckDBCombinedOperations:
947
1012
  "South|Sales": 108955.79400000005,
948
1013
  "West|Sales": 165134.77900000007,
949
1014
  },
950
- ]
1015
+ ])
951
1016
  view.delete()
952
1017
 
953
1018
  def test_split_by_only(self, client):
@@ -990,13 +1055,13 @@ class TestDuckDBCombinedOperations:
990
1055
  aggregates={"profitmargin": "avg"},
991
1056
  )
992
1057
  json = view.to_json()
993
- assert json == [
1058
+ assert json == approx_floats([
994
1059
  {"__ROW_PATH__": [], "profitmargin": 12.031392972104467},
995
1060
  {"__ROW_PATH__": ["West"], "profitmargin": 21.948661793784012},
996
1061
  {"__ROW_PATH__": ["East"], "profitmargin": 16.722695960406636},
997
1062
  {"__ROW_PATH__": ["South"], "profitmargin": 16.35190329218107},
998
1063
  {"__ROW_PATH__": ["Central"], "profitmargin": -10.407293926323575},
999
- ]
1064
+ ])
1000
1065
  view.delete()
1001
1066
 
1002
1067
 
@@ -69,7 +69,8 @@ def client():
69
69
 
70
70
  session = server.new_session(handle_response)
71
71
  c = Client(handle_request)
72
- return c
72
+ yield c
73
+ session.close()
73
74
 
74
75
 
75
76
  class TestPolarsClient:
@@ -166,7 +166,8 @@ def client(pg_db):
166
166
 
167
167
  session = server.new_session(handle_response)
168
168
  c = Client(handle_request)
169
- return c
169
+ yield c
170
+ session.close()
170
171
 
171
172
 
172
173
  def approx(x):
@@ -617,8 +618,8 @@ class TestPostgresSort:
617
618
  view.delete()
618
619
 
619
620
  def test_sort_with_multi_level_group_by(self, client):
620
- # Hierarchical rollup sort - exercises the `first_value(...) OVER
621
- # __WINDOW_N__` emission, which must be that spelling for Postgres
621
+ # Hierarchical rollup sort - exercises the inline `first_value(...)
622
+ # OVER (...)` emission, which must be that spelling for Postgres
622
623
  # (DuckDB's `first` does not exist).
623
624
  table = client.open_table("psp_test.superstore")
624
625
  view = table.view(
@@ -0,0 +1,139 @@
1
+ # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2
+ # ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3
+ # ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4
+ # ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5
+ # ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6
+ # ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7
+ # ┃ Copyright (c) 2017, the Perspective Authors. ┃
8
+ # ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9
+ # ┃ This file is part of the Perspective library, distributed under the terms ┃
10
+ # ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
+ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
+
13
+ import asyncio
14
+ import gc
15
+ import weakref
16
+
17
+ import duckdb
18
+ import pytest
19
+
20
+ from perspective import Client
21
+ from perspective.virtual_servers.duckdb import DuckDBVirtualServer
22
+
23
+
24
+ def table_names(db):
25
+ return {
26
+ row[0]
27
+ for row in db.execute(
28
+ "SELECT table_name FROM information_schema.tables"
29
+ ).fetchall()
30
+ }
31
+
32
+
33
+ def make_db():
34
+ db = duckdb.connect(":memory:")
35
+ db.execute("CREATE TABLE data AS SELECT * FROM range(10) t(x)")
36
+ return db
37
+
38
+
39
+ def make_session(db):
40
+ server = DuckDBVirtualServer(db)
41
+
42
+ def handle_request(msg):
43
+ session.handle_request(msg)
44
+
45
+ def handle_response(msg):
46
+ client.handle_response(msg)
47
+
48
+ session = server.new_session(handle_response)
49
+ client = Client(handle_request)
50
+ return session, client
51
+
52
+
53
+ class TestVirtualSessionClose:
54
+ def test_close_deletes_open_views(self):
55
+ db = make_db()
56
+ session, client = make_session(db)
57
+ table = client.open_table("memory.data")
58
+ table.view(columns=["x"], group_by=["x"])
59
+ table.view(columns=["x"])
60
+ assert len(table_names(db)) == 3
61
+ session.close()
62
+ assert table_names(db) == {"data"}
63
+
64
+ def test_close_skips_deleted_views(self):
65
+ db = make_db()
66
+ session, client = make_session(db)
67
+ view = client.open_table("memory.data").view(columns=["x"])
68
+ view.delete()
69
+ session.close()
70
+ assert table_names(db) == {"data"}
71
+
72
+ def test_close_without_views(self):
73
+ db = make_db()
74
+ session, _ = make_session(db)
75
+ session.close()
76
+ assert table_names(db) == {"data"}
77
+
78
+ def test_close_is_idempotent(self):
79
+ db = make_db()
80
+ session, client = make_session(db)
81
+ client.open_table("memory.data").view(columns=["x"])
82
+ session.close()
83
+ session.close()
84
+ assert table_names(db) == {"data"}
85
+
86
+ def test_close_releases_client_cycle(self):
87
+ session, client = make_session(make_db())
88
+ client.open_table("memory.data").view(columns=["x"])
89
+ callback = weakref.ref(session.callback)
90
+ session.close()
91
+ del client
92
+ gc.collect()
93
+ assert callback() is None
94
+
95
+ def test_bundled_sessions_close(self):
96
+ from perspective.virtual_servers.clickhouse import ClickhouseVirtualSession
97
+ from perspective.virtual_servers.duckdb import DuckDBVirtualSession
98
+ from perspective.virtual_servers.polars import PolarsVirtualSession
99
+
100
+ for session in [
101
+ ClickhouseVirtualSession,
102
+ DuckDBVirtualSession,
103
+ PolarsVirtualSession,
104
+ ]:
105
+ assert callable(getattr(session, "close", None))
106
+
107
+ def test_postgres_session_close(self):
108
+ pytest.importorskip("psycopg")
109
+ from perspective.virtual_servers.postgres import PostgresVirtualSession
110
+
111
+ assert callable(getattr(PostgresVirtualSession, "close", None))
112
+
113
+
114
+ class TestStarletteDisconnect:
115
+ def test_disconnect_closes_virtual_session(self):
116
+ websockets = pytest.importorskip("starlette.websockets")
117
+ from perspective.handlers.starlette import PerspectiveStarletteHandler
118
+
119
+ class DisconnectingWebSocket:
120
+ async def accept(self):
121
+ pass
122
+
123
+ async def receive_bytes(self):
124
+ raise websockets.WebSocketDisconnect(1000)
125
+
126
+ async def send_bytes(self, msg):
127
+ pass
128
+
129
+ db = make_db()
130
+ server = DuckDBVirtualServer(db)
131
+
132
+ async def run():
133
+ handler = PerspectiveStarletteHandler(
134
+ perspective_server=server, websocket=DisconnectingWebSocket()
135
+ )
136
+ await handler.run()
137
+
138
+ with pytest.raises(websockets.WebSocketDisconnect):
139
+ asyncio.run(run())
@@ -135,7 +135,8 @@ class VirtualServerHandler:
135
135
  `view_name`, into the `PerspectiveColumn` serialization API injected
136
136
  via `data`. The push-only `PerspectiveColumn` type can handle casting
137
137
  Python types as input, but once a type is pushed to a column name it
138
- must not be changed.
138
+ must not be changed. `data` is consumed when this method returns, and
139
+ any later use of a retained reference raises `ValueError`.
139
140
  """
140
141
 
141
142
  pass
@@ -111,6 +111,11 @@ class ClickhouseVirtualSession:
111
111
  def handle_request(self, msg):
112
112
  self.callback(self.session.handle_request(msg))
113
113
 
114
+ def close(self):
115
+ session, self.session, self.callback = self.session, None, None
116
+ if session is not None:
117
+ session.close()
118
+
114
119
 
115
120
  class ClickhouseVirtualServer:
116
121
  def __init__(self, db):