sailing Foudra MRP

Tools

Ready-made scripts that work with Foudra through its API, published at github.com/kalopa/foudra_tools. Use them as they are, or copy them as a starting point for your own. They are what we use at Kalopa Robotics, where Foudra began.

Each is Python, standard library only: nothing to install beyond Python 3.8 or later. They read the same two variables as the examples in this manual:

export FOUDRA_URL=https://acme.foudra.com
export FOUDRA_API_KEY=fdr_…

Every script that changes anything takes --dry-run, which says what it would do and does nothing; run that first. --help is each one's manual.

foudra.py

A small client the other scripts share, and the easiest way to start your own. Copy the file beside your script:

from foudra import Foudra, FoudraError

api = Foudra.from_env()

for part in api.every("/api/parts", category="504"):          # every page
    print(part["part_number"], part["name"])

part = api.find_part("504-00000017-00")
api.upload(f"/api/parts/{part['id']}/documents", "mount_COREONE.bgcode", type="gcode")

for doc in api.get(f"/api/parts/{part['id']}/documents")["data"]:
    if doc["printer_model"] == "COREONE":
        api.download(doc["url"], "job.bgcode")                   # returns the SHA-256

It sends the key, walks paged lists, uploads and streams files, turns a refusal into a FoudraError carrying Foudra's own message, and retries a request that failed on the way only when that is safe: a GET, PUT or DELETE, or a POST with an Idempotency-Key.

The scripts

Script What it does
import-digikey.py Brings in DigiKey order exports: refreshes prices of parts already sourced from DigiKey, matches resistors and capacitors to existing parts by value, creates the rest, records DigiKey as a source, and with --po raises a draft purchase order for the whole file
service-order.py Raises a work order for a service on a vessel, labelled with the vessel's id, safely: running it twice the same day raises one order
sync-prints.py Keeps a category of 3D-printed parts in step with a folder of sliced prints: a part per print, the filament on its BOM at the sliced weight, a Print routing step, and its render as the image

The last two are shaped to the way Kalopa works (boats, a Prusa print farm), and are there to show how a real integration goes about it.

Contributing

Found a bug, or written something others could use? Open an issue or a pull request on the repository.