Skip to content

Commit

Permalink
chore: fixed examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mgordel committed Jun 6, 2024
1 parent 8b9a8bd commit 8c051ee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
17 changes: 7 additions & 10 deletions examples/advanced/hello-world.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DraftOfferProposalPool, GolemNetwork, MarketOrderSpec } from "@golem-sdk/golem-js";

import { pinoPrettyLogger } from "@golem-sdk/pino-logger";

(async () => {
Expand All @@ -14,13 +13,6 @@ import { pinoPrettyLogger } from "@golem-sdk/pino-logger";
try {
await glm.connect();

const pricing = {
model: "linear",
maxStartPrice: 1,
maxCpuPerHourPrice: 1,
maxEnvPerHourPrice: 1,
};

const order: MarketOrderSpec = {
demand: {
workload: {
Expand All @@ -30,7 +22,12 @@ import { pinoPrettyLogger } from "@golem-sdk/pino-logger";
},
market: {
rentHours: 0.5,
pricing,
pricing: {
model: "linear",
maxStartPrice: 1,
maxCpuPerHourPrice: 1,
maxEnvPerHourPrice: 1,
},
},
};

Expand All @@ -45,7 +42,7 @@ import { pinoPrettyLogger } from "@golem-sdk/pino-logger";
const demandSpecification = await glm.market.buildDemandDetails(order.demand, allocation);
const draftProposal$ = glm.market.collectDraftOfferProposals({
demandSpecification,
pricing,
pricing: order.market.pricing,
});
const proposalSubscription = proposalPool.readFrom(draftProposal$);
const draftProposal = await proposalPool.acquire();
Expand Down
8 changes: 5 additions & 3 deletions examples/advanced/local-image/serveLocalGvmi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DraftOfferProposalPool, GolemNetwork } from "@golem-sdk/golem-js";
import { DraftOfferProposalPool, GolemNetwork, MarketOrderSpec } from "@golem-sdk/golem-js";

import { pinoPrettyLogger } from "@golem-sdk/pino-logger";
import { fileURLToPath } from "url";
Expand All @@ -18,7 +18,7 @@ const getImagePath = (path: string) => fileURLToPath(new URL(path, import.meta.u
try {
await glm.connect();

const demand = {
const order: MarketOrderSpec = {
demand: {
workload: {
// Here you supply the path to the GVMI file that you want to deploy and use
Expand All @@ -29,6 +29,7 @@ const getImagePath = (path: string) => fileURLToPath(new URL(path, import.meta.u
market: {
rentHours: 12,
pricing: {
model: "linear",
maxStartPrice: 1,
maxCpuPerHourPrice: 1,
maxEnvPerHourPrice: 1,
Expand All @@ -44,9 +45,10 @@ const getImagePath = (path: string) => fileURLToPath(new URL(path, import.meta.u
budget: 1,
expirationSec: 30 * 60, // 30 minutes
});
const demandSpecification = await glm.market.buildDemandDetails(demand.demand, allocation);
const demandSpecification = await glm.market.buildDemandDetails(order.demand, allocation);
const draftProposal$ = glm.market.collectDraftOfferProposals({
demandSpecification,
pricing: order.market.pricing,
});
const proposalSubscription = proposalPool.readFrom(draftProposal$);
const draftProposal = await proposalPool.acquire();
Expand Down
5 changes: 1 addition & 4 deletions examples/advanced/manual-pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ const demandOptions = {
maxCpuPerHourPrice: 1,
maxEnvPerHourPrice: 1,
},
withProviders: ["0x123123"],
withoutProviders: ["0x123123"],
withOperators: ["0x123123"],
withoutOperators: ["0x123123"],
},
} as const;

Expand All @@ -47,6 +43,7 @@ const demandOptions = {

const draftProposal$ = glm.market.collectDraftOfferProposals({
demandSpecification,
pricing: demandOptions.market.pricing,
});

const proposalSubscription = proposalPool.readFrom(draftProposal$);
Expand Down

0 comments on commit 8c051ee

Please sign in to comment.