SJM HPC-SGE 投遞任務(wù)管理工具簡(jiǎn)介

HPC-SGE環(huán)境下的任務(wù)投遞方式

??HPC指的是高可用計(jì)算集群吮廉,是相對(duì)于單機(jī)服務(wù)或節(jié)點(diǎn)而言的苞尝,通過(guò)節(jié)點(diǎn)或集群間的分布式結(jié)構(gòu)解決任務(wù)需求中的高算力、高存儲(chǔ)宦芦、強(qiáng)動(dòng)態(tài)調(diào)節(jié)等功能宙址。
??每個(gè)節(jié)點(diǎn)在集群中是以相對(duì)獨(dú)立的姿態(tài)在系統(tǒng)中存在,在多節(jié)點(diǎn)的集群中调卑,需要任務(wù)投遞時(shí)選擇合適的任務(wù)投遞工具管理任務(wù)和集群抡砂。
??一般使用SGE集群時(shí),采用的投遞工具為QSUB恬涧,具體的使用方式參見博客集群任務(wù)管理系統(tǒng)SGE的簡(jiǎn)明教程注益。

SJM 一種HPC-SGE的任務(wù)組織與狀態(tài)監(jiān)控工具

  1. SJM簡(jiǎn)介
    SJM全稱為Simple Job Manager,由StanfordBioinformatics團(tuán)隊(duì)負(fù)責(zé)開發(fā)與維護(hù)溯捆,它是一個(gè)用于管理在計(jì)算集群上運(yùn)行的一組相關(guān)作業(yè)的程序聊浅,是在sge-qsub的更上一層的抽象,具有如下特性:
    • 它提供了一種方便的方法來(lái)指定作業(yè)之間的依賴關(guān)系以及每個(gè)作業(yè)的資源需求(例如內(nèi)存现使、CPU內(nèi)核)
    • 它監(jiān)視作業(yè)的狀態(tài)低匙,以便您可以知道整個(gè)組何時(shí)完成。如果任何作業(yè)失斕夹狻(例如顽冶,由于計(jì)算節(jié)點(diǎn)崩潰),SJM允許您恢復(fù)售碳,而無(wú)需重新運(yùn)行成功完成的作業(yè)
    • 最后强重,SJM提供了一種可移植的方式绞呈,可以將作業(yè)提交給不同的作業(yè)調(diào)度器,如Sun網(wǎng)格引擎或平臺(tái)LSF
  2. 軟件安裝
    # 注:軟件安裝前需要確認(rèn)是否安裝了Boost http://www.boost.org
    git clone https://github.com/StanfordBioinformatics/SJM.git
    cd SJM
    ./configure
    make
    sudo make install
    
  3. SJM job中的屬性介紹
    一個(gè)示例,任務(wù)以job_begin和job_end開始和結(jié)尾间景,任務(wù)名稱用name標(biāo)注佃声,內(nèi)存申請(qǐng)用memory標(biāo)注,任務(wù)命令用cmd標(biāo)注倘要,投遞隊(duì)列用queue標(biāo)注圾亏,:
    job_begin
        name jobA
        queue test.q
        time 1h
        memory 500m
        cmd echo "hello from job jobA"
    job_end
    
    或者用一下的形式代替:
    job_begin
        name jobA
        sched_options -cwd -l vf=1G,p=1 -q test.q
        cmd echo "hello from job jobA"
    job_end
    
    多行命令在一個(gè)任務(wù)中時(shí)可以如下編寫:
    job_begin
        name jobB
        time 2d
        memory 1G
        queue test.q
        cmd_begin
            /home/lacroute/project/jobB_prolog.sh;
            /home/lacroute/project/jobB.sh;
            /home/lacroute/project/jobB_epilog.sh
        cmd_end
    job_end
    
    編寫多個(gè)任務(wù)之間的前后關(guān)系時(shí),采用order屬性標(biāo)記封拧,如下:
    order jobA before jobB
  4. 編寫一個(gè)SJM的JOB并投遞
    編寫任務(wù):假設(shè)一個(gè)任務(wù)有A志鹃,B兩個(gè)部分,且A必須在B正常結(jié)束后才能執(zhí)行泽西,可復(fù)用代碼如下:
    job_begin
        name jobA
        time 4h
        memory 3G
        queue standard
        project sequencing
        cmd /home/lacroute/project/jobA.sh
    job_end
    job_begin
        name jobB
        time 2d
        memory 1G
        queue extended
        cmd_begin
            /home/lacroute/project/jobB_prolog.sh;
            /home/lacroute/project/jobB.sh;
            /home/lacroute/project/jobB_epilog.sh
        cmd_end
    job_end
    order jobA before jobB
    log_dir /home/lacroute/project/log
    
    投遞任務(wù):基于以上代碼寫在在test.job文件中曹铃,流程投遞命令如下:
    export PATH=sjm的文件夾:$PATH
    # 投遞至后臺(tái)
    sjm test.job
    # 前臺(tái)投遞
    sjm --interactive --log test.job.status.log  test.job 
    
  5. 基于SJM的任務(wù)流的監(jiān)控
    sjm投遞任務(wù)后(后臺(tái)投遞情況下),將會(huì)產(chǎn)生額外三個(gè)文件捧杉,其中*.status文件為每個(gè)job任務(wù)狀態(tài)記錄文件陕见,會(huì)伴隨更新,job狀態(tài)如下幾種味抖,注意及時(shí)查看輸出的log文件信息评甜。
    # 文件
    test.job.status
    test.job.status.bak
    test.job.status.log
    # 狀態(tài)
    waiting 等待,未投遞
    running 正在執(zhí)行
    failed 運(yùn)行失敗
    done 運(yùn)行成功
    
  6. 基于sjm-job 抽象的模板式任務(wù)編輯工具暢想
    我們可以規(guī)定一套模板非竿,模塊使用makefile編寫蜕着,模塊組織使用sjm谋竖,實(shí)現(xiàn)流程模塊的高復(fù)用和高可用

