From ec9253b479695a2987a94dca42be72a70d2fb412 Mon Sep 17 00:00:00 2001 From: Mohsen Hariri Date: Wed, 9 Aug 2023 22:35:17 -0400 Subject: [PATCH 1/4] fix:pkg dir init --- scripts/init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/init b/scripts/init index 7437763..445e79c 100755 --- a/scripts/init +++ b/scripts/init @@ -14,7 +14,7 @@ change_name(){ echo $new_name mv "$WORKDIR/pkg" "$WORKDIR/$new_name" - + sed -i "s/^SRC := .*/SRC := "$new_name"/" "$WORKDIR/Makefile" sed -i "s/^name = .*/name = \"$new_name\"/" "$WORKDIR/pyproject.toml" sed -i "s/^SRC='.*/SRC='$new_name'/" "$WORKDIR/scripts/.githooks/pre-commit" sed -i "s/^files = .*/files = \"$new_name\"/" "$WORKDIR/.mypy.ini" @@ -25,4 +25,4 @@ change_name(){ change_name "$1" -exit 0 \ No newline at end of file +exit 0 From bbcd04ec865296bb5e6131a83e7c04fc66d95e85 Mon Sep 17 00:00:00 2001 From: Mohsen Hariri Date: Sun, 8 Oct 2023 14:27:07 -0400 Subject: [PATCH 2/4] typo fixed mypy --- scripts/init | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/init b/scripts/init index 445e79c..366c3b6 100755 --- a/scripts/init +++ b/scripts/init @@ -14,11 +14,11 @@ change_name(){ echo $new_name mv "$WORKDIR/pkg" "$WORKDIR/$new_name" - sed -i "s/^SRC := .*/SRC := "$new_name"/" "$WORKDIR/Makefile" + sed -i "s/^SRC := .*/SRC := $new_name/" "$WORKDIR/Makefile" sed -i "s/^name = .*/name = \"$new_name\"/" "$WORKDIR/pyproject.toml" sed -i "s/^SRC='.*/SRC='$new_name'/" "$WORKDIR/scripts/.githooks/pre-commit" - sed -i "s/^files = .*/files = \"$new_name\"/" "$WORKDIR/.mypy.ini" - sed -i "s/^files = .*/files = \"$new_name\"/" "$WORKDIR/.mypy.ini.prod" + sed -i "s/^files = .*/files = $new_name\//" "$WORKDIR/.mypy.ini" + sed -i "s/^files = .*/files = $new_name\//" "$WORKDIR/.mypy.ini.prod" } From c06225c74ae1899a942bad1fe577a6b29d374bcf Mon Sep 17 00:00:00 2001 From: Mohsen Hariri Date: Sun, 8 Oct 2023 14:27:27 -0400 Subject: [PATCH 3/4] jupyter init --- Makefile | 20 ++++++++++++++- notebooks/note.ipynb | 59 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 notebooks/note.ipynb diff --git a/Makefile b/Makefile index 02c2dc4..b2f34ad 100755 --- a/Makefile +++ b/Makefile @@ -13,6 +13,9 @@ PROJECT := $(shell basename $(CURDIR)) ENV_PATH := $(ENV_PATH_ROOT)/$(PROJECT) ENV_NAME := $(shell $(PYTHON) -c 'import sys;import socket;print(f"env_{socket.gethostname()}_{sys.platform}_{sys.version_info.major}.{sys.version_info.minor}")') +ENV_JUPYTER := $(ENV_PATH_ROOT)/jupyter +JUPYTER_PORT := 3000 + ifeq ($(strip $(VIRTUAL_ENV)),) PATH := $(ENV_PATH)/$(ENV_NAME)/bin:$(PATH) PY := $(ENV_PATH)/$(ENV_NAME)/bin/python @@ -200,4 +203,19 @@ gen-commands: clean-commands $(foreach file,$(PY_FILES),$(shell echo "\n$(subst /,-,$(subst $(SRC)/,,$(basename $(file)))):\n\t\t$(PY) $(file)" >> py.make)) $(foreach file,$(PY_FILES_API),$(shell echo "\n$(subst /,-,$(subst $(API)/,,$(basename $(file)))):\n\t\t$(PY) $(file)" >> api.make)) - +jupyter: + if [ ! -d $(ENV_JUPYTER) ] ; then \ + $(PYTHON) -m venv $(ENV_JUPYTER); fi + $(ENV_JUPYTER)/bin/python -m pip install --upgrade jupyter + $(ENV_JUPYTER)/bin/jupyter notebook --no-browser --port=$(JUPYTER_PORT) --notebook-dir=$(WORKDIR) > ./logs/jupyter.log 2>&1 & echo $$! > ./logs/jupyter.pid + +jupyter-url: + @echo "Fetching Jupyter URL..." + @grep -oP "http://.*\?token=[a-z0-9]*" ./logs/jupyter.log || echo "URL not found in logs." + +stop-jupyter: + if [ -f ./logs/jupyter.pid ]; then \ + kill `cat ./logs/jupyter.pid` && rm ./logs/jupyter.pid; \ + else \ + echo "No Jupyter PID file found."; \ + fi diff --git a/notebooks/note.ipynb b/notebooks/note.ipynb new file mode 100644 index 0000000..3624787 --- /dev/null +++ b/notebooks/note.ipynb @@ -0,0 +1,59 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%bash\n", + "/home/mohsen/envs/py/jupyter/bin/python -m ensurepip --default-pip\n", + "/home/mohsen/envs/py/jupyter/bin/python -m pip install --upgrade pip\n", + "/home/mohsen/envs/py/jupyter/bin/python -m pip install numpy" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import sys\n", + "current_directory = os.getcwd()\n", + "parent = os.path.dirname(current_directory)\n", + "os.chdir(parent)\n", + "print(\"working directory:\", parent)\n", + "print(\"python path:\", sys.executable)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 4ea7e6b8d81276e7bafcaf1a61423f70756dff79 Mon Sep 17 00:00:00 2001 From: Mohsen Hariri Date: Sat, 11 Nov 2023 01:21:26 -0500 Subject: [PATCH 4/4] sort args --- Makefile | 3 +-- git.make | 2 ++ requirements.txt | 26 +++++++++++--------------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index b2f34ad..8af9108 100755 --- a/Makefile +++ b/Makefile @@ -170,7 +170,6 @@ pkg-poetry-publish: lint: ruff check $(SRC) - pylint-dev: pylint --rcfile .pylintrc.dev $(SRC) @@ -181,7 +180,7 @@ format: black $(SRC) sort: - isort $(SRC) + isort $(SRC) --profile black --skip $(SRC)/__init__.py type: mypy diff --git a/git.make b/git.make index 88d9d19..dc81e39 100644 --- a/git.make +++ b/git.make @@ -9,3 +9,5 @@ g-commit: format pylint-dev g-log: git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit + +pre-add: sort format clean-command \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c3207a4..e604891 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,14 @@ -astroid==2.15.5 -black==23.3.0 -click==8.1.3 -dill==0.3.6 +astroid==3.0.1 +black==23.11.0 +click==8.1.7 +dill==0.3.7 isort==5.12.0 -lazy-object-proxy==1.9.0 mccabe==0.7.0 -mypy==1.3.0 +mypy==1.7.0 mypy-extensions==1.0.0 -packaging==23.1 -pathspec==0.11.1 -platformdirs==3.5.1 -pylint==2.17.4 -ruff==0.0.269 -tomli==2.0.1 -tomlkit==0.11.8 -typing-extensions==4.5.0 -wrapt==1.15.0 +packaging==23.2 +pathspec==0.11.2 +platformdirs==4.0.0 +pylint==3.0.2 +tomlkit==0.12.2 +typing_extensions==4.8.0