Skip to main content

Spotfire Community tools for working with the Spotfire Library API and DXP files.

Project description

Spotfire Community

Tools for working with the Spotfire Library REST API (v2) and DXP files. The repo includes a production-ready Python client, DXP utilities, a FastAPI mock server for tests, and a uv-powered workflow.

What’s inside

  • Library client: upload to/create/delete in the Spotfire Library
  • DXP helpers: unzip, inspect, and repackage DXP artifacts
  • Mock Library v2 API (FastAPI): deterministic tests without a real server
  • uv environment: fast resolution, lockfile, and “run” for commands

Installation (uv)

uv sync --dev

Python: see requires-python in pyproject.toml (3.13+).

Usage

Library client

from spotfire_community import LibraryClient
from spotfire_community.library.models import ItemType

client = LibraryClient(
	spotfire_url="https://your-spotfire-host",  # e.g., https://dev.spotfire.com
	client_id="YOUR_CLIENT_ID",
	client_secret="YOUR_CLIENT_SECRET",
)

file_id = client.upload_file(
	data=b"...bytes...",            # upload raw content
	path="/Samples/Doc1",           # library path
	item_type=ItemType.DXP,
	description="Uploaded via LibraryClient",
	overwrite=False,
)
print("uploaded:", file_id)

DXP utilities

from spotfire_community import Dxp

dxp = Dxp("/path/to/Analysis.dxp")
print(dxp.get_all_files())
zip_bytes = dxp.get_zip_folder_in_memory()  # BytesIO

Mock Library v2 API and tests

Mock endpoints implemented in src/mock_spotfire/library_v2/:

  • Router and handlers: src/mock_spotfire/library_v2/paths.py
  • Models: src/mock_spotfire/library_v2/models.py
  • Errors: src/mock_spotfire/library_v2/errors.py
  • In-memory state: src/mock_spotfire/library_v2/state.py

Endpoints:

  • POST /spotfire/oauth2/token
  • GET/POST /spotfire/api/rest/library/v2/items
  • DELETE /spotfire/api/rest/library/v2/items/{id}
  • POST /spotfire/api/rest/library/v2/upload
  • POST /spotfire/api/rest/library/v2/upload/{jobId}

Tests use fastapi.testclient.TestClient and monkeypatch requests.Session so the client talks to the mock app in‑memory. See tests/library/upload/*.py.

Run tests:

uv run -m pytest -q

Dev Container (VS Code)

This repo ships a devcontainer for a consistent environment (Debian 12 + Python 3.13 + uv).

What you get

  • Python 3.13 base image
  • uv installed by post-create script
  • .venv virtual environment managed by uv
  • Extensions: Python, TOML

Open it

  1. Install “Dev Containers” in VS Code.
  2. Open the repo folder and choose “Reopen in Container”.
  3. Wait for the post-create to finish; then run:
uv sync --dev
uvx pyright
uvx ruff format --check .
uv run -m pytest -q

Notes

  • The container uses the vscode user and exposes WORKSPACE_PATH.
  • After changing dependencies, run uv sync again.
  • If uv is not found, ensure it’s on PATH or re-run the post-create.

CI

GitHub Actions runs lint, type‑check, and tests. See .github/workflows/ci.yaml.

License

Open source. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spotfire_community-0.1.1.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spotfire_community-0.1.1-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file spotfire_community-0.1.1.tar.gz.

File metadata

  • Download URL: spotfire_community-0.1.1.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for spotfire_community-0.1.1.tar.gz
Algorithm Hash digest
SHA256 38efac7d4c48f5526c84b1a4896c48ece33d2e9d04fe1023e0c312e959f9cc68
MD5 57b7a4f7c3c682be05824f62eb191530
BLAKE2b-256 0a1d660c5c0b04bc61071ca7b681938bde7b266c14011fc1471c21a0e8374b06

See more details on using hashes here.

File details

Details for the file spotfire_community-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for spotfire_community-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a10cceafb85b287a36a9c51dfda5e200807c99438a3e9f55975dd0282d6b451
MD5 c101bca5a4d6c5e06155ec39ad59785a
BLAKE2b-256 e4839bd6af4412c92b1ee7c9a7eca0a31574d2eb68d59590ff097a32626e883a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page