From 68b3e7ec3af133e666eb5ee037b8928548114207 Mon Sep 17 00:00:00 2001 From: Srinivas Gorur-Shandilya Date: Wed, 9 Aug 2023 13:46:50 -0400 Subject: [PATCH] modernization --- .gitignore | 5 ++++- Makefile | 36 ++++++++++++++++++++++++++++++++++ README.md | 50 +---------------------------------------------- config.ini | 9 +++++++++ pyproject.toml | 44 ++++++++++++++++------------------------- pyvocab/vocab.py | 3 --- pyvocab/words.csv | 2 +- requirements.txt | 6 ------ setup.py | 5 ----- start-app.sh | 1 + 10 files changed, 69 insertions(+), 92 deletions(-) create mode 100644 Makefile create mode 100644 config.ini delete mode 100644 requirements.txt delete mode 100644 setup.py create mode 100644 start-app.sh diff --git a/.gitignore b/.gitignore index 700d777..afc42e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,11 @@ *__pycache__* *.DS_Store *sublime-workspace +pyvocab.sublime-project .clientid .clientsecret distractors.csv -*pyvocab.egg-info/* \ No newline at end of file +*pyvocab.egg-info/* +poetry.lock +streamlit.pid diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f3f1d8e --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ + +PID := $(shell cat streamlit.pid) + +.PHONY: nightly start-app stop-app restart-app install-launch-agent test coverage-report bump-version jupyter + +jupyter: + @echo "Installing kernel in jupyter" + -yes | jupyter kernelspec uninstall pyvocab + poetry run python -m ipykernel install --user --name pyvocab + + + + +start-app: stop-app + @echo "Starting streamlit app.." + @bash start-app.sh + +stop-app: + @echo "Stopping streamlit app..." + -kill $(PID) + + +restart-app: stop-app start-app + @echo "Restarting app..." + +test: + poetry run coverage run -m pytest -sx --failed-first + -rm coverage.svg + poetry run coverage-badge -o coverage.svg + +coverage-report: .coverage + poetry run coverage html --omit="*/test*" + open htmlcov/index.html + +bump-version: + poetry run bump \ No newline at end of file diff --git a/README.md b/README.md index df1aa43..49817ec 100644 --- a/README.md +++ b/README.md @@ -2,53 +2,5 @@ A simple python vocabulary builder -## Usage - - -The recommended way of using this is within [Jupyter Lab](https://jupyter.org/install). Once you have that installed, import it using: - -```python -from pyvocab import vocab -``` - - - - -### Read all words in the dictionary - -```python -words = vocab.read() -``` - -### Lookup all words using a dictionary service, and save definitions - -```python -vocab.lookup() -``` - -### Interactive test - -```python -vocab.test() -``` - - -### Scrape /r/logophilia for new words - -First, create two files called `.clientid` and `.clientsecret` with your reddit bot clientID and client secret. Then: - -```python -vocab.reddit() -``` - - -## Developing - -If you are developing this, you probably want to make your life a little easier. Before importing `pyvocab`, - -```python -%load_ext autoreload -%autoreload 2 - -``` +## Installation diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..8de0093 --- /dev/null +++ b/config.ini @@ -0,0 +1,9 @@ +# configuration file for pyvocab +# rename this file to "config.ini" +# and populate the fields below before running anything in this package + +["pyvocab"] + + +# streamlit app options +streamlit_port = 8510 diff --git a/pyproject.toml b/pyproject.toml index 4098fb2..71ec37f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,33 +1,23 @@ -[build-system] -requires = ["setuptools", "setuptools-scm"] -build-backend = "setuptools.build_meta" - -[project] +[tool.poetry] name = "pyvocab" -description = "Simple python-based vocabulary builder" +version = "23.1.10" +description = "" +authors = ["Srinivas Gorur-Shandilya "] readme = "README.md" -requires-python = ">=3.8" -version = "22.9.11" -authors = [ - {name = "Srinivas Gorur-Shandilya", email="code@srinivas.gs"} -] -license = {text = "GPLv3 License"} -classifiers = [ - "Framework :: streamlit", - "Programming Language :: Python :: 3", -] -dependencies = [ - "pandas>=1.3.2", - "watchdog", - "streamlit>=1.11.0", - "interrogate>=1.0", - "python-Levenshtein", - "pycore @ git+https://github.com/sg-s/pycore.git", -] +[tool.poetry.dependencies] +python = "^3.10" +streamlit = "^1.16.0" +pandas = "^1.5.2" +watchdog = "^2.2.1" +pycore = {git = "https://github.com/sg-s/pycore.git"} +python-levenshtein = "^0.20.9" - -[project.optional-dependencies] -dev = ["pytest"] +[tool.poetry.group.dev.dependencies] +ipykernel = "^6.20.1" +debugpy = "1.6" +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/pyvocab/vocab.py b/pyvocab/vocab.py index ef2a371..a61904e 100644 --- a/pyvocab/vocab.py +++ b/pyvocab/vocab.py @@ -2,10 +2,7 @@ from pathlib import Path -import numpy as np -import pandas as pd import praw - from PyDictionary import PyDictionary diff --git a/pyvocab/words.csv b/pyvocab/words.csv index 68230ce..ae7337e 100644 --- a/pyvocab/words.csv +++ b/pyvocab/words.csv @@ -826,7 +826,7 @@ toska | a dull ache of the soul, a longing with nothing to long for, a sick pin tosspot | a drunkard, a habitual drinker tranche | A division or portion of a pool or whole. trichiliocosm | (Buddhism) A concept in cosmology of a third-orderuniverse containing one thousand second-order clusters, which are made of one thousand first-order clusters, which are in turn made of a thousand worlds each. Billion-fold universe. -tricoteuse | a woman who sits and knits (personally found from a David Bowie song) +tricoteuse | a woman who sits and knits trilemma | trumpery | worthless nonsense tulpa | A magical creature that attains corporeal reality, having been originally merely imaginary; thought that has taken physical form. diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 50c7146..0000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -pandas>=1.3.2 -watchdog -streamlit>=1.11.0 -interrogate>=1.0 -python-Levenshtein -pycore @ git+https://github.com/sg-s/pycore.git \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 46a69dd..0000000 --- a/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -"""setup file""" - -from setuptools import setup - -setup() diff --git a/start-app.sh b/start-app.sh new file mode 100644 index 0000000..f1e62f3 --- /dev/null +++ b/start-app.sh @@ -0,0 +1 @@ +nohup poetry run streamlit run --server.port $(less config.ini | grep "streamlit_port" | cut -d = -f 2) pyvocab/game.py > /dev/null 2>&1 & echo $! > streamlit.pid \ No newline at end of file