figpack 0.1.0__tar.gz → 0.1.2__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.

Potentially problematic release.


This version of figpack might be problematic. Click here for more details.

Files changed (38) hide show
  1. {figpack-0.1.0 → figpack-0.1.2}/MANIFEST.in +1 -1
  2. figpack-0.1.2/PKG-INFO +104 -0
  3. figpack-0.1.2/README.md +73 -0
  4. {figpack-0.1.0 → figpack-0.1.2}/figpack/__init__.py +1 -1
  5. figpack-0.1.2/figpack/core/__init__.py +0 -0
  6. figpack-0.1.2/figpack/core/_bundle_utils.py +56 -0
  7. {figpack-0.1.0/figpack → figpack-0.1.2/figpack/core}/_show_view.py +37 -34
  8. figpack-0.1.2/figpack/core/_upload_bundle.py +451 -0
  9. figpack-0.1.2/figpack/core/figpack_view.py +70 -0
  10. figpack-0.1.2/figpack/figpack-gui-dist/assets/index-BA_v5Jep.css +1 -0
  11. figpack-0.1.2/figpack/figpack-gui-dist/assets/index-CMzZutX1.js +78 -0
  12. figpack-0.1.2/figpack/figpack-gui-dist/assets/neurosift-logo-CLsuwLMO.png +0 -0
  13. figpack-0.1.2/figpack/figpack-gui-dist/index.html +14 -0
  14. figpack-0.1.2/figpack/views/Box.py +68 -0
  15. figpack-0.1.2/figpack/views/LayoutItem.py +55 -0
  16. figpack-0.1.2/figpack/views/Splitter.py +66 -0
  17. figpack-0.1.2/figpack/views/TabLayout.py +66 -0
  18. figpack-0.1.2/figpack/views/TabLayoutItem.py +39 -0
  19. figpack-0.1.0/figpack/views.py → figpack-0.1.2/figpack/views/TimeseriesGraph.py +5 -1
  20. figpack-0.1.2/figpack/views/__init__.py +6 -0
  21. figpack-0.1.2/figpack.egg-info/PKG-INFO +104 -0
  22. figpack-0.1.2/figpack.egg-info/SOURCES.txt +27 -0
  23. {figpack-0.1.0 → figpack-0.1.2}/figpack.egg-info/top_level.txt +1 -0
  24. {figpack-0.1.0 → figpack-0.1.2}/pyproject.toml +2 -2
  25. figpack-0.1.0/PKG-INFO +0 -33
  26. figpack-0.1.0/README.md +0 -2
  27. figpack-0.1.0/figpack/_upload_view.py +0 -334
  28. figpack-0.1.0/figpack/figpack-gui-dist/assets/index-BrKvMWud.js +0 -65
  29. figpack-0.1.0/figpack/figpack-gui-dist/assets/index-CeWL3OeJ.css +0 -1
  30. figpack-0.1.0/figpack/figpack-gui-dist/index.html +0 -14
  31. figpack-0.1.0/figpack/figpack_view.py +0 -62
  32. figpack-0.1.0/figpack.egg-info/PKG-INFO +0 -33
  33. figpack-0.1.0/figpack.egg-info/SOURCES.txt +0 -18
  34. {figpack-0.1.0 → figpack-0.1.2}/LICENSE +0 -0
  35. {figpack-0.1.0 → figpack-0.1.2}/figpack-gui/node_modules/flatted/python/flatted.py +0 -0
  36. {figpack-0.1.0 → figpack-0.1.2}/figpack.egg-info/dependency_links.txt +0 -0
  37. {figpack-0.1.0 → figpack-0.1.2}/figpack.egg-info/requires.txt +0 -0
  38. {figpack-0.1.0 → figpack-0.1.2}/setup.cfg +0 -0
@@ -1,8 +1,8 @@
1
1
  include README.md
2
2
  include LICENSE
3
3
  include pyproject.toml
4
- include build_gui.py
5
4
  recursive-include figpack *.py
