python
import unittest
for the functions: for example one time create file and then detected in between all operations in this function
def setUp(self):
def tearDown(self)
for the class:
@classmethod
def setUpClass(cls):
@classmethod
def tearDownClass(cls):
List files and folders
If you want to list directories which shows specific folder name in path in windows you can use
dir /s /b /o:n /ad "farshid" > farshid.txt
this command listed all directories which have "farshid" in the path and save it to the farshid.txt file
in python you can use below code to search and find specific folders and files
###################################################################################### import
import os
import glob
###################################################################################### config
root="C:\\farshid\\"
specific_directories=root+"/**/farshid/**/*.jpg"
path_dir_detection_check=""
###################################################################################### function
files= glob.glob(specific_directories, recursive=True)
for file in files:
b=file.rfind("farshid")
path_dir_detection=file[0:b-1]
if (path_dir_detection != path_dir_detection_check):
dirname = os.path.dirname(file)
print("******************************************************* Next Directories ************************")
print(dirname)
path_dir_detection_check=path_dir_detection
print(file)
The source code can be found in GitHub
make -j$(sysctl -n hw.physicalcpu)
shift+enter -> run selection
menue
code-> pereferences -> user snippets -> python.json
pip freeze > requirements.txt
extensions
Visual Studio IntelliCode
SSH FS
ext install Kelvin.vscode-sshfs
command+ shift+ p ->SSH SF: Create new SSH SF configuration
code ~/.zshrc
Bracket Pair Colorizer 2 => color (){}[] different color
Prettier - Code formatter => when you save. setting->(format on save)
indent-rainbow
shell => .code
Compare Folders
Command +p = all files -> if I press alt+ it open new tab the file
control + ` = open terminal
Command + o= open folder
Command + , = open setting
Command + /= #
shift+enter=run one line of code
option+shift+arrow down = duplicate line in code
command+ click mouse => go to function
command++ -> bigger
command+ shift +P
command+ K , command+ S => shourcuts
command+ L => select currnt line
command+ left/right arrow => start or end of line
command+ P => go to file in search
git config --global core.excludesfile ~/.gitignore
code ~/.gitignore
brew install pyenv
brew install poetry
pyenv install 3.7.5
pyenv global 3.7.5
poetry new "name of project"
-> go to folder
-> change python version if you want in the pyproject.toml
pyenv global 3.7.5
poetry new "pytorch_pretrained"
poetry install
pip install --upgrade pip
poetry add matplotlib numpy kubernetes=10.0.0 kfp=0.2.4 click=7.0.0 opencv-python opencv-contrib-python imutils pylint fastapi uvicorn python-dateutil seldon_core spacy sklearn torch torchvision jupyter pycocotools cython pyyaml==5.1
poetry remove torch torchvision
pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
pip3 install matplotlib numpy kubernetes==10.0.0 kfp==0.2.4 click==7.0.0 opencv-python opencv-contrib-python imutils pylint fastapi uvicorn python-dateutil seldon_core spacy sklearn torch torchvision jupyter pycocotools cython
pip3 install pyyaml==5.1
pip3 install 'git+https://github.com/facebookresearch/detectron2.git'
pip3 install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
poetry shell
jupyter notebook