-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor the module to reduce the technical debt and improve tournesol's distribution #11
base: main
Are you sure you want to change the base?
Conversation
Dynamically compute the percentage by rounding the given result rather than using a result matrix.
FROM_TOP = 70 | ||
LAST_N_DAYS = 120 | ||
|
||
def get_top_percentage(criteria_row): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely refactored the function below to use math instead a result of matrix.
Please have a look to 3823c5d
This is why I wrote a sentence about gerrit vs github pull request in the description of this pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a global manner these changes will allow us to implement CI pipelines to check this repo, the code, and the changes.
@@ -1,7 +1,7 @@ | |||
import requests | |||
import pandas as pd | |||
|
|||
from data.utils_dict import YT_2_TWITTER, already_shared_filepath | |||
from tournesolbot.data.utils_dict import YT_2_TWITTER, already_shared_filepath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports are now absolute.
@@ -242,7 +232,7 @@ def print_help(): | |||
print("-t\ttweet the corresponding string (e.g. 'My tweet').\n") | |||
|
|||
|
|||
if __name__ == '__main__': | |||
def main(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called by the entry points to launch the bot
flake8-logging-format | ||
commands = flake8 | ||
|
||
[testenv:venv] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow us to run virtualenv by using tox:
tox -e venv -- virtualenv
-r{toxinidir}/requirements.txt | ||
commands = nosetests | ||
|
||
[testenv:pep8] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow us to lint the code
envlist = py36,py37,py38,pep8 | ||
ignore_basepython_conflict = true | ||
|
||
[testenv] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run unit tests
[testenv:venv] | ||
commands = {posargs} | ||
|
||
[flake8] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linter configuration
from tournesolbot import get_top_percentage | ||
|
||
|
||
class TestGetTopPercentage(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding few unit test to test our math refactor.
This refactor allow us to: - introduce entry points for a better CLI integration - introduce unit tests - introduce tox environment - run unit tests - run pep8 checks and linters - start a virtualenv to interact with tournesolbot by using `tox -e venv -- tournesolbot`. Useful for development session.
Hello,
This pull request is composed of two non squashed commits.
The first one aim to reduce the technical debt by using maths. It dynamically compute the percentage by rounding the given result rather than using a result matrix.
The second one aim to refactor a bit the tournesolbot module in global manner to allow us to introduce various features like:
tox -e venv -- tournesolbot
)Now it will allow a better integration with pypi and will allow us to more merely distribute
tournesolbot
.These 2 commits are independent unfortunately github pull request doesn't reflect well the git history like doing by gerrit.
Hopefully these changes will help you.