Skip to main content

The Python framework for Data Applications

Project description

Plateforme

Plateforme Core - OSS (alpha release)

ci pypi downloads versions license

Plateforme enables you to build and deploy modern data-driven applications and services in seconds with the power of SQLAlchemy, Pydantic, and FastAPI.

Help

See the documentation for more details.

Installation

Install using pip install -U plateforme or conda install plateforme -c conda-forge.

For more details and advanced installation options, see the installation guide from the official documentation site.

A basic example

Create a simple application

from typing import Self

from plateforme import Plateforme
from plateforme.api import route
from plateforme.resources import ConfigDict, CRUDResource, Field

app = Plateforme(debug=True, database_engines='plateforme.db')

class Rocket(CRUDResource):
    code: str = Field(unique=True)
    name: str
    parts: list['RocketPart'] = Field(default_factory=list)
    launched: bool = False

    @route.post()
    async def launch(self) -> Self:
        self.launched = True
        return self

class RocketPart(CRUDResource):
    __config__ = ConfigDict(indexes=[{'rocket', 'code'}])
    rocket: Rocket
    code: str
    quantity: int

Validate and use data

some_data = {
    'code': 'FAL-9',
    'name': 'Falcon 9',
    'parts': [
        {'code': 'dragon', 'quantity': 1},
        {'code': 'raptor', 'quantity': 9},
        {'code': 'tank', 'quantity': 1},
    ],
}

rocket = Rocket.resource_validate(some_data)
print(repr(rocket))
#> Rocket(code='FAL-9')

print(repr(rocket.parts[0].code))
#> 'dragon'

Persist data

# Create the database schema
app.metadata.create_all()

# Persist the data
with app.session() as session:
    session.add(rocket)
    session.commit()

# Query the data
with app.session() as session:
    rocket = session.query(Rocket).filter_by(code='FAL-9').one()

print(repr(rocket))
#> Rocket(id=1, code='FAL-9')

Run the application

uvicorn main:app

Play with the API

Use the built-in CRUD and query engine

With the built-in CRUD and query engine, you can easily create, read, update, and delete resources. The following query finds all parts in rocket #1 whose part codes contain the sequence ra.

GET http://localhost:8000/rockets/1/parts?.code=like~*ra* HTTP/1.1
[
  {
    "id": 1,
    "type": "rocket_part",
    "code": "dragon",
    "quantity": 1
  },
  {
    "id": 2,
    "type": "rocket_part",
    "code": "raptor",
    "quantity": 9
  }
]

Use custom routes

You can also define custom routes to perform more complex operations. The following request launches rocket #1 and persists in the database the launched flag to true.

POST http://localhost:8000/rockets/1/launch HTTP/1.1
{
  "id": 1,
  "type": "rocket",
  "code": "FAL-9",
  "name": "Falcon 9",
  "parts": [
    ...
  ],
  "launched": true
}

Use the built-in CLI

Plateforme comes with a built-in CLI to help you automate common tasks. For instance, the following commands initialize a new project, build it, and start the server.

# Initialize the project
plateforme init

# Build the project
plateforme build

# Start the server
plateforme start --reload

For detailed documentation and more examples, see the official documentation.

Contributing

For guidance on setting up a development environment and how to make a contribution to Plateforme, read the contributing guidelines from the official documentation site.

Reporting a security vulnerability

See our security policy.

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

plateforme-0.1.0a1.tar.gz (320.2 kB view details)

Uploaded Source

Built Distribution

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

plateforme-0.1.0a1-py3-none-any.whl (399.0 kB view details)

Uploaded Python 3

File details

Details for the file plateforme-0.1.0a1.tar.gz.

File metadata

  • Download URL: plateforme-0.1.0a1.tar.gz
  • Upload date:
  • Size: 320.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for plateforme-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 5292763cc6800f868ac406a79e06bf18d3325981c5991db97b222200b7311a05
MD5 a8aa675fe8abecaccf6168b821b697ef
BLAKE2b-256 fdfc5e33bb93331c005fa8785abf84577a8401619bd4c1f224ea055c01638cea

See more details on using hashes here.

File details

Details for the file plateforme-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: plateforme-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 399.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for plateforme-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 934a8e2d7cf47717f2f135767b9165f2aa1036782234999e8a17e54fa6e4c259
MD5 16755c6989bc24a857e93197ce39ec2f
BLAKE2b-256 e6384a0ff99d43867264fac44b346383fe85b8839cc6005c231f5bebc44d2982

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