其他類型的HPC任務(wù)流投遞工具

  1. 基于Kubernetes集群的ARGO
    Argo Workflows是一個(gè)開源的容器原生工作流引擎红柱,用于在Kubernetes上編排并行作業(yè)”统耍可應(yīng)用與混合云等多種云計(jì)算集群的任務(wù)編排工具锤悄,高度滿足命令式編排和聲明式自動(dòng)化的特點(diǎn)。
    基于argo創(chuàng)建任務(wù)流可參見博客ARGO-工作流部署與管理工具
  2. 基于Cromwell的WDL
    WDL 是主要應(yīng)用與生物信息領(lǐng)域的流程定義工具嘉抒,需要依賴Cromwell引擎投遞任務(wù)零聚,但集群如果是SGE,其底層也是依賴QSUB投遞任務(wù)的些侍,單機(jī)節(jié)點(diǎn)下的配置文件如下:
    # Cromwell HTTP server settings
    include required(classpath("application"))
    webservice {
    #port = 8100
    interface = 0.0.0.0
    binding-timeout = 5s
    instance.name = "reference"
    }
    
    #database {
    #  profile = "slick.jdbc.MySQLProfile$"
    ##  db {
    #    driver = "com.mysql.cj.jdbc.Driver"
    #    url = "jdbc:mysql://host/cromwell?rewriteBatchedStatements=true"
    #    user = "user"
    #    password = "pass"
    #    connectionTimeout = 5000
    #  }
    #}
    
    call-caching {
    enabled = true
    
    # In a multi-user environment this should be false so unauthorized users don't invalidate results for authorized users.
    invalidate-bad-cache-results = true
    
    }
    
    docker {
    hash-lookup {
        # Set this to match your available quota against the Google Container Engine API
        #gcr-api-queries-per-100-seconds = 1000
    
        # Time in minutes before an entry expires from the docker hashes cache and needs to be fetched again
        #cache-entry-ttl = "20 minutes"
    
        # Maximum number of elements to be kept in the cache. If the limit is reached, old elements will be removed from the cache
        #cache-size = 200
    
        # How should docker hashes be looked up. Possible values are "local" and "remote"
        # "local": Lookup hashes on the local docker daemon using the cli
        # "remote": Lookup hashes on docker hub and gcr
        #method = "remote"
    }
    }
    
    backend {
    default = Local
    
    providers {
        Local {
        actor-factory = "cromwell.backend.impl.sfs.config.ConfigBackendLifecycleActorFactory"
        config {
                run-in-background = true
                runtime-attributes = """
                String? docker
                String? docker_user
                String? sge_mount
                """
                submit = "${job_shell} ${script}"
                submit-docker = """
                # make sure there is no preexisting Docker CID file
                rm -f ${docker_cid}
                # run as in the original configuration without --rm flag (will remove later)
                docker run \
                    --cidfile ${docker_cid} \
                    -i \
                    ${"--user " + docker_user} \
                    --entrypoint ${job_shell} \
                    -v ${cwd}:${docker_cwd}:delegated \
                    ${sge_mount} \
                    ${docker} ${docker_script}
    
                # get the return code (working even if the container was detached)
                rc=$(docker wait `cat ${docker_cid}`)
    
                # remove the container after waiting
                docker rm `cat ${docker_cid}`
    
                # return exit code
                exit $rc
                """
            kill-docker = "docker kill `cat ${docker_cid}`"
            root = "cromwell-executions"
            filesystems {
    
                # For SFS backends, the "local" configuration specifies how files are handled.
                local {
    
                    # Try to hard link (ln), then soft-link (ln -s), and if both fail, then copy the files.
                    localization: [
                    "hard-link", "soft-link", "copy"
                    ]
    
                    # Call caching strategies
                    caching {
                    # When copying a cached result, what type of file duplication should occur.
                    # For more information check: https://cromwell.readthedocs.io/en/stable/backends/HPC/#shared-filesystem
                    duplication-strategy: [
                        "hard-link", "soft-link", "copy"
                    ]
    
                    # Strategy to determine if a file has been used before.
                    # For extended explanation and alternative strategies check: https://cromwell.readthedocs.io/en/stable/Configuring/#call-caching
                    hashing-strategy: "md5"
    
                    # When true, will check if a sibling file with the same name and the .md5 extension exists, and if it does, use the content of this file as a hash.
                    # If false or the md5 does not exist, will proceed with the above-defined hashing strategy.
                    check-sibling-md5: false
                    }
                }
                }
    
                # The defaults for runtime attributes if not provided.
                default-runtime-attributes {
                failOnStderr: false
                continueOnReturnCode: 0
                }
            }
        }
    }
    }
    
    
  3. nextflow
    流程預(yù)定義隶症,可以直接下載模板后運(yùn)行,定制化程度不高岗宣,特殊需求下蚂会,需要手動(dòng)運(yùn)行命令分析,詳情參考生信流程大全-基于nextflow的nf-core
  4. snakemake
    某種程度上和WDL比較像耗式,通過(guò)模塊間的輸入輸出定義流程的DAG胁住。

