Skip to content

Commit

Permalink
Merge pull request #1027 from golemfactory/grisha/developer-experienc…
Browse files Browse the repository at this point in the history
…e-improvements-24.07.11

Grisha/developer experience improvements 24.07.11
  • Loading branch information
grisha87 authored Jul 15, 2024
2 parents e2ca433 + 4989850 commit 9ef1197
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/activity/exe-script-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class ExeScriptExecutor {
const batchId = await this.send(script);
const batchSize = JSON.parse(script.text).length;

this.logger.debug(`Script sent.`, { batchId });
this.logger.debug(`Script sent.`, { batchId, script });
return { batchId, batchSize };
} catch (error) {
const message = getMessageFromApiError(error);
Expand Down Expand Up @@ -235,7 +235,7 @@ export class ExeScriptExecutor {
private parseEventToResult(event: StreamingBatchEvent, batchSize: number): Result {
// StreamingBatchEvent has a slightly more extensive structure,
// including a return code that could be added to the Result entity... (?)
return new Result({
const result = new Result({
index: event.index,
eventDate: event.timestamp,
result: event?.kind?.finished
Expand All @@ -250,5 +250,9 @@ export class ExeScriptExecutor {
message: event?.kind?.finished?.message,
isBatchFinished: event.index + 1 >= batchSize && Boolean(event?.kind?.finished),
});

this.logger.debug("Received stream batch execution result", { result });

return result;
}
}
2 changes: 1 addition & 1 deletion src/activity/exe-unit/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class Batch {
this.executor.activity.agreement.provider,
error,
);
this.logger.debug("Error in batch script execution");
this.logger.debug("Error in batch script execution", { error });
this.script
.after(allResults)
.then(() => reject(golemError))
Expand Down
7 changes: 7 additions & 0 deletions src/activity/exe-unit/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,11 @@ export class RemoteProcess {
this.subscription.add(() => end());
});
}

/**
* Checks if the exe-script batch from Yagna has completed, reflecting all work and streaming to be completed
*/
isFinished() {
return this.lastResult?.isBatchFinished ?? false;
}
}
3 changes: 2 additions & 1 deletion src/shared/yagna/yagnaApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class YagnaApi {

eventSource.addEventListener("runtime", (event) => observer.next(JSON.parse(event.data)));
eventSource.addEventListener("error", (error) => observer.error(error));

return () => eventSource.close();
});
},
Expand All @@ -155,7 +156,7 @@ export class YagnaApi {

this.gsb = gsbClient.requestor;

this.logger = options?.logger ?? defaultLogger("yagna");
this.logger = options?.logger ? options.logger.child("yagna") : defaultLogger("yagna");

const identityClient = new YaTsClient.IdentityApi.Client({
BASE: this.basePath,
Expand Down

0 comments on commit 9ef1197

Please sign in to comment.