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
nameis 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.2rc1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mpships_infra-0.0.2rc1.tar.gz | 19.5 kB | Without provenance | Details for mpships_infra-0.0.2rc1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mpships_infra-0.0.2rc1-py3-none-any.whl | Python 3 | none | any | Details for mpships_infra-0.0.2rc1-py3-none-any.whl |
Total release size: 30.2 kB
Release files / mpships_infra-0.0.2rc1.tar.gz
| Download URL | mpships_infra-0.0.2rc1.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e36d137896da32a28c34d3e29f9cacefe16c8c526a9010d96aab65ba32083b0
|
|
BLAKE2b-256 checksum How to use checksums |
ad88fa669c080e98b9676e6afc050c212cd4dd702b4544bdc292dc4363ac3bdd
|
| 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.2rc1-py3-none-any.whl
| Download URL | mpships_infra-0.0.2rc1-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
44949225f3527e1767c963dac31d7179e565af1750dc17af32c102c03607fa8c
|
|
BLAKE2b-256 checksum How to use checksums |
88a688f902e88fc4c9e697fe41b83c006b34adafe1cf1c41e23357be7e758c8f
|
| 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.2rc1
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.