Skip to content

vedicreader/vercello

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vercello

Deploy serverless apps to Vercel, use Vercel Blob storage, and cache functions and methods in the Vercel Runtime Cache — all from Python. The Vercel sibling of vpseasy.

Install

pip install vercello
export VERCEL_TOKEN=your_token            # required for deploys
export BLOB_READ_WRITE_TOKEN=your_token   # required for Blob

The @cached decorator

Memoize any function or method in the Vercel Runtime Cache. On Vercel, entries persist across serverless invocations and deployments; locally it transparently falls back to an in-process cache, so dev behaves like prod. Sync and async functions both work, values are pickled (FastHTML FT trees cache fine), and tags give you bulk invalidation.

from vercello.core import *

@cached                        # bare — 1h ttl
def expensive(x): ...

@cached(ttl=60, tags=['blog'])  # parametrized
def render_post(slug): ...

class Post:
    def __cache_key__(self): return self.slug   # equal objects share entries
    @cached(ttl=3600, tags=['blog'])
    def render(self, width): ...

expire(render_post, 'hello-world')   # drop one entry
expire_tag('blog')                   # drop every tagged entry

Set VERCELLO_NOCACHE=1 to bypass every @cached at once.

Blob

r = blob_put('avatars/me.png', Path('me.png'))   # AttrDict(url, download_url, pathname, ...)
data = blob_get(r.url)
blob_ls(prefix='avatars/')
blob_rm(r.url)

Deploy

vercel_deploy is idempotent: ensure project → upsert env vars → upload files → create deployment → wait until READY.

vercel_app('.')            # scaffold requirements.txt + vercel.json for an ASGI app
r = vercel_deploy('myapp', '.', env=dict(MODE='production'))
print(f'deployed: {r.url}')   # AttrDict(url, name, id)

Lower-level pieces are exposed too: Vercel (projects, env, deployments), collect_files (include/exclude filtering with sha1 digests), and wait_ready (deployment polling).

About

Vercel deployments made easy

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors