首页 > 其他分享 >利用cwltool从CWL文件中提取出commandline

利用cwltool从CWL文件中提取出commandline

时间:2024-08-07 10:28:26浏览次数:14  
标签:commandline args uri job cwltool CWL home my zcy

import os.path

from cwltool.main import setup_loadingContext, load_job_order, init_job_order
from cwltool.context import RuntimeContext
from cwltool.argparser import arg_parser
from cwltool.load_tool import resolve_tool_uri, make_tool, fetch_document, resolve_and_validate_document
from cwltool.flatten import flatten

import argcomplete
import sys
# import logging
# _logger = logging.getLogger("cwltool")
my_args = [ '/home/zcy/yy.cwl', '/home/zcy/custom-types.yml']
# my_args = ['/home/zcy/hello_world.cwl', '--message=zcy']
my_args = ['/home/zcy/bandage.cwl', '/home/zcy/aa.yml']
my_args = ['/home/zcy/bandage.cwl', '/home/zcy/output.json']
#my_args = ['/home/zcy/hello_world.cwl', '/home/zcy/hh.yml']
my_args = ['/home/zcy/stdout.cwl', '/home/zcy/echo-job.yml']
my_args = ['/home/zcy/other/bedtools_bamtobed_1.cwl', '/home/zcy/other/zzz.yml']
parser = arg_parser()
argcomplete.autocomplete(parser)
args = parser.parse_args(my_args)
runtimeContext = RuntimeContext(vars(args))
loadingContext = setup_loadingContext(None, runtimeContext, args)



# 'file:///home/zcy/yy.cwl'  'file:///home/zcy/yy.cwl' ,so tool_file_uri can be "" or 手动拼
# uri, tool_file_uri = resolve_tool_uri(
#             args.workflow,
#             resolver=loadingContext.resolver,
#             fetcher_constructor=loadingContext.fetcher_constructor,
#         )
uri = 'file://' + args.workflow
tool_file_uri = uri
job_order_object, input_basedir, jobloader = load_job_order(
                args,
                sys.stdin,
                loadingContext.fetcher_constructor,
                loadingContext.overrides_list,
                tool_file_uri,
            )


loadingContext, workflowobj, uri = fetch_document(uri, loadingContext)
loadingContext, uri = resolve_and_validate_document(
                loadingContext,
                workflowobj,
                uri,
                preprocess_only=(args.print_pre or args.pack),
            )


tool = make_tool(uri, loadingContext)
stdout = sys.stdout # cast(IO[str], stdout) todo
stdout = None
input_required = True # todo 会随着输入变化吗
initialized_job_order_object = init_job_order(
                    job_order_object,
                    args,
                    tool,
                    jobloader,
                    stdout,
                    print_input_deps=args.print_input_deps,
                    relative_deps=args.relative_deps,
                    make_fs_access=runtimeContext.make_fs_access,
                    input_basedir=input_basedir,
                    secret_store=runtimeContext.secret_store,
                    input_required=input_required,
                    runtime_context=runtimeContext,
                )


def output_callback(out, process_status: str):
    pass

jobiter = tool.job(initialized_job_order_object, output_callback, runtimeContext)

for job in jobiter:
    if job is not None:
        print(job.command_line)
        print(job.builder.bindings)
        my_job = job.builder.job
        for k,v in my_job.items():
            if isinstance(v, dict):
                if v.get('class') in ['File', 'Directory']:
                    v_location = v['location'][7:]
                    v['path'] = v_location
                    v['dirname'] = os.path.dirname(v_location)
        my_bindings = job.builder.bindings
        for rd in my_bindings:
            if isinstance(rd['datum'], dict):
                if rd['datum'].get('class') in ['File', 'Directory']:
                    rd_location = rd['datum']['location'][7:]
                    rd['datum']['path'] = rd_location
                    rd['datum']['dirname'] = os.path.dirname(rd_location)
        command_line = flatten(list(map(job.builder.generate_arg, my_bindings)))
        print(command_line)

 

