Skip to content

Commit

Permalink
add status command
Browse files Browse the repository at this point in the history
  • Loading branch information
dtinth committed May 17, 2024
1 parent e916900 commit 773de25
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 15 deletions.
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
# Parallelizer Project
# parallelizer

## Description

Parallelizer is a tool designed to optimize and parallelize tasks across multiple computing resources, enhancing efficiency and reducing execution time.
A tool that allows for the parallelization of tasks across multiple worker nodes. The tool is designed to distribute tasks dynamically based on the availability of resources.

## Setup and Usage

To set up the project, ensure you have `pnpm` installed on your system. Clone the repository and run `pnpm install` to install dependencies. Use the following commands to interact with the project:

- `pnpm run build`: Compiles the project using `tsup`.
- `pnpm run build`: Compiles the project.
- `pnpm run dev`: Runs the project in development mode with hot reloading.

## Features

- Task parallelization across multiple nodes.
- Dynamic task distribution based on resource availability.
- Comprehensive logging and monitoring of task execution.

## Note

This project uses `pnpm` for package management to ensure efficient handling of node modules and dependencies. It is designed to work with Node.js version 20.

## Testing procedure

```sh
Expand Down
58 changes: 58 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,62 @@ yargs(process.argv.slice(2))
console.log("Number of tasks failed:", failed);
}
)
.command(
"status",
"Check the status of the tasks",
{
"job-file": {
type: "string",
demandOption: true,
description: "Path to the job file",
},
"out-file": {
type: "string",
description:
"Path to the output file. If not provided, prints to stdout.",
},
},
async (args) => {
const jobFile = args["job-file"];
console.log("Reading job file:", jobFile);
const jobFileContents = fs.readFileSync(jobFile, "utf-8");
const job = TaskListFile.parse(JSON.parse(jobFileContents));
console.log("Queue name:", job.id);
console.log("Number of tasks:", job.tasks.length);
const ctx: Context = createContext();
const statuses = await getPreviouslyRunTaskStatuses(ctx, job.id);
type Status = {
taskId: string;
workerId: string;
attemptCount: number;
startedAt: string;
finishedAt?: string;
status: string;
};
const statusMap = new Map<string, Status>();
for (const item of statuses.Items ?? []) {
statusMap.set(item.TaskId.S!, {
taskId: item.TaskId.S!,
workerId: item.WorkerId.S!,
attemptCount: +(item.AttemptCount?.N || "0"),
startedAt: item.StartedAt?.S || "",
finishedAt: item.FinishedAt?.S,
status: item.Status.S!,
});
}
const result = job.tasks.map((task) => {
return {
id: task.id,
displayName: task.displayName,
status: statusMap.get(task.id),
};
});
const out = JSON.stringify(result, null, 2);
if (args["out-file"]) {
fs.writeFileSync(args["out-file"], out);
} else {
console.log(out);
}
}
)
.parse();

0 comments on commit 773de25

Please sign in to comment.