The SDK you install #

Generated from tensorchain.cloud and tensorchain.connectors. Local(path) runs offline on one file; Client(url, api_key) runs the same methods against the hosted service. A refusal raises tensorchain.cloud.Refused with .code (the server's code) and .status (its HTTP status).

import tensorchain.cloud as tc
p = tc.Local("provenance.sqlite")    # or tc.Client("https://tensorchain.io", api_key)

add_source #

p.add_source(name)

Register a source you own (a folder, bucket, repo or crawl) by name. Refused exists if it is already registered.

audit #

p.audit()

One report of every source, dataset, model and revocation with its status, and your issuer's public key card.

dataset #

p.dataset(consumer, use, sources, cut=None)

Gate every source for (consumer, use), then attest a dataset over their current manifests; or raise Refused.

datasets #

p.datasets()

Every dataset with its consumer, use, sources and status (valid or revoked).

p.head(source)

The root of the newest manifest of source (None before the first ingest).

impact #

p.impact(source)

What revoking source reaches: its manifests, the datasets over it, the models trained on them.

ingest #

p.ingest(source, items, chunk=1000, names='plain')

Send items [name, sha256, bytes] as chained manifests; names="hash" sends sha256(name). Returns roots.

ingest_folder #

p.ingest_folder(source, path, state=None, chunk=1000, names='plain')

(no docstring)

ingest_items_new #

p.ingest_items_new(source, items, state, chunk=1000, names='plain')

Only the items not sent before (state: a JSON file of sent [name, sha256]); the state grows after a send.

license #

p.license(source, licensee, uses, days=365)

Licence a source you own to licensee (e.g. "agent:trainer") for uses (e.g. ["train"]) for days.

model #

p.model(dataset, weights_root_, run=None)

Attest a model (its weights by sha256) trained on dataset; run adds your own fields (round, config, ...).

models #

p.models()

Every model with its weights, dataset and state: usable, or revoked when anything it was built from is revoked.

revoke #

p.revoke(source=None, attestation=None, reason='')

Revoke a source you own, or one attestation (a manifest, a dataset, a model), with a reason. Deletes nothing.

sources #

p.sources()

Every registered source: its head manifest, manifest and licence counts, and whether it is revoked.

training #

p.training(consumer, use, sources, cut=None)

The gated dataset first (a refusal raises here, before the body runs); then run.model(weights).

verify #

p.verify(root)

Re-check one attestation: valid, revoked or invalid, with its reasons and claims.

weights_root #

tc.weights_root(path_or_root)

A weights file's sha256; a directory's: sha256 of the canonical sorted [path, sha256] list; a 64-hex root as is.

Connectors #

Each returns sorted items [name, sha256, bytes], the only thing that leaves your machine.

connectors.folder #

connectors.folder(path)

connectors.git #

connectors.git(repo, rev='HEAD')

connectors.s3 #

connectors.s3(bucket, prefix='', client=None)

connectors.huggingface #

connectors.huggingface(repo_id, repo_type='dataset', revision=None, client=None)