npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

slurmjs

v0.1.4

Published

A lightweight wrapper for the Slurm command line tool in JavaScript

Readme

slurmjs

在 JavaScript 中调用 Slurm 命令行工具的轻量封装。底层通过 squeuesbatchscancelsinfosacct 与集群交互,并将 JSON 输出整理为统一的数据结构。

环境要求

  • Bun 运行时
  • 已配置并可用的 Slurm 环境(上述命令需在 PATH 中)

安装

bun install
# or npm install

快速开始

import {
  getSlurmJobInfo,
  submitSlurmJob,
  cancelSlurmJob,
  getSlurmClusterInfo,
  getFinishedSlurmJobInfo,
} from "./index.js";

// 查看集群分区信息
const cluster = await getSlurmClusterInfo();
console.log(cluster.data);

// 提交作业
const { data: jobId } = await submitSlurmJob("test/test.slurm");

// 查看队列中的作业
const jobs = await getSlurmJobInfo();
console.log(jobs.data);

// 查看已结束作业
const finished = await getFinishedSlurmJobInfo();
console.log(finished.data);

// 取消作业
await cancelSlurmJob(jobId);

项目内示例脚本:

bun test/test.js

API

所有函数均为 async,返回统一结构:

// 成功
{ success: true, data: ... }

// 失败
{ success: false, error: "错误信息" }

命令行参数 kwargs

各函数均接受可选的 kwargs 对象,会转换为 Slurm 命令行参数:

  • 键名长度大于 1:加 -- 前缀,如 { json: "" }--json
  • 键名长度为 1:加 - 前缀,如 { u: "liuxy" }-u liuxy

getSlurmJobInfo(kwargs?)

调用 squeue --json,返回当前队列中的作业列表。

| 字段 | 说明 | | ------------- | ---------------------------------------------------------------------- | | jobId | 作业 ID | | account | 账户 | | user | 提交用户 | | status | 作业状态 | | cluster | 集群名 | | nodes | 运行节点 | | cpus | CPU 数 | | memory | 每节点内存 | | gres | GPU 等资源详情 | | partition | 分区 | | timeLimit | 时间限制(分钟) | | submitTime | 提交时间(Date) | | startTime | 开始时间(Date) | | runningTime | 运行时长(dayjs Duration) | | name | 作业名 |

submitSlurmJob(jobScript, kwargs?)

调用 sbatch 提交作业脚本。

  • jobScript.slurm 脚本路径
  • 成功时 data 为新建作业的 ID(number

cancelSlurmJob(jobId, kwargs?)

调用 scancel 取消指定作业。

  • jobId:要取消的作业 ID
  • 成功时 data 为空字符串

getSlurmClusterInfo(kwargs?)

调用 sinfo --json,返回集群分区与节点信息。

| 字段 | 说明 | | -------------- | ---------- | | name | 分区名 | | availability | 分区可用状态 | | memory | 最大内存 | | disk | 最大磁盘 | | cpus | 最大 CPU 数 | | gres | 资源总量 | | state | 节点状态 | | nodes | 节点列表 | | time_limit | 最大时间限制(分钟) |

getFinishedSlurmJobInfo(kwargs?)

调用 sacct --json,返回已结束(非 RUNNING)的作业记录。

| 字段 | 说明 | | ------------ | ------------ | | jobId | 作业 ID | | account | 账户 | | user | 提交用户 | | cluster | 集群名 | | name | 作业名 | | partition | 分区 | | stdout | 标准输出路径 | | stderr | 标准错误路径 | | exitCode | 退出码 | | workDir | 工作目录 | | status | 最终状态 | | submitTime | 提交时间(Date) | | startTime | 开始时间(Date) | | endTime | 结束时间(Date) |