syd 1.2.5__tar.gz → 1.2.7__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 (29) hide show
  1. {syd-1.2.5 → syd-1.2.7}/.gitignore +1 -0
  2. {syd-1.2.5 → syd-1.2.7}/PKG-INFO +13 -16
  3. {syd-1.2.5 → syd-1.2.7}/README.md +12 -15
  4. {syd-1.2.5 → syd-1.2.7}/syd/__init__.py +1 -1
  5. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/deployer.py +9 -43
  6. {syd-1.2.5 → syd-1.2.7}/syd/viewer.py +62 -6
  7. {syd-1.2.5 → syd-1.2.7}/LICENSE +0 -0
  8. {syd-1.2.5 → syd-1.2.7}/pyproject.toml +0 -0
  9. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/__init__.py +0 -0
  10. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/__init__.py +0 -0
  11. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/css/styles.css +0 -0
  12. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/css/viewer.css +0 -0
  13. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/js/modules/api.js +0 -0
  14. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/js/modules/config.js +0 -0
  15. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/js/modules/plot.js +0 -0
  16. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/js/modules/state.js +0 -0
  17. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/js/modules/system_controls.js +0 -0
  18. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/js/modules/ui_controls.js +0 -0
  19. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/js/modules/utils.js +0 -0
  20. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/js/old_viewer.js +0 -0
  21. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/static/js/viewer.js +0 -0
  22. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/templates/__init__.py +0 -0
  23. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/templates/index.html +0 -0
  24. {syd-1.2.5 → syd-1.2.7}/syd/flask_deployment/testing_principles.md +0 -0
  25. {syd-1.2.5 → syd-1.2.7}/syd/notebook_deployment/__init__.py +0 -0
  26. {syd-1.2.5 → syd-1.2.7}/syd/notebook_deployment/deployer.py +0 -0
  27. {syd-1.2.5 → syd-1.2.7}/syd/notebook_deployment/widgets.py +0 -0
  28. {syd-1.2.5 → syd-1.2.7}/syd/parameters.py +0 -0
  29. {syd-1.2.5 → syd-1.2.7}/syd/support.py +0 -0
@@ -2,6 +2,7 @@
2
2
  _historical/
3
3
  _planning/
4
4
  local/
5
+ data/
5
6
 
6
7
  # Byte-compiled / optimized / DLL files
7
8
  __pycache__/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: syd
3
- Version: 1.2.5
3
+ Version: 1.2.7
4
4
  Summary: A Python package for making GUIs for data science easy.
5
5
  Project-URL: Homepage, https://github.com/landoskape/syd
6
6
  Author-email: Andrew Landau <andrew+tyler+landau+getridofthisanddtheplusses@gmail.com>
