You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Snakefile使用workflow.get_source()报错:Workflow对象无该属性

Snakemake中workflow.get_source报错的解决办法
  • 不需要额外导入模块,报错核心原因是Snakemake版本不支持get_source方法。该方法是Snakemake 7.15.0版本之后新增的API,若本地版本低于此,就会触发'Workflow' object has no attribute 'get_source'错误。

    • 可执行snakemake --version查看当前版本,若版本过低,运行pip install --upgrade snakemake升级到符合要求的版本即可正常使用该方法。
  • 若无法升级版本,可使用兼容绝大多数Snakemake版本的替代方案:用workflow.basedir拼接相对路径,示例代码如下:

    import os
    
    rule process_static_input:
        input:
            # 拼接Snakefile所在目录与静态文件的相对路径
            os.path.join(workflow.basedir, "path/relative/to/snakefile")
        output:
            "output_dir/result.txt"
        shell:
            "your_command {input} > {output}"
    

    workflow.basedir会自动返回Snakefile所在的绝对路径,结合相对路径即可准确定位到静态输入文件。

内容的提问来源于stack exchange,提问作者newuser

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 10:48:17