Skip to content

Commit

Permalink
feat: derive budget and expiration time from components in deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
SewerynKras committed May 29, 2024
1 parent 22a29e9 commit 3a7d724
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/experimental/deployment/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,18 @@ export class Deployment {
this.networks.set(network.name, networkInstance);
}

// TODO: Derive this from deployment spec
// Allocation is re-used for all demands so the expiration date should
// be the equal to the longest expiration date of all demands
const longestExpiration =
Math.max(...this.components.leaseProcessPools.map((pool) => pool.options.market.rentHours)) * 3600;
const totalBudget = this.components.leaseProcessPools.reduce(
(acc, pool) => acc + this.modules.market.estimateBudget(pool.options),
0,
);

const allocation = await this.modules.payment.createAllocation({
budget: 1,
expirationSec: 30 * 60, // 30 minutes
budget: totalBudget,
expirationSec: longestExpiration,
});

for (const pool of this.components.leaseProcessPools) {
Expand Down

0 comments on commit 3a7d724

Please sign in to comment.