6
5
  recursive-include figpack/figpack-gui-dist *
7
6
  global-exclude __pycache__
8
7
  global-exclude *.py[co]
8
+
figpack-0.1.2/PKG-INFO ADDED
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: figpack
3
+ Version: 0.1.2
4
+ Summary: A Python package for creating shareable, interactive visualizations in the browser
5
+ Author-email: Jeremy Magland <jmagland@flatironinstitute.org>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/magland/figpack
8
+ Project-URL: Repository, https://github.com/magland/figpack
9
+ Project-URL: Documentation, https://github.com/magland/figpack#readme
10
+ Project-URL: Bug Tracker, https://github.com/magland/figpack/issues
11
+ Keywords: visualization,plotting,timeseries,interactive
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Scientific/Engineering :: Visualization
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: numpy
28
+ Requires-Dist: zarr
29
+ Requires-Dist: requests
30
+ Dynamic: license-file
31
+
32
+ # figpack
33
+
34
+ A Python package for creating shareable, interactive visualizations in the browser.
35
+
36
+ ## Overview
37
+
38
+ figpack enables you to create interactive data visualizations that can be displayed in a web browser and optionally shared online. The package focuses on timeseries data visualization with support for complex, nested layouts.
39
+
40
+ ### Key Features
41
+
42
+ - **Interactive timeseries graphs** with line series, markers, and interval plots
43
+ - **Flexible layout system** with boxes, splitters, and tab layouts
44
+ - **Web-based rendering** that works in any modern browser
45
+ - **Shareable visualizations** that can be uploaded and shared via URLs
46
+ - **Zarr-based data storage** for efficient handling of large datasets
47
+
48
+ ## Installation
49
+
50
+ Install figpack using pip:
51
+
52
+ ```bash
53
+ pip install figpack
54
+ ```
55
+
56
+ ## Quick Start
57
+
58
+ ```python
59
+ import numpy as np
60
+ import figpack.views as vv
61
+
62
+ # Create a timeseries graph
63
+ graph = vv.TimeseriesGraph(y_label="Signal")
64
+
65
+ # Add some data
66
+ t = np.linspace(0, 10, 1000)
67
+ y = np.sin(2 * np.pi * t)
68
+ graph.add_line_series(name="sine wave", t=t, y=y, color="blue")
69
+
70
+ # Display the visualization
71
+ graph.show(open_in_browser=True)
72
+ ```
73
+
74
+ ## Examples
75
+
76
+ See the `examples/` directory.
77
+
78
+ ## Usage Modes
79
+
80
+ ### Local Development
81
+
82
+ ```python
83
+ view.show(open_in_browser=True)
84
+ ```
85
+
86
+ ### Sharing Online
87
+
88
+ Set the `FIGPACK_UPLOAD_PASSCODE` environment variable and use:
89
+
90
+ ```python
91
+ view.show(upload=True, open_in_browser=True)
92
+ ```
93
+
94
+ ### Development Mode
95
+
96
+ Set `_dev=True` in the call to show() to enable development mode, which allows for live updates and debugging with figpack-gui.
97
+
98
+ ## License
99
+
100
+ Apache-2.0
101
+
102
+ ## Contributing
103
+
104
+ Visit the [GitHub repository](https://github.com/magland/figpack) for issues, contributions, and the latest updates.
@@ -0,0 +1,73 @@
1
+ # figpack
2
+
3
+ A Python package for creating shareable, interactive visualizations in the browser.
4
+
5
+ ## Overview
6
+
7
+ figpack enables you to create interactive data visualizations that can be displayed in a web browser and optionally shared online. The package focuses on timeseries data visualization with support for complex, nested layouts.
8
+
9
+ ### Key Features
10
+
11
+ - **Interactive timeseries graphs** with line series, markers, and interval plots
12
+ - **Flexible layout system** with boxes, splitters, and tab layouts
13
+ - **Web-based rendering** that works in any modern browser
14
+ - **Shareable visualizations** that can be uploaded and shared via URLs
15
+ - **Zarr-based data storage** for efficient handling of large datasets
16
+
17
+ ## Installation
18
+
19
+ Install figpack using pip:
20
+
21
+ ```bash
22
+ pip install figpack
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ```python
28
+ import numpy as np
29
+ import figpack.views as vv
30
+
31
+ # Create a timeseries graph
32
+ graph = vv.TimeseriesGraph(y_label="Signal")
33
+
34
+ # Add some data
35
+ t = np.linspace(0, 10, 1000)
36
+ y = np.sin(2 * np.pi * t)
37
+ graph.add_line_series(name="sine wave", t=t, y=y, color="blue")
38
+
39
+ # Display the visualization
40
+ graph.show(open_in_browser=True)
41
+ ```
42
+
43
+ ## Examples
44
+
45
+ See the `examples/` directory.
46
+
47
+ ## Usage Modes
48
+
49
+ ### Local Development
50
+
51
+ ```python
52
+ view.show(open_in_browser=True)
53
+ ```
54
+
55
+ ### Sharing Online
56
+
57
+ Set the `FIGPACK_UPLOAD_PASSCODE` environment variable and use:
58
+
59
+ ```python
60
+ view.show(upload=True, open_in_browser=True)
61
+ ```
62
+
63
+ ### Development Mode
64
+
65
+ Set `_dev=True` in the call to show() to enable development mode, which allows for live updates and debugging with figpack-gui.
66
+
67
+ ## License
68
+
69
+ Apache-2.0
70
+
71
+ ## Contributing
72
+
73
+ Visit the [GitHub repository](https://github.com/magland/figpack) for issues, contributions, and the latest updates.
@@ -1,5 +1,5 @@
1
1
  """
2
- figpack - A Python package for creating interactive visualizations
2
+ figpack - A Python package for creating shareable, interactive visualizations in the browser
3
3
  """
4
4
 
5
5
  __version__ = "0.1.0"
File without changes
@@ -0,0 +1,56 @@
1
+ import os
2
+ import pathlib
3
+ import zarr
4
+ from .figpack_view import FigpackView
5
+
6
+ thisdir = pathlib.Path(__file__).parent.resolve()
7
+
8
+
9
+ def prepare_figure_bundle(
10
+ view: FigpackView, tmpdir: str, *, title: str = None, description: str = None
11
+ ) -> None:
12
+ """
13
+ Prepare a figure bundle in the specified temporary directory.
14
+
15
+ This function:
16
+ 1. Copies all files from the figpack-gui-dist directory to tmpdir
17
+ 2. Writes the view data to a zarr group
18
+ 3. Consolidates zarr metadata
19
+
20
+ Args:
21
+ view: The figpack view to prepare
22
+ tmpdir: The temporary directory to prepare the bundle in
23
+ title: Optional title for the figure
24
+ description: Optional description for the figure (markdown supported)
25
+ """
26
+ html_dir = thisdir / ".." / "figpack-gui-dist"
27
+ if not os.path.exists(html_dir):
28
+ raise SystemExit(f"Error: directory not found: {html_dir}")
29
+
30
+ # Copy all files in html_dir recursively to tmpdir
31
+ for item in html_dir.iterdir():
32
+ if item.is_file():
33
+ target = pathlib.Path(tmpdir) / item.name
34
+ target.write_bytes(item.read_bytes())
35
+ elif item.is_dir():
36
+ target = pathlib.Path(tmpdir) / item.name
37
+ target.mkdir(exist_ok=True)
38
+ for subitem in item.iterdir():
39
+ target_sub = target / subitem.name
40
+ target_sub.write_bytes(subitem.read_bytes())
41
+
42
+ # Write the graph data to the Zarr group
43
+ zarr_group = zarr.open_group(
44
+ pathlib.Path(tmpdir) / "data.zarr",
45
+ mode="w",
46
+ synchronizer=zarr.ThreadSynchronizer(),
47
+ )
48
+ view._write_to_zarr_group(zarr_group)
49
+
50
+ # Add title and description as attributes on the top-level zarr group
51
+ if title is not None:
52
+ zarr_group.attrs["title"] = title
53
+ if description is not None:
54
+ zarr_group.attrs["description"] = description
55
+
56
+ zarr.consolidate_metadata(zarr_group.store)
@@ -1,7 +1,6 @@
1
1
  import os
2
2
 
3
3
  from typing import Union
4
- import zarr
5
4
  import tempfile
6
5
 
7
6
  import webbrowser
@@ -11,50 +10,54 @@ import pathlib
11
10
  import threading
12
11
  from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
13
12
 
14
- from .views import TimeseriesGraph
13
+ from .figpack_view import FigpackView
14
+ from ._bundle_utils import prepare_figure_bundle
15
+ from ._upload_bundle import _upload_bundle
15
16
 
16
17
  thisdir = pathlib.Path(__file__).parent.resolve()
17
18
 
18
19
 
19
20
  def _show_view(
20
- view: TimeseriesGraph,
21
+ view: FigpackView,
21
22
  *,
22
23
  open_in_browser: bool = False,
23
24
  port: Union[int, None] = None,
24
25
  allow_origin: Union[str, None] = None,
26
+ upload: bool = False,
27
+ title: Union[str, None] = None,
28
+ description: Union[str, None] = None,
25
29
  ):
26
30
  with tempfile.TemporaryDirectory(prefix="figpack_") as tmpdir:
27
- html_dir = thisdir / "figpack-gui-dist"
28
- if not os.path.exists(html_dir):
29
- raise SystemExit(f"Error: directory not found: {html_dir}")
30
- # copy all files in html_dir recursively to tmpdir
31
- for item in html_dir.iterdir():
32
- if item.is_file():
33
- target = pathlib.Path(tmpdir) / item.name
34
- target.write_bytes(item.read_bytes())
35
- elif item.is_dir():
36
- target = pathlib.Path(tmpdir) / item.name
37
- target.mkdir(exist_ok=True)
38
- for subitem in item.iterdir():
39
- target_sub = target / subitem.name
40
- target_sub.write_bytes(subitem.read_bytes())
41
-
42
- # Write the graph data to the Zarr group
43
- zarr_group = zarr.open_group(
44
- pathlib.Path(tmpdir) / "data.zarr",
45
- mode="w",
46
- synchronizer=zarr.ThreadSynchronizer(),
47
- )
48
- view._write_to_zarr_group(zarr_group)
49
-
50
- zarr.consolidate_metadata(zarr_group.store)
51
-
52
- serve_files(
53
- tmpdir,
54
- port=port,
55
- open_in_browser=open_in_browser,
56
- allow_origin=allow_origin,
57
- )
31
+ prepare_figure_bundle(view, tmpdir, title=title, description=description)
32
+
33
+ if upload:
34
+ # Check for required environment variable
35
+ passcode = os.environ.get("FIGPACK_UPLOAD_PASSCODE")
36
+ if not passcode:
37
+ raise EnvironmentError(
38
+ "FIGPACK_UPLOAD_PASSCODE environment variable must be set to upload views."
39
+ )
40
+
41
+ # Upload the bundle
42
+ print("Starting upload...")
43
+ figure_url = _upload_bundle(tmpdir, passcode)
44
+
45
+ if open_in_browser:
46
+ webbrowser.open(figure_url)
47
+ print(f"Opening {figure_url} in browser.")
48
+ # wait until user presses Enter
49
+ input("Press Enter to continue...")
50
+ else:
51
+ print(f"View the figure at: {figure_url}")
52
+
53
+ return figure_url
54
+ else:
55
+ serve_files(
56
+ tmpdir,
57
+ port=port,
58
+ open_in_browser=open_in_browser,
59
+ allow_origin=allow_origin,
60
+ )
58
61
 
59
62
 
60
63
  class CORSRequestHandler(SimpleHTTPRequestHandler):