@hatchet-dev/typescript-sdk 0.16.0-alpha.4 → 0.17.0
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/clients/dispatcher/dispatcher-client.d.ts +2 -1
- package/clients/dispatcher/dispatcher-client.js +10 -1
- package/clients/event/event-client.js +13 -8
- package/clients/hatchet-client/client-config.d.ts +0 -6
- package/clients/hatchet-client/client-config.js +0 -2
- package/clients/hatchet-client/features/cron-client.d.ts +79 -0
- package/clients/hatchet-client/features/cron-client.js +127 -0
- package/clients/hatchet-client/features/schedule-client.d.ts +76 -0
- package/clients/hatchet-client/features/schedule-client.js +120 -0
- package/clients/hatchet-client/hatchet-client.d.ts +4 -2
- package/clients/hatchet-client/hatchet-client.js +6 -25
- package/clients/listener/child-listener-client.js +16 -13
- package/clients/rest/api.d.ts +0 -3
- package/clients/rest/api.js +0 -10
- package/clients/rest/generated/Api.d.ts +152 -2
- package/clients/rest/generated/Api.js +81 -1
- package/clients/rest/generated/data-contracts.d.ts +86 -0
- package/clients/rest/generated/data-contracts.js +27 -1
- package/clients/rest/index.d.ts +2 -2
- package/clients/rest/index.js +21 -10
- package/clients/worker/handler.js +16 -11
- package/clients/worker/worker.d.ts +2 -10
- package/clients/worker/worker.js +24 -38
- package/examples/crons/cron-worker.d.ts +2 -0
- package/examples/crons/cron-worker.js +48 -0
- package/examples/crons/programatic-crons.js +55 -0
- package/examples/on-failure.js +15 -10
- package/examples/retries-with-backoff.d.ts +1 -0
- package/examples/{managed-worker.js → retries-with-backoff.js} +24 -33
- package/examples/scheduled-runs/programatic-schedules.d.ts +1 -0
- package/examples/scheduled-runs/programatic-schedules.js +54 -0
- package/examples/simple-worker.d.ts +2 -1
- package/examples/simple-worker.js +6 -3
- package/package.json +8 -8
- package/protoc/dispatcher/dispatcher.js +1 -1
- package/protoc/events/events.js +1 -1
- package/protoc/google/protobuf/timestamp.js +1 -1
- package/protoc/google/protobuf/wrappers.js +17 -7
- package/protoc/workflows/workflows.d.ts +13 -0
- package/protoc/workflows/workflows.js +160 -7
- package/step.d.ts +17 -121
- package/step.js +23 -9
- package/util/config-loader/config-loader.js +18 -26
- package/util/retrier.js +8 -3
- package/version.d.ts +1 -0
- package/version.js +4 -0
- package/workflow.d.ts +67 -459
- package/workflow.js +17 -7
- package/clients/rest/generated/cloud/Api.d.ts +0 -377
- package/clients/rest/generated/cloud/Api.js +0 -326
- package/clients/rest/generated/cloud/data-contracts.d.ts +0 -468
- package/clients/rest/generated/cloud/data-contracts.js +0 -68
- package/clients/rest/generated/cloud/http-client.d.ts +0 -41
- package/clients/rest/generated/cloud/http-client.js +0 -102
- package/clients/worker/compute/compute-config.d.ts +0 -156
- package/clients/worker/compute/compute-config.js +0 -82
- package/clients/worker/compute/managed-compute.d.ts +0 -15
- package/clients/worker/compute/managed-compute.js +0 -104
- /package/examples/{managed-worker.d.ts → crons/programatic-crons.d.ts} +0 -0
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { ManagedWorkerRegion } from '../../rest/generated/cloud/data-contracts';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
export declare const SharedCPUComputeSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
4
|
-
pool: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
5
|
-
numReplicas: z.ZodDefault<z.ZodNumber>;
|
|
6
|
-
regions: z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof ManagedWorkerRegion>, "many">>;
|
|
7
|
-
cpus: z.ZodNumber;
|
|
8
|
-
}, {
|
|
9
|
-
cpuKind: z.ZodLiteral<"shared">;
|
|
10
|
-
memoryMb: z.ZodEffects<z.ZodNumber, number, number>;
|
|
11
|
-
}>, "strip", z.ZodTypeAny, {
|
|
12
|
-
numReplicas: number;
|
|
13
|
-
cpus: number;
|
|
14
|
-
cpuKind: "shared";
|
|
15
|
-
memoryMb: number;
|
|
16
|
-
pool?: string | undefined;
|
|
17
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
18
|
-
}, {
|
|
19
|
-
cpus: number;
|
|
20
|
-
cpuKind: "shared";
|
|
21
|
-
memoryMb: number;
|
|
22
|
-
pool?: string | undefined;
|
|
23
|
-
numReplicas?: number | undefined;
|
|
24
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
25
|
-
}>;
|
|
26
|
-
export type SharedCPUCompute = z.infer<typeof SharedCPUComputeSchema>;
|
|
27
|
-
export declare const PerformanceCPUComputeSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
28
|
-
pool: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
29
|
-
numReplicas: z.ZodDefault<z.ZodNumber>;
|
|
30
|
-
regions: z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof ManagedWorkerRegion>, "many">>;
|
|
31
|
-
cpus: z.ZodNumber;
|
|
32
|
-
}, {
|
|
33
|
-
cpuKind: z.ZodLiteral<"performance">;
|
|
34
|
-
memoryMb: z.ZodEffects<z.ZodNumber, number, number>;
|
|
35
|
-
}>, "strip", z.ZodTypeAny, {
|
|
36
|
-
numReplicas: number;
|
|
37
|
-
cpus: number;
|
|
38
|
-
cpuKind: "performance";
|
|
39
|
-
memoryMb: number;
|
|
40
|
-
pool?: string | undefined;
|
|
41
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
42
|
-
}, {
|
|
43
|
-
cpus: number;
|
|
44
|
-
cpuKind: "performance";
|
|
45
|
-
memoryMb: number;
|
|
46
|
-
pool?: string | undefined;
|
|
47
|
-
numReplicas?: number | undefined;
|
|
48
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
49
|
-
}>;
|
|
50
|
-
export type PerformanceCPUCompute = z.infer<typeof PerformanceCPUComputeSchema>;
|
|
51
|
-
export declare const GPUComputeSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
52
|
-
pool: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
53
|
-
numReplicas: z.ZodDefault<z.ZodNumber>;
|
|
54
|
-
regions: z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof ManagedWorkerRegion>, "many">>;
|
|
55
|
-
cpus: z.ZodNumber;
|
|
56
|
-
}, {
|
|
57
|
-
cpuKind: z.ZodLiteral<"shared">;
|
|
58
|
-
gpuKind: z.ZodEnum<["a10", "l40s", "a100-40gb", "a100-80gb"]>;
|
|
59
|
-
gpus: z.ZodNumber;
|
|
60
|
-
regions: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodNativeEnum<typeof ManagedWorkerRegion>, "many">, ManagedWorkerRegion[], ManagedWorkerRegion[]>>;
|
|
61
|
-
memoryMb: z.ZodEffects<z.ZodNumber, number, number>;
|
|
62
|
-
}>, "strip", z.ZodTypeAny, {
|
|
63
|
-
numReplicas: number;
|
|
64
|
-
cpus: number;
|
|
65
|
-
cpuKind: "shared";
|
|
66
|
-
memoryMb: number;
|
|
67
|
-
gpuKind: "a10" | "l40s" | "a100-40gb" | "a100-80gb";
|
|
68
|
-
gpus: number;
|
|
69
|
-
pool?: string | undefined;
|
|
70
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
71
|
-
}, {
|
|
72
|
-
cpus: number;
|
|
73
|
-
cpuKind: "shared";
|
|
74
|
-
memoryMb: number;
|
|
75
|
-
gpuKind: "a10" | "l40s" | "a100-40gb" | "a100-80gb";
|
|
76
|
-
gpus: number;
|
|
77
|
-
pool?: string | undefined;
|
|
78
|
-
numReplicas?: number | undefined;
|
|
79
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
80
|
-
}>;
|
|
81
|
-
export type GPUCompute = z.infer<typeof GPUComputeSchema>;
|
|
82
|
-
export declare const ComputeSchema: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
|
83
|
-
pool: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
84
|
-
numReplicas: z.ZodDefault<z.ZodNumber>;
|
|
85
|
-
regions: z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof ManagedWorkerRegion>, "many">>;
|
|
86
|
-
cpus: z.ZodNumber;
|
|
87
|
-
}, {
|
|
88
|
-
cpuKind: z.ZodLiteral<"shared">;
|
|
89
|
-
memoryMb: z.ZodEffects<z.ZodNumber, number, number>;
|
|
90
|
-
}>, "strip", z.ZodTypeAny, {
|
|
91
|
-
numReplicas: number;
|
|
92
|
-
cpus: number;
|
|
93
|
-
cpuKind: "shared";
|
|
94
|
-
memoryMb: number;
|
|
95
|
-
pool?: string | undefined;
|
|
96
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
97
|
-
}, {
|
|
98
|
-
cpus: number;
|
|
99
|
-
cpuKind: "shared";
|
|
100
|
-
memoryMb: number;
|
|
101
|
-
pool?: string | undefined;
|
|
102
|
-
numReplicas?: number | undefined;
|
|
103
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
104
|
-
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
105
|
-
pool: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
106
|
-
numReplicas: z.ZodDefault<z.ZodNumber>;
|
|
107
|
-
regions: z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof ManagedWorkerRegion>, "many">>;
|
|
108
|
-
cpus: z.ZodNumber;
|
|
109
|
-
}, {
|
|
110
|
-
cpuKind: z.ZodLiteral<"performance">;
|
|
111
|
-
memoryMb: z.ZodEffects<z.ZodNumber, number, number>;
|
|
112
|
-
}>, "strip", z.ZodTypeAny, {
|
|
113
|
-
numReplicas: number;
|
|
114
|
-
cpus: number;
|
|
115
|
-
cpuKind: "performance";
|
|
116
|
-
memoryMb: number;
|
|
117
|
-
pool?: string | undefined;
|
|
118
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
119
|
-
}, {
|
|
120
|
-
cpus: number;
|
|
121
|
-
cpuKind: "performance";
|
|
122
|
-
memoryMb: number;
|
|
123
|
-
pool?: string | undefined;
|
|
124
|
-
numReplicas?: number | undefined;
|
|
125
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
126
|
-
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
127
|
-
pool: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
128
|
-
numReplicas: z.ZodDefault<z.ZodNumber>;
|
|
129
|
-
regions: z.ZodOptional<z.ZodArray<z.ZodNativeEnum<typeof ManagedWorkerRegion>, "many">>;
|
|
130
|
-
cpus: z.ZodNumber;
|
|
131
|
-
}, {
|
|
132
|
-
cpuKind: z.ZodLiteral<"shared">;
|
|
133
|
-
gpuKind: z.ZodEnum<["a10", "l40s", "a100-40gb", "a100-80gb"]>;
|
|
134
|
-
gpus: z.ZodNumber;
|
|
135
|
-
regions: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodNativeEnum<typeof ManagedWorkerRegion>, "many">, ManagedWorkerRegion[], ManagedWorkerRegion[]>>;
|
|
136
|
-
memoryMb: z.ZodEffects<z.ZodNumber, number, number>;
|
|
137
|
-
}>, "strip", z.ZodTypeAny, {
|
|
138
|
-
numReplicas: number;
|
|
139
|
-
cpus: number;
|
|
140
|
-
cpuKind: "shared";
|
|
141
|
-
memoryMb: number;
|
|
142
|
-
gpuKind: "a10" | "l40s" | "a100-40gb" | "a100-80gb";
|
|
143
|
-
gpus: number;
|
|
144
|
-
pool?: string | undefined;
|
|
145
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
146
|
-
}, {
|
|
147
|
-
cpus: number;
|
|
148
|
-
cpuKind: "shared";
|
|
149
|
-
memoryMb: number;
|
|
150
|
-
gpuKind: "a10" | "l40s" | "a100-40gb" | "a100-80gb";
|
|
151
|
-
gpus: number;
|
|
152
|
-
pool?: string | undefined;
|
|
153
|
-
numReplicas?: number | undefined;
|
|
154
|
-
regions?: ManagedWorkerRegion[] | undefined;
|
|
155
|
-
}>]>;
|
|
156
|
-
export declare const computeHash: (compute: z.infer<typeof ComputeSchema>) => string;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.computeHash = exports.ComputeSchema = exports.GPUComputeSchema = exports.PerformanceCPUComputeSchema = exports.SharedCPUComputeSchema = void 0;
|
|
4
|
-
const data_contracts_1 = require("../../rest/generated/cloud/data-contracts");
|
|
5
|
-
const crypto_1 = require("crypto");
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
const BaseComputeSchema = zod_1.z.object({
|
|
8
|
-
pool: zod_1.z.string().default('default').optional().describe('The name of the compute pool to use'),
|
|
9
|
-
numReplicas: zod_1.z
|
|
10
|
-
.number()
|
|
11
|
-
.int()
|
|
12
|
-
.min(0, { message: 'Must be at least 0' })
|
|
13
|
-
.max(1000, { message: 'Must be at most 1000' })
|
|
14
|
-
.default(1)
|
|
15
|
-
.describe('The number of replicas'),
|
|
16
|
-
regions: zod_1.z
|
|
17
|
-
.array(zod_1.z.nativeEnum(data_contracts_1.ManagedWorkerRegion))
|
|
18
|
-
.optional()
|
|
19
|
-
.describe('The regions to deploy the worker to'),
|
|
20
|
-
cpus: zod_1.z
|
|
21
|
-
.number()
|
|
22
|
-
.int()
|
|
23
|
-
.min(1, { message: 'Must be at least 1' })
|
|
24
|
-
.max(64, { message: 'Must be at most 64' })
|
|
25
|
-
.describe('The number of CPUs to use for the worker'),
|
|
26
|
-
});
|
|
27
|
-
exports.SharedCPUComputeSchema = BaseComputeSchema.extend({
|
|
28
|
-
cpuKind: zod_1.z.literal('shared'),
|
|
29
|
-
memoryMb: zod_1.z
|
|
30
|
-
.number()
|
|
31
|
-
.int()
|
|
32
|
-
.min(256, { message: 'Must be at least 256 MB' })
|
|
33
|
-
.max(65536, { message: 'Must be at most 65536 MB' })
|
|
34
|
-
.refine((val) => val % 256 === 0, { message: 'Must be divisible by 256 MB' })
|
|
35
|
-
.describe('The amount of memory in MB to use for the worker'),
|
|
36
|
-
});
|
|
37
|
-
exports.PerformanceCPUComputeSchema = BaseComputeSchema.extend({
|
|
38
|
-
cpuKind: zod_1.z.literal('performance'),
|
|
39
|
-
memoryMb: zod_1.z
|
|
40
|
-
.number()
|
|
41
|
-
.int()
|
|
42
|
-
.min(2048, { message: 'Must be at least 1024 MB' })
|
|
43
|
-
.max(65536, { message: 'Must be at most 65536 MB' })
|
|
44
|
-
.refine((val) => val % 256 === 0, { message: 'Must be divisible by 256 MB' })
|
|
45
|
-
.describe('The amount of memory in MB to use for the worker'),
|
|
46
|
-
});
|
|
47
|
-
// eslint-disable-next-line no-shadow
|
|
48
|
-
const AllowedGPUManagedWorkerRegions = [data_contracts_1.ManagedWorkerRegion.Ord];
|
|
49
|
-
exports.GPUComputeSchema = BaseComputeSchema.extend({
|
|
50
|
-
cpuKind: zod_1.z.literal('shared'),
|
|
51
|
-
gpuKind: zod_1.z.enum(['a10', 'l40s', 'a100-40gb', 'a100-80gb']),
|
|
52
|
-
gpus: zod_1.z
|
|
53
|
-
.number()
|
|
54
|
-
.int()
|
|
55
|
-
.min(1, { message: 'Must be at least 1' })
|
|
56
|
-
.max(8, { message: 'Must be at most 8' })
|
|
57
|
-
.describe('The number of GPUs to use for the worker'),
|
|
58
|
-
regions: zod_1.z
|
|
59
|
-
.array(zod_1.z.nativeEnum(data_contracts_1.ManagedWorkerRegion))
|
|
60
|
-
.refine((val) => val.every((region) => AllowedGPUManagedWorkerRegions.includes(region)), {
|
|
61
|
-
message: 'Invalid GPU region',
|
|
62
|
-
})
|
|
63
|
-
.optional()
|
|
64
|
-
.describe('The regions to deploy the worker to'),
|
|
65
|
-
memoryMb: zod_1.z
|
|
66
|
-
.number()
|
|
67
|
-
.int()
|
|
68
|
-
.min(2048, { message: 'Must be at least 1024 MB' })
|
|
69
|
-
.max(65536, { message: 'Must be at most 65536 MB' })
|
|
70
|
-
.refine((val) => val % 256 === 0, { message: 'Must be divisible by 256 MB' })
|
|
71
|
-
.describe('The amount of memory in MB to use for the worker'),
|
|
72
|
-
});
|
|
73
|
-
exports.ComputeSchema = zod_1.z.union([
|
|
74
|
-
exports.SharedCPUComputeSchema,
|
|
75
|
-
exports.PerformanceCPUComputeSchema,
|
|
76
|
-
exports.GPUComputeSchema,
|
|
77
|
-
]);
|
|
78
|
-
const computeHash = (compute) => {
|
|
79
|
-
const str = JSON.stringify(compute);
|
|
80
|
-
return (0, crypto_1.createHash)('sha256').update(str).digest('hex');
|
|
81
|
-
};
|
|
82
|
-
exports.computeHash = computeHash;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { HatchetClient } from '../../hatchet-client';
|
|
2
|
-
import { CreateManagedWorkerRuntimeConfigRequest } from '../../rest/generated/cloud/data-contracts';
|
|
3
|
-
import { Logger } from '../../../util/logger';
|
|
4
|
-
import { ActionRegistry } from '../worker';
|
|
5
|
-
export declare class ManagedCompute {
|
|
6
|
-
actions: ActionRegistry;
|
|
7
|
-
client: HatchetClient;
|
|
8
|
-
maxRuns: number;
|
|
9
|
-
configs: CreateManagedWorkerRuntimeConfigRequest[];
|
|
10
|
-
cloudRegisterId: string | undefined;
|
|
11
|
-
logger: Logger;
|
|
12
|
-
constructor(actions: ActionRegistry, client: HatchetClient, maxRuns?: number);
|
|
13
|
-
getComputeConfigs(actions: ActionRegistry): CreateManagedWorkerRuntimeConfigRequest[];
|
|
14
|
-
cloudRegister(): Promise<void>;
|
|
15
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ManagedCompute = void 0;
|
|
13
|
-
const logger_1 = require("../../../util/logger");
|
|
14
|
-
const compute_config_1 = require("./compute-config");
|
|
15
|
-
class ManagedCompute {
|
|
16
|
-
constructor(actions, client, maxRuns = 1) {
|
|
17
|
-
this.actions = actions;
|
|
18
|
-
this.client = client;
|
|
19
|
-
this.maxRuns = maxRuns;
|
|
20
|
-
this.configs = this.getComputeConfigs(this.actions);
|
|
21
|
-
this.cloudRegisterId = this.client.config.cloud_register_id;
|
|
22
|
-
this.logger = new logger_1.Logger(`Compute`, this.client.config.log_level);
|
|
23
|
-
if (this.configs.length === 0) {
|
|
24
|
-
this.logger.debug('No compute configs found, skipping cloud registration and running all actions locally.');
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (!this.cloudRegisterId) {
|
|
28
|
-
this.logger.warn('Managed cloud compute plan:');
|
|
29
|
-
this.configs.forEach((compute) => {
|
|
30
|
-
var _a;
|
|
31
|
-
this.logger.warn(' ----------------------------');
|
|
32
|
-
this.logger.warn(` actions: ${(_a = compute.actions) === null || _a === void 0 ? void 0 : _a.join(', ')}`);
|
|
33
|
-
this.logger.warn(` num replicas: ${compute.numReplicas}`);
|
|
34
|
-
this.logger.warn(` cpu kind: ${compute.cpuKind}`);
|
|
35
|
-
this.logger.warn(` cpus: ${compute.cpus}`);
|
|
36
|
-
this.logger.warn(` memory mb: ${compute.memoryMb}`);
|
|
37
|
-
// this.logger.warn(` regions: ${compute.regions?.join(', ')}`);
|
|
38
|
-
});
|
|
39
|
-
this.logger.warn('NOTICE: local mode detected, skipping cloud registration and running all actions locally.');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
getComputeConfigs(actions) {
|
|
43
|
-
/**
|
|
44
|
-
* Builds a map of compute hashes to compute configs and lists of actions that correspond to each compute hash.
|
|
45
|
-
*/
|
|
46
|
-
const computeMap = {};
|
|
47
|
-
try {
|
|
48
|
-
Object.entries(actions).forEach(([action, { compute }]) => {
|
|
49
|
-
if (!compute) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const key = (0, compute_config_1.computeHash)(compute);
|
|
53
|
-
const gpuKind = 'gpuKind' in compute ? compute.gpuKind : undefined;
|
|
54
|
-
const gpus = 'gpus' in compute ? compute.gpus : undefined;
|
|
55
|
-
if (!computeMap[key]) {
|
|
56
|
-
computeMap[key] = {
|
|
57
|
-
actions: [],
|
|
58
|
-
numReplicas: compute.numReplicas,
|
|
59
|
-
cpuKind: compute.cpuKind,
|
|
60
|
-
cpus: compute.cpus,
|
|
61
|
-
memoryMb: compute.memoryMb,
|
|
62
|
-
regions: compute.regions,
|
|
63
|
-
slots: this.maxRuns,
|
|
64
|
-
gpuKind,
|
|
65
|
-
gpus,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
computeMap[key].actions.push(action);
|
|
69
|
-
});
|
|
70
|
-
return Object.values(computeMap);
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
this.logger.error(`Error getting compute configs: ${e}`);
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
cloudRegister() {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
/**
|
|
80
|
-
* Registers the compute plan with the cloud if the environment variable is set.
|
|
81
|
-
* Exits the process upon completion.
|
|
82
|
-
*/
|
|
83
|
-
if (this.cloudRegisterId) {
|
|
84
|
-
this.logger.info(`Registering cloud compute plan with ID: ${this.cloudRegisterId}`);
|
|
85
|
-
try {
|
|
86
|
-
if (this.configs.length === 0) {
|
|
87
|
-
this.logger.warn('No actions to register, skipping cloud registration.');
|
|
88
|
-
process.exit(0);
|
|
89
|
-
}
|
|
90
|
-
const req = {
|
|
91
|
-
runtimeConfigs: this.configs,
|
|
92
|
-
};
|
|
93
|
-
yield this.client.cloudApi.infraAsCodeCreate(this.cloudRegisterId, req);
|
|
94
|
-
process.exit(0);
|
|
95
|
-
}
|
|
96
|
-
catch (e) {
|
|
97
|
-
this.logger.error(`ERROR: ${e}`);
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.ManagedCompute = ManagedCompute;
|
|
File without changes
|