How to Autostart Apps on Your Server

[TOC] Title: How to Autostart Apps on Your Server Review Date: Fri, Apr 12, 2024 url: - How to Autostart Apps on Your Server we can try systemd --user modules First of all, write the service in the ~/.config/systemd/user/ folder 1 2 3 4 5 6 7 8 9 10 11 12 [Unit] Description=My TorchSErve Server Wants=network-online.target After=network-online.target [Service] Type=forking ExecStart=/datadrive/run_torchserve.sh [Install] WantedBy=multi-user.target Note that Type=forking is important if you want to maintain the session, especially when you want to maintain a tmux...

<span title='2024-04-12 12:23:29 +1000 AEST'>April 12, 2024</span>&nbsp;ยท&nbsp;6 min&nbsp;ยท&nbsp;1109 words&nbsp;ยท&nbsp;Sukai Huang

Using Kedro And Optuna for Your Project

[TOC] Title: Using Kedro And Optuna for Your Project Review Date: Wed, Mar 27, 2024 url: https://neptune.ai/blog/kedro-pipelines-with-optuna-hyperparameter-sweeps Use Kedro and Optuan for your ML project Kedro - manage the ML pipeline Optuna - hyperparameter tuning tool Example pyproject.toml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 [build-system] requires = [ "setuptools",] build-backend = "setuptools....

<span title='2024-03-27 21:50:10 +1100 AEDT'>March 27, 2024</span>&nbsp;ยท&nbsp;4 min&nbsp;ยท&nbsp;641 words&nbsp;ยท&nbsp;Sukai Huang

How to Design Your Research Project Structure

[TOC] Title: How to Design Your Research Project Structure Review Date: Fri, Feb 2, 2024 Basic Component Policy model Environment Reward model Evaluation Logging and Result Postprocess Training train reward train policy Dataloader Utils Logging Setup Multiprocessing Helper etc itโ€™s better to have interface class in the __init__.py Separate subproject for Data collection and PreTraining Environment simulation running how to save label, how to save images, align with the requirement of dali....

<span title='2024-02-02 19:50:31 +1100 AEDT'>February 2, 2024</span>&nbsp;ยท&nbsp;2 min&nbsp;ยท&nbsp;237 words&nbsp;ยท&nbsp;Sukai Huang

React Js Development 2024

[TOC] Title: React Js Development 2024 Review Date: Sun, Jan 21, 2024 url: React JS development (Typescript + Vite + React) VSC extension ES7 + React NPM support for VS Coe Vite JavaScript and TypeScript Init 1 2 3 4 5 6 7 8 9 10 11 curl -fsSL https://deb.nodesource.com/setup_21.x | sudo -E bash - &&\ sudo apt-get install -y nodejs npm create vite@latest npm create vite@latest yourapp -- --template react-ts cd yourapp npm install npm install antd react-redux react-router-dom redux sass reset-css # can also add them to package npm i -D @types/node npm run dev add path hint in tsconfig add resolve alias @ in vite....

<span title='2024-01-21 17:40:43 +1100 AEDT'>January 21, 2024</span>&nbsp;ยท&nbsp;1 min&nbsp;ยท&nbsp;140 words&nbsp;ยท&nbsp;Sukai Huang

Python and Os Utils 2024

[TOC] Title: Python and Os Utils 2024 Review Date: Thu, Jan 18, 2024 Useful Programming Tips What does " 2>&1 " mean? To combine stderr and stdout into the stdout stream, we append this to a command: 1 2>&1 Answer File descriptor 1 is the standard output (stdout). File descriptor 2 is the standard error (stderr). At first, 2>1 may look like a good way to redirect stderr to stdout. However, it will actually be interpreted as โ€œredirect stderr to a file named 1โ€....

<span title='2024-01-18 18:51:51 +1100 AEDT'>January 18, 2024</span>&nbsp;ยท&nbsp;2 min&nbsp;ยท&nbsp;325 words&nbsp;ยท&nbsp;Sukai Huang

Python Logger

[TOC] Title: Python Logger Review Date: Mon, Dec 4, 2023 Python Logger python logging library is a good way to logging the progress Common use case 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') # console handler stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.DEBUG) stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) # file handler logging_folder = Path(yourfolder) logging_fp = os....

<span title='2023-12-04 20:25:12 +1100 AEDT'>December 4, 2023</span>&nbsp;ยท&nbsp;3 min&nbsp;ยท&nbsp;496 words&nbsp;ยท&nbsp;Sukai Huang

Langchain Use Cases 2023

[TOC] Title: Langchain Use Cases 2023 Review Date: Sat, Aug 26, 2023 url: https://python.langchain.com/docs/get_started/quickstart Langchain quickstart The core building block of LangChain applications is the LLMChain. This combines three things: LLM: The language model is the core reasoning engine here. In order to work with LangChain, you need to understand the different types of language models and how to work with them. Prompt Templates: This provides instructions to the language model....

<span title='2023-08-26 17:36:47 +1000 AEST'>August 26, 2023</span>&nbsp;ยท&nbsp;4 min&nbsp;ยท&nbsp;700 words&nbsp;ยท&nbsp;Sukai Huang

Pytorch Multiprocessing 2023

[TOC] Title: Pytorch Multiprocessing 2023 Review Date: Tue, Jul 18, 2023 url: https://pytorch.org/docs/stable/multiprocessing.html Best Practices for Pytorch multiprocessing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 from torch import multiprocessing from torch.multiprocessing import Pipe multiprocessing.set_start_method('spawn') # for torch multiprocessing, spawn method is required model = Model() model.share_memory() p_conn, c_conn = Pipe() tensor_1 = torch.tensor([1]) tensor_1.share_memory() # need to pass tensor to shared memeory p_conn....

<span title='2023-07-18 16:48:13 +1000 AEST'>July 18, 2023</span>&nbsp;ยท&nbsp;1 min&nbsp;ยท&nbsp;93 words&nbsp;ยท&nbsp;Sukai Huang

Remote Server, Tmux and Joshuto 2023

[TOC] Title: Remote Server and Tmux 2023 Review Date: Sun, Jul 16, 2023 url: https://tmuxcheatsheet.com/ url: https://explainshell.com When you want to have a long-run Jupyter notebook when you ssh to a remote server and have a long-run program (e.g., using jupyter notebook for training deep learning models ) you need to detach your job to background otherwise the program will stop when you exit ssh. you need tmux some useful tmux shortcut 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 tmux new -s <yourname> # start a new session with the name <yourname> tmux kill-session -t <sname> # kill session with name <sname> tmux ls # list all sessions tmux a # attach the last session tmux a -t <sname> # attach the session with name <sname> # in the tmux ctrl + b + $ # rename the session name ctrl + b + d # detach session ctrl + b + w # list windows ctrl + b + c # new window ctrl + b + % # split a new pane # panes ctrl + b + [ # scroll mode ctrl + b + arrow # switch pane focus ctrl + b + x # close pane tqdm to file for long-run jobs when you want to have a long-run jupyter and you cannot directly use tqdm to monitor....

<span title='2023-07-16 18:45:57 +1000 AEST'>July 16, 2023</span>&nbsp;ยท&nbsp;3 min&nbsp;ยท&nbsp;557 words&nbsp;ยท&nbsp;Sukai Huang

Web Scrawler Using Selenium 2023

[TOC] Title: Web Scrawler Using Selenium 2023 Review Date: Thu, Jun 22, 2023 Web scrawler, ticket buying as a case study Preparation: python venv check https://www.youtube.com/watch?v=Kg1Yvry_Ydk 1 2 3 4 5 6 7 8 9 python -m venv venv source venv/bin/activate # install the following using pip selenium==4.9.1 undetected-chromedriver>=3.4.6 webdriver-manager jupyterlab pyopenssl known where is the Google Chrome user file location 1 2 MAC ~/Library/Application Support/Google/Chrome Linux ~/.config/google-chrome 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 # load options options = uc....

<span title='2023-06-22 22:38:28 +1000 AEST'>June 22, 2023</span>&nbsp;ยท&nbsp;4 min&nbsp;ยท&nbsp;813 words&nbsp;ยท&nbsp;Sukai Huang

Python Module and Package Management 2023

[TOC] Title: Python Module and Package Management 2023 url: https://www.youtube.com/watch?v=v6tALyc4C10 Python module common issue 1: python -m dir vs python dir python dir will use the dir as the PYTHONPATH as run __main__.py file. however, python -m dir will not use the dir as PYTHONPATH but rather it will search the local library. thus ModuleNotFoundError may appear Standard way of import when you want to create a module use absolute path -> from moduledir/packagename import filename avoid using relative path e....

<span title='2023-05-28 11:56:47 +1000 AEST'>May 28, 2023</span>&nbsp;ยท&nbsp;5 min&nbsp;ยท&nbsp;1024 words&nbsp;ยท&nbsp;Sukai Huang