Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rahulvigneswaran/63ab4ff6ccb77f1d2d001ef5bdc0d6a8 to your computer and use it in GitHub Desktop.
Save rahulvigneswaran/63ab4ff6ccb77f1d2d001ef5bdc0d6a8 to your computer and use it in GitHub Desktop.
python2vscode debugger args converter.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyN4QPJTmDDprvcrNKDOtGLi",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/rahulvigneswaran/63ab4ff6ccb77f1d2d001ef5bdc0d6a8/python2vscode-debugger-args-converter.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"Am lazy. For using in vscode debugger. This snippet will to the following:\n",
"\n",
"```bash\n",
"Before: --sub_exp \"cRT\" --cfg \"configs/classification/CIFAR100LT/crt.yaml\" --opts GENERAL.GPUS [4] \n",
"After: \"--sub_exp\", \"cRT\", \"--cfg\", \"configs/classification/CIFAR100LT/crt.yaml\", \"--opts\", \"GENERAL.GPUS\", \"[4]\"\n",
"```\n"
],
"metadata": {
"id": "KEQBkd597E5K"
}
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"id": "BIuj0Ld769Ld"
},
"outputs": [],
"source": [
"py_args = '--sub_exp \"cRT\" --cfg \"configs/classification/CIFAR100LT/crt.yaml\" --opts GENERAL.GPUS [4]'"
]
},
{
"cell_type": "code",
"source": [
"py_args_split = py_args.split(\" \")\n",
"\n",
"for i in range(len(py_args_split)) :\n",
" if py_args_split[i][0] == '\"' and py_args_split[i][-1] == '\"' : \n",
" pass\n",
" else :\n",
" py_args_split[i] = f'\"{py_args_split[i]}\"'\n",
"vs_code_args = \", \".join(py_args_split)\n",
"\n",
"print(f\"Before: {py_args} \\nAfter: {vs_code_args}\")"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "412ZHUqK7Pb2",
"outputId": "75269f9c-8c64-4030-d6a0-9d11fcfaf5fd"
},
"execution_count": 19,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Before: --sub_exp \"cRT\" --cfg \"configs/classification/CIFAR100LT/crt.yaml\" --opts GENERAL.GPUS [4] \n",
"After: \"--sub_exp\", \"cRT\", \"--cfg\", \"configs/classification/CIFAR100LT/crt.yaml\", \"--opts\", \"GENERAL.GPUS\", \"[4]\"\n"
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment