fabric ·nu.service

Plug a Python service into Nu.

You already have a Python class. Point Nu at it and its methods start behaving like the rest of your Nu program.

Point Nu at your service.

List the methods you want to reach. Give Nu the running instance. Now inside your Nu program, calling a method hits the real service and hands the result back.

Start with a plain Python class. Nothing special about it — it is the same object you already have.

Tell Nu which methods to expose. Each one gets a small tag that says how it behaves: this one just reads, this one changes something, this one runs and returns nothing.

Now anywhere in the program, call the method like a normal function. The result flows into your UI, your storage, or the next call — same as any other value in Nu.

calculator.py
python · 20 locpy
import nu
class Calculator:
def __init__(self): self.total = 0
def add(self, a, b): return a + b
def bump(self, by): self.total += by; return self.total
def reset(self): self.total = 0
class Calc(nu.Service):
add = nu.service.QueryRef.method()
bump = nu.service.ActionRef.method()
reset = nu.service.CommandRef.method()
# bind the Python target, then call methods like any other Ref
app = nu.With(
nu.service.bind(Calc, target=Calculator()),
body=nu.print(Calc.add(a=1, b=2)),
)
nu.run(app)

What you get out of it.

A few things that fall out once your object speaks Nu.

Your class stays your class.

No rewrite, no inheritance, no funny decorators on every method. You point Nu at what already works.

Sync or async, your call.

Write methods however you write them today. Nu runs sync programs and async programs the same way, and does the right thing with each method.

Plays with everything else.

A method result can feed a live UI, land in storage, or flow into the next call. It is a normal Nu value the moment you get it.

Try Nu.

One command gets you the wheel with every fabric. Then follow the movies tutorial to build a real app in an afternoon.

01 Install

pip install "nustack-py[all]"

02 Run the demo

nu demo movies

03 Build your app

Browse examples

Like what you see?

The project is young. Star it, join the room, watch what we ship next.