figpack 0.3.12__tar.gz → 0.3.14__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.
- {figpack-0.3.12/figpack.egg-info → figpack-0.3.14}/PKG-INFO +2 -2
- {figpack-0.3.12 → figpack-0.3.14}/README.md +1 -1
- {figpack-0.3.12 → figpack-0.3.14}/figpack/__init__.py +1 -1
- {figpack-0.3.12 → figpack-0.3.14}/figpack/cli.py +162 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_bundle_utils.py +5 -0
- figpack-0.3.12/figpack/figpack-figure-dist/assets/index-DxfhOqh0.js → figpack-0.3.14/figpack/figpack-figure-dist/assets/index-CeJiyHt4.js +71 -71
- {figpack-0.3.12 → figpack-0.3.14}/figpack/figpack-figure-dist/index.html +1 -1
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/PlotlyExtension/_plotly_extension.py +36 -3
- figpack-0.3.14/figpack/views/VerticalLayout.py +75 -0
- figpack-0.3.14/figpack/views/VerticalLayoutItem.py +44 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/__init__.py +2 -0
- {figpack-0.3.12 → figpack-0.3.14/figpack.egg-info}/PKG-INFO +2 -2
- {figpack-0.3.12 → figpack-0.3.14}/figpack.egg-info/SOURCES.txt +3 -1
- {figpack-0.3.12 → figpack-0.3.14}/pyproject.toml +1 -1
- {figpack-0.3.12 → figpack-0.3.14}/LICENSE +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/MANIFEST.in +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/__init__.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_figure_utils.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_file_handler.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_patch_figure.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_revert_patch_figure.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_save_figure.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_server_manager.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_show_view.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_upload_bundle.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_view_figure.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/_zarr_consolidate.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/config.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/extension_view.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/figpack_extension.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/figpack_view.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/core/zarr.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/extensions.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/figpack-figure-dist/assets/index-GPjx4QpG.css +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/figpack-figure-dist/assets/neurosift-logo-CLsuwLMO.png +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/utils/__init__.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/Box.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/CaptionedView.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/DataFrame.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/Gallery.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/GalleryItem.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/Iframe.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/Image.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/LayoutItem.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/Markdown.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/MatplotlibFigure.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/MountainLayout.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/MountainLayoutItem.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/MultiChannelTimeseries.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/PlotlyExtension/PlotlyExtension.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/PlotlyExtension/__init__.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/PlotlyExtension/plotly_view.js +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/Spectrogram.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/Splitter.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/TabLayout.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/TabLayoutItem.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack/views/TimeseriesGraph.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack-serve/worker/container/app.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack.egg-info/dependency_links.txt +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack.egg-info/entry_points.txt +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack.egg-info/requires.txt +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/figpack.egg-info/top_level.txt +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/setup.cfg +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_box.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_cli.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_core.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_dataframe.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_extension_system.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_figpack_view.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_file_handler.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_gallery.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_image.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_markdown.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_matplotlib_figure.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_multichannel_timeseries.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_plotly_figure.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_server_manager.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_spectrogram.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_splitter.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_tablayout.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_timeseries_graph.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_upload_bundle.py +0 -0
- {figpack-0.3.12 → figpack-0.3.14}/tests/test_view_figure.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: figpack
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.14
|
|
4
4
|
Summary: A Python package for creating shareable, interactive visualizations in the browser
|
|
5
5
|
Author-email: Jeremy Magland <jmagland@flatironinstitute.org>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -133,7 +133,7 @@ If you use figpack in your research, please cite it:
|
|
|
133
133
|
|
|
134
134
|
Or in APA format:
|
|
135
135
|
|
|
136
|
-
> Magland, J. (2025). figpack (Version 0.
|
|
136
|
+
> Magland, J. (2025). figpack (Version 0.14) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.17419621
|
|
137
137
|
|
|
138
138
|
## Contributing
|
|
139
139
|
|
|
@@ -57,7 +57,7 @@ If you use figpack in your research, please cite it:
|
|
|
57
57
|
|
|
58
58
|
Or in APA format:
|
|
59
59
|
|
|
60
|
-
> Magland, J. (2025). figpack (Version 0.
|
|
60
|
+
> Magland, J. (2025). figpack (Version 0.14) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.17419621
|
|
61
61
|
|
|
62
62
|
## Contributing
|
|
63
63
|
|
|
@@ -4,6 +4,7 @@ Command-line interface for figpack
|
|
|
4
4
|
|
|
5
5
|
import argparse
|
|
6
6
|
import json
|
|
7
|
+
import os
|
|
7
8
|
import pathlib
|
|
8
9
|
import sys
|
|
9
10
|
import tarfile
|
|
@@ -20,6 +21,7 @@ from .core._view_figure import view_figure
|
|
|
20
21
|
from .core._patch_figure import patch_figure as core_patch_figure
|
|
21
22
|
from .core._revert_patch_figure import revert_patch_figure as core_revert_patch_figure
|
|
22
23
|
from .core._figure_utils import get_figure_base_url, download_file
|
|
24
|
+
from .core._upload_bundle import _upload_bundle
|
|
23
25
|
from .extensions import ExtensionManager
|
|
24
26
|
|
|
25
27
|
MAX_WORKERS_FOR_DOWNLOAD = 16
|
|
@@ -348,6 +350,154 @@ def revert_figure(figure_url: str, admin_override: bool = False) -> None:
|
|
|
348
350
|
sys.exit(1)
|
|
349
351
|
|
|
350
352
|
|
|
353
|
+
def upload_figure(dir_path: str, title: str, description: str = None) -> None:
|
|
354
|
+
"""
|
|
355
|
+
Upload a saved figure directory to figpack
|
|
356
|
+
|
|
357
|
+
Args:
|
|
358
|
+
dir_path: Path to the directory containing the figure bundle
|
|
359
|
+
title: Title for the figure
|
|
360
|
+
description: Optional description for the figure
|
|
361
|
+
"""
|
|
362
|
+
# Validate directory path
|
|
363
|
+
dir_pathlib = pathlib.Path(dir_path)
|
|
364
|
+
if not dir_pathlib.exists():
|
|
365
|
+
print(f"Error: Directory does not exist: {dir_path}")
|
|
366
|
+
sys.exit(1)
|
|
367
|
+
|
|
368
|
+
if not dir_pathlib.is_dir():
|
|
369
|
+
print(f"Error: Path is not a directory: {dir_path}")
|
|
370
|
+
sys.exit(1)
|
|
371
|
+
|
|
372
|
+
# Check for API key
|
|
373
|
+
api_key = os.getenv("FIGPACK_API_KEY", "")
|
|
374
|
+
if not api_key:
|
|
375
|
+
print("Error: FIGPACK_API_KEY environment variable not set.")
|
|
376
|
+
print("Please set your API key with: export FIGPACK_API_KEY=your_api_key")
|
|
377
|
+
sys.exit(1)
|
|
378
|
+
|
|
379
|
+
# Validate figure bundle structure
|
|
380
|
+
print(f"Validating figure bundle in: {dir_path}")
|
|
381
|
+
|
|
382
|
+
# Check for required files (manifest.json is optional, will be created if missing)
|
|
383
|
+
required_files = {
|
|
384
|
+
"index.html": dir_pathlib / "index.html",
|
|
385
|
+
"data.zarr": dir_pathlib / "data.zarr",
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
missing_files = []
|
|
389
|
+
for file_name, file_path in required_files.items():
|
|
390
|
+
if not file_path.exists():
|
|
391
|
+
missing_files.append(file_name)
|
|
392
|
+
|
|
393
|
+
if missing_files:
|
|
394
|
+
print("Error: Invalid figure bundle. Missing required files:")
|
|
395
|
+
for missing_file in missing_files:
|
|
396
|
+
print(f" - {missing_file}")
|
|
397
|
+
print("\nA valid figure bundle must contain:")
|
|
398
|
+
print(" - index.html (viewer)")
|
|
399
|
+
print(" - data.zarr/ (zarr data directory)")
|
|
400
|
+
sys.exit(1)
|
|
401
|
+
|
|
402
|
+
# Validate zarr structure
|
|
403
|
+
zarr_dir = dir_pathlib / "data.zarr"
|
|
404
|
+
if not zarr_dir.is_dir():
|
|
405
|
+
print("Error: data.zarr must be a directory")
|
|
406
|
+
sys.exit(1)
|
|
407
|
+
|
|
408
|
+
# Check for .zmetadata file (consolidated metadata)
|
|
409
|
+
zmetadata_path = zarr_dir / ".zmetadata"
|
|
410
|
+
if not zmetadata_path.exists():
|
|
411
|
+
print("Warning: .zmetadata file not found in data.zarr/")
|
|
412
|
+
print("This file is typically created when saving a figure.")
|
|
413
|
+
|
|
414
|
+
# Check if manifest.json exists, create if missing
|
|
415
|
+
manifest_path = dir_pathlib / "manifest.json"
|
|
416
|
+
manifest_temp_file = None
|
|
417
|
+
|
|
418
|
+
if not manifest_path.exists():
|
|
419
|
+
print("manifest.json not found, creating one...")
|
|
420
|
+
|
|
421
|
+
# Create manifest by scanning all files in the directory
|
|
422
|
+
import time
|
|
423
|
+
|
|
424
|
+
manifest = {
|
|
425
|
+
"timestamp": time.time(),
|
|
426
|
+
"files": [],
|
|
427
|
+
"total_size": 0,
|
|
428
|
+
"total_files": 0,
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
for file_path in dir_pathlib.rglob("*"):
|
|
432
|
+
if file_path.is_file():
|
|
433
|
+
rel_path = str(file_path.relative_to(dir_pathlib))
|
|
434
|
+
file_size = file_path.stat().st_size
|
|
435
|
+
manifest["files"].append({"path": rel_path, "size": file_size})
|
|
436
|
+
manifest["total_size"] += file_size
|
|
437
|
+
|
|
438
|
+
manifest["total_files"] = len(manifest["files"])
|
|
439
|
+
|
|
440
|
+
# Create temporary manifest file
|
|
441
|
+
manifest_temp_file = tempfile.NamedTemporaryFile(
|
|
442
|
+
mode="w", suffix=".json", delete=False, dir=str(dir_pathlib)
|
|
443
|
+
)
|
|
444
|
+
manifest_temp_file.write(json.dumps(manifest, indent=2))
|
|
445
|
+
manifest_temp_file.close()
|
|
446
|
+
|
|
447
|
+
# Move temp file to manifest.json location
|
|
448
|
+
temp_manifest_path = pathlib.Path(manifest_temp_file.name)
|
|
449
|
+
temp_manifest_path.rename(manifest_path)
|
|
450
|
+
|
|
451
|
+
print(f"Created manifest.json with {len(manifest['files'])} files")
|
|
452
|
+
else:
|
|
453
|
+
# Validate existing manifest.json
|
|
454
|
+
try:
|
|
455
|
+
with open(manifest_path) as f:
|
|
456
|
+
manifest = json.load(f)
|
|
457
|
+
if "files" not in manifest:
|
|
458
|
+
print("Error: manifest.json is missing 'files' field")
|
|
459
|
+
sys.exit(1)
|
|
460
|
+
print(f"Found {len(manifest['files'])} files in manifest")
|
|
461
|
+
except json.JSONDecodeError as e:
|
|
462
|
+
print(f"Error: Invalid manifest.json format: {e}")
|
|
463
|
+
sys.exit(1)
|
|
464
|
+
except Exception as e:
|
|
465
|
+
print(f"Error: Could not read manifest.json: {e}")
|
|
466
|
+
sys.exit(1)
|
|
467
|
+
|
|
468
|
+
# Override description in zarr attrs if provided
|
|
469
|
+
if description is not None:
|
|
470
|
+
print(f"Setting description from command line argument")
|
|
471
|
+
import zarr
|
|
472
|
+
|
|
473
|
+
try:
|
|
474
|
+
zarr_group = zarr.open_group(str(zarr_dir), mode="r+")
|
|
475
|
+
zarr_group.attrs["description"] = description
|
|
476
|
+
except Exception as e:
|
|
477
|
+
print(f"Warning: Could not update description in zarr data: {e}")
|
|
478
|
+
|
|
479
|
+
# Upload the bundle
|
|
480
|
+
print(f"\nUploading figure with title: '{title}'")
|
|
481
|
+
if description:
|
|
482
|
+
print(f"Description: {description}")
|
|
483
|
+
|
|
484
|
+
try:
|
|
485
|
+
figure_url = _upload_bundle(
|
|
486
|
+
str(dir_pathlib),
|
|
487
|
+
api_key,
|
|
488
|
+
title=title,
|
|
489
|
+
ephemeral=False,
|
|
490
|
+
use_consolidated_metadata_only=True,
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
print(f"\n✓ Upload completed successfully!")
|
|
494
|
+
print(f"\nFigure URL: {figure_url}")
|
|
495
|
+
|
|
496
|
+
except Exception as e:
|
|
497
|
+
print(f"\nError during upload: {e}")
|
|
498
|
+
sys.exit(1)
|
|
499
|
+
|
|
500
|
+
|
|
351
501
|
def _old_revert_figure(
|
|
352
502
|
figure_url: str, api_key: str, admin_override: bool = False
|
|
353
503
|
) -> None:
|
|
@@ -627,6 +777,16 @@ def main():
|
|
|
627
777
|
"extensions", nargs="+", help="Extension package names to uninstall"
|
|
628
778
|
)
|
|
629
779
|
|
|
780
|
+
# Upload command
|
|
781
|
+
upload_parser = subparsers.add_parser(
|
|
782
|
+
"upload", help="Upload a saved figure directory to figpack"
|
|
783
|
+
)
|
|
784
|
+
upload_parser.add_argument("dir_path", help="Path to the figure directory")
|
|
785
|
+
upload_parser.add_argument("--title", required=True, help="Title for the figure")
|
|
786
|
+
upload_parser.add_argument(
|
|
787
|
+
"--description", help="Description for the figure (optional)"
|
|
788
|
+
)
|
|
789
|
+
|
|
630
790
|
args = parser.parse_args()
|
|
631
791
|
|
|
632
792
|
if args.command == "download":
|
|
@@ -641,6 +801,8 @@ def main():
|
|
|
641
801
|
patch_figure(args.figure_url, admin_override=args.admin_override)
|
|
642
802
|
elif args.command == "revert-patch-figure":
|
|
643
803
|
revert_figure(args.figure_url, admin_override=args.admin_override)
|
|
804
|
+
elif args.command == "upload":
|
|
805
|
+
upload_figure(args.dir_path, args.title, args.description)
|
|
644
806
|
elif args.command == "extensions":
|
|
645
807
|
handle_extensions_command(args)
|
|
646
808
|
else:
|
|
@@ -144,6 +144,11 @@ def _discover_required_extensions(view: FigpackView) -> List[str]:
|
|
|
144
144
|
if v.extension.name not in extension_names_discovered:
|
|
145
145
|
extension_names_discovered.add(v.extension.name)
|
|
146
146
|
extensions_discovered.append(v.extension)
|
|
147
|
+
if hasattr(v, "other_extensions"):
|
|
148
|
+
for ext in v.other_extensions:
|
|
149
|
+
if ext.name not in extension_names_discovered:
|
|
150
|
+
extension_names_discovered.add(ext.name)
|
|
151
|
+
extensions_discovered.append(ext)
|
|
147
152
|
|
|
148
153
|
# Recursively check all attributes that might contain child views
|
|
149
154
|
for attr_name in dir(v):
|