@@ -36,6 +36,7 @@ Description-Content-Type: text/markdown
36
36
  [![Documentation Status](https://readthedocs.org/projects/shareyourdata/badge/?version=stable)](https://shareyourdata.readthedocs.io/en/stable/?badge=stable)
37
37
  [![codecov](https://codecov.io/gh/landoskape/syd/branch/main/graph/badge.svg)](https://codecov.io/gh/landoskape/syd)
38
38
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
39
+ [![DOI](https://joss.theoj.org/papers/10.21105/joss.08447/status.svg)](https://doi.org/10.21105/joss.08447)
39
40
 
40
41
 
41
42
  <div>
@@ -59,8 +60,10 @@ pip install syd
59
60
  ## Documentation
60
61
  The full documentation is available [here](https://shareyourdata.readthedocs.io/). It includes a quick start guide, a comprehensive tutorial, and an API reference for the different elements of Syd. If you have any questions or want to suggest improvements to the docs, please let us know on the [github issues page](https://github.com/landoskape/syd/issues)!
61
62
 
63
+ **For AI agents/LLMs:** A comprehensive skills file ([SKILLS.md](./SKILLS.md)) is available with workflow patterns, parameter reference tables, common gotchas, and best practices for using Syd in other projects.
64
+
62
65
  ## Quick Start
63
- This is an example of a sine wave viewer which is about as simple as it gets. You can choose which env to use - if you use ``env="notebook"`` then the GUI will deploy as the output of a jupyter cell (this only works in jupyter!). If you use ``env="browser"`` then the GUI will open a page in your default web browser and you can interact with the data there (works in jupyter notebooks and also from python scripts!).
66
+ This is an example of a sine wave viewer which is about as simple as it gets. You can choose where you want to display the viewer. If you use ``viewer.show()`` then the GUI will deploy as the output of a jupyter cell (this only works in jupyter or colab!). If you use ``viewer.share()`` then the GUI will open a page in your default web browser and you can interact with the data there (works in jupyter notebooks and also from python scripts!).
64
67
 
65
68
  ```python
66
69
  import numpy as np
@@ -95,7 +98,9 @@ We have several examples of more complex viewers with detailed explanations in t
95
98
  | [Making a Viewer Class](examples/2b-subclass_example.ipynb) | Rewrites the comprehensive example as a class, which is useful when you have complex data processing or callbacks. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/2b-subclass_example.ipynb) |
96
99
  | [Data Loading](examples/3-data_loading.ipynb) | Showcases different ways to get your data into a Syd viewer. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/3-data_loading.ipynb) |
97
100
  | [Hierarchical Callbacks](examples/4-hierarchical_callbacks.ipynb) | Demonstrates how to handle complicated callback situations. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/4-hierarchical_callbacks.ipynb) |
98
-
101
+ | [Interactive plots with Seaborn](examples/5-interactive-with-seaborn.ipynb) | Showcases how to use Syd with Seaborn. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/5-interactive-with-seaborn.ipynb) |
102
+ | [Histology Viewer](examples/6-histology-viewer.ipynb) | Showcases how to use Syd to create a histology viewer for viewing histology slides on the fly. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/6-histology-viewer.ipynb) |
103
+ | [Image Labeler](examples/7-image-labeler.ipynb) | Showcases how to use Syd to create an image labeler for annotating images (like ROIs). | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/7-image-labeler.ipynb) |
99
104
 
100
105
  ### Data loading
101
106
  Thinking about how to get data into a Syd viewer can be non-intuitive. For some examples that showcase different ways to get your data into a Syd viewer, check out the [data loading example](examples/3-data_loading.ipynb). Or, if you just want a quick and fast example, check this one out:
@@ -232,16 +237,8 @@ pip install black
232
237
  black . # from the root directory of the repo
233
238
  ```
234
239
 
235
- ## To-Do List
236
- This section doubles as a checklist for things I think could be useful and _a place to get feedback about what users think is useful_. If you think something in this is critical and should be prioritized, or if you think something is missing, please let me know by submitting an issue on the [github issues page](https://github.com/landoskape/syd/issues).
237
- - Layout controls
238
- - [ ] Add a "save" button that saves the current state of the viewer to a json file
239
- - [ ] Add a "load" button that loads the viewer state from a json file
240
- - [ ] Add a "freeze" button that allows the user to update state variables without updating the plot until unfreezing
241
- - [ ] Add a window for capturing any error messages that might be thrown by the plot function. Maybe we could have a little interface for looking at each one (up to a point) and the user could press a button to throw an error for the traceback.
242
- - [ ] Consider "app_deployed" context for each deployer...
243
- - Export options:
244
- - [ ] Export lite: export the viewer as a HTML/Java package that contains an incomplete set of renderings of figures -- using a certain set of parameters.
245
- - [ ] Export full: export the viewer in a way that contains the data to give full functionality.
246
- - [ ] Idea for sharing: https://github.com/analyticalmonk/awesome-neuroscience, https://github.com/fasouto/awesome-dataviz
247
- - [ ] The handling of value in Selection parameters is kind of weird.... I think we need to think more about what to do for fails!!!!
240
+ ## Citing this package
241
+ If you use this package, let us know! It's made to help the community so we're happy to hear about how this has helped (or any suggestions!).
242
+ If you publish anything that depended on Syd, we'd appreciate if you cite the JOSS paper:
243
+
244
+ Landau, A., (2025). Syd: A package for making interactive data visualizations in python. Journal of Open Source Software, 10(112), 8447, https://doi.org/10.21105/joss.08447
@@ -5,6 +5,7 @@
5
5
  [![Documentation Status](https://readthedocs.org/projects/shareyourdata/badge/?version=stable)](https://shareyourdata.readthedocs.io/en/stable/?badge=stable)
6
6
  [![codecov](https://codecov.io/gh/landoskape/syd/branch/main/graph/badge.svg)](https://codecov.io/gh/landoskape/syd)
7
7
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
8
+ [![DOI](https://joss.theoj.org/papers/10.21105/joss.08447/status.svg)](https://doi.org/10.21105/joss.08447)
8
9
 
9
10
 
10
11
  <div>
@@ -28,8 +29,10 @@ pip install syd
28
29
  ## Documentation
29
30
  The full documentation is available [here](https://shareyourdata.readthedocs.io/). It includes a quick start guide, a comprehensive tutorial, and an API reference for the different elements of Syd. If you have any questions or want to suggest improvements to the docs, please let us know on the [github issues page](https://github.com/landoskape/syd/issues)!
30
31
 
32
+ **For AI agents/LLMs:** A comprehensive skills file ([SKILLS.md](./SKILLS.md)) is available with workflow patterns, parameter reference tables, common gotchas, and best practices for using Syd in other projects.
33
+
31
34
  ## Quick Start
32
- This is an example of a sine wave viewer which is about as simple as it gets. You can choose which env to use - if you use ``env="notebook"`` then the GUI will deploy as the output of a jupyter cell (this only works in jupyter!). If you use ``env="browser"`` then the GUI will open a page in your default web browser and you can interact with the data there (works in jupyter notebooks and also from python scripts!).
35
+ This is an example of a sine wave viewer which is about as simple as it gets. You can choose where you want to display the viewer. If you use ``viewer.show()`` then the GUI will deploy as the output of a jupyter cell (this only works in jupyter or colab!). If you use ``viewer.share()`` then the GUI will open a page in your default web browser and you can interact with the data there (works in jupyter notebooks and also from python scripts!).
33
36
 
34
37
  ```python
35
38
  import numpy as np
@@ -64,7 +67,9 @@ We have several examples of more complex viewers with detailed explanations in t
64
67
  | [Making a Viewer Class](examples/2b-subclass_example.ipynb) | Rewrites the comprehensive example as a class, which is useful when you have complex data processing or callbacks. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/2b-subclass_example.ipynb) |
65
68
  | [Data Loading](examples/3-data_loading.ipynb) | Showcases different ways to get your data into a Syd viewer. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/3-data_loading.ipynb) |
66
69
  | [Hierarchical Callbacks](examples/4-hierarchical_callbacks.ipynb) | Demonstrates how to handle complicated callback situations. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/4-hierarchical_callbacks.ipynb) |
67
-
70
+ | [Interactive plots with Seaborn](examples/5-interactive-with-seaborn.ipynb) | Showcases how to use Syd with Seaborn. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/5-interactive-with-seaborn.ipynb) |
71
+ | [Histology Viewer](examples/6-histology-viewer.ipynb) | Showcases how to use Syd to create a histology viewer for viewing histology slides on the fly. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/6-histology-viewer.ipynb) |
72
+ | [Image Labeler](examples/7-image-labeler.ipynb) | Showcases how to use Syd to create an image labeler for annotating images (like ROIs). | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/landoskape/syd/blob/main/examples/7-image-labeler.ipynb) |
68
73
 
69
74
  ### Data loading
70
75
  Thinking about how to get data into a Syd viewer can be non-intuitive. For some examples that showcase different ways to get your data into a Syd viewer, check out the [data loading example](examples/3-data_loading.ipynb). Or, if you just want a quick and fast example, check this one out:
@@ -201,16 +206,8 @@ pip install black
201
206
  black . # from the root directory of the repo
202
207
  ```
203
208
 
204
- ## To-Do List
205
- This section doubles as a checklist for things I think could be useful and _a place to get feedback about what users think is useful_. If you think something in this is critical and should be prioritized, or if you think something is missing, please let me know by submitting an issue on the [github issues page](https://github.com/landoskape/syd/issues).
206
- - Layout controls
207
- - [ ] Add a "save" button that saves the current state of the viewer to a json file
208
- - [ ] Add a "load" button that loads the viewer state from a json file
209
- - [ ] Add a "freeze" button that allows the user to update state variables without updating the plot until unfreezing
210
- - [ ] Add a window for capturing any error messages that might be thrown by the plot function. Maybe we could have a little interface for looking at each one (up to a point) and the user could press a button to throw an error for the traceback.
211
- - [ ] Consider "app_deployed" context for each deployer...
212
- - Export options:
213
- - [ ] Export lite: export the viewer as a HTML/Java package that contains an incomplete set of renderings of figures -- using a certain set of parameters.
214
- - [ ] Export full: export the viewer in a way that contains the data to give full functionality.
215
- - [ ] Idea for sharing: https://github.com/analyticalmonk/awesome-neuroscience, https://github.com/fasouto/awesome-dataviz
216
- - [ ] The handling of value in Selection parameters is kind of weird.... I think we need to think more about what to do for fails!!!!
209
+ ## Citing this package
210
+ If you use this package, let us know! It's made to help the community so we're happy to hear about how this has helped (or any suggestions!).
211
+ If you publish anything that depended on Syd, we'd appreciate if you cite the JOSS paper:
212
+
213
+ Landau, A., (2025). Syd: A package for making interactive data visualizations in python. Journal of Open Source Software, 10(112), 8447, https://doi.org/10.21105/joss.08447
@@ -1,4 +1,4 @@
1
- __version__ = "1.2.5"
1
+ __version__ = "1.2.7"
2
2
 
3
3
  from .viewer import make_viewer, Viewer
4
4
  from .support import show_open_servers, close_servers
@@ -396,49 +396,14 @@ class FlaskDeployer:
396
396
  "Flask app not built. Call build_layout() before display()."
397
397
  )
398
398
 
399
+ print(self.port, self.host)
400
+
399
401
  # Find an available port if none is specified
400
- self.port = port or _find_available_port()
401
402
  self.host = host or socket.gethostbyname(socket.gethostname())
403
+ self.port = port or _find_available_port(address=self.host)
402
404
  self.url = f"http://{self.host}:{self.port}"
403
405
  print(f" * Syd Flask server running on {self.url}")
404
406
 
405
- # if open_browser:
406
-
407
- # def wait_until_responsive(url, timeout=self.timeout_threshold):
408
- # start_time = time.time()
409
- # while time.time() - start_time < timeout:
410
- # try:
411
- # r = requests.get(url, timeout=0.5)
412
- # if r.status_code == 200:
413
- # return True
414
- # except requests.exceptions.RequestException:
415
- # pass
416
- # time.sleep(0.1)
417
- # return False
418
-
419
- # def open_browser_tab_when_ready():
420
- # if wait_until_responsive(self.url):
421
- # out = webbrowser.open(self.url, new=1, autoraise=True)
422
- # else:
423
- # print(
424
- # f"Could not open browser: server at {self.url} not responding."
425
- # f"Increase the timeout_threshold to fix this! It's set to {self.timeout_threshold} seconds."
426
- # "You can do this from viewer.show(timeout_threshold=...) or in the FlaskDeployer constructor."
427
- # "Also, this is unexpected so please report this issue on GitHub."
428
- # )
429
-
430
- # threading.Thread(target=open_browser_tab_when_ready, daemon=True).start()
431
-
432
- # # Run the Flask server using Werkzeug's run_simple
433
- # # Pass debug status to run_simple for auto-reloading
434
- # run_simple(
435
- # self.host,
436
- # self.port,
437
- # self.app,
438
- # use_reloader=False,
439
- # use_debugger=self.debug,
440
- # )
441
-
442
407
  # 1) Spin up the server thread
443
408
  srv_thread = ServerThread(self.host, self.port, self.app, debug=self.debug)
444
409
  srv_thread.start()
@@ -460,7 +425,7 @@ class FlaskDeployer:
460
425
  """
461
426
  Deploy the viewer using Flask.
462
427
 
463
- Builds components (no-op), layout (Flask app/routes),
428
+ Builds components, layout (Flask app/routes),
464
429
  and then starts the server.
465
430
  """
466
431
  # build_layout creates the Flask app and routes
@@ -704,14 +669,15 @@ class FlaskDeployer:
704
669
  )
705
670
 
706
671
 
707
- def _find_available_port(start_port=5000, max_attempts=1000):
672
+ def _find_available_port(
673
+ start_port=5000,
674
+ max_attempts=1000,
675
+ address: str = "127.0.0.1",
676
+ ):
708
677
  """
709
678
  Find an available port starting from start_port.
710
- (Identical to original)
711
679
  """
712
680
  for port in range(start_port, start_port + max_attempts):
713
- # Use localhost address explicitly
714
- address = "127.0.0.1"
715
681
  try:
716
682
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
717
683
  # Check if the port is usable
@@ -209,7 +209,7 @@ class Viewer:
209
209
  def plot(self, state: Dict[str, Any]) -> Figure:
210
210
  """Create and return a matplotlib figure.
211
211
 
212
- This is a placeholder. You must either:
212
+ Hello user! This is a placeholder that raises a NotImplementedError. You must either:
213
213
 
214
214
  1. Call set_plot() with your plotting function
215
215
  This will look like this:
@@ -249,7 +249,19 @@ class Viewer:
249
249
  )
250
250
 
251
251
  def set_plot(self, func: Callable) -> None:
252
- """Set the plot method for the viewer"""
252
+ """Set the plot method for the viewer.
253
+
254
+ For viewers created with make_viewer(), this function is used to set the plot method.
255
+ The input must be a callable function that takes a state dictionary and returns a matplotlib figure.
256
+
257
+ Examples
258
+ --------
259
+ >>> def plot(state):
260
+ >>> ... generate figure, plot stuff ...
261
+ >>> return fig
262
+ >>> viewer = make_viewer()
263
+ >>> viewer.set_plot(plot)
264
+ """
253
265
  self.plot = self._prepare_function(func, context="Setting plot:")
254
266
 
255
267
  def show(
@@ -259,9 +271,25 @@ class Viewer:
259
271
  suppress_warnings: bool = True,
260
272
  update_threshold: float = 1.0,
261
273
  ):
262
- """Show the viewer in a notebook
274
+ """
275
+ Show the viewer locally in a notebook.
263
276
 
264
- Same as deploy(env="notebook") except it doesn't return the viewer object.
277
+ This method displays the viewer in a Jupyter notebook environment with interactive controls.
278
+
279
+ Parameters
280
+ ----------
281
+ controls_position : {'left', 'top', 'right', 'bottom'}, optional
282
+ Position of the controls relative to the plot (default is 'left').
283
+ controls_width_percent : int, optional
284
+ Width of the controls as a percentage of the total viewer width (default is 20).
285
+ suppress_warnings : bool, optional
286
+ If True, suppress warnings during deployment (default is True).
287
+ update_threshold : float, optional
288
+ Minimum time in seconds between updates to the viewer (default is 1.0).
289
+
290
+ Notes
291
+ -----
292
+ This method is equivalent to calling `deploy(env="notebook")` but does not return the viewer object.
265
293
  """
266
294
  _ = self.deploy(
267
295
  env="notebook",
@@ -285,9 +313,37 @@ class Viewer:
285
313
  update_threshold: float = 1.0,
286
314
  timeout_threshold: float = 10.0,
287
315
  ):
288
- """Share the viewer on a web browser using Flask
316
+ """
317
+ Share the viewer on a web browser using Flask.
289
318
 
290
- Same as deploy(env="browser") except it doesn't return the viewer object.
319
+ Parameters
320
+ ----------
321
+ controls_position : str, optional
322
+ Position of the controls relative to the plot (default is 'left').
323
+ fig_dpi : int, optional
324
+ Dots per inch for the figure resolution (default is 300).
325
+ controls_width_percent : int, optional
326
+ Width of the controls as a percentage of the total viewer width (default is 20).
327
+ plot_margin_percent : float, optional
328
+ Margin around the plot as a percentage of the plot size (default is 2.5).
329
+ suppress_warnings : bool, optional
330
+ If True, suppress warnings during deployment (default is True).
331
+ debug : bool, optional
332
+ If True, run the server in debug mode (default is False).
333
+ host : str, optional
334
+ Hostname to use for the server (default is None, which uses 'localhost').
335
+ port : int, optional
336
+ Port number to use for the server (default is None, which selects the first available port).
337
+ open_browser : bool, optional
338
+ If True, automatically open the web browser to the viewer (default is True).
339
+ update_threshold : float, optional
340
+ Minimum time in seconds between updates to the viewer (default is 1.0).
341
+ timeout_threshold : float, optional
342
+ Maximum time in seconds to wait for a response before timing out (default is 10.0).
343
+
344
+ Notes
345
+ -----
346
+ This method is equivalent to calling `deploy(env="browser")` but does not return the viewer object.
291
347
  """
292
348
  _ = self.deploy(
293
349
  env="browser",
File without changes
File without changes
File without changes
File without changes