Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

mpships-infra

Core infrastructure for MPShips, the contributed-app platform for Materials Project. It provides the base class that contributed apps extend, a shared client for Materials Project data, and the app factory that wires everything together.

What's in this package

Piece Purpose
MPShipsApp Base class for every contributed app. Contributors fill in three hooks.
get_rester() The one way an app gets a Materials Project API client.

Installation

pip install mpships-infra

MPShipsApp

MPShipsApp extends MPComponent (from crystal_toolkit) and is an abstract base class. A contributed app is a subclass that implements the hooks below. The framework calls the hooks for you, so the subclass never calls any of them directly, and none of them needs a super() call.

from dash import html
from mpships_infra import MPShipsApp


class MyApp(MPShipsApp):
    def ships_setup(self, *args, **kwargs):      # optional
        self.greeting = "Hello"

    def ships_layout(self):                      # required
        return html.Div(f"{self.greeting}")

    def ships_callbacks(self, app, cache):       # optional
        pass

Hooks

Hook Required? Called Purpose
ships_setup(*args, **kwargs) No At the end of __init__ Set instance state
ships_layout() Yes (@abstractmethod) Each time the page renders Return the app's Dash layout
ships_callbacks(app, cache) No Once per app class, after the page layout exists Register callbacks with @app.callback

A subclass that omits ships_layout can't be instantiated, and Python raises a TypeError at load time.

What subclasses must not override

__init__, get_layout, and generate_callbacks carry framework behavior. Overriding them without calling the base implementation silently breaks registration or routing, which is why the contributor-facing surface is limited to the three ships_ hooks.

Metadata properties

These read-only properties describe the app in navigation and documentation views:

name, description, long_description, url, author, category, credits, icon, dois, docs_url, external_links, contributed, contributed_app

  • name is the class name.

Because they are properties without setters, assigning to one (for example self.name = "x" in ships_setup) raises an AttributeError. Use a different attribute name for custom values.

get_rester()

get_rester() returns the Materials Project API client that apps use to fetch data. Apps call it instead of constructing their own MPRester, so the platform controls how the client is configured in one place.

Setup

Set your Materials Project API key as an environment variable before running your app:

export MP_API_KEY=<YOUR_API_KEY>

The export applies to the current terminal session. Add it to your shell profile (for example ~/.zshrc) to keep it across sessions.

Usage

from mpships_infra import get_rester

docs = get_rester().materials.summary.search(
    chemsys=["Au"], fields=["material_id", "has_props"]
)
from mpships_infra import get_rester

contribs_docs = mpr.contribs.query_contributions(
    query={
        "project": "<YOUR_PROJECT>",
    }
)

See the Materials Project API documentation for the available endpoints.

Metadata

Release files for mpships-infra 0.0.2rc2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpships-infra 0.0.2rc2
File Size Uploaded Provenance Actions
mpships_infra-0.0.2rc2.tar.gz 19.5 kB Without provenance Details for mpships_infra-0.0.2rc2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mpships-infra 0.0.2rc2
File Interpreter ABI Platform Actions
mpships_infra-0.0.2rc2-py3-none-any.whl Python 3 none any Details for mpships_infra-0.0.2rc2-py3-none-any.whl

Total release size: 30.2 kB

Release files / mpships_infra-0.0.2rc2.tar.gz

Download URL mpships_infra-0.0.2rc2.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2dd15701783aeff89b274c87d43eddfa7ccf93a0152075bb9b05d748ecdfc3c1
BLAKE2b-256 checksum
How to use checksums
adacdca83d407cb817030f46dab44d7632f22d5abaaacc3678f5e3c6cd443278
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mpships_infra-0.0.2rc2-py3-none-any.whl

Download URL mpships_infra-0.0.2rc2-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d65699203494ed3eeff697fe620b6835a367cb7d2e5b17f8a4d0ae9e2629d3ca
BLAKE2b-256 checksum
How to use checksums
ddfea70827aabc11e5dbb4d17b916baf2d82d9c163da41d28f319153dece8560
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for mpships-infra 0.0.2rc2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page