@nosana/node 1.1.73-dev.mr80.17351441846 → 1.1.73
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 +9 -10
- package/dist/packages/container-orchestrator/src/docker/createDockerRunOptions.d.ts +1 -1
- package/dist/packages/container-orchestrator/src/docker/dockerExtended/index.d.ts +1 -1
- package/dist/packages/container-orchestrator/src/docker/index.d.ts +1 -3
- package/dist/packages/container-orchestrator/src/docker/index.js +21 -16
- package/dist/packages/container-orchestrator/src/hooks.d.ts +2 -9
- package/dist/packages/container-orchestrator/src/hooks.js +0 -5
- package/dist/packages/container-orchestrator/src/index.d.ts +0 -1
- package/dist/packages/container-orchestrator/src/index.js +0 -1
- package/dist/packages/container-orchestrator/src/interface.d.ts +1 -4
- package/dist/packages/container-orchestrator/src/labels.d.ts +0 -2
- package/dist/packages/container-orchestrator/src/labels.js +0 -2
- package/dist/packages/container-orchestrator/src/podman/index.js +9 -4
- package/dist/packages/container-orchestrator/src/podman/utils/createPodmanRunOptions.d.ts +1 -1
- package/dist/packages/container-orchestrator/src/types.d.ts +5 -0
- package/dist/src/NodeManager/clients/hostManager/index.js +3 -3
- package/dist/src/NodeManager/clients/types.utils.d.ts +1 -0
- package/dist/src/NodeManager/configs/configs.d.ts +2 -1
- package/dist/src/NodeManager/configs/configs.js +1 -0
- package/dist/src/NodeManager/db/index.d.ts +44 -11
- package/dist/src/NodeManager/db/index.js +3 -5
- package/dist/src/NodeManager/errors/NodeNotQualifiedError.js +2 -2
- package/dist/src/NodeManager/index.js +14 -25
- package/dist/src/NodeManager/input/OperatorInput.d.ts +2 -0
- package/dist/src/NodeManager/jobs/index.d.ts +6 -1
- package/dist/src/NodeManager/jobs/index.js +45 -2
- package/dist/src/NodeManager/monitoring/log/NodeLog.d.ts +8 -6
- package/dist/src/NodeManager/monitoring/log/NodeLog.js +461 -38
- package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.d.ts +1 -0
- package/dist/src/NodeManager/monitoring/log/console/ConsoleLogger.js +5 -5
- package/dist/{packages/common/src → src/NodeManager/monitoring/proxy}/loggingProxy.d.ts +1 -0
- package/dist/{packages/common/src → src/NodeManager/monitoring/proxy}/loggingProxy.js +1 -0
- package/dist/src/NodeManager/monitoring/reportError.js +3 -2
- package/dist/src/NodeManager/monitoring/state/NodeState.d.ts +1 -1
- package/dist/src/NodeManager/monitoring/state/NodeState.js +29 -1
- package/dist/src/NodeManager/node/Node.d.ts +8 -28
- package/dist/src/NodeManager/node/Node.js +45 -81
- package/dist/src/NodeManager/node/api/ApiEventEmitter.d.ts +1 -0
- package/dist/src/NodeManager/node/api/ApiHandler.d.ts +7 -21
- package/dist/src/NodeManager/node/api/ApiHandler.js +46 -67
- package/dist/src/NodeManager/node/api/eventsource/index.d.ts +6 -0
- package/dist/src/NodeManager/node/api/middlewares/index.d.ts +1 -0
- package/dist/src/NodeManager/node/api/middlewares/index.js +2 -0
- package/dist/src/NodeManager/node/api/middlewares/rest/verifyJobOwnerSignatureMiddleware.d.ts +5 -0
- package/dist/src/NodeManager/node/api/middlewares/rest/verifyJobOwnerSignatureMiddleware.js +29 -0
- package/dist/src/NodeManager/node/api/middlewares/ws/verifyWSJobOwnerSignatureMiddleware.js +8 -6
- package/dist/src/NodeManager/node/api/routes/get/index.d.ts +7 -0
- package/dist/src/NodeManager/node/api/routes/get/index.js +7 -0
- package/dist/src/NodeManager/node/api/routes/get/job-definition.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/job-definition.js +16 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/buildInfoObject.d.ts +17 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/buildInfoObject.js +15 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/job-info.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/job-info.js +18 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/pollActiveJob.d.ts +6 -0
- package/dist/src/NodeManager/node/api/routes/get/job-info/pollActiveJob.js +42 -0
- package/dist/src/NodeManager/node/api/routes/get/job-operation-info.d.ts +28 -0
- package/dist/src/NodeManager/node/api/routes/get/job-operation-info.js +53 -0
- package/dist/src/NodeManager/node/api/routes/get/job-results.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/job-results.js +15 -0
- package/dist/src/NodeManager/node/api/routes/get/job-stats-stream.d.ts +5 -0
- package/dist/{packages/job-runtime/src/api/routes/stats.js → src/NodeManager/node/api/routes/get/job-stats-stream.js} +5 -25
- package/dist/src/NodeManager/node/api/routes/get/job-stats.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/job-stats.js +22 -0
- package/dist/src/NodeManager/node/api/routes/get/service-url.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/get/service-url.js +27 -0
- package/dist/src/NodeManager/node/api/routes/index.d.ts +1 -0
- package/dist/src/NodeManager/node/api/routes/index.js +1 -0
- package/dist/src/NodeManager/node/api/routes/post/index.d.ts +4 -0
- package/dist/src/NodeManager/node/api/routes/post/index.js +4 -0
- package/dist/src/NodeManager/node/api/routes/post/job-definition.d.ts +6 -0
- package/dist/src/NodeManager/node/api/routes/post/job-definition.js +15 -0
- package/dist/src/NodeManager/node/api/routes/post/job-operation-actions.d.ts +20 -0
- package/dist/src/NodeManager/node/api/routes/post/job-operation-actions.js +63 -0
- package/dist/src/NodeManager/node/api/routes/post/service-stop.d.ts +5 -0
- package/dist/src/NodeManager/node/api/routes/post/service-stop.js +13 -0
- package/dist/src/NodeManager/node/api/routes/post/ssh-authorize.d.ts +17 -0
- package/dist/src/NodeManager/node/api/routes/post/ssh-authorize.js +53 -0
- package/dist/src/NodeManager/node/api/routes/wss/index.d.ts +2 -0
- package/dist/src/NodeManager/node/api/routes/wss/index.js +2 -0
- package/dist/src/NodeManager/node/api/routes/wss/log.d.ts +9 -0
- package/dist/src/NodeManager/node/api/routes/wss/log.js +55 -2
- package/dist/src/NodeManager/node/api/routes/wss/status.js +4 -2
- package/dist/{packages/job-runtime/src/api/terminal/terminalBridge.d.ts → src/NodeManager/node/api/routes/wss/terminal/terminal.d.ts} +7 -6
- package/dist/{packages/job-runtime/src/api/terminal/terminalBridge.js → src/NodeManager/node/api/routes/wss/terminal/terminal.js} +23 -15
- package/dist/{packages/job-runtime/src/api → src/NodeManager/node/api/routes/wss}/terminal/terminalAuthorization.d.ts +1 -0
- package/dist/{packages/job-runtime/src/api → src/NodeManager/node/api/routes/wss}/terminal/terminalAuthorization.js +3 -3
- package/dist/src/NodeManager/node/api/types/index.d.ts +2 -2
- package/dist/{packages/job-runtime/src/api → src/NodeManager/node/api/utils}/interval.d.ts +5 -2
- package/dist/{packages/job-runtime/src/api → src/NodeManager/node/api/utils}/interval.js +1 -1
- package/dist/src/NodeManager/node/balance/balanceHandler.d.ts +5 -4
- package/dist/src/NodeManager/node/balance/balanceHandler.js +5 -6
- package/dist/src/NodeManager/node/expiry/expiryHandler.d.ts +10 -2
- package/dist/src/NodeManager/node/expiry/expiryHandler.js +36 -8
- package/dist/src/NodeManager/node/grid/gridHandler.d.ts +13 -0
- package/dist/src/NodeManager/node/grid/gridHandler.js +35 -0
- package/dist/src/NodeManager/node/health/healthHandler.d.ts +4 -3
- package/dist/src/NodeManager/node/health/healthHandler.js +8 -5
- package/dist/src/NodeManager/node/job/JobRegistry.d.ts +6 -16
- package/dist/src/NodeManager/node/job/JobRegistry.js +22 -68
- package/dist/src/NodeManager/node/job/defination/JobDefinitionStrategy.d.ts +13 -0
- package/dist/src/NodeManager/node/job/defination/JobDefinitionStrategy.js +21 -0
- package/dist/src/NodeManager/node/job/defination/strategy/ApiJobDefinitionStrategy.d.ts +8 -0
- package/dist/{packages/job-runtime/src/logistics/definition → src/NodeManager/node/job/defination/strategy}/ApiJobDefinitionStrategy.js +5 -5
- package/dist/{packages/job-runtime/src/logistics/definition → src/NodeManager/node/job/defination/strategy}/ApiListenJobDefinitionStrategy.d.ts +3 -2
- package/dist/src/NodeManager/node/job/defination/strategy/IpfsJobDefinitionStrategy.d.ts +5 -0
- package/dist/src/NodeManager/node/job/defination/strategy/IpfsJobDefinitionStrategy.js +11 -0
- package/dist/src/NodeManager/node/job/jobExternalUtil.d.ts +10 -0
- package/dist/src/NodeManager/node/job/jobExternalUtil.js +96 -0
- package/dist/src/NodeManager/node/job/jobHandler.d.ts +14 -78
- package/dist/src/NodeManager/node/job/jobHandler.js +129 -224
- package/dist/src/NodeManager/node/job/result/ResultReturnStrategy.d.ts +13 -0
- package/dist/src/NodeManager/node/job/result/ResultReturnStrategy.js +21 -0
- package/dist/{packages/job-runtime/src/logistics/result → src/NodeManager/node/job/result/startegy}/ApiListenResultReturnStrategy.d.ts +2 -1
- package/dist/src/NodeManager/node/job/result/startegy/ApiResultReturnStrategy.d.ts +8 -0
- package/dist/{packages/job-runtime/src/logistics/result → src/NodeManager/node/job/result/startegy}/ApiResultReturnStrategy.js +5 -5
- package/dist/src/NodeManager/node/key/keyHandler.d.ts +9 -15
- package/dist/src/NodeManager/node/key/keyHandler.js +9 -18
- package/dist/src/NodeManager/node/market/benchmark.d.ts +4 -11
- package/dist/src/NodeManager/node/market/benchmark.js +40 -55
- package/dist/src/NodeManager/node/market/hostManager.d.ts +16 -14
- package/dist/src/NodeManager/node/market/hostManager.js +12 -0
- package/dist/src/NodeManager/node/market/marketAccess.d.ts +3 -9
- package/dist/src/NodeManager/node/market/marketAccess.js +9 -27
- package/dist/src/NodeManager/node/market/marketHandler.d.ts +7 -11
- package/dist/src/NodeManager/node/market/marketHandler.js +18 -33
- package/dist/src/NodeManager/node/register/index.js +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createResourceName.d.ts +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createResourceName.js +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createS3Args.d.ts +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createS3Args.js +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/isAuthGatedResource.d.ts +1 -1
- package/dist/src/NodeManager/node/resource/image/imageManager.d.ts +16 -12
- package/dist/src/NodeManager/node/resource/image/imageManager.js +35 -21
- package/dist/src/NodeManager/node/resource/resourceManager.d.ts +10 -26
- package/dist/src/NodeManager/node/resource/resourceManager.js +40 -48
- package/dist/src/NodeManager/node/resource/volume/volumeManager.d.ts +75 -11
- package/dist/src/NodeManager/node/resource/volume/volumeManager.js +347 -25
- package/dist/src/NodeManager/node/run/runHandler.d.ts +4 -17
- package/dist/src/NodeManager/node/run/runHandler.js +46 -69
- package/dist/src/NodeManager/node/stake/StakeHandler.d.ts +5 -18
- package/dist/src/NodeManager/node/stake/StakeHandler.js +24 -56
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/TaskManager.d.ts +47 -16
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/TaskManager.js +59 -20
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createExecutionPlan.js +1 -0
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createOperationMap.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/finalizeEnv.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/interpolateOperation.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setDefaults.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setDefaults.js +13 -10
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/stanatizeArrays.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/transformCollections.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/helpers/createDefaultOpState.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/helpers/createInitialFlow.d.ts +2 -2
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/StatsBuffer.d.ts +1 -1
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/enforceOperationTimeout.d.ts +1 -0
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/runTaskManagerOperation.d.ts +2 -2
- package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/runTaskManagerOperation.js +3 -2
- package/dist/{packages/job-runtime/src/resources/helpers → src/NodeManager/node/utils}/extractLogsAndResultsFromLogBuffer.d.ts +3 -1
- package/dist/{packages/job-runtime/src/resources/helpers → src/NodeManager/node/utils}/extractLogsAndResultsFromLogBuffer.js +2 -2
- package/dist/{packages/common/src → src/NodeManager/node/utils}/extractResultsFromLogs.d.ts +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/utils}/multiProgressBarReporter.d.ts +2 -4
- package/dist/src/NodeManager/node/utils/multiProgressBarReporter.js +22 -0
- package/dist/src/NodeManager/node/utils/poll.d.ts +1 -1
- package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/utils}/progressBarReporter.d.ts +2 -4
- package/dist/src/NodeManager/node/utils/progressBarReporter.js +28 -0
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/ContainerStateManager.d.ts +3 -10
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/ContainerStateManager.js +5 -23
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/ExposedPortHealthCheck.d.ts +5 -4
- package/dist/src/NodeManager/provider/Provider.d.ts +92 -69
- package/dist/src/NodeManager/provider/Provider.js +534 -205
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/SshAccessManager.d.ts +4 -4
- package/dist/src/NodeManager/provider/orchestrationHooks.js +2 -2
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/sshSidecar.d.ts +7 -7
- package/dist/{packages/job-runtime/src → src/NodeManager}/provider/sshSidecar.js +4 -2
- package/dist/src/NodeManager/provider/types.d.ts +9 -0
- package/dist/{packages/container-orchestrator/src → src/NodeManager/provider}/utils/parseBuffer.d.ts +3 -1
- package/dist/{packages/job-runtime/src/provider → src/NodeManager/provider/utils}/parseDockerStat.d.ts +1 -1
- package/dist/src/NodeManager/provider/webTerminal.d.ts +24 -0
- package/dist/{packages/job-runtime/src/api/runtime/terminal.js → src/NodeManager/provider/webTerminal.js} +9 -13
- package/dist/src/NodeManager/repository/NodeRepository.d.ts +41 -5
- package/dist/src/NodeManager/repository/NodeRepository.js +155 -8
- package/dist/src/NodeManager/sdk/index.d.ts +9 -6
- package/dist/src/NodeManager/sdk/index.js +94 -78
- package/dist/src/NodeManager/types/index.d.ts +9 -0
- package/dist/src/NodeManager/utils/expose-util.d.ts +14 -0
- package/dist/{packages/job-runtime/src/provider/expose.js → src/NodeManager/utils/expose-util.js} +39 -8
- package/dist/src/NodeManager/utils/jobDefinitionParser.d.ts +4 -0
- package/dist/src/NodeManager/utils/jobDefinitionParser.js +7 -1
- package/dist/src/NodeManager/utils/ops-util.d.ts +3 -0
- package/dist/src/NodeManager/utils/ops-util.js +19 -0
- package/dist/src/NodeManager/utils/tolerateBrokenStdio.d.ts +1 -0
- package/dist/src/NodeManager/utils/utils.d.ts +2 -1
- package/dist/src/NodeManager/utils/utils.js +4 -1
- package/dist/src/cli/commands/address/action.js +2 -3
- package/dist/src/cli/commands/run/action.d.ts +0 -5
- package/dist/src/cli/commands/run/action.js +18 -65
- package/dist/src/cli/commands/run/generateDeploymentEndpointsTable.d.ts +2 -2
- package/dist/src/cli/commands/run/generateDeploymentEndpointsTable.js +5 -6
- package/dist/src/cli/commands/sharedOptions/--api.d.ts +2 -0
- package/dist/src/cli/commands/sharedOptions/--api.js +2 -0
- package/dist/src/cli/commands/sharedOptions/--tee-runtime.js +1 -1
- package/dist/src/cli/commands/sharedOptions/--timeout.d.ts +2 -0
- package/dist/src/cli/commands/sharedOptions/--timeout.js +12 -0
- package/dist/src/cli/commands/start/action.d.ts +1 -0
- package/dist/src/cli/commands/start/action.js +1 -0
- package/dist/src/cli/createNosanaCli.js +4 -2
- package/dist/src/index.d.ts +1 -0
- package/dist/src/ipfs/IpfsClient.d.ts +1 -3
- package/dist/src/ipfs/IpfsClient.js +1 -1
- package/dist/src/output-formatter/outputEvents.d.ts +1 -1
- package/dist/src/static/index.d.ts +1 -1
- package/npm-shrinkwrap.json +1466 -3257
- package/package.json +9 -10
- package/dist/packages/common/src/OperationError.d.ts +0 -14
- package/dist/packages/common/src/OperationError.js +0 -18
- package/dist/packages/common/src/expose-id.d.ts +0 -12
- package/dist/packages/common/src/expose-id.js +0 -23
- package/dist/packages/common/src/index.d.ts +0 -11
- package/dist/packages/common/src/index.js +0 -11
- package/dist/packages/common/src/jobPhaseLog.d.ts +0 -42
- package/dist/packages/common/src/jobPhaseLog.js +0 -207
- package/dist/packages/job-runtime/src/api/eventsource.d.ts +0 -6
- package/dist/packages/job-runtime/src/api/middlewares/verifyJobOwnerSignature.d.ts +0 -13
- package/dist/packages/job-runtime/src/api/middlewares/verifyJobOwnerSignature.js +0 -39
- package/dist/packages/job-runtime/src/api/middlewares/verifyWSSignatures.d.ts +0 -10
- package/dist/packages/job-runtime/src/api/middlewares/verifyWSSignatures.js +0 -34
- package/dist/packages/job-runtime/src/api/paths.d.ts +0 -52
- package/dist/packages/job-runtime/src/api/paths.js +0 -52
- package/dist/packages/job-runtime/src/api/router.d.ts +0 -10
- package/dist/packages/job-runtime/src/api/router.js +0 -64
- package/dist/packages/job-runtime/src/api/routes/definitionAndResults.d.ts +0 -8
- package/dist/packages/job-runtime/src/api/routes/definitionAndResults.js +0 -69
- package/dist/packages/job-runtime/src/api/routes/info.d.ts +0 -23
- package/dist/packages/job-runtime/src/api/routes/info.js +0 -69
- package/dist/packages/job-runtime/src/api/routes/operations.d.ts +0 -36
- package/dist/packages/job-runtime/src/api/routes/operations.js +0 -120
- package/dist/packages/job-runtime/src/api/routes/ssh.d.ts +0 -11
- package/dist/packages/job-runtime/src/api/routes/ssh.js +0 -83
- package/dist/packages/job-runtime/src/api/routes/stats.d.ts +0 -4
- package/dist/packages/job-runtime/src/api/runtime/terminal.d.ts +0 -15
- package/dist/packages/job-runtime/src/api/types.d.ts +0 -170
- package/dist/packages/job-runtime/src/api/wsClose.d.ts +0 -6
- package/dist/packages/job-runtime/src/api/wsClose.js +0 -10
- package/dist/packages/job-runtime/src/api/wsHandler.d.ts +0 -10
- package/dist/packages/job-runtime/src/api/wsHandler.js +0 -145
- package/dist/packages/job-runtime/src/chain.d.ts +0 -28
- package/dist/packages/job-runtime/src/chain.js +0 -72
- package/dist/packages/job-runtime/src/config.d.ts +0 -39
- package/dist/packages/job-runtime/src/config.js +0 -57
- package/dist/packages/job-runtime/src/host/HostClient.d.ts +0 -29
- package/dist/packages/job-runtime/src/host/HostClient.js +0 -91
- package/dist/packages/job-runtime/src/host/contract.d.ts +0 -171
- package/dist/packages/job-runtime/src/host/contract.js +0 -163
- package/dist/packages/job-runtime/src/host/hostPorts.d.ts +0 -7
- package/dist/packages/job-runtime/src/host/hostPorts.js +0 -13
- package/dist/packages/job-runtime/src/host/index.d.ts +0 -10
- package/dist/packages/job-runtime/src/host/index.js +0 -10
- package/dist/packages/job-runtime/src/logistics/JobDefinitionStrategy.d.ts +0 -21
- package/dist/packages/job-runtime/src/logistics/JobDefinitionStrategy.js +0 -27
- package/dist/packages/job-runtime/src/logistics/ResultReturnStrategy.d.ts +0 -21
- package/dist/packages/job-runtime/src/logistics/ResultReturnStrategy.js +0 -27
- package/dist/packages/job-runtime/src/logistics/definition/ApiJobDefinitionStrategy.d.ts +0 -11
- package/dist/packages/job-runtime/src/logistics/ports.d.ts +0 -10
- package/dist/packages/job-runtime/src/logistics/ports.js +0 -1
- package/dist/packages/job-runtime/src/logistics/result/ApiResultReturnStrategy.d.ts +0 -11
- package/dist/packages/job-runtime/src/main.d.ts +0 -1
- package/dist/packages/job-runtime/src/main.js +0 -83
- package/dist/packages/job-runtime/src/provider/ContainerProvider.d.ts +0 -82
- package/dist/packages/job-runtime/src/provider/ContainerProvider.js +0 -449
- package/dist/packages/job-runtime/src/provider/expose.d.ts +0 -12
- package/dist/packages/job-runtime/src/provider/gpu/gpuSampler.d.ts +0 -24
- package/dist/packages/job-runtime/src/provider/gpu/gpuSampler.js +0 -97
- package/dist/packages/job-runtime/src/provider/gpu/gpuStats.d.ts +0 -63
- package/dist/packages/job-runtime/src/provider/gpu/gpuStats.js +0 -144
- package/dist/packages/job-runtime/src/provider/ports.d.ts +0 -59
- package/dist/packages/job-runtime/src/provider/ports.js +0 -1
- package/dist/packages/job-runtime/src/resources/FileResourceRecords.d.ts +0 -21
- package/dist/packages/job-runtime/src/resources/FileResourceRecords.js +0 -53
- package/dist/packages/job-runtime/src/resources/ImageCache.d.ts +0 -35
- package/dist/packages/job-runtime/src/resources/ImageCache.js +0 -55
- package/dist/packages/job-runtime/src/resources/VolumeCache.d.ts +0 -110
- package/dist/packages/job-runtime/src/resources/VolumeCache.js +0 -359
- package/dist/packages/job-runtime/src/resources/index.d.ts +0 -13
- package/dist/packages/job-runtime/src/resources/index.js +0 -13
- package/dist/packages/job-runtime/src/resources/jobResources.d.ts +0 -12
- package/dist/packages/job-runtime/src/resources/jobResources.js +0 -88
- package/dist/packages/job-runtime/src/resources/multiProgressBarReporter.js +0 -12
- package/dist/packages/job-runtime/src/resources/progressBarReporter.js +0 -12
- package/dist/packages/job-runtime/src/resources/records.d.ts +0 -67
- package/dist/packages/job-runtime/src/resources/records.js +0 -6
- package/dist/packages/job-runtime/src/runtime/RuntimeLog.d.ts +0 -26
- package/dist/packages/job-runtime/src/runtime/RuntimeLog.js +0 -79
- package/dist/packages/job-runtime/src/runtime/retrieveJobDefinition.d.ts +0 -6
- package/dist/packages/job-runtime/src/runtime/retrieveJobDefinition.js +0 -19
- package/dist/packages/job-runtime/src/runtime/runJob.d.ts +0 -31
- package/dist/packages/job-runtime/src/runtime/runJob.js +0 -534
- package/dist/packages/job-runtime/src/runtime/streams.d.ts +0 -32
- package/dist/packages/job-runtime/src/runtime/streams.js +0 -81
- package/dist/packages/job-runtime/src/server.d.ts +0 -23
- package/dist/packages/job-runtime/src/server.js +0 -66
- package/dist/packages/job-runtime/src/store/FlowStore.d.ts +0 -62
- package/dist/packages/job-runtime/src/store/FlowStore.js +0 -170
- package/dist/packages/job-runtime/src/taskManager/index.d.ts +0 -11
- package/dist/packages/job-runtime/src/taskManager/index.js +0 -8
- package/dist/packages/job-runtime/src/taskManager/ports/FlowRepository.d.ts +0 -22
- package/dist/packages/job-runtime/src/taskManager/ports/FlowRepository.js +0 -1
- package/dist/packages/job-runtime/src/taskManager/ports/OrchestrationProvider.d.ts +0 -24
- package/dist/packages/job-runtime/src/taskManager/ports/OrchestrationProvider.js +0 -1
- package/dist/packages/job-runtime/src/taskManager/ports/TaskContext.d.ts +0 -9
- package/dist/packages/job-runtime/src/taskManager/ports/TaskContext.js +0 -1
- package/dist/packages/job-runtime/src/taskManager/ports/index.d.ts +0 -3
- package/dist/packages/job-runtime/src/taskManager/ports/index.js +0 -1
- package/dist/packages/job-runtime/src/taskManager/runtimeConfig.d.ts +0 -23
- package/dist/packages/job-runtime/src/taskManager/runtimeConfig.js +0 -14
- package/dist/packages/job-runtime/src/taskManager/stopReasons.d.ts +0 -10
- package/dist/packages/job-runtime/src/taskManager/stopReasons.js +0 -9
- package/dist/packages/job-runtime/src/taskManager/types.d.ts +0 -53
- package/dist/packages/job-runtime/src/taskManager/types.js +0 -3
- package/dist/packages/job-runtime/src/utils/abort.d.ts +0 -17
- package/dist/packages/job-runtime/src/utils/abort.js +0 -55
- package/dist/packages/job-runtime/src/utils/files.d.ts +0 -7
- package/dist/packages/job-runtime/src/utils/files.js +0 -19
- package/dist/src/NodeManager/node/api/jobRuntimeProxy.d.ts +0 -29
- package/dist/src/NodeManager/node/api/jobRuntimeProxy.js +0 -105
- package/dist/src/NodeManager/node/job/JobRuntimeHost.d.ts +0 -26
- package/dist/src/NodeManager/node/job/JobRuntimeHost.js +0 -87
- package/dist/src/NodeManager/node/job/JobRuntimeSession.d.ts +0 -91
- package/dist/src/NodeManager/node/job/JobRuntimeSession.js +0 -213
- package/dist/src/NodeManager/node/utils/subscription.d.ts +0 -8
- package/dist/src/NodeManager/node/utils/subscription.js +0 -37
- package/dist/src/cli/commands/run/jobRuntimeConsole.d.ts +0 -10
- package/dist/src/cli/commands/run/jobRuntimeConsole.js +0 -26
- /package/dist/{packages/job-runtime/src/api/eventsource.js → src/NodeManager/node/api/eventsource/index.js} +0 -0
- /package/dist/{packages/job-runtime/src/logistics/definition → src/NodeManager/node/job/defination/strategy}/ApiListenJobDefinitionStrategy.js +0 -0
- /package/dist/{packages/job-runtime/src/logistics/result → src/NodeManager/node/job/result/startegy}/ApiListenResultReturnStrategy.js +0 -0
- /package/dist/{packages/job-runtime/src/resources/helpers/nosanaBucket.d.ts → src/NodeManager/node/resource/definition/index.d.ts} +0 -0
- /package/dist/{packages/job-runtime/src/resources/helpers/nosanaBucket.js → src/NodeManager/node/resource/definition/index.js} +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createHFArgs.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createHFArgs.js +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createOllamaArgs.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/createOllamaArgs.js +0 -0
- /package/dist/{packages/job-runtime/src/resources → src/NodeManager/node/resource}/helpers/isAuthGatedResource.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/TaskManagerRegistry.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/TaskManagerRegistry.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createDependencyMap.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createDependencyMap.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createExecutionPlan.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/createOperationMap.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/validateExecutionPlan.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/executions/validateExecutionPlan.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/finalizeEnv.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/getByPath.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/getByPath.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/index.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/index.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/interpolate.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/interpolate.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/interpolateOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/resolveLiteralsInString.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/resolveLiteralsInString.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setContainerIp.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setContainerIp.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setHost.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setHost.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setResult.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setResult.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setResults.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/setResults.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/stanatizeArrays.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/globalStore/transformCollections.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/helpers/createDefaultOpState.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/helpers/createInitialFlow.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/StatsBuffer.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/logManager.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/logManager.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/statsManager.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/loggers/statsManager.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/enforceOperationTimeout.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/getOperationsInfos.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/getOperationsInfos.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/restartTaskManagerGroupOperation.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/restartTaskManagerGroupOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/restartTaskManagerOperation.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/restartTaskManagerOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopAllTaskManagerOperations.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopAllTaskManagerOperations.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopTaskManagerGroupOperation.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopTaskManagerGroupOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopTaskManagerOperation.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/taskManager → src/NodeManager/node/task}/operations/stopTaskManagerOperation.js +0 -0
- /package/dist/{packages/job-runtime/src/resources/helpers → src/NodeManager/node/utils}/convertFromBytes.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/resources/helpers → src/NodeManager/node/utils}/convertFromBytes.js +0 -0
- /package/dist/{packages/common/src → src/NodeManager/node/utils}/extractResultsFromLogs.js +0 -0
- /package/dist/{packages/job-runtime/src → src/NodeManager}/provider/ExposedPortHealthCheck.js +0 -0
- /package/dist/{packages/job-runtime/src → src/NodeManager}/provider/SshAccessManager.js +0 -0
- /package/dist/{packages/job-runtime/src/api → src/NodeManager/provider}/types.js +0 -0
- /package/dist/{packages/container-orchestrator/src → src/NodeManager/provider}/utils/parseBuffer.js +0 -0
- /package/dist/{packages/job-runtime/src/provider → src/NodeManager/provider/utils}/parseDockerStat.js +0 -0
- /package/dist/{packages/common/src → src/NodeManager/utils}/formatTime.d.ts +0 -0
- /package/dist/{packages/common/src → src/NodeManager/utils}/formatTime.js +0 -0
- /package/dist/{packages/job-runtime/src/provider → src/NodeManager/utils}/timeoutPromiseWrapper.d.ts +0 -0
- /package/dist/{packages/job-runtime/src/provider → src/NodeManager/utils}/timeoutPromiseWrapper.js +0 -0
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import type { FlowState, JobDefinition } from '@nosana/kit';
|
|
2
|
-
import type { StopReason } from '../taskManager/stopReasons.js';
|
|
3
|
-
import type { ResourceCacheSnapshot } from '../resources/records.js';
|
|
4
|
-
/**
|
|
5
|
-
* What passes between the node and a job's runtime sidecar. The node knows the
|
|
6
|
-
* job and nothing else: the sidecar resolves it (onchain, IPFS, logistics),
|
|
7
|
-
* pulls its images and downloads its resources, runs it, pins its result and
|
|
8
|
-
* exits. The two meet in a per-job directory the node makes and the sidecar
|
|
9
|
-
* has bind-mounted:
|
|
10
|
-
*
|
|
11
|
-
* - the node writes the {@link JobRuntimeSeed} before the sidecar starts;
|
|
12
|
-
* - the sidecar keeps its {@link JobRuntimeStatus} there, the last one
|
|
13
|
-
* carrying its result, and what it changed in the cache records
|
|
14
|
-
* (ResourceCacheChanges), each as it happens;
|
|
15
|
-
* - the node serves a unix socket there for the two things that need it
|
|
16
|
-
* live: its signature on the job address, and the job's stop.
|
|
17
|
-
*
|
|
18
|
-
* Neither needs the other up to make progress: the files and the sidecar's
|
|
19
|
-
* container outlive either process. Nothing the sidecar sends can point the
|
|
20
|
-
* socket at another job.
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* A job's sidecar container is `<prefix><job address>`, which is also its
|
|
24
|
-
* name on the gateway network, and its data volume.
|
|
25
|
-
*/
|
|
26
|
-
export declare const JOB_RUNTIME_CONTAINER_PREFIX = "job-runtime-";
|
|
27
|
-
/** The port the sidecar serves the job API on, inside the gateway network. */
|
|
28
|
-
export declare const JOB_RUNTIME_PORT = 8080;
|
|
29
|
-
/** Where the sidecar's data volume (its records of the job) is mounted. */
|
|
30
|
-
export declare const JOB_RUNTIME_DATA_DIR = "/nosana-job-runtime";
|
|
31
|
-
/**
|
|
32
|
-
* What the sidecar runs. An `onchain` job it resolves itself from its
|
|
33
|
-
* address, serving its poster the job API and pinning its result. An `inline`
|
|
34
|
-
* run (the node's market benchmark, `nosana node run`) has no job onchain and
|
|
35
|
-
* no poster: the node hands it the definition in the seed and takes the
|
|
36
|
-
* finished flow state back whole, nothing pinned.
|
|
37
|
-
*/
|
|
38
|
-
export type JobRuntimeKind = 'onchain' | 'inline';
|
|
39
|
-
/**
|
|
40
|
-
* What the sidecar's console (the container's log) carries: its phases as
|
|
41
|
-
* lines of text, or, for `nosana node run`, which renders them with the
|
|
42
|
-
* node's spinners and progress bars, each job-log entry as a JSON line
|
|
43
|
-
* marked with {@link JOB_RUNTIME_LOG_ENTRY_MARK}. Other lines stay text.
|
|
44
|
-
*/
|
|
45
|
-
export type JobRuntimeConsole = 'text' | 'entries';
|
|
46
|
-
/** Starts a console line that is a job-log entry (ASCII record separator). */
|
|
47
|
-
export declare const JOB_RUNTIME_LOG_ENTRY_MARK = "\u001E";
|
|
48
|
-
/** The job's directory, as the sidecar has it bind-mounted. */
|
|
49
|
-
export declare const JOB_RUNTIME_HOST_DIR = "/nosana-host";
|
|
50
|
-
export declare const JOB_RUNTIME_HOST_SOCKET = "host.sock";
|
|
51
|
-
/** The files in the job's directory. */
|
|
52
|
-
export declare const JOB_RUNTIME_FILES: {
|
|
53
|
-
/** {@link JobRuntimeSeed}, from the node. */
|
|
54
|
-
readonly seed: "seed.json";
|
|
55
|
-
/** {@link JobRuntimeStatus}, from the sidecar. */
|
|
56
|
-
readonly status: "status.json";
|
|
57
|
-
/** ResourceCacheChanges, from the sidecar. */
|
|
58
|
-
readonly resources: "resources.json";
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* The versions of the files in the job's directory that carry one. A reader
|
|
62
|
-
* takes any version up to its own and refuses a newer one, whose meaning it
|
|
63
|
-
* cannot know: a node keeps reading what an older sidecar wrote (it takes
|
|
64
|
-
* over a running one after it restarts, maybe upgraded), and a sidecar
|
|
65
|
-
* refuses a seed from a node newer than itself rather than misread it.
|
|
66
|
-
*
|
|
67
|
-
* The status has none: the node reads only a few of its fields and checks
|
|
68
|
-
* their shape instead, a status it cannot read counting as none. A change to
|
|
69
|
-
* what a field means would add one, its absence meaning the format of today.
|
|
70
|
-
*/
|
|
71
|
-
export declare const JOB_RUNTIME_SEED_VERSION = 1;
|
|
72
|
-
/** The version of the cache changes (ResourceCacheChanges) the sidecar writes. */
|
|
73
|
-
export declare const RESOURCE_CHANGES_VERSION = 1;
|
|
74
|
-
/** Whether a file's `version` is one a reader at `current` can read. */
|
|
75
|
-
export declare function isKnownVersion(version: unknown, current: number): boolean;
|
|
76
|
-
/** What the sidecar starts from. */
|
|
77
|
-
export interface JobRuntimeSeed {
|
|
78
|
-
version: number;
|
|
79
|
-
/** The node's cache records as the job starts. */
|
|
80
|
-
resources: ResourceCacheSnapshot;
|
|
81
|
-
/** An inline run's definition; absent for an onchain job. */
|
|
82
|
-
inline?: InlineJob;
|
|
83
|
-
}
|
|
84
|
-
export declare const JOB_RUNTIME_HOST_PATHS: {
|
|
85
|
-
/**
|
|
86
|
-
* GET → {@link SignAuthResponse}: a fresh authorization header the node
|
|
87
|
-
* wallet signed for the job address (time included). Takes no input, so the
|
|
88
|
-
* sidecar cannot choose what is signed.
|
|
89
|
-
*/
|
|
90
|
-
readonly signAuth: "/sign-auth";
|
|
91
|
-
/**
|
|
92
|
-
* GET → {@link StopRequest}, held open until the node wants the job stopped
|
|
93
|
-
* (expiry, a stop onchain, the node quitting). Answered at once when it
|
|
94
|
-
* already does.
|
|
95
|
-
*/
|
|
96
|
-
readonly stop: "/stop";
|
|
97
|
-
};
|
|
98
|
-
/** An inline run: its definition, and who it runs for and on. */
|
|
99
|
-
export interface InlineJob {
|
|
100
|
-
definition: JobDefinition;
|
|
101
|
-
/** Surfaced to workloads as %%global.project%%; the node's own address. */
|
|
102
|
-
project: string;
|
|
103
|
-
/** Surfaced to workloads as %%global.host%%. */
|
|
104
|
-
host: string;
|
|
105
|
-
}
|
|
106
|
-
export interface SignAuthResponse {
|
|
107
|
-
authorization: string;
|
|
108
|
-
}
|
|
109
|
-
export interface StopRequest {
|
|
110
|
-
reason: StopReason;
|
|
111
|
-
}
|
|
112
|
-
/** Coarse lifecycle phase the node acts on, derived from the flow status. */
|
|
113
|
-
export type JobRuntimePhase = 'running' | 'success' | 'failed' | 'stopped';
|
|
114
|
-
/** One operation, without its logs. */
|
|
115
|
-
export interface JobRuntimeOpSummary {
|
|
116
|
-
operationId: string | null;
|
|
117
|
-
status: string | null;
|
|
118
|
-
exitCode: number | null;
|
|
119
|
-
/** Messages of the errors recorded against the op, oldest first. */
|
|
120
|
-
errors: string[];
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Where the finished result went: for an onchain job, the hash the sidecar
|
|
124
|
-
* pinned, which the node submits onchain, or why it could not pin one; for an
|
|
125
|
-
* inline run, the flow state itself.
|
|
126
|
-
*/
|
|
127
|
-
export interface JobRuntimeResult {
|
|
128
|
-
ipfsHash?: string;
|
|
129
|
-
state?: FlowState;
|
|
130
|
-
error?: string;
|
|
131
|
-
}
|
|
132
|
-
export interface JobRuntimeStatus {
|
|
133
|
-
phase: JobRuntimePhase;
|
|
134
|
-
/** Raw flow status (`init`/`running`/`success`/`failed`/`stopped`/...). */
|
|
135
|
-
status: string;
|
|
136
|
-
/** True until the job is over: until `result` is set. */
|
|
137
|
-
running: boolean;
|
|
138
|
-
/** Overall exit code once terminal; null while still running. */
|
|
139
|
-
exitCode: number | null;
|
|
140
|
-
opStates: JobRuntimeOpSummary[];
|
|
141
|
-
/** Flow-level error messages (a resolution or logistics failure). */
|
|
142
|
-
errors: string[];
|
|
143
|
-
startTime: number | null;
|
|
144
|
-
endTime: number | null;
|
|
145
|
-
/**
|
|
146
|
-
* Set once the sidecar has tried to pin the result, which is the last thing
|
|
147
|
-
* it does. The job is finished for the node when this is set.
|
|
148
|
-
*/
|
|
149
|
-
result?: JobRuntimeResult;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* The one line that best explains a terminal status: the first error of the
|
|
153
|
-
* first op that recorded one, else the first flow-level error.
|
|
154
|
-
*/
|
|
155
|
-
export declare function describeFailure(status: JobRuntimeStatus): string | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* A flow state as the node sees it.
|
|
158
|
-
*
|
|
159
|
-
* - The job is over once its `result` is there, which the sidecar sets last.
|
|
160
|
-
* - The phase is `running` until the task manager stamps `endTime` at a
|
|
161
|
-
* terminal state, and while the result is delivered to the poster.
|
|
162
|
-
* - The overall `exitCode` is 0 on success, the first non-zero op exit on
|
|
163
|
-
* failure (falling back to 1), and 0 for a stop with no failed op.
|
|
164
|
-
*/
|
|
165
|
-
export declare function deriveJobRuntimeStatus(flow: FlowState | undefined, result?: JobRuntimeResult): JobRuntimeStatus;
|
|
166
|
-
/**
|
|
167
|
-
* The result the node pins itself when the sidecar could not: the outcome
|
|
168
|
-
* from the last status, without the poster's op results or logs, which the
|
|
169
|
-
* node never had.
|
|
170
|
-
*/
|
|
171
|
-
export declare function outcomeOnlyResult(status: JobRuntimeStatus): FlowState;
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { describeError } from '../../../common/src/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* What passes between the node and a job's runtime sidecar. The node knows the
|
|
4
|
-
* job and nothing else: the sidecar resolves it (onchain, IPFS, logistics),
|
|
5
|
-
* pulls its images and downloads its resources, runs it, pins its result and
|
|
6
|
-
* exits. The two meet in a per-job directory the node makes and the sidecar
|
|
7
|
-
* has bind-mounted:
|
|
8
|
-
*
|
|
9
|
-
* - the node writes the {@link JobRuntimeSeed} before the sidecar starts;
|
|
10
|
-
* - the sidecar keeps its {@link JobRuntimeStatus} there, the last one
|
|
11
|
-
* carrying its result, and what it changed in the cache records
|
|
12
|
-
* (ResourceCacheChanges), each as it happens;
|
|
13
|
-
* - the node serves a unix socket there for the two things that need it
|
|
14
|
-
* live: its signature on the job address, and the job's stop.
|
|
15
|
-
*
|
|
16
|
-
* Neither needs the other up to make progress: the files and the sidecar's
|
|
17
|
-
* container outlive either process. Nothing the sidecar sends can point the
|
|
18
|
-
* socket at another job.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* A job's sidecar container is `<prefix><job address>`, which is also its
|
|
22
|
-
* name on the gateway network, and its data volume.
|
|
23
|
-
*/
|
|
24
|
-
export const JOB_RUNTIME_CONTAINER_PREFIX = 'job-runtime-';
|
|
25
|
-
/** The port the sidecar serves the job API on, inside the gateway network. */
|
|
26
|
-
export const JOB_RUNTIME_PORT = 8080;
|
|
27
|
-
/** Where the sidecar's data volume (its records of the job) is mounted. */
|
|
28
|
-
export const JOB_RUNTIME_DATA_DIR = '/nosana-job-runtime';
|
|
29
|
-
/** Starts a console line that is a job-log entry (ASCII record separator). */
|
|
30
|
-
export const JOB_RUNTIME_LOG_ENTRY_MARK = '\u001e';
|
|
31
|
-
/** The job's directory, as the sidecar has it bind-mounted. */
|
|
32
|
-
export const JOB_RUNTIME_HOST_DIR = '/nosana-host';
|
|
33
|
-
export const JOB_RUNTIME_HOST_SOCKET = 'host.sock';
|
|
34
|
-
/** The files in the job's directory. */
|
|
35
|
-
export const JOB_RUNTIME_FILES = {
|
|
36
|
-
/** {@link JobRuntimeSeed}, from the node. */
|
|
37
|
-
seed: 'seed.json',
|
|
38
|
-
/** {@link JobRuntimeStatus}, from the sidecar. */
|
|
39
|
-
status: 'status.json',
|
|
40
|
-
/** ResourceCacheChanges, from the sidecar. */
|
|
41
|
-
resources: 'resources.json',
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* The versions of the files in the job's directory that carry one. A reader
|
|
45
|
-
* takes any version up to its own and refuses a newer one, whose meaning it
|
|
46
|
-
* cannot know: a node keeps reading what an older sidecar wrote (it takes
|
|
47
|
-
* over a running one after it restarts, maybe upgraded), and a sidecar
|
|
48
|
-
* refuses a seed from a node newer than itself rather than misread it.
|
|
49
|
-
*
|
|
50
|
-
* The status has none: the node reads only a few of its fields and checks
|
|
51
|
-
* their shape instead, a status it cannot read counting as none. A change to
|
|
52
|
-
* what a field means would add one, its absence meaning the format of today.
|
|
53
|
-
*/
|
|
54
|
-
export const JOB_RUNTIME_SEED_VERSION = 1;
|
|
55
|
-
/** The version of the cache changes (ResourceCacheChanges) the sidecar writes. */
|
|
56
|
-
export const RESOURCE_CHANGES_VERSION = 1;
|
|
57
|
-
/** Whether a file's `version` is one a reader at `current` can read. */
|
|
58
|
-
export function isKnownVersion(version, current) {
|
|
59
|
-
return Number.isInteger(version) && version >= 1 && version <= current;
|
|
60
|
-
}
|
|
61
|
-
export const JOB_RUNTIME_HOST_PATHS = {
|
|
62
|
-
/**
|
|
63
|
-
* GET → {@link SignAuthResponse}: a fresh authorization header the node
|
|
64
|
-
* wallet signed for the job address (time included). Takes no input, so the
|
|
65
|
-
* sidecar cannot choose what is signed.
|
|
66
|
-
*/
|
|
67
|
-
signAuth: '/sign-auth',
|
|
68
|
-
/**
|
|
69
|
-
* GET → {@link StopRequest}, held open until the node wants the job stopped
|
|
70
|
-
* (expiry, a stop onchain, the node quitting). Answered at once when it
|
|
71
|
-
* already does.
|
|
72
|
-
*/
|
|
73
|
-
stop: '/stop',
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Error records as plain messages. Op errors are `{event, message}` objects;
|
|
77
|
-
* flow errors are whatever was recorded (a string, an Error, an object).
|
|
78
|
-
*/
|
|
79
|
-
function describeErrors(errors) {
|
|
80
|
-
return (errors ?? []).map(describeError);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* The one line that best explains a terminal status: the first error of the
|
|
84
|
-
* first op that recorded one, else the first flow-level error.
|
|
85
|
-
*/
|
|
86
|
-
export function describeFailure(status) {
|
|
87
|
-
for (const op of status.opStates) {
|
|
88
|
-
const message = op.errors[0];
|
|
89
|
-
if (message)
|
|
90
|
-
return `${op.operationId ?? 'op'}: ${message}`;
|
|
91
|
-
}
|
|
92
|
-
return status.errors[0];
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* A flow state as the node sees it.
|
|
96
|
-
*
|
|
97
|
-
* - The job is over once its `result` is there, which the sidecar sets last.
|
|
98
|
-
* - The phase is `running` until the task manager stamps `endTime` at a
|
|
99
|
-
* terminal state, and while the result is delivered to the poster.
|
|
100
|
-
* - The overall `exitCode` is 0 on success, the first non-zero op exit on
|
|
101
|
-
* failure (falling back to 1), and 0 for a stop with no failed op.
|
|
102
|
-
*/
|
|
103
|
-
export function deriveJobRuntimeStatus(flow, result) {
|
|
104
|
-
const rawStatus = flow?.status ?? 'init';
|
|
105
|
-
const going = !flow || flow.endTime == null || rawStatus === 'waiting-for-result';
|
|
106
|
-
let phase;
|
|
107
|
-
if (going) {
|
|
108
|
-
phase = 'running';
|
|
109
|
-
}
|
|
110
|
-
else if (rawStatus === 'success') {
|
|
111
|
-
phase = 'success';
|
|
112
|
-
}
|
|
113
|
-
else if (rawStatus === 'stopped' || rawStatus === 'restart') {
|
|
114
|
-
phase = 'stopped';
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
phase = 'failed';
|
|
118
|
-
}
|
|
119
|
-
const opStates = (flow?.opStates ?? []).map((op) => ({
|
|
120
|
-
operationId: op.operationId,
|
|
121
|
-
status: op.status,
|
|
122
|
-
exitCode: op.exitCode,
|
|
123
|
-
errors: describeErrors(op.errors),
|
|
124
|
-
}));
|
|
125
|
-
let exitCode = null;
|
|
126
|
-
if (!going) {
|
|
127
|
-
if (phase === 'success') {
|
|
128
|
-
exitCode = 0;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
const failingOp = opStates.find((op) => op.exitCode != null && op.exitCode !== 0);
|
|
132
|
-
exitCode = failingOp?.exitCode ?? (phase === 'stopped' ? 0 : 1);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
phase,
|
|
137
|
-
status: rawStatus,
|
|
138
|
-
running: result === undefined,
|
|
139
|
-
exitCode,
|
|
140
|
-
opStates,
|
|
141
|
-
errors: describeErrors(flow?.errors),
|
|
142
|
-
startTime: flow?.startTime ?? null,
|
|
143
|
-
endTime: flow?.endTime ?? null,
|
|
144
|
-
...(result ? { result } : {}),
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* The result the node pins itself when the sidecar could not: the outcome
|
|
149
|
-
* from the last status, without the poster's op results or logs, which the
|
|
150
|
-
* node never had.
|
|
151
|
-
*/
|
|
152
|
-
export function outcomeOnlyResult(status) {
|
|
153
|
-
return {
|
|
154
|
-
status: status.status,
|
|
155
|
-
startTime: status.startTime ?? 0,
|
|
156
|
-
endTime: status.endTime,
|
|
157
|
-
opStates: [],
|
|
158
|
-
errors: [
|
|
159
|
-
...status.errors,
|
|
160
|
-
...(status.result?.error ? [status.result.error] : []),
|
|
161
|
-
],
|
|
162
|
-
};
|
|
163
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { AuthHeaderGenerator } from '../logistics/ports.js';
|
|
2
|
-
import type { HostClient } from './HostClient.js';
|
|
3
|
-
/**
|
|
4
|
-
* Signs as the node, for the logistics: the node signs only the job address,
|
|
5
|
-
* whatever is asked.
|
|
6
|
-
*/
|
|
7
|
-
export declare function hostAuthHeaders(host: HostClient, signal?: AbortSignal): AuthHeaderGenerator;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signs as the node, for the logistics: the node signs only the job address,
|
|
3
|
-
* whatever is asked.
|
|
4
|
-
*/
|
|
5
|
-
export function hostAuthHeaders(host, signal) {
|
|
6
|
-
return {
|
|
7
|
-
async generateHeader() {
|
|
8
|
-
const headers = new Headers();
|
|
9
|
-
headers.append('Authorization', await host.signAuth(signal));
|
|
10
|
-
return headers;
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How the node and a job's sidecar meet (`@nosana/job-runtime/host`): the
|
|
3
|
-
* contract of the job's directory and the socket the node serves in it, the
|
|
4
|
-
* sidecar's client for that socket, and the JSON file helpers both use. The
|
|
5
|
-
* sidecar itself is `src/main.ts`.
|
|
6
|
-
*/
|
|
7
|
-
export * from './contract.js';
|
|
8
|
-
export { HostClient, HostRequestError } from './HostClient.js';
|
|
9
|
-
export { readJson, writeJsonAtomic } from '../utils/files.js';
|
|
10
|
-
export { StopReasons, type StopReason, } from '../taskManager/stopReasons.js';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How the node and a job's sidecar meet (`@nosana/job-runtime/host`): the
|
|
3
|
-
* contract of the job's directory and the socket the node serves in it, the
|
|
4
|
-
* sidecar's client for that socket, and the JSON file helpers both use. The
|
|
5
|
-
* sidecar itself is `src/main.ts`.
|
|
6
|
-
*/
|
|
7
|
-
export * from './contract.js';
|
|
8
|
-
export { HostClient, HostRequestError } from './HostClient.js';
|
|
9
|
-
export { readJson, writeJsonAtomic } from '../utils/files.js';
|
|
10
|
-
export { StopReasons, } from '../taskManager/stopReasons.js';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { EventEmitter } from 'events';
|
|
2
|
-
import type { JobDefinition, Logistic } from '@nosana/kit';
|
|
3
|
-
import type { AuthHeaderGenerator } from './ports.js';
|
|
4
|
-
export interface JobDefinitionStrategy {
|
|
5
|
-
load(jobId: string, args: Logistic['args']): Promise<JobDefinition>;
|
|
6
|
-
}
|
|
7
|
-
export declare class JobDefinitionStrategySelector {
|
|
8
|
-
private readonly events;
|
|
9
|
-
private readonly auth;
|
|
10
|
-
/**
|
|
11
|
-
* @param events - Where the job API relays a posted definition ('job-definition').
|
|
12
|
-
* @param auth - Signs 'api' requests as the node.
|
|
13
|
-
*/
|
|
14
|
-
constructor(events: EventEmitter, auth: AuthHeaderGenerator);
|
|
15
|
-
/**
|
|
16
|
-
* Selects the appropriate JobDefinitionStrategy based on the name.
|
|
17
|
-
* @param name - The name/type of the strategy ('api-listen' or 'api').
|
|
18
|
-
* @returns JobDefinitionStrategy
|
|
19
|
-
*/
|
|
20
|
-
selectStrategy(name: string): JobDefinitionStrategy;
|
|
21
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ApiListenJobDefinitionStrategy } from './definition/ApiListenJobDefinitionStrategy.js';
|
|
2
|
-
import { ApiJobDefinitionStrategy } from './definition/ApiJobDefinitionStrategy.js';
|
|
3
|
-
export class JobDefinitionStrategySelector {
|
|
4
|
-
/**
|
|
5
|
-
* @param events - Where the job API relays a posted definition ('job-definition').
|
|
6
|
-
* @param auth - Signs 'api' requests as the node.
|
|
7
|
-
*/
|
|
8
|
-
constructor(events, auth) {
|
|
9
|
-
this.events = events;
|
|
10
|
-
this.auth = auth;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Selects the appropriate JobDefinitionStrategy based on the name.
|
|
14
|
-
* @param name - The name/type of the strategy ('api-listen' or 'api').
|
|
15
|
-
* @returns JobDefinitionStrategy
|
|
16
|
-
*/
|
|
17
|
-
selectStrategy(name) {
|
|
18
|
-
switch (name) {
|
|
19
|
-
case 'api-listen':
|
|
20
|
-
return new ApiListenJobDefinitionStrategy(this.events);
|
|
21
|
-
case 'api':
|
|
22
|
-
return new ApiJobDefinitionStrategy(this.auth);
|
|
23
|
-
default:
|
|
24
|
-
throw new Error(`Unsupported strategy: ${name}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { EventEmitter } from 'events';
|
|
2
|
-
import type { FlowState, Logistic } from '@nosana/kit';
|
|
3
|
-
import type { AuthHeaderGenerator } from './ports.js';
|
|
4
|
-
export interface ResultReturnStrategy {
|
|
5
|
-
load(jobId: string, args: Logistic['args'], results: FlowState, orginalState: string): Promise<boolean>;
|
|
6
|
-
}
|
|
7
|
-
export declare class ResultReturnStrategySelector {
|
|
8
|
-
private readonly events;
|
|
9
|
-
private readonly auth;
|
|
10
|
-
/**
|
|
11
|
-
* @param events - Where the job API relays a collected result ('job-result').
|
|
12
|
-
* @param auth - Signs 'api' requests as the node.
|
|
13
|
-
*/
|
|
14
|
-
constructor(events: EventEmitter, auth: AuthHeaderGenerator);
|
|
15
|
-
/**
|
|
16
|
-
* Selects the appropriate JobDefinitionStrategy based on the name.
|
|
17
|
-
* @param name - The name/type of the strategy ('api-listen' or 'api').
|
|
18
|
-
* @returns JobDefinitionStrategy
|
|
19
|
-
*/
|
|
20
|
-
selectStrategy(name: string): ResultReturnStrategy;
|
|
21
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ApiResultReturnStrategy } from './result/ApiResultReturnStrategy.js';
|
|
2
|
-
import { ApiListenResultReturnStrategy } from './result/ApiListenResultReturnStrategy.js';
|
|
3
|
-
export class ResultReturnStrategySelector {
|
|
4
|
-
/**
|
|
5
|
-
* @param events - Where the job API relays a collected result ('job-result').
|
|
6
|
-
* @param auth - Signs 'api' requests as the node.
|
|
7
|
-
*/
|
|
8
|
-
constructor(events, auth) {
|
|
9
|
-
this.events = events;
|
|
10
|
-
this.auth = auth;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Selects the appropriate JobDefinitionStrategy based on the name.
|
|
14
|
-
* @param name - The name/type of the strategy ('api-listen' or 'api').
|
|
15
|
-
* @returns JobDefinitionStrategy
|
|
16
|
-
*/
|
|
17
|
-
selectStrategy(name) {
|
|
18
|
-
switch (name) {
|
|
19
|
-
case 'api-listen':
|
|
20
|
-
return new ApiListenResultReturnStrategy(this.events);
|
|
21
|
-
case 'api':
|
|
22
|
-
return new ApiResultReturnStrategy(this.auth);
|
|
23
|
-
default:
|
|
24
|
-
throw new Error(`Unsupported strategy: ${name}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { JobDefinition, Logistic } from '@nosana/kit';
|
|
2
|
-
import type { AuthHeaderGenerator } from '../ports.js';
|
|
3
|
-
import type { JobDefinitionStrategy } from '../JobDefinitionStrategy.js';
|
|
4
|
-
export declare class ApiJobDefinitionStrategy implements JobDefinitionStrategy {
|
|
5
|
-
private readonly auth;
|
|
6
|
-
private attempts;
|
|
7
|
-
private jobDefinition;
|
|
8
|
-
constructor(auth: AuthHeaderGenerator);
|
|
9
|
-
private retrieveJobDefinition;
|
|
10
|
-
load(jobId: string, args: Logistic['args']): Promise<JobDefinition>;
|
|
11
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Signs outbound logistics requests ('api' strategies) as the node: the shape
|
|
3
|
-
* of `sdk.authorization.generateHeader`. The sidecar holds no wallet, so its
|
|
4
|
-
* generator asks the node, which signs only the job address.
|
|
5
|
-
*/
|
|
6
|
-
export interface AuthHeaderGenerator {
|
|
7
|
-
generateHeader(message: string, options: {
|
|
8
|
-
includeTime: boolean;
|
|
9
|
-
}): Promise<Headers>;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { FlowState, Logistic } from '@nosana/kit';
|
|
2
|
-
import type { ResultReturnStrategy } from '../ResultReturnStrategy.js';
|
|
3
|
-
import type { AuthHeaderGenerator } from '../ports.js';
|
|
4
|
-
export declare class ApiResultReturnStrategy implements ResultReturnStrategy {
|
|
5
|
-
private readonly auth;
|
|
6
|
-
private attempts;
|
|
7
|
-
private success;
|
|
8
|
-
constructor(auth: AuthHeaderGenerator);
|
|
9
|
-
private postJobResults;
|
|
10
|
-
load(jobId: string, args: Logistic['args'], results: FlowState, orginalStatus: string): Promise<boolean>;
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Entrypoint of the job runtime sidecar image (see ../Dockerfile).
|
|
3
|
-
*
|
|
4
|
-
* By default it runs the one job named by `JOB_ADDRESS` (see runtime/runJob.ts).
|
|
5
|
-
*
|
|
6
|
-
* With `--probe` it is a readiness probe for the image instead: it checks the
|
|
7
|
-
* two things the GPU stats sampling depends on, that the runtime mounted
|
|
8
|
-
* `nvidia-smi` into the container and that `/proc` shows the host's process
|
|
9
|
-
* tree, and prints what it found. Exit code 0 means the image is fit to host
|
|
10
|
-
* the sidecar on this machine.
|
|
11
|
-
*/
|
|
12
|
-
import { execFile } from 'child_process';
|
|
13
|
-
import { readFile } from 'fs/promises';
|
|
14
|
-
import { promisify } from 'util';
|
|
15
|
-
import { readJobRuntimeServerConfig } from './config.js';
|
|
16
|
-
import { runJob } from './runtime/runJob.js';
|
|
17
|
-
const run = promisify(execFile);
|
|
18
|
-
async function probeNvidiaSmi() {
|
|
19
|
-
try {
|
|
20
|
-
const { stdout } = await run('nvidia-smi', [
|
|
21
|
-
'--query-gpu=index,name,memory.total',
|
|
22
|
-
'--format=csv,noheader',
|
|
23
|
-
]);
|
|
24
|
-
return { ok: true, detail: stdout.trim() };
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
return { ok: false, detail: error?.message ?? String(error) };
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* In the host pid namespace pid 1 is the host's init, not this process; in a
|
|
32
|
-
* private namespace this node process is pid 1 itself. Read the way the
|
|
33
|
-
* sampler reads ancestry: straight from `/proc`.
|
|
34
|
-
*/
|
|
35
|
-
async function probeHostPids() {
|
|
36
|
-
try {
|
|
37
|
-
const init = (await readFile('/proc/1/comm', 'utf8')).trim();
|
|
38
|
-
return { ok: process.pid !== 1 && init !== 'node', detail: `pid 1 is ${init}` };
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
return { ok: false, detail: error?.message ?? String(error) };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function probe() {
|
|
45
|
-
const [nvidiaSmi, hostPids] = await Promise.all([
|
|
46
|
-
probeNvidiaSmi(),
|
|
47
|
-
probeHostPids(),
|
|
48
|
-
]);
|
|
49
|
-
console.log(JSON.stringify({ nvidiaSmi, hostPids }, null, 2));
|
|
50
|
-
process.exit(nvidiaSmi.ok && hostPids.ok ? 0 : 1);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Runs the job named by `JOB_ADDRESS` (see config.ts for the rest of the
|
|
54
|
-
* environment) and exits once it is over: its result written, its job API
|
|
55
|
-
* closed. The node waits for this container to exit and takes the job from
|
|
56
|
-
* there.
|
|
57
|
-
*
|
|
58
|
-
* SIGTERM is not the job's stop, which comes from the node over its socket:
|
|
59
|
-
* it is the runtime going away (a daemon restart, a host shutdown). The
|
|
60
|
-
* sidecar exits without ending the job, and resumes it from its data volume
|
|
61
|
-
* when it is started again.
|
|
62
|
-
*/
|
|
63
|
-
async function serve() {
|
|
64
|
-
const config = readJobRuntimeServerConfig(process.env);
|
|
65
|
-
const runtime = await runJob(config);
|
|
66
|
-
process.once('SIGTERM', () => {
|
|
67
|
-
console.log(`Interrupted; job ${config.jobAddress} resumes when this runtime starts again`);
|
|
68
|
-
process.exit(143);
|
|
69
|
-
});
|
|
70
|
-
await runtime.done;
|
|
71
|
-
await runtime.close();
|
|
72
|
-
console.log(`Job ${config.jobAddress} is over`);
|
|
73
|
-
process.exit(0);
|
|
74
|
-
}
|
|
75
|
-
if (process.argv.includes('--probe')) {
|
|
76
|
-
await probe();
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
await serve().catch((error) => {
|
|
80
|
-
console.error(error instanceof Error ? error.message : error);
|
|
81
|
-
process.exit(1);
|
|
82
|
-
});
|
|
83
|
-
}
|