Руководство по интеграции Django и Jupyter
Считаем, что django и jupyter уже установлены
-
Установить django-extensions
pip install django-extensions
import argparse | |
import logging | |
import os | |
import time | |
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor | |
from datetime import timedelta | |
from functools import partial | |
from pathlib import Path | |
import pydicom |
import argparse | |
import logging | |
import os | |
import time | |
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor | |
from datetime import timedelta | |
from functools import partial | |
from pathlib import Path | |
import pydicom |
# Based on https://gist.github.com/spicycode/1229612 | |
# Automatically set window title | |
set-window-option -g automatic-rename on | |
set-option -g set-titles on | |
#set -g default-terminal screen-256color | |
set -g status-keys vi | |
set -g history-limit 10000 |
""" | |
Небольшая шпаргалка по библиотечке respx. Все это есть в документации https://lundberg.github.io/respx/guide/, | |
но местами написано очень коротко и не очевидно. | |
Зависимости: python > 3.10, httpx, respx, pytest-asyncio | |
""" | |
from typing import Any | |
import httpx | |
import pytest |
[alias] | |
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold cyan)<%an>%Creset' --abbrev-commit | |
ss = status -s | |
b = branch | |
ca = commit -a -m | |
last = log -1 HEAD | |
co = checkout | |
# fuzzy checkout by ticket number for branches like feature/cool-stuff-abc1234 | |
fco = "!f() { git branch -a | egrep -m1 \"(feature|hotfix)/.*${1}\" | sed \"s/remotes\\/origin\\///\" | xargs git checkout; }; f" | |
amend = commit --amend --no-edit |
# https://janakiev.com/blog/jupyter-virtual-envs/ | |
# https://ipython.readthedocs.io/en/stable/install/kernel_install.html | |
1. Activate your venv | |
2. pip install --user ipykernel | |
3. python -m ipykernel install --user --name=myenv --display-name "Python (myenv)" |
conda install -y nodejs | |
pip install ipympl | |
pip install --upgrade jupyterlab | |
jupyter labextension install @jupyter-widgets/jupyterlab-manager | |
jupyter labextension install jupyter-matplotlib | |
jupyter nbextension enable --py widgetsnbextension | |
# then use magic %matplotlib widget |
def find_package_dirs(paths): | |
"""Find all package directories in given paths""" | |
dirs = [] | |
for importer, modname, ispkg in pkgutil.iter_modules(paths): | |
module_loader = importer.find_module(modname) | |
if ispkg: | |
yield module_loader.filename | |
# tmpdir is pytest fixture | |
def test_find_package_dirs(tmpdir): |
def profile(func): | |
import functools | |
@functools.wraps(func) | |
def inner(*args, **kwargs): | |
from line_profiler import LineProfiler | |
lp = LineProfiler() | |
lp_wrapper = lp(func) | |
result = lp_wrapper(*args, **kwargs) | |
lp.print_stats() | |
return result |
Руководство по интеграции Django и Jupyter
Считаем, что django и jupyter уже установлены
Установить django-extensions
pip install django-extensions