This release is a pre-release and may not be stable for production use.
portail
The framework a workspace web app is built on. An app serves ONE object — its workspace — behind a Flask page and is managed from the command line. portail holds everything that does not depend on what the workspace holds:
- serving in the foreground or detached (
--background), the port settled before anything starts, the browser opened once the server answers; stop/restart/listby the server's IDENTITY (its live/api/metaanswer), never by a port alone;- the page's shell:
/api/meta, the ⏻ and ↻ buttons, and every open page told when its server goes; - jobs: background work with its progress and a cooperative stop (docs/jobs.md);
- the panes' layout: every pane of a page in one layout of rows and columns, dragged to the left, right, top or bottom of another (docs/layout.md);
- the MCP server base (docs/mcp.md) and the filter language a records list is searched with (docs/query.md).
What each lifecycle command does, in user terms: docs/serving.md. Why it works this way: docs/architecture.md.
Install
pip install portail # serving, the CLI commands, the page's shell
pip install "portail[mcp]" # + the MCP server base
Quickstart: an app on portail
1. Say who the app is — AppSpec
from portail import AppSpec, Hooks
SPEC = AppSpec(
name="demoapp", # every message, file and log name: `demoapp stop`, demoapp.log
cli_module="demoapp.cli", # what `python -m` runs for a --background child and the page's ↻
default_port=8710,
hooks=Hooks(), # optional, see below
)
The per-user state (the server registry, the last served workspace) lives in ~/.demoapp unless state_folder
names another folder; environment variables are named through SPEC.env("continue_folder") →
DEMOAPP_CONTINUE_FOLDER.
2. Implement Served — the workspace as portail sees it
class DemoWorkspace:
def __init__(self, path: str = "", template: str = "", port: int = 8710) -> None:
self.host, self.port, self.path, self.template, self.title = "127.0.0.1", port, path, template, "workspace"
def state_dir(self) -> Path: ... # its folder (a never-saved one: a temp folder); cheap, never raises
def info(self) -> dict: # what /api/meta answers under "workspace"
return {"path": self.path, "template": self.template, "state_dir": str(self.state_dir()), "dirty": False}
path is the workspace's file (absolute, "" when never saved), template the type it was opened from ("" for
none). info()["dirty"] with a path makes ⏻ and ↻ ask before losing unsaved changes.
3. Add the lifecycle commands to the app's own CLI
from liquifai import LiquifyApp
from portail.cli import add_lifecycle_commands
app = LiquifyApp(name="demoapp", description="The demo workspace app.", strict_flags=True)
lifecycle = add_lifecycle_commands(
app,
SPEC,
open_file=open_file, # (absolute path) -> Served; raise a LiquifaiError for a file it refuses
open_empty=DemoWorkspace, # () -> Served
open_type=open_type, # (type name) -> Served; leave out for an app without types
type_names=lambda: ["classification", "detection"],
create_app=create_app, # (Server) -> Flask; leave out to serve the bare shell
)
if __name__ == "__main__":
app.run()
This registers demoapp [workspace.yaml] (the default command), demoapp workspace <type>, demoapp stop [target] [--all], demoapp restart [target] and demoapp list, with --auto-port, --port, --background/-b and
--browser always|new|never on the serving commands. strict_flags=True is the app's choice — and the recommended
one: a misspelled option is then refused instead of silently dropped.
An app that serves a folder says so — AppSpec(..., workspace="folder") — and its open_file is handed the
folder's absolute path. Nothing is read from the folder before it is served, so its port is the default one or
--port.
A serving option of the app's own (--notes-dir, say): the workspace carries it as options = {"notes_dir": "/n"}
and answers it under options in info(). The app registers open and restart itself, asks portail for the other
commands, and hands the option on:
lifecycle = add_lifecycle_commands(app, SPEC, open_file=open_folder, open_empty=open_here, commands=("stop", "list"))
@app.command(name="open", default=True, positionals=["folder"], short={"b": "background"})
def open_(folder: str = "", notes_dir: str = "", port: int = 0, background: bool = False) -> None:
lifecycle.open(folder, port=port, background=background, options={"notes_dir": notes_dir} if notes_dir else {})
open_file then receives it as a keyword argument (open_folder(path, notes_dir="/n")), a --background child is
started with --notes-dir /n, and a restart that names no option serves with the ones the running server has.
4. Mount the shell on the app's Flask app
from flask import Flask
from portail.serving import Server
from portail.web import mount_shell
def create_app(server: Server) -> Flask:
app = Flask("demoapp", static_folder=None)
@app.get("/")
def index():
return PAGE # the app's own page
return mount_shell(app, server) # AFTER the app's own "/" — the shell's minimal page only fills a gap
The page loads the shell with relative addresses and names where ⏻ and ↻ go:
<link rel="stylesheet" href="portail/shell.css">
<header id="top">…</header>
<script src="portail/shell.js"></script>
<script>Portail.start({ buttons: "#top" });</script>
Portail.beforeLeaving = async (what) => true lets the page ask its own question before ⏻ / ↻ (return false to
stay); Portail.toast is how a refusal is said. create_shell(server) is a Flask app holding only the shell.
Hooks
| hook | runs | for |
|---|---|---|
prepare(served) |
in the TERMINAL, before the server registers or a --background child starts |
checks the person must read, a page to build |
starting(served) |
in the serving process, before the page answers | startup jobs, a cleanup |
leaving(served) |
on every way out, after the open pages were told | keep unsaved work |
holds_work(folder) |
when a never-saved workspace's folder is looked at | whether a restart should continue it |
kept_until() |
in messages | how long such work is kept, in words |
continued(folder, template) |
on a restart that continues a never-saved workspace | open it from its folder |
A hook that fails is logged and serving goes on. Without continued a restart never continues a never-saved
workspace: it opens what it names.
For a Python caller
portail.serving.running_servers(spec) lists every server of the app that answers right now, lowest port first —
each entry carries host, port, label, identity, path, template, state_dir and pid.
portail.serving.post_json / get_json talk to one of them, with every failure one ServeError line.
Jobs, the MCP server base, the filter language, the protocols
- Jobs:
portail.jobs.Jobs().start(key, title, work)runswork(job)in a thread of its own; the work steps the job (job.step()), reads the stop between items (job.stop_asked, orjob.check_stop()), andJobs.list()is what the app's page polls. See docs/jobs.md. - MCP server base (
pip install portail[mcp]):portail.mcp.make_server(spec, instructions)andServerChoice(spec, start_hint=...)give an app tools that relay to its running page. The user picks the server — aportargument, a question to the user, or a kept "always" answer — and every failure answers in-band. See docs/mcp.md. - Filter language:
portail.query.parse(text, aliases=..., flags=...)readsclass = 7,class has 3, 7,snr 5..20,class != @pred, a name search, and the app's own flag words (flag_pairs("edited")). See docs/query.md. - Protocols:
portail.protocolsholds the structuralCanvas,Recording,RecordingsandOpenera domain package implements without importing the app.
License
PolyForm Noncommercial License 1.0.0 (the LICENSE file): free for personal, academic and other noncommercial use. Commercial use needs a separate licence from the author.
Metadata
Release files for portail 0.1.0a2
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 |
|---|---|---|---|---|
| portail-0.1.0a2.tar.gz | 161.6 kB | With provenance | Details for portail-0.1.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| portail-0.1.0a2-py3-none-any.whl | Python 3 | none | any | Details for portail-0.1.0a2-py3-none-any.whl |
Total release size: 244.5 kB
Release files / portail-0.1.0a2.tar.gz
| Download URL | portail-0.1.0a2.tar.gz |
|---|---|
| Size | 161.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ce25de433f475ed6e714703554b53d5a06cc0506230f8aa76f1155552e8e8dc
|
|
BLAKE2b-256 checksum How to use checksums |
2306be15515f13d7dfc24886edb7a66af06538672734e4359012cbbca554f548
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / portail-0.1.0a2-py3-none-any.whl
| Download URL | portail-0.1.0a2-py3-none-any.whl |
|---|---|
| Size | 82.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
890c040856bcfb182f92dae284479d507b8fa12fe099ee63c357681d2d51eb22
|
|
BLAKE2b-256 checksum How to use checksums |
cf813d57f67abe79af808b7c1297337ff28a59012768aac2b6dd91c06bd68df2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for portail 0.1.0a2
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for portail-0.1.0a2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA 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.