diff --git a/examples/experimental/job/cancel.ts b/examples/experimental/job/cancel.ts index 422caf4ba..80221cafa 100644 --- a/examples/experimental/job/cancel.ts +++ b/examples/experimental/job/cancel.ts @@ -1,8 +1,8 @@ import { JobManager } from "@golem-sdk/golem-js/experimental"; import { MarketOrderSpec } from "@golem-sdk/golem-js"; const golem = new JobManager({ - yagna: { - apiKey: "try_golem", + api: { + key: "try_golem", }, }); diff --git a/examples/experimental/job/getJobById.ts b/examples/experimental/job/getJobById.ts index 7276a2984..ba808ca57 100644 --- a/examples/experimental/job/getJobById.ts +++ b/examples/experimental/job/getJobById.ts @@ -2,8 +2,8 @@ import { JobManager } from "@golem-sdk/golem-js/experimental"; import { MarketOrderSpec } from "@golem-sdk/golem-js"; const golem = new JobManager({ - yagna: { - apiKey: "try_golem", + api: { + key: "try_golem", }, }); diff --git a/examples/experimental/job/waitForResults.ts b/examples/experimental/job/waitForResults.ts index d71bdf73b..e3d9497cf 100644 --- a/examples/experimental/job/waitForResults.ts +++ b/examples/experimental/job/waitForResults.ts @@ -1,8 +1,8 @@ import { JobManager } from "@golem-sdk/golem-js/experimental"; import { MarketOrderSpec } from "@golem-sdk/golem-js"; const golem = new JobManager({ - yagna: { - apiKey: "try_golem", + api: { + key: "try_golem", }, }); diff --git a/src/experimental/job/job.ts b/src/experimental/job/job.ts index dad128af5..f4971d203 100644 --- a/src/experimental/job/job.ts +++ b/src/experimental/job/job.ts @@ -1,11 +1,8 @@ -import { ExeUnitOptions, ExeUnit } from "../../activity/exe-unit"; -import { NetworkOptions } from "../../network"; -import { PaymentModuleOptions } from "../../payment"; +import { ExeUnit } from "../../activity/exe-unit"; import { EventEmitter } from "eventemitter3"; import { GolemAbortError, GolemUserError } from "../../shared/error/golem-error"; import { GolemNetwork, MarketOrderSpec } from "../../golem-network/golem-network"; import { Logger } from "../../shared/utils"; -import { WorkloadDemandDirectorConfigOptions } from "../../market/demand/options"; export enum JobState { New = "new", @@ -16,13 +13,6 @@ export enum JobState { Rejected = "rejected", } -export type RunJobOptions = { - payment?: PaymentModuleOptions; - network?: NetworkOptions; - workload?: WorkloadDemandDirectorConfigOptions; - work?: ExeUnitOptions; -}; - export type WorkFunction = (exe: ExeUnit) => Promise; export interface JobEventsDict { diff --git a/src/experimental/job/job_manager.ts b/src/experimental/job/job_manager.ts index 8a1d8fc8d..b3b0da5fd 100644 --- a/src/experimental/job/job_manager.ts +++ b/src/experimental/job/job_manager.ts @@ -1,16 +1,13 @@ import { v4 } from "uuid"; -import { Job, RunJobOptions } from "./job"; -import { defaultLogger, Logger, YagnaOptions, isNode, isBrowser } from "../../shared/utils"; +import { Job } from "./job"; +import { defaultLogger, Logger, YagnaOptions } from "../../shared/utils"; import { GolemUserError } from "../../shared/error/golem-error"; -import { GolemNetwork, MarketOrderSpec } from "../../golem-network/golem-network"; -import { - GftpStorageProvider, - NullStorageProvider, - StorageProvider, - WebSocketBrowserStorageProvider, -} from "../../shared/storage"; +import { GolemNetwork, GolemNetworkOptions, MarketOrderSpec } from "../../golem-network/golem-network"; -export type JobManagerConfig = Partial & { +export type JobManagerConfig = Partial & { + /** Type of engine required: vm, wasm, vm-nvidia, etc... + * @deprecated This field is deprecated and will be removed in future versions. Please use the 'api.key` and `api.url' instead. + */ yagna?: YagnaOptions; }; @@ -28,20 +25,16 @@ export class JobManager { * @param logger */ constructor( - private readonly config?: JobManagerConfig, + config?: JobManagerConfig, private readonly logger: Logger = defaultLogger("jobs"), ) { - const storageProvider = this.getDefaultStorageProvider(); - - this.logger.debug("Jobs using storage provider", { storageProvider }); - this.glm = new GolemNetwork({ api: { - key: this.config?.yagna?.apiKey, - url: this.config?.yagna?.basePath, + key: config?.yagna?.apiKey, + url: config?.yagna?.basePath, }, - dataTransferProtocol: storageProvider, logger: this.logger, + ...config, }); } @@ -89,16 +82,4 @@ export class JobManager { throw new GolemUserError("GolemNetwork not initialized, please run init() first"); } } - - private getDefaultStorageProvider(): StorageProvider { - if (isNode) { - return new GftpStorageProvider(); - } - - if (isBrowser) { - return new WebSocketBrowserStorageProvider(this.glm.services.yagna, {}); - } - - return new NullStorageProvider(); - } }