From 65e93d4be27cd43d4b7d6b0eb49594df8a37a708 Mon Sep 17 00:00:00 2001 From: Michael Bentz Date: Tue, 7 May 2024 08:54:45 -0400 Subject: [PATCH 1/2] Migrate project to use `poetry` --- .github/workflows/lint.yml | 2 +- .github/workflows/run-unit-tests.yml | 15 ++++++++++--- .gitignore | 4 ++++ .vscode/tasks.json | 20 ----------------- poetry.toml | 3 +++ pyproject.toml | 32 ++++++++++++++-------------- 6 files changed, 36 insertions(+), 40 deletions(-) delete mode 100644 .vscode/tasks.json create mode 100644 poetry.toml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e6ec5ea..f74230c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,6 +17,6 @@ jobs: - name: Set up Python environment uses: actions/setup-python@v2 with: - python-version: "3.8.0" + python-version: "3.9.0" - name: flake8 Lint uses: py-actions/flake8@v2 diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 1ffbd83..c2ef740 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -18,8 +18,17 @@ jobs: - name: Set up Python environment uses: actions/setup-python@v2 with: - python-version: "3.8.0" - - name: Install dependencies and test with unittest + python-version: "3.9.0" + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + # installer-parallel: true + - name: Install dependencies + run: | + poetry install + - name: Run unittests run: | - pip install -e . + source .venv/bin/activate python -m unittest -v diff --git a/.gitignore b/.gitignore index 68bc17f..07c7be9 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,7 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + + +.DS_Store +poetry.lock diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index c46e93c..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,20 +0,0 @@ - -{ - "version": "2.0.0", - "tasks": [ - { - // Create a python virtual environment when the folder is opened - "label": "Create python venv", - "type": "shell", - "command": "python3 -m venv .venv", - "group": "none", - "presentation": { - "reveal": "always", - "panel": "new" - }, - "runOptions": { - "runOn": "folderOpen", - } - } - ] -} diff --git a/poetry.toml b/poetry.toml new file mode 100644 index 0000000..62e2dff --- /dev/null +++ b/poetry.toml @@ -0,0 +1,3 @@ +[virtualenvs] +in-project = true +create = true diff --git a/pyproject.toml b/pyproject.toml index 8f1b6af..ec98410 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,24 +1,24 @@ -[project] +[tool.poetry] name = "report_handler" version = "1.2.0" +description = "" authors = [ - { name="Kshitij Sinha", email="kshitij.sinha1608@gmail.com" }, - { name="Michael Bentz", email="mbentz@ufl.edu" } + "Kshitij Sinha ", + "Michael Bentz ", ] -description = "" +license = "MIT" readme = "README.md" -requires-python = ">=3.7" -classifiers = [ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", -] -dependencies = [ - "XlsxWriter==3.0.6", - "pandas>=2.0.3", - "openpyxl>=3.1.2" -] -[project.urls] +[tool.poetry.dependencies] +python = "^3.9" +XlsxWriter = "^3.0.6" +pandas = "^2.0.3" +openpyxl = "^3.1.2" + +[tool.poetry.urls] "Homepage" = "https://github.com/ctsit/report_handler" "Bug Tracker" = "https://github.com/ctsit/report_handler/issues" + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" From 0a74f3f2008d9bc2a2566675fdb5153acf2848f8 Mon Sep 17 00:00:00 2001 From: Michael Bentz Date: Tue, 7 May 2024 09:14:36 -0400 Subject: [PATCH 2/2] Update README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4aa26d2..2e636e4 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ This project helps separate the database and report logging from [`python_db_log There are two methods to install this package in your project, - Using `pyproject.toml`: - - Add `"report_handler @ git+https://git@github.com:/ctsit/report_handler.git"` in the `dependencies` section of the file. - - Run `pip3 install .` to install in the virtual environment. + - Add `report-handler = { git = "https://github.com/ctsit/report_handler.git", rev = "master", tag = "1.2.0" }` in the `tool.poetry.dependencies` section of the file. + - Run `poetry install` to install in the virtual environment. - Using `setup.py`: - Add `"report_handler @ git+https://git@github.com:/ctsit/report_handler.git"` in the `install_requires` section of the file. - Run `pip3 install .` to install in the virtual environment. @@ -68,6 +68,7 @@ logger = logging.getLogger() logger.addHandler(report_handler) ``` +Note: By default the `ReportHandler` will only capture logs that provide the dictionary (defined below) in the `extra` keyword argument of logging calls. To capture all logs without providing the dictionary, set the `verbose` flag in the `ReportHandler` constructor to `True`, i.e., `report_handler = ReportHandler(verbose=True)`. To log, call the following functions as required by the logging level: ```python