Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 0 additions & 22 deletions .github/workflows/pylint.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__pycache__/
metastore_db/
.coverage
.DS_Store
gurobi.log
derby.log
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2021, Diptesh
All rights reserved.

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

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ It's good practice to follow accepted standards while coding in python:

Also, it's a good idea to rate all our python scripts with [Pylint](https://www.pylint.org/). If we score anything less than 8/10, we should consider redesigning the code architecture.

A composite pylint ratings for all the codes are automatically computed when we [run the tests](./bin/runTests.sh) and prepended on top of this file.
A composite pylint ratings for all the codes are automatically computed when we [run the tests](./bin/run_tests.sh) and prepended on top of this file.

#### Version control

Expand Down
23 changes: 23 additions & 0 deletions bin/programs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# =============================================================================
# Python dependencies
#
# Objective: Install python dependencies from requirements.txt
#
# Version: 0.1.0
#
# Author: Diptesh
#
# Date: Mar 03, 2020
#
# =============================================================================

# Set test directory
path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)\
/$(basename "${BASH_SOURCE[0]}")"

proj_dir=$(sed -E 's/(.+)(\/bin\/.+)/\1/' <<< $path)

if ! [[ $(hostname) =~ .+target\.com ]]; then
pip install -r $proj_dir/requirements.txt
fi
80 changes: 80 additions & 0 deletions bin/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash
# =============================================================================
# Python unit tests and code ratings
#
# Objective: Test all python test modules and rate all python scripts
#
# Version: 0.2.0
#
# Author: Diptesh
#
# Date: Jun 24, 2020
#
# =============================================================================

# Set test directory
path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)\
/$(basename "${BASH_SOURCE[0]}")"

test_dir=$(sed -E 's/(.+)(\/bin\/.+)/\1\/tests/' <<< $path)
proj_dir=$(sed -E 's/(.+)(\/bin\/.+)/\1/' <<< $path)

if [[ -z $1 ]]
then
module="-a"
else
module=$1
fi

printf "=%.0s" {1..70}

# Run unit tests
if [[ $module == "-a" || $module == "-u" ]]
then
printf "\nRunning unit & integration tests...\n\n"
coverage run -m unittest discover -v -s $test_dir -p "test_*.py"
coverage report -m --omit="*/tests/test_*,*/opt/spark-*" > "$proj_dir/log/cov.out"
COV_SCORE=`grep "TOTAL" $proj_dir/log/cov.out | tail -1 | awk '{ printf("%d", $4) }'`
COV_COLOR="red"
if [[ $COV_SCORE == "100" ]]
then
COV_COLOR="dagreen"
fi
sed -i "2s/.*/\[\!\[Coverage score\]\(\https\:\/\/img\.shields\.io\/badge\/coverage\-$COV_SCORE\%25\-$COV_COLOR.svg\)\]\(\.\/log\/cov\.out\)/" "$proj_dir/README.md"
printf "=%.0s" {1..70}
printf "\n"
fi

# Rate coding styles for all python scripts
if [[ $module == "-a" || $module == "-r" ]]
then
printf "\nRating code style...\n\n"
score=0
cnt=0
for i in $(find "$proj_dir" -name "*.py")
do
file=${i#$(dirname "$(dirname "$i")")/}
printf "%-67s %s" "$file"
file_dir=$(sed -E 's/(.+\/)(.+\.py)/\1/' <<< $i)
cd "$file_dir"
pylint "$i" > "$proj_dir/log/pylint/pylint.out"
PYLINT_SCORE=`grep "Your code has been rated" $proj_dir/log/pylint/pylint.out | cut -d" " -f7 | cut -d"." -f1`
file_name=$(sed -E 's/(\/)/-/' <<< $file)
file_name=$(sed -E 's/(\.)/-/' <<< $file_name)
cp "$proj_dir/log/pylint/pylint.out" "$proj_dir/log/pylint/$file_name.out"
score=$((score + PYLINT_SCORE))
cnt=$((cnt + 1))
printf "$PYLINT_SCORE\n"
cd "$proj_dir"
done
tot_score=$(echo "scale=1; $score/$cnt" | bc)
printf "\nTotal score: $tot_score\n"
# Add pylint badge to README.md
sed -i "1s/.*/\[\!\[pylint Score\]\(https\:\/\/mperlet\.github\.io\/pybadge\/badges\/$tot_score.svg\)\]\(\.\/log\/pylint\/\)/" "$proj_dir/README.md"
printf "=%.0s" {1..70}
printf "\n"
fi

pipreqs --force $proj_dir &> $proj_dir/log/pip.out

exit 0
151 changes: 151 additions & 0 deletions data/input/iris.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
x3,x4,x1,x2,y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