标签:commandline,args,uri,job,cwltool,CWL,home,my,zcy
From: https://www.cnblogs.com/testzcy/p/18346531

相关文章

  • 【SpringBoot】实现项目启动后执行的两个接口ApplicationRunner和CommandLineRunner
    开发中可能会有这样的场景,需要在容器启动的时候执行一些内容。比如读取配置文件,数据库连接之类的。SpringBoot给我们提供了两个接口来帮助我们实现这种需求。两个启动加载接口分别是:CommandLineRunner和ApplicationRunner。Spring提供了接口InitializingBean,jdk提供了@PostCo......
  • 利用SpringBoot的CommandLineRunner编写命令行jar程序
    1.项目pom<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.......
  • 记录一个springcloud-task-core.jar导致CommandLineRunner @order排序失效的问题
    项目中编写了几个CommandLineRunner,并且加上了spring的@order注解,期望在启动时会按顺序执行(从order的value小到大执行),但是实际使用发现排序不生效于是进行debug,CommandLineRunner类的排序是在SpringApplication.class的callRunners方法privatevoidcallRunners(ApplicationCon......
  • springboot应用中根据特定条件使用CommandLineRunner
    PS使用SpringBoot3.1.2进行测试1.使用@ConditionalOnProperty仅当特定属性存在或具有特定值时,注释@ConditionalOnProperty才会创建bean。在此示例中,仅当或文件中的CommandLineRunner属性db.init.enabled设置为true时才会执行application.propertiesapplication.ymlpac......
  • allure commandline 命令行参数
    一、allurehtml产生流程方法一:alluregenerate+allureopen方法二:allureserver二、语法格式generateopenserver参考资料本文地址:https://www.cnblogs.com/hchengmx/p/17892977.html一、allurehtml产生流程Step1.test文件运行后产生allure-results文......
  • CommandLineRunner - Spring Boot应用程序启动后执行
    在springboot启动的时候,有的时候需要做一些初始化或者预加载的事情。springboot给我们提供了这样一个接口CommandLineRunnerCommandLineRunner是一个接口,用于在SpringBoot应用程序启动后执行一些特定的任务或代码块。当应用程序启动完成后,SpringBoot会查找并执行实现了Comma......
  • cwltoo学习笔记
    执行工作流:cwltool/home/zcy/download/cwl/wf.cwl/home/zcy/download/cwl/echo-job.ymlwf.cwlcwlVersion:v1.2class:Workflowinputs:message:stringoutputs:out:type:FileoutputSource:uppercase/example_outsteps:echo:run:/home/......
  • CommandLineRunner、ApplicationRunner、InitializingBean、@PostConstruct 执行顺序
    概述开发中可能会有这样的场景,需要在容器启动的时候执行一些内容。比如读取配置文件,数据库连接之类的。SpringBoot给我们提供了两个接口来帮助我们实现这种需求,两个启动加载接口分别是:CommandLineRunner和ApplicationRunner。Spring提供了接口InitializingBean,jdk提供了@PostC......
  • Qt QCommandLineOption类
    QCommandLineOption类定义了可能的命令行选项头文件:#include<QCommandLineOption>cmake:find_package(Qt6COMPONENTSCoreREQUIRED)target_link_libraries(mytargetPRIVATEQt6::Core)qmake:QT+=core引入:Qt5.2详细说明该类用于描述命令行上的选项。它允许......
  • Qt 解析命令行(QCommandLineOption和QCommandLineParser类)
    Qt从5.2版开始提供了两个类QCommandLineOption和QCommandLineParser来解析应用的命令行参数。一、命令行写法命令行:"-abc"在QCommandLineParser的解析模式为ParseAsCompactedShortOptions(默认)时会被认为是3个参数,即"-a"、"-b"和"-c"1QCommandLineOptionop1("a");2......