Skip to main content

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

Project description

Spotfire Community

Spotfire Community is a Python package for working with the Spotfire Library REST API (v2) and DXP files.

It also includes an Automation Services client for starting and monitoring jobs.

Installation

Install from PyPI (recommended):

Using pip:

pip install spotfire-community

Using uv:

uv add spotfire-community

Python 3.10+ is required (see pyproject.toml).

Usage

Library Client

Upload, create, and delete items in the Spotfire Library:

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)

Automation Services Client

Start and monitor Automation Services jobs:

from spotfire_community.automation_services import (
	AutomationServicesClient,
	JobDefinition,
	OpenAnalysisTask,
)

client = AutomationServicesClient(
	spotfire_url="https://your-spotfire-host",
	client_id="YOUR_CLIENT_ID",
	client_secret="YOUR_CLIENT_SECRET",
)

# Build a minimal job definition
job_def = JobDefinition()
job_def.add_task(OpenAnalysisTask(path="/Samples/Analysis.dxp"))

# Start and wait for completion
status = client.start_job_definition_and_wait(job_def, poll_interval=1, timeout=120)
print("status:", status)

DXP Utilities

Inspect and repackage DXP files:

from spotfire_community import Dxp


print(dxp.get_all_files())
zip_bytes = dxp.get_zip_folder_in_memory()  # BytesIO

Development

For development and testing (requires uv):

uv sync --dev

Mock APIs and Tests

The repo includes a FastAPI mock server for deterministic tests (not included in the PyPI package):

  • Router and handlers: src/mock_spotfire/library_v2/routes/
  • 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

Automation Services (v1) mock:

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

Endpoints:

  • Core: POST /spotfire/oauth2/token
  • Library v2: GET/POST /spotfire/api/rest/library/v2/items
  • Library v2: DELETE /spotfire/api/rest/library/v2/items/{id}
  • Library v2: POST /spotfire/api/rest/library/v2/upload
  • Library v2: POST /spotfire/api/rest/library/v2/upload/{jobId}
  • Automation Services v1: GET /spotfire/api/rest/as/job/status/{job_id}
  • Automation Services v1: POST /spotfire/api/rest/as/job/abort/{job_id}
  • Automation Services v1: POST /spotfire/api/rest/as/job/start-content
  • Automation Services v1: POST /spotfire/api/rest/as/job/start-library

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.4.1.tar.gz (26.4 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.4.1-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for spotfire_community-0.4.1.tar.gz
Algorithm Hash digest
SHA256 b130ffc63c40bbea99dbbefafb11708ed90aec2f4dd4a8abd0b763584405c540
MD5 f38c480717eec53aa5e87d7db61da156
BLAKE2b-256 b3c2189b6b97fa27d18d41266a4103c88f2c0334e3c8441654f13082c13fc9e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spotfire_community-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7489105de3c499b92f295c871d135f4bfb5a7a19b1e961c467cd1ddbd2ded2ac
MD5 3626f609d45b78e2a7500c4d90b9426e
BLAKE2b-256 cdeafbdabe365d01f328e94e9fb99ee4a7c3de0b5c79166a2e93745dc32bd007

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