引用

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末趁猴,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子彪见,更是在濱河造成了極大的恐慌儡司,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,036評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件余指,死亡現(xiàn)場(chǎng)離奇詭異捕犬,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)浪规,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,046評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門或听,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人笋婿,你說(shuō)我怎么就攤上這事誉裆。” “怎么了缸濒?”我有些...
    開封第一講書人閱讀 164,411評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵足丢,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我庇配,道長(zhǎng)斩跌,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,622評(píng)論 1 293
  • 正文 為了忘掉前任捞慌,我火速辦了婚禮耀鸦,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘啸澡。我一直安慰自己袖订,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,661評(píng)論 6 392
  • 文/花漫 我一把揭開白布嗅虏。 她就那樣靜靜地躺著洛姑,像睡著了一般。 火紅的嫁衣襯著肌膚如雪皮服。 梳的紋絲不亂的頭發(fā)上楞艾,一...
    開封第一講書人閱讀 51,521評(píng)論 1 304
  • 那天,我揣著相機(jī)與錄音龄广,去河邊找鬼硫眯。 笑死,一個(gè)胖子當(dāng)著我的面吹牛择同,可吹牛的內(nèi)容都是我干的两入。 我是一名探鬼主播,決...
    沈念sama閱讀 40,288評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼奠衔,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼谆刨!你這毒婦竟也來(lái)了塘娶?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,200評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤痊夭,失蹤者是張志新(化名)和其女友劉穎刁岸,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體她我,經(jīng)...
    沈念sama閱讀 45,644評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡虹曙,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,837評(píng)論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了番舆。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片酝碳。...
    茶點(diǎn)故事閱讀 39,953評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖恨狈,靈堂內(nèi)的尸體忽然破棺而出疏哗,到底是詐尸還是另有隱情,我是刑警寧澤禾怠,帶...
    沈念sama閱讀 35,673評(píng)論 5 346
  • 正文 年R本政府宣布返奉,位于F島的核電站,受9級(jí)特大地震影響吗氏,放射性物質(zhì)發(fā)生泄漏芽偏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,281評(píng)論 3 329
  • 文/蒙蒙 一弦讽、第九天 我趴在偏房一處隱蔽的房頂上張望污尉。 院中可真熱鬧,春花似錦往产、人聲如沸被碗。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,889評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)蛮放。三九已至缩抡,卻和暖如春奠宜,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背瞻想。 一陣腳步聲響...
    開封第一講書人閱讀 33,011評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工压真, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人蘑险。 一個(gè)月前我還...
    沈念sama閱讀 48,119評(píng)論 3 370
  • 正文 我出身青樓滴肿,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親佃迄。 傳聞我的和親對(duì)象是個(gè)殘疾皇子泼差,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,901評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容