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

Undetected Chromedriver Use Case

[TOC] Parsing a Property website in multiprocessing way 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 # %% import sqlite3 from selenium....

<span title='2023-06-22 22:38:28 +1000 AEST'>June 22, 2023</span>&nbsp;ยท&nbsp;10 min&nbsp;ยท&nbsp;2086 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

Xpath-cheatsheet

[TOC] Xpath cheatsheet Previous Next Page: /

<span title='2023-06-22 22:38:28 +1000 AEST'>June 22, 2023</span>&nbsp;ยท&nbsp;1 min&nbsp;ยท&nbsp;7 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