当前位置: 首页 > news >正文

VScode执行任务

背景

  • 在vscode 中 如果执行命令需要传递进来参数,那么直接通过命令行终端的方式不太方便。
  • 通过task 任务的方式来进行启动执行,降低反复输入参数等繁琐工作。

首先可以查看vscode 官方文档

  • task 启动 crtl + shift + p

.vscode/task.json 示例

执行cpp 带参数二进制

{"version": "2.0.0","tasks": [{"label": "Run BIN","type": "shell",  // shell 类型的任务"command": "${command:cmake.launchTargetPath}", // CMake 生成的二进制文件路径"args": ["${workspaceFolder}/config.toml",  // 第一个参数"${workspaceFolder}/model.onnx"  // 第二个参数],"options": {"cwd": "${command:cmake.launchTargetDirectory}"},"group": {"kind": "build", // 此任务的组别"isDefault": true // 设为默认任务},"problemMatcher": [], // 没有特定的错误匹配器"presentation": {"echo": true, // 在输出面板中回显命令"reveal": "always", // 始终在面板中显示"focus": false, // 不聚焦到输出面板"panel": "new", // 在新面板中显示输出"close": false, // 任务完成后关闭输出面板"clear": false // 任务启动前清空输出面板}}]
}

在执行task时,手动输入传参

  • 硬编码方式虽然比较简单粗暴,但是,当使用git来管理的时候,会引入一些没有必要的改变,那么此时就需要将参数,不是使用硬编码,而是去通过启动任务时,动态加载进去。
  • 那就简单介绍几种输入方式
        {  // 简单理解就是输入文本框"type": "promptString","id": "outputPath","description": "Please input the output path:",},{ // 简单理解说就是选择框"type": "pickString","id": "quantize","description": "use quantize","options": [{"label": "True","value": "-q"},{"label": "False","value": ""}],"default": ""},
  • 详细示例如下
{"version": "2.0.0","inputs":[{"type": "promptString","id": "outputPath","description": "Please input the output path:",},{"type": "pickString","id": "quantize","description": "use quantize","options": [{"label": "True","value": "-q"},{"label": "False","value": ""}],"default": ""},{"type": "pickString","id": "task","description": "task type","options": ["weigh","arc"],"default": "arc"},{"type": "promptString","id": "config","description": "Please input using configs file",},{"type": "pickString","id": "test_data","description": "juse use test data","options": [{"label": "True","value": "-b"},{"label": "False","value": ""}],"default": ""},{"type": "pickString","id": "qat","description": "use keras quantization aware training","options": [{"label": "True","value": "--qat"},{"label": "False","value": ""}],"default": ""},],"tasks": [{"label": "torch_inf","type": "shell","command": "${command:python.interpreterPath}","args": ["${workspaceFolder}/inference_torch.py","-i","${workspaceFolder}/output/${input:task}/${input:outputPath}"],"presentation": {"echo": true,"reveal": "always","focus": false,"panel": "shared","showReuseMessage": true,"clear": true},"problemMatcher": []},{"label" : "train","type": "shell","command": "${command:python.interpreterPath}","args": ["${workspaceFolder}/test.py","-c","${workspaceFolder}/configs/${input:config}"],"presentation": {"echo": true,"reveal": "always","focus": false,"panel": "shared","showReuseMessage": true,"clear": true},"problemMatcher": []},{"label" : "exprot_tfl","type": "shell","command": "${command:python.interpreterPath}","args": ["${workspaceFolder}/export2.py","-i","${workspaceFolder}/output/${input:task}/${input:outputPath}","${input:quantize}"],"presentation": {"echo": true,"reveal": "always","focus": false,"panel": "shared","showReuseMessage": true,"clear": true},"problemMatcher": []}]
}
http://www.lryc.cn/news/502215.html

相关文章:

  • MySQL(数据类型)
  • pytorch中的tqdm库
  • NoSQL大数据存储技术测试(5)MongoDB的原理和使用
  • 【Golang】Go语言编程思想(六):Channel,第四节,Select
  • Vue2简介
  • EasyPlayer.js播放器如何在iOS上实现低延时直播?
  • ChatGPT Pro是什么
  • 基于Springboot汽车资讯网站【附源码】
  • MySQL-DQL之数据表操作
  • Luckysheet 实现 excel 多人在线协同编辑(全功能实现增强版)
  • vue 给div增加title属性
  • 设计模式之工厂模式:从汽车工厂到代码工厂
  • 人脸识别Adaface之libpytorch部署
  • vue3+echarts+websocket分时图与K线图实时推送
  • 小程序开发实战项目:构建简易待办事项列表
  • SD Express 卡漏洞导致笔记本电脑和游戏机遭受内存攻击
  • 前端node环境安装:nvm安装详细教程(安装nvm、node、npm、cnpm、yarn及环境变量配置)
  • java之集合(详细-Map,Set,List)
  • 常见LeetCode-Saw200
  • Unity 制作一个视频播放器(打包后,可在外部编辑并放置新的视频)
  • MySQL-SQL语句
  • 腾讯微信大数据面试题及参考答案
  • Python跳动的爱心
  • 计算机启动过程 | Linux 启动流程
  • 反射简单介绍
  • 工具篇--GitHub Desktop 使用
  • 单臂路由配置
  • 河工oj第七周补题题解2024
  • 卷积的数学原理与作用
  • 路由介绍.