Skip to content

Commit dc1b152

Browse files
authored
code (#21)
1 parent 6abf568 commit dc1b152

File tree

17 files changed

+332
-244
lines changed

17 files changed

+332
-244
lines changed

.github/workflows/documentation.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,26 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v2
18-
1918
- name: "Set up Python 3.9"
2019
uses: actions/setup-python@v2
2120
with:
2221
python-version: 3.9
23-
2422
- name: "Update Tools"
2523
run: |
2624
python -m pip install --upgrade pip
2725
python -m pip install --upgrade setuptools
2826
python -m pip install --upgrade wheel
29-
3027
- name: "Install Dependencies"
3128
run: make dependencies
32-
3329
- name: "Install Doc Dependencies"
3430
run: make doc-dependencies
35-
3631
- name: "Build Documentation"
3732
run: make build-docs
38-
3933
- name: "Archive Documentation"
4034
uses: actions/upload-artifact@v1
4135
with:
4236
name: documentation
4337
path: site
44-
4538
- name: "Push to gh-pages Branch"
4639
uses: peaceiris/actions-gh-pages@v3
4740
with:

.github/workflows/release.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,23 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
1413
- name: "Set up Python 3.9"
1514
uses: actions/setup-python@v2
1615
with:
1716
python-version: 3.9
18-
1917
- name: "Install and Upgrade Dependencies"
2018
run: |
2119
python -m pip install --upgrade pip
2220
python -m pip install --upgrade setuptools
2321
python -m pip install --upgrade wheel
2422
python -m pip install --upgrade twine
25-
2623
- name: "Add Release Version"
2724
env:
2825
SOURCE_TAG: ${{ github.event.release.tag_name }}
2926
run: |
3027
echo -n "${SOURCE_TAG:1}" > ml_base/version.txt
31-
3228
- name: "Build Package"
3329
run: make build
34-
3530
- name: "Publish to PyPi"
3631
env:
3732
TWINE_USERNAME: __token__

.github/workflows/test.yml

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,56 @@ on:
55
branches:
66
- main
77

8+
# TODO: add dependency caching
89
jobs:
9-
10-
test:
10+
inspect:
1111
runs-on: ubuntu-latest
12-
1312
steps:
14-
- uses: actions/checkout@v2
15-
13+
- uses: actions/checkout@v3
1614
- name: "Set up Python 3.9"
17-
uses: actions/setup-python@v1
15+
uses: actions/setup-python@v4
1816
with:
1917
python-version: 3.9
20-
21-
- name: "Upgrade Tools"
22-
run: |
23-
python -m pip install --upgrade pip
24-
python -m pip install --upgrade setuptools
25-
python -m pip install --upgrade wheel
26-
2718
- name: "Install Dependencies"
2819
run: make dependencies
29-
3020
- name: "Install Test Dependencies"
3121
run : make test-dependencies
32-
3322
- name: "Check Codestyle"
3423
run: make check-codestyle
35-
3624
- name: "Check Docstyle"
3725
run: make check-docstyle
38-
3926
- name: "Code Metrics"
4027
run: make check-codemetrics
41-
4228
- name: "Security Issues"
4329
run: make check-security
44-
4530
- name: "Dependency Security"
4631
run: make check-dependencies
4732

48-
- name: "Static Analysis"
49-
run: make check-pytype
50-
33+
test-matrix:
34+
runs-on: ubuntu-latest
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
python-version: ["3.8", "3.9", "3.10", "3.11"]
39+
steps:
40+
- uses: actions/checkout@v3
41+
- name: "Set up Python"
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: ${{ matrix.python-version }}
45+
- name: "Install Dependencies"
46+
run: make dependencies
47+
- name: "Install Test Dependencies"
48+
run: make test-dependencies
5149
- name: "Run Unit Tests"
5250
run: make test-reports
53-
5451
- name: "Archive Unit Test Report"
55-
uses: actions/upload-artifact@v1
52+
uses: actions/upload-artifact@v3
5653
with:
5754
name: unit-test-report
5855
path: reports/unit_tests
59-
6056
- name: "Archive Code Coverage Report"
61-
uses: actions/upload-artifact@v1
57+
uses: actions/upload-artifact@v3
6258
with:
6359
name: code-coverage-report
64-
path: reports/coverage
60+
path: reports/coverage

CHANGELOG.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,30 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.2.2] - 2023-02-01
9+
10+
## Added
11+
- Added lock to StatusManager singleton __new__() method to prevent race conditions.
12+
813
## [0.2.1] - 2022-05-10
914

