Skip to content

Commit

Permalink
Merge branch 'main' into hpc
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenhariri committed Nov 11, 2023
2 parents 15e0d99 + 4ea7e6b commit 409fc36
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 22 deletions.
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -167,7 +170,6 @@ pkg-poetry-publish:
lint:
ruff check $(SRC)


pylint-dev:
pylint --rcfile .pylintrc.dev $(SRC)

Expand All @@ -178,7 +180,7 @@ format:
black $(SRC)

sort:
isort $(SRC)
isort $(SRC) --profile black --skip $(SRC)/__init__.py

type:
mypy
Expand All @@ -200,4 +202,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
2 changes: 2 additions & 0 deletions git.make
Original file line number Diff line number Diff line change
Expand Up @@ -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
59 changes: 59 additions & 0 deletions notebooks/note.ipynb
Original file line number Diff line number Diff line change
@@ -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
}
26 changes: 11 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions scripts/init
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ 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"
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"
}


change_name "$1"


exit 0
exit 0

0 comments on commit 409fc36

Please sign in to comment.