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 ormdb query 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.

Functions

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?

jobs: status, startTime, endTime, slice counters, offer per slice.

How far along is a job?

count of jobResults for the job; activeSlices for what’s out on workers; jobs.nextSliceNumber for what’s been handed out.

How big are my slices, and how long do they take?

jobPerfData: moving averages of CPU time, GPU time, bytes in and out, with variances.

What’s the scheduler doing with my job?

jobPerfData: taskDistribution, taskCount, returnCount, retaskedCount; workRejectHistory for why workers refused it.

What am I paying?

jobs.absoluteSlicePayment and mvMultSlicePayment; jobFinData for paid totals and escrow.

What are the results?

jobResults.value, a data: URI or a URL per slice.

Which groups is a job in?

computeGroupsJobs_byJob.

How busy is my Compute Group, and what did it earn?

computeGroupJobPeriodStats: per job, per period, requests, slices tasked, earnings and compute totals.

What are my workers, and are they alive?

workerSnapshot: hardware, versions, target utilization, last start, last task, earnings.

What keys exist for my account?

proxyAuth in pxAuth, from a Portal session.

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() and isearch() return nothing; use the like descriptor in a prototype instead.

  • groupCount() fails in the client; use selectDistinct() and count().

  • jobResults has no timestamp, so throughput over time has to be sampled by the caller.

  • jobFinData returned 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_public and computeGroups_public accept an empty prototype and then list every job or group on the scheduler.