1015
## Fixed
11-
1216
- Removed debugging statement from root of package.
1317
- Removed newline character from version string.
1418

1519
## [0.2.0] - 2022-02-16
1620

1721
### Added
18-
1922
- MLModelDecorator base class.
2023
- Ability to add a decorator to a model in the ModelManager.
2124

2225
## [0.1.1] - 2021-01-17
2326

2427
### Fixed
25-
2628
- Double initialization issue in ModelManager singleton class
2729

2830
## [0.1.0] - 2020-11-04
2931

3032
### Added
31-
3233
- Base class "MLModel" for holding machine learning model prediction functionality
33-
- Class "ModelManager" for managing MLModel objects
34+
- Class "ModelManager" for managing MLModel objects

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2022 Brian Schmidt
1+
Copyright 2023 Brian Schmidt
22

33
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
44
following conditions are met:

Makefile

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,59 @@ TEST_PATH=./tests
22

33
.DEFAULT_GOAL := help
44

5-
.PHONY: help clean-pyc build clean-build venv dependencies test-dependencies clean-venv test test-reports clean-test check-codestyle check-docstyle
6-
75
help:
8-
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
7+
.PHONY: help
98

109
clean-pyc: ## Remove python artifacts.
1110
find . -name '*.pyc' -exec rm -f {} +
1211
find . -name '*.pyo' -exec rm -f {} +
1312
find . -name '*~' -exec rm -f {} +
13+
.PHONY: clean-pyc
1414

15-
build: ## build a package
15+
build: ## Build the package
1616
python setup.py sdist bdist_wheel
17+
.PHONY: build
1718

18-
clean-build: ## clean build artifacts
19+
clean-build: ## Clean build artifacts
1920
rm -rf build
2021
rm -rf dist
2122
rm -rf vendors
2223
rm -rf ml_base.egg-info
24+
.PHONY: clean-build
2325

24-
venv: ## create virtual environment
26+
venv: ## Create virtual environment
2527
python3 -m venv venv
28+
.PHONY: venv
2629

27-
dependencies: ## install dependencies from requirements.txt
30+
dependencies: ## Install dependencies from requirements.txt
2831
python -m pip install --upgrade pip
2932
python -m pip install --upgrade setuptools
3033
python -m pip install --upgrade wheel
3134
pip install -r requirements.txt
35+
.PHONY: dependencies
3236

33-
test-dependencies: ## install dependencies from test_requirements.txt
37+
test-dependencies: ## Install dependencies from test_requirements.txt
3438
pip install -r test_requirements.txt
39+
.PHONY: test-dependencies
3540

36-
doc-dependencies: ## install dependencies from doc_requirements.txt
41+
doc-dependencies: ## Install dependencies from doc_requirements.txt
3742
pip install -r doc_requirements.txt
43+
.PHONY: doc-dependencies
3844

3945
update-dependencies: ## Update dependency versions
4046
pip-compile requirements.in > requirements.txt
4147
pip-compile test_requirements.in > test_requirements.txt
4248
pip-compile doc_requirements.in > doc_requirements.txt
49+
.PHONY: update-dependencies
4350

44-
clean-venv: ## remove all packages from virtual environment
51+
clean-venv: ## Remove all packages from virtual environment
4552
pip freeze | grep -v "^-e" | xargs pip uninstall -y
53+
.PHONY: clean-venv
4654

4755
test: clean-pyc ## Run unit test suite.
4856
pytest --verbose --color=yes $(TEST_PATH)
57+
.PHONY: test
4958

5059
test-reports: clean-pyc clean-test ## Run unit test suite with reporting
5160
mkdir -p reports
@@ -55,42 +64,55 @@ test-reports: clean-pyc clean-test ## Run unit test suite with reporting
5564
python -m coverage run --source ml_base -m pytest --verbose --color=yes --html=./reports/unit_tests/report.html --junitxml=./reports/unit_tests/report.xml $(TEST_PATH)
5665
coverage html -d ./reports/coverage
5766
coverage-badge -o ./reports/badge/coverage.svg
67+
.PHONY: test-reports
5868

5969
clean-test: ## Remove test artifacts
6070
rm -rf .pytest_cache
6171
rm -rf .coverage
6272
rm -rf reports
6373
rm -rf .pytype
74+
.PHONY: clean-test
6475

65-
check-codestyle: ## checks the style of the code against PEP8
76+
check-codestyle: ## Check the style of the code against PEP8
6677
pycodestyle ml_base --max-line-length=120
78+
.PHONY: check-codestyle
6779

68-
check-docstyle: ## checks the style of the docstrings against PEP257
80+
check-docstyle: ## Check the style of the docstrings against PEP257
6981
pydocstyle ml_base
82+
.PHONY: check-docstyle
7083

71-
check-security: ## checks for common security vulnerabilities
84+
check-security: ## Checks for common security vulnerabilities
7285
bandit -r ml_base
86+
.PHONY: check-security
7387

74-
check-dependencies: ## checks for security vulnerabilities in dependencies
88+
check-dependencies: ## Check for security vulnerabilities in dependencies
7589
safety check -r requirements.txt
90+
.PHONY: check-dependencies
7691

77-
check-codemetrics: ## calculate code metrics of the package
92+
check-codemetrics: ## Calculate code metrics of the package
7893
radon cc ml_base
94+
.PHONY: check-codemetrics
7995

80-
check-pytype: ## perform static code analysis
81-
pytype ml_base
96+
check-annotations: ## Check for type annotations coverage
97+
flake8 ml_base --max-line-length=120 --ignore=ANN101,ANN102,ANN401
98+
.PHONY: check-annotations
8299

83-
build-docs: ## build the documentation
100+
build-docs: ## Build the documentation
84101
mkdocs build
102+
.PHONY:build-docs
85103

86-
view-docs: ## open a web browser to view the documentation
104+
view-docs: ## Open a web browser to view the documentation
87105
open site/index.html
106+
.PHONY: view-docs
88107

89-
clean-docs: ## clean up the files in the docs build folder
108+
clean-docs: ## Clean up the files in the docs build folder
90109
rm -rf site
110+
.PHONY: clean-docs
91111

92-
run-examples: ## run all example notebooks in examples directory
112+
run-examples: ## Run all example notebooks in examples directory
93113
jupyter nbconvert --to notebook --execute examples/basic.ipynb
114+
.PHONY: run-examples
94115

95-
convert-examples: ## convert the example notebooks into Markdown files in docs folder
96-
jupyter nbconvert --to markdown examples/*.ipynb --output-dir='./docs'
116+
convert-examples: ## Convert the example notebooks into Markdown files in docs folder
117+
jupyter nbconvert --to markdown examples/*.ipynb --output-dir='./docs'
118+
.PHONY:convert-examples

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Code Quality Status](https://github.com/schmidtbri/ml-base/actions/workflows/test.yml/badge.svg)
22
[![License](https://img.shields.io/badge/license-BSD--3--Clause-green)](https://opensource.org/licenses/BSD-3-Clause)
3-
[![PyPi](https://img.shields.io/badge/pypi-v0.2.1-green)](https://pypi.org/project/ml-base/)
3+
[![PyPi](https://img.shields.io/badge/pypi-v0.2.2-green)](https://pypi.org/project/ml-base/)
44

55
# ml-base
66

doc_requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ jupyter
33
mkdocs
44
mkdocs-material
55
mkdocs-material-extensions
6-
mkdocstrings
6+
mkdocstrings[python]

0 commit comments

Comments
 (0)