The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { ComputeQuota } from "@alchemy.run/aws/SageMaker"; |
| 3 | import { expect } from "@alchemy.run/test"; |
| 4 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 5 | import * as sagemaker from "@distilled.cloud/aws/sagemaker"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | |
| 8 | const { test } = Test.make({ providers: AWS.providers() }); |
| 9 | |
| 10 | // Ungated typed-error probe: prove describeComputeQuota returns the typed |
| 11 | // ResourceNotFound for a nonexistent quota id. |
| 12 | test.provider( |
| 13 | "describeComputeQuota on a nonexistent id fails with ResourceNotFound", |
| 14 | () => |
| 15 | Effect.gen(function* () { |
| 16 | const error = yield* Effect.flip( |
| 17 | sagemaker.describeComputeQuota({ ComputeQuotaId: "abcdef012345" }), |
| 18 | ); |
| 19 | expect(error._tag).toBe("ResourceNotFound"); |
| 20 | }), |
| 21 | { tags: ["provider:aws", "provider:aws:sagemaker", "live"] }, |
| 22 | ); |
| 23 | |
| 24 | const findQuota = (quotaId: string) => |
| 25 | sagemaker |
| 26 | .describeComputeQuota({ ComputeQuotaId: quotaId }) |
| 27 | .pipe(Effect.catchTag("ResourceNotFound", () => Effect.succeed(undefined))); |
| 28 | |
| 29 | // Compute quotas require an EKS-orchestrated HyperPod cluster, which takes |
| 30 | // ~30 minutes and real ML + EKS capacity to stand up. Gated behind an |
| 31 | // existing cluster: |
| 32 | // AWS_TEST_SAGEMAKER_HYPERPOD_EKS_CLUSTER_ARN=<arn of an EKS HyperPod cluster> |
| 33 | test.provider.skipIf(!process.env.AWS_TEST_SAGEMAKER_HYPERPOD_EKS_CLUSTER_ARN)( |
| 34 | "create compute quota, update it, destroy", |
| 35 | (stack) => |
| 36 | Effect.gen(function* () { |
| 37 | yield* stack.destroy(); |
| 38 | |
| 39 | const clusterArn = process.env.AWS_TEST_SAGEMAKER_HYPERPOD_EKS_CLUSTER_ARN!; |
| 40 | |
| 41 | const { quota } = yield* stack.deploy( |
| 42 | Effect.gen(function* () { |
| 43 | const quota = yield* ComputeQuota("TestQuota", { |
| 44 | clusterArn, |
| 45 | computeQuotaTarget: { TeamName: "alchemy-research", FairShareWeight: 10 }, |
| 46 | computeQuotaConfig: { |
| 47 | ComputeQuotaResources: [{ InstanceType: "ml.t3.medium", Count: 1 }], |
| 48 | }, |
| 49 | activationState: "Enabled", |
| 50 | tags: { purpose: "alchemy-test" }, |
| 51 | }); |
| 52 | return { quota }; |
| 53 | }), |
| 54 | ); |
| 55 | |
| 56 | expect(quota.computeQuotaArn).toContain(":compute-quota/"); |
| 57 | expect(quota.clusterArn).toBe(clusterArn); |
| 58 | |
| 59 | // Out-of-band verification via distilled. |
| 60 | const described = yield* findQuota(quota.computeQuotaId); |
| 61 | expect(described?.Status).toBe("Created"); |
| 62 | expect(described?.ComputeQuotaTarget?.TeamName).toBe("alchemy-research"); |
| 63 | |
| 64 | // Update in place — the id must remain stable and the version bump. |
| 65 | const { quota: updated } = yield* stack.deploy( |
| 66 | Effect.gen(function* () { |
| 67 | const quota = yield* ComputeQuota("TestQuota", { |
| 68 | clusterArn, |
| 69 | computeQuotaTarget: { TeamName: "alchemy-research", FairShareWeight: 20 }, |
| 70 | computeQuotaConfig: { |
| 71 | ComputeQuotaResources: [{ InstanceType: "ml.t3.medium", Count: 2 }], |
| 72 | }, |
| 73 | activationState: "Enabled", |
| 74 | tags: { purpose: "alchemy-test" }, |
| 75 | }); |
| 76 | return { quota }; |
| 77 | }), |
| 78 | ); |
| 79 | expect(updated.computeQuotaId).toBe(quota.computeQuotaId); |
| 80 | expect(updated.computeQuotaVersion).toBeGreaterThan(quota.computeQuotaVersion); |
| 81 | |
| 82 | // Destroy and verify gone. |
| 83 | yield* stack.destroy(); |
| 84 | const gone = yield* findQuota(quota.computeQuotaId); |
| 85 | expect(gone === undefined || gone.Status === "Deleted").toBe(true); |
| 86 | }), |
| 87 | { tags: ["provider:aws", "provider:aws:sagemaker", "live"], timeout: 600_000 }, |
| 88 | ); |