Skip to main content

No project description provided

Project description

spork

PyPI - Version

PyPI - Python Version

Exposing simple ways to render pydantic models in notebooks and other interactive computing environments.


Table of Contents


Installation

pip install spork

Background

I created this module because I wanted a simple way to describe how to render pydantic models, especially when streaming in data to update a model. Wouldn't it be nice to see a visual display of the model as it's being updated?

To explore this space a bit, I've created a ViewModel and an AutoViewModel. This lets you update fields and have them update within the notebook.

Usage

You can use existing pydantic models or create new ones by inheriting from AutoViewModel:

from spork import AutoViewModel
from pydantic import BaseModel

class Record(BaseModel):
    name: str
    age: int

class RecordView(Record, AutoViewModel):
    def render(self):
        return f"<b>{self.name}</b> is {self.age} years old."


rv = RecordView(name="Kyle", age=35)
rv.display()

When using an AutoViewModel, you can update the fields and the view will update wherever you ran .display()

rv.age = 101

License

spork is distributed under the terms of the MIT 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

spork-1.0.0.tar.gz (7.3 kB view hashes)

Uploaded Source

Built Distribution

spork-1.0.0-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

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