dcp/jnu
Jnu is the database connector in dcp-client. It gives programs, web pages and notebooks signed, permission-checked access to the data behind the DCP Scheduler, the Portal and the proxy key authority, without database credentials and without any server-side code of your own. The Portal’s own pages are built on it, and yours can be too.
Three things to know before the API:
Data is scoped by identity. You see your jobs, your Compute Groups, your workers, and a few public columns from other accounts. The signing key decides which account you are. See Identity and access.
Queries are
ormdbquery objects: a table, a prototype to match, and optional columns, ordering and paging. See Query model.Three services, each with its own tables: scheduler, portal and proxy keys.
Classes
First query
const jnu = require('dcp/jnu');
const wallet = require('dcp/wallet');
const db = await jnu.connect('scheduler', await wallet.get('id'));
const jobs = await db.select({
table: 'jobs',
prototype: { status: 'running' },
order: 'startTime',
desc: true,
limit: 20,
skip: 0,
});
console.log(jobs.rowCount, 'of', jobs.totalRowCount, 'running jobs');
for (let job = await jobs.getFirst(); job; job = await jobs.getNext())
console.log(
job.opaqueId,
job.name,
job.nextSliceNumber - 1,
'of',
job.lastSliceNumber,
'slices distributed',
);
In a browser, load dcp-client.js, set an identity, and the same calls work on dcp.jnu:
<script src="https://scheduler.distributed.computer/dcp-client/dcp-client.js"></script>
<script>
await dcp.identity.set('<api-key>');
const db = await dcp.jnu.connect('scheduler');
</script>
For pages that are mostly markup, the Jnu data-binding library renders tables and forms from <jnu-record-set> elements; see Building web apps with Jnu data binding.
What you can find out
A short map from questions to tables. Each table’s columns are on the data pages.
Question |
Where |
|---|---|
What jobs do I have, and what state are they in? |
|
How far along is a job? |
|
How big are my slices, and how long do they take? |
|
What’s the scheduler doing with my job? |
|
What am I paying? |
|
What are the results? |
|
Which groups is a job in? |
|
How busy is my Compute Group, and what did it earn? |
|
What are my workers, and are they alive? |
|
What keys exist for my account? |
|
Example: Job completion
A command-line program that reports how many slices of each of your jobs have finished. The identity that signs each query decides what you can see: the Scheduler returns only jobs whose owner is that account, so use the API key or id keystore that deployed the jobs. count() resolves with a plain number. The web version of this program, built from HTML attributes rather than query code, is in Building web apps with Jnu data binding.
'use strict';
/**
* completion.js - report how many slices of each of your jobs have finished.
*
* Usage: node completion.js [job-id]
* job-id optional opaqueId of one job; default is your 20 most recent jobs
*/
async function main() {
const wallet = require('dcp/wallet');
const jnu = require('dcp/jnu');
const opaqueId = process.argv[2];
const idKeystore = process.env.DCP_API_KEY
? await new wallet.Keystore(process.env.DCP_API_KEY, '')
: await wallet.get('id');
const db = await jnu.connect('scheduler', idKeystore);
const jobs = await db.select({
table: 'jobs',
prototype: opaqueId ? { opaqueId } : {},
order: 'startTime',
desc: true,
limit: 20,
});
console.log('\nJOB COMPLETION\n');
for (let job = await jobs.getFirst(); job; job = await jobs.getNext()) {
const total = job.lastSliceNumber ?? 0;
const completed = await db.count({
table: 'jobResults',
prototype: { jobId: job.id },
});
const pct =
total > 0 ? ((completed / total) * 100).toFixed(1) + '%' : 'N/A';
console.log(
` ${job.name ?? 'Unnamed Job'} (${job.opaqueId}) ${job.status}: ${completed}/${total} ${pct}`,
);
}
console.log('');
}
require('dcp-client').init().then(main).catch(console.error);
Current limitations
Everything in this list is expected to change. It was verified against the public scheduler on 2026-10-03; if that date is old, check before relying on it.
search()andisearch()return nothing; use thelikedescriptor in a prototype instead.groupCount()fails in the client; useselectDistinct()andcount().jobResultshas no timestamp, so throughput over time has to be sampled by the caller.jobFinDatareturned no rows for finished jobs; estimate spend from the offer and the completed count.A job’s slice price can’t be changed through Jnu; cancel and redeploy.
The market value behind
compute.marketValue()is a constant 0.001 DCC per slice rather than a computed rate.jobs_publicandcomputeGroups_publicaccept an empty prototype and then list every job or group on the scheduler.