@nosana/node 1.1.92-rc → 1.1.93-rc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.env +1 -1
- package/dist/package.json +1 -1
- package/dist/packages/job-runtime/src/main.js +12 -0
- package/dist/packages/job-runtime/src/marketResources.d.ts +12 -0
- package/dist/packages/job-runtime/src/marketResources.js +8 -0
- package/dist/src/NodeManager/node/Node.js +6 -0
- package/dist/src/NodeManager/node/job/ContainerJobRuntime.d.ts +6 -0
- package/dist/src/NodeManager/node/job/ContainerJobRuntime.js +43 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/.env
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
BACKEND_SOLANA_ADDRESS=7rFPFnxjXHC2sfDy3qrDa9pEb4j49oivMuV7e8sYDPmB
|
|
2
2
|
FRP_SERVER_IMAGE=registry.hub.docker.com/nosana/frpc:v1.0.45
|
|
3
|
-
JOB_RUNTIME_IMAGE="nosana/job-runtime:v0.3.
|
|
3
|
+
JOB_RUNTIME_IMAGE="nosana/job-runtime:v0.3.5"
|
|
4
4
|
GOLDEN_VM_IMAGE=https://models.nosana.io/golden-vm/cuda13-580-dev-2/golden-vm-cuda13-580-dev-2.qcow2
|
|
5
5
|
RESOURCE_MANAGER_IMAGE=registry.hub.docker.com/nosana/resource-manager:v1.1.19
|
|
6
6
|
FRP_SERVER_PORT=7000
|
package/dist/package.json
CHANGED
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
* stats sampling depends on, and that it runs unprivileged, and prints what
|
|
9
9
|
* it found. Exit code 0 means the image is fit to host the sidecar on this
|
|
10
10
|
* machine.
|
|
11
|
+
*
|
|
12
|
+
* With `--market-resources` it fetches a market's required images and resources (in
|
|
13
|
+
* MARKET_RESOURCES) where it runs jobs, for the node (see marketResources.ts).
|
|
11
14
|
*/
|
|
12
15
|
import { execFile } from 'child_process';
|
|
13
16
|
import { promisify } from 'util';
|
|
14
17
|
import { readJobRuntimeServerConfig } from './config.js';
|
|
18
|
+
import { fetchMarketResources } from './marketResources.js';
|
|
15
19
|
import { runJob } from './runtime/runJob.js';
|
|
16
20
|
const run = promisify(execFile);
|
|
17
21
|
async function probeNvidiaSmi() {
|
|
@@ -63,6 +67,14 @@ async function serve() {
|
|
|
63
67
|
if (process.argv.includes('--probe')) {
|
|
64
68
|
await probe();
|
|
65
69
|
}
|
|
70
|
+
else if (process.argv.includes('--market-resources')) {
|
|
71
|
+
await fetchMarketResources(JSON.parse(process.env.MARKET_RESOURCES ?? '{"images":[],"resources":[]}'))
|
|
72
|
+
.then(() => process.exit(0))
|
|
73
|
+
.catch((error) => {
|
|
74
|
+
console.error(error instanceof Error ? error.message : error);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
66
78
|
else {
|
|
67
79
|
await serve().catch((error) => {
|
|
68
80
|
console.error(error instanceof Error ? error.message : error);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RequiredResource } from '@nosana/kit';
|
|
2
|
+
/** A market's required images and resources, as the node hands them (MARKET_RESOURCES). */
|
|
3
|
+
export type MarketResources = {
|
|
4
|
+
images: string[];
|
|
5
|
+
resources: RequiredResource[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Fetches a market's required images and resources where this runtime runs its jobs, ahead of
|
|
9
|
+
* them (`--market-resources`). Here jobs run on the node's own host, whose node fetches them:
|
|
10
|
+
* nothing to do. A runtime that runs jobs elsewhere fetches them there.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchMarketResources(market: MarketResources): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches a market's required images and resources where this runtime runs its jobs, ahead of
|
|
3
|
+
* them (`--market-resources`). Here jobs run on the node's own host, whose node fetches them:
|
|
4
|
+
* nothing to do. A runtime that runs jobs elsewhere fetches them there.
|
|
5
|
+
*/
|
|
6
|
+
export async function fetchMarketResources(market) {
|
|
7
|
+
console.log(`${market.images.length} images and ${market.resources.length} resources: fetched by the node`);
|
|
8
|
+
}
|
|
@@ -3,6 +3,7 @@ import { MarketHandler } from './market/marketHandler.js';
|
|
|
3
3
|
import { NodeNotRegisteredError } from '../errors/NodeNotRegisteredError.js';
|
|
4
4
|
import { RunHandler } from './run/runHandler.js';
|
|
5
5
|
import { JobHandler } from './job/jobHandler.js';
|
|
6
|
+
import { ContainerJobRuntime } from './job/ContainerJobRuntime.js';
|
|
6
7
|
import { selectJobRuntimeEnvironment } from './job/selectJobRuntimeEnvironment.js';
|
|
7
8
|
import { DB } from '../db/index.js';
|
|
8
9
|
import { Provider } from '../provider/Provider.js';
|
|
@@ -155,6 +156,11 @@ export class BasicNode {
|
|
|
155
156
|
await this.jobHandler.removeLeftoverJobs(liveJob);
|
|
156
157
|
}
|
|
157
158
|
async fetchMarketResources(market) {
|
|
159
|
+
// For a job runtime that runs its jobs elsewhere: it fetches them there instead.
|
|
160
|
+
if (process.env.MARKET_RESOURCES_IN_JOB_RUNTIME === 'true' &&
|
|
161
|
+
this.environment instanceof ContainerJobRuntime) {
|
|
162
|
+
return this.environment.fetchMarketResources(market.address.toString());
|
|
163
|
+
}
|
|
158
164
|
await this.resourceManager.fetchMarketRequiredResources(market);
|
|
159
165
|
}
|
|
160
166
|
/**
|
|
@@ -111,6 +111,12 @@ export declare class ContainerJobRuntime implements JobRuntimeEnvironment {
|
|
|
111
111
|
* runtime cannot give it.
|
|
112
112
|
*/
|
|
113
113
|
output(jobAddress: string, read: (stream: 'stdout' | 'stderr', text: string) => void): Promise<(() => void) | undefined>;
|
|
114
|
+
/**
|
|
115
|
+
* Has the job runtime fetch the market's required images and resources itself, in a one-shot
|
|
116
|
+
* container (`--market-resources`), for a runtime that runs its jobs elsewhere: the node then
|
|
117
|
+
* fetches none of them (MARKET_RESOURCES_IN_JOB_RUNTIME).
|
|
118
|
+
*/
|
|
119
|
+
fetchMarketResources(market: string): Promise<void>;
|
|
114
120
|
/**
|
|
115
121
|
* Pulls the sidecar image `.env` names and records it in the image cache,
|
|
116
122
|
* where the resync between jobs ages out what goes unused, so a bump's
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { configs } from '../../configs/configs.js';
|
|
4
|
+
import { normalizeMarketImages, normalizeMarketResources, } from '../resource/resourceManager.js';
|
|
5
|
+
import { HostManager } from '../market/hostManager.js';
|
|
4
6
|
import { applyLoggingProxyToClass } from '../../../../packages/common/src/index.js';
|
|
5
7
|
import { parseLogFrames, } from '../../../../packages/container-orchestrator/src/index.js';
|
|
6
8
|
import { JOB_LABEL, NODE_LABEL, SERVICE_LABEL, } from '../../../../packages/container-orchestrator/src/index.js';
|
|
@@ -368,6 +370,47 @@ export class ContainerJobRuntime {
|
|
|
368
370
|
return undefined;
|
|
369
371
|
}
|
|
370
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Has the job runtime fetch the market's required images and resources itself, in a one-shot
|
|
375
|
+
* container (`--market-resources`), for a runtime that runs its jobs elsewhere: the node then
|
|
376
|
+
* fetches none of them (MARKET_RESOURCES_IN_JOB_RUNTIME).
|
|
377
|
+
*/
|
|
378
|
+
async fetchMarketResources(market) {
|
|
379
|
+
const data = await HostManager.getMarketRequiredResources(market);
|
|
380
|
+
if (!data)
|
|
381
|
+
return;
|
|
382
|
+
const { jobRuntime, frp, network } = configs();
|
|
383
|
+
const name = `${JOB_RUNTIME_CONTAINER_PREFIX}market-resources`;
|
|
384
|
+
await this.containerOrchestration.stopAndDeleteContainer(name);
|
|
385
|
+
await this.containerOrchestration.pullImage(jobRuntime.containerImage);
|
|
386
|
+
const container = await this.containerOrchestration.runFlowContainer(jobRuntime.containerImage, {
|
|
387
|
+
name,
|
|
388
|
+
cmd: ['--market-resources'],
|
|
389
|
+
env: {
|
|
390
|
+
...buildJobRuntimeEnv({
|
|
391
|
+
jobAddress: market,
|
|
392
|
+
kind: 'inline',
|
|
393
|
+
consoleOutput: 'text',
|
|
394
|
+
nodeAddress: nodeAddress(),
|
|
395
|
+
network,
|
|
396
|
+
rpc: getKit().config.solana.rpcEndpoint,
|
|
397
|
+
frp,
|
|
398
|
+
resourceManagerImage: this.resourceManager.volumes.resourceManagerImage,
|
|
399
|
+
nodeVersion: pkg.version,
|
|
400
|
+
}),
|
|
401
|
+
MARKET_RESOURCES: JSON.stringify({
|
|
402
|
+
images: normalizeMarketImages(data.required_images).map((image) => image.name),
|
|
403
|
+
resources: normalizeMarketResources(data.required_remote_resources),
|
|
404
|
+
}),
|
|
405
|
+
},
|
|
406
|
+
labels: { [NODE_LABEL]: nodeAddress(), [SERVICE_LABEL]: 'job-runtime-market-resources' },
|
|
407
|
+
});
|
|
408
|
+
const { StatusCode } = await container.wait({ condition: 'not-running' });
|
|
409
|
+
await this.containerOrchestration.stopAndDeleteContainer(name);
|
|
410
|
+
if (StatusCode !== 0) {
|
|
411
|
+
throw new Error(`The job runtime could not fetch the market's resources (exited ${StatusCode})`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
371
414
|
/**
|
|
372
415
|
* Pulls the sidecar image `.env` names and records it in the image cache,
|
|
373
416
|
* where the resync between jobs ages out what goes unused, so a bump's
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosana/node",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.93-rc",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@nosana/node",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.93-rc",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"workspaces": [
|
|
12
12
|
"packages/*"
|