Skip to main content

nfctl

nf-server CLI,面向生信工程师和 AI Agent。

nfctl 3.x 对应 nf-server 5.x。3.0 起存储生命周期改为 LaunchDir 资源, 不兼容旧的 workflow 级 archive API。

安装与配置

pip install nfctl

# 没有系统默认时,用户可配置自己的 profile
nfctl config set url http://nf-server:8000

# 多环境 profile
nfctl config set url http://test-server:8000 --profile test
nfctl config use test
nfctl --profile prod list

# 环境变量可直连
export NFCTL_URL=http://nf-server:8000

集群管理员可提供 /etc/nfctl/config.json,让新用户无需初始化即可使用:

{
  "current": "prod",
  "profiles": {
    "prod": {"url": "https://nf-server.internal"},
    "test": {"url": "https://nf-server-test.internal"}
  }
}

系统配置只读,用户命令只修改 ~/.nfctl/config.json。用户的同名 profile 覆盖系统 profile;nfctl config list/show 会显示来源和两个 配置文件路径。

解析优先级:--profile / NFCTL_PROFILE > NFCTL_URL > 用户当前 profile > 系统当前 profile。显式指定 profile 时仍是用户同名配置优先。

两类资源

  • Workflow:一次分析,由 workflow_id 标识。每次 submit/resume 是它的一次执行, 用 attempt_no(1、2、3…)区分;列表和详情默认展示当前执行,即最大的那个序号。
  • LaunchDir:物理启动目录及其存储生命周期,由规范化绝对路径标识。

分析状态只出现在 Workflow;归档、迁移和 restore 状态只出现在 LaunchDir。不要用某个 Workflow ID 代表目录存储状态。

查询

nfctl overview
nfctl list --status running
nfctl list --pipeline WGS --env prod
nfctl list --project-sn P2026001
nfctl list --launch-dir .              # 该目录的 Workflow 历史
nfctl status <workflow_id>
nfctl attempts <workflow_id>           # 执行历史,新的在前
nfctl progress <workflow_id>
nfctl tasks <workflow_id> --status failed
nfctl task <workflow_id> <task_id>
nfctl log <workflow_id> --grep ERROR
nfctl resources <workflow_id> --exclude-cached

status、progress、tasks、task、log、resources 默认看当前执行; --attempt N 看第 N 次,--previous 看上一次。标题里的 wf-001#2 表示第 2 次执行。 log 按该次执行的 runName 找到对应的 .nextflow.log*,文件名打印在 stderr; 日志被 Nextflow 轮转删除后返回 LOG_NOT_FOUND。

按目录盘点:

nfctl list --group-by launch-dir
nfctl list --group-by launch-dir --all
nfctl list --group-by launch-dir --state unknown,materialized,partial --all
nfctl list --group-by launch-dir --state archived,empty --all
nfctl list --group-by launch-dir --archive-due --all

--group-by launch-dir 的分页单位是目录,组内返回完整 Workflow 历史。 unknown,materialized,partial 适合盘点仍有工作盘数据或物理状态不确定的目录; archived,empty 表示目录已经归档,或确认没有需要归档的数据。

分析控制

nfctl submit <launch_dir> -p <pipeline> -S <project_sn> [--env prod]
nfctl submit . -p <pipeline> -S <project_sn> [--env prod]
nfctl submit <launch_dir> -p <pipeline> -S <project_sn> --dry-run
nfctl resume <workflow_id>
nfctl cancel <workflow_id> [--reason 原因]
nfctl delete <workflow_id>

相对 launch_dir 会先按 nfctl 调用者的当前目录转换为绝对路径,因此可以在启动目录内直接使用 submit .。submit 会从 run.sh 读取 TOWER_WORKFLOW_ID 并校验请求一致。受理成功后服务端立即记录 progress=1,由 reconciler 异步启动。手动 qsub 只有在 Workflow 已通过 submit 登记时才能被 trace 接管。

控制命令只作用于当前执行:

  • cancel:运行中则停止,先进入 stopping,调度任务确认退出后变为 cancelled;已成功则作废结果。 LIMS 都会收到 error。不取消目录存储操作。
  • resume:新建一次执行,支持 failed/cancelled(含作废的成功结果);已归档目录会先自动恢复再投递。
  • delete:删除分析及全部执行历史,不动目录文件;有效的成功结果要先 cancel 作废。

存储控制

所有参数都是 launch_dir,可直接在目录内传 .:

nfctl archive status .
nfctl archive start .
nfctl archive restore . --wait
nfctl archive resume .
nfctl archive cancel . --reason maintenance
  • start:立即发起 archive,不以 workflow_id 定位。
  • restore:不覆盖已有数据。归档里的目录都已在原位时直接视为已恢复;只有一部分在时失败, 需人工核对。--wait 按 operation_id 等待终态。
  • resume:重试最近一次 failed/cancelled migrate/archive/restore。
  • cancel:关闭自动归档并请求取消活跃 job;operation 在 scheduler 确认退出前保持 cancelling。

storage_state 为 unknown | materialized | archived | empty | partial;operation 状态为 pending | running | cancelling | succeeded | failed | cancelled。

Pipeline

nfctl pipeline list
nfctl pipeline create WGS --archive --archive-delay-hours 72
nfctl pipeline update WGS --large-file-threshold 500M

归档范围固定为 launch_dir 下所有一级非隐藏真实目录。Pipeline 只配置开关、迁移阈值、延迟、并发、通知和分析超时。

JSON / Agent

nfctl -f json list
nfctl -f json archive status .
nfctl --jq '.data.items[].workflow_id' list

JSON 使用统一信封:

{"ok": true, "data": {}}
{"ok": false, "error": {"type": "LAUNCH_DIR_BUSY", "message": "...", "hint": "..."}}

服务端的结构化错误上下文会保留在 error 中。例如执行已变化会返回 error.current_attempt_no,存储任务冲突会返回 error.operation_id / error.job_id。

全局选项写在子命令前。--format json 自动跳过交互确认。

开发

uv sync
uv run ruff check nfctl tests
uv run pytest

Metadata

Release files for nfctl 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nfctl 3.1.0
File Size Uploaded Provenance Actions
nfctl-3.1.0.tar.gz 61.4 kB With provenance Details for nfctl-3.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nfctl 3.1.0
File Interpreter ABI Platform Actions
nfctl-3.1.0-py3-none-any.whl Python 3 none any Details for nfctl-3.1.0-py3-none-any.whl

Total release size: 93.6 kB

Release files / nfctl-3.1.0.tar.gz

Download URL nfctl-3.1.0.tar.gz
Size 61.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ee54af483e9c38f8ef54ceefcb991dcd4ee458773f339868ff19cc567a815e65
BLAKE2b-256 checksum
How to use checksums
bdf6967a6658e2ea0dc5e2f14035cc82c8590aac757d1da289ed7272f3580930
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / nfctl-3.1.0-py3-none-any.whl

Download URL nfctl-3.1.0-py3-none-any.whl
Size 32.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8c54cd284ca4ff757ddeea1fce0789d781567e5883f5b440840b99b88240a1d
BLAKE2b-256 checksum
How to use checksums
48378d8ef0b6fd03210bce3990dec90da00f9ea8a51d7e4e4528626eccd2398d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Security for nfctl 3.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nfctl-3.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page