Skip to content

Commit

Permalink
feature: remove "python -m", add "poetry build" in ci.yml, add [tool.…
Browse files Browse the repository at this point in the history
…poetry.scripts] in pyproject.toml
  • Loading branch information
Ghefira233 committed May 29, 2024
1 parent a2cd7c4 commit e4c9b1d
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 29 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ jobs:
run: |
poetry config virtualenvs.create false && poetry install --only main
- name: Build package
run: |
poetry build
- name: Verify dist directory
run: |
ls -l dist
- name: Install built package
run: |
pip install dist/*.whl
- name: Install make
run: |
sudo apt-get update
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ dill = "0.3.8"
black = "^24.4.2"
isort = "^5.13.2"

[tool.poetry.scripts]
kumparanian = "kumparanian.cli:main"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Expand Down
34 changes: 17 additions & 17 deletions tests/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,50 @@ class TestCLI(unittest.TestCase):
def test_kumparanian(self):
with open("tests/kumparanian.output") as file:
expected_output = file.read()
command = "python -m kumparanian"
command = "kumparanian"
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
self.assertEqual(expected_output, output.decode("utf-8"))

def test_kumparanian_help(self):
with open("tests/kumparanian_help.output") as file:
expected_output = file.read()
command = "python -m kumparanian --help"
command = "kumparanian --help"
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
self.assertEqual(expected_output, output.decode("utf-8"))

def test_kumparanian_ds(self):
with open("tests/kumparanian_ds.output") as file:
expected_output = file.read()
command = "python -m kumparanian ds"
command = "kumparanian ds"
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
self.assertEqual(expected_output, output.decode("utf-8"))

def test_kumparanian_ds_help(self):
with open("tests/kumparanian_ds_help.output") as file:
expected_output = file.read()
command = "python -m kumparanian ds --help"
command = "kumparanian ds --help"
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
self.assertEqual(expected_output, output.decode("utf-8"))

def test_kumparanian_ds_verify(self):
with open("tests/kumparanian_ds_verify.output") as file:
expected_output = file.read()
command = "python -m kumparanian ds verify; exit 0"
command = "kumparanian ds verify; exit 0"
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
self.assertEqual(expected_output, output.decode("utf-8"))

def test_kumparanian_ds_verify_help(self):
with open("tests/kumparanian_ds_verify_help.output") as file:
expected_output = file.read()
command = "python -m kumparanian ds verify --help"
command = "kumparanian ds verify --help"
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
self.assertEqual(expected_output, output.decode("utf-8"))

def test_kumparanian_ds_verify_valid_sklearn_model(self):
with open("tests/kumparanian_ds_verify_valid_model.output") as file:
expected_output = file.read()
command = (
"python -m kumparanian ds verify tests/sklearn_valid_model.pickle "
"kumparanian ds verify tests/sklearn_valid_model.pickle "
"tests/vectorizer_label_encoder.pickle"
)
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
Expand All @@ -58,15 +58,15 @@ def test_kumparanian_ds_verify_valid_sklearn_model(self):
def test_kumparanian_ds_verify_valid_tf_model(self):
with open("tests/kumparanian_ds_verify_valid_model.output") as file:
expected_output = file.read()
command = "python -m kumparanian ds verify tests/tf_valid_model.keras tests/tokenizer_label_encoder.pickle"
command = "kumparanian ds verify tests/tf_valid_model.keras tests/tokenizer_label_encoder.pickle"
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
self.assertEqual(expected_output, output.decode("utf-8"))

def test_kumparanian_ds_verify_invalid_pickle_file(self):
with open("tests/kumparanian_ds_verify_invalid_pickle_file.output") as file:
expected_output = file.read()
command = (
"python -m kumparanian ds verify tests/invalid_pickle.pickle "
"kumparanian ds verify tests/invalid_pickle.pickle "
"tests/tokenizer_label_encoder.pickle; exit 0"
)
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
Expand All @@ -76,7 +76,7 @@ def test_kumparanian_ds_verify_invalid_tokenizer(self):
with open("tests/kumparanian_ds_verify_invalid_tokenizer.output") as file:
expected_output = file.read()
command = (
"python -m kumparanian ds verify tests/tf_valid_model.keras "
"kumparanian ds verify tests/tf_valid_model.keras "
"tests/invalid_tokenizer.pickle; exit 0"
)
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
Expand All @@ -86,7 +86,7 @@ def test_kumparanian_ds_verify_invalid_vectorizer(self):
with open("tests/kumparanian_ds_verify_invalid_vectorizer.output") as file:
expected_output = file.read()
command = (
"python -m kumparanian ds verify tests/sklearn_valid_model.pickle "
"kumparanian ds verify tests/sklearn_valid_model.pickle "
"tests/invalid_vectorizer.pickle; exit 0"
)
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
Expand All @@ -96,7 +96,7 @@ def test_kumparanian_ds_verify_invalid_label_encoder(self):
with open("tests/kumparanian_ds_verify_invalid_label_encoder.output") as file:
expected_output = file.read()
command = (
"python -m kumparanian ds verify tests/tf_valid_model.keras "
"kumparanian ds verify tests/tf_valid_model.keras "
"tests/invalid_label_encoder.pickle; exit 0"
)
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
Expand All @@ -106,7 +106,7 @@ def test_kumparanian_ds_verify_invalid_model_predict(self):
with open("tests/kumparanian_ds_verify_invalid_model_predict.output") as file:
expected_output = file.read()
command = (
"python -m kumparanian ds verify tests/invalid_model.pickle "
"kumparanian ds verify tests/invalid_model.pickle "
"tests/vectorizer_label_encoder.pickle; exit 0"
)
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
Expand All @@ -115,22 +115,22 @@ def test_kumparanian_ds_verify_invalid_model_predict(self):
def test_kumparanian_ds_evaluate(self):
with open("tests/kumparanian_ds_evaluate.output") as file:
expected_output = file.read()
command = "python -m kumparanian ds evaluate; exit 0"
command = "kumparanian ds evaluate; exit 0"
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
self.assertEqual(expected_output, output.decode("utf-8"))

def test_kumparanian_ds_evaluate_help(self):
with open("tests/kumparanian_ds_evaluate_help.output") as file:
expected_output = file.read()
command = "python -m kumparanian ds evaluate --help"
command = "kumparanian ds evaluate --help"
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
self.assertEqual(expected_output, output.decode("utf-8"))

def test_kumparanian_ds_evaluate_model(self):
with open("tests/kumparanian_ds_evaluate_model.output") as file:
expected_output = file.read()
command = (
"python -m kumparanian ds evaluate tests/sklearn_valid_model.pickle "
"kumparanian ds evaluate tests/sklearn_valid_model.pickle "
"tests/vectorizer_label_encoder.pickle; exit 0"
)
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
Expand All @@ -140,7 +140,7 @@ def test_kumparanian_ds_evaluate_model_test(self):
with open("tests/kumparanian_ds_evaluate_model_test.output") as file:
expected_output = file.read()
command = (
"python -m kumparanian ds evaluate tests/tf_valid_model.keras tests/tokenizer_label_encoder.pickle "
"kumparanian ds evaluate tests/tf_valid_model.keras tests/tokenizer_label_encoder.pickle "
"tests/test_set.csv; exit 0"
)
output = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/kumparanian.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: python -m kumparanian [OPTIONS] COMMAND [ARGS]...
Usage: kumparanian [OPTIONS] COMMAND [ARGS]...

Options:
--help Show this message and exit.
Expand Down
2 changes: 1 addition & 1 deletion tests/kumparanian_ds.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: python -m kumparanian ds [OPTIONS] COMMAND [ARGS]...
Usage: kumparanian ds [OPTIONS] COMMAND [ARGS]...

For Data Scientist role.

Expand Down
4 changes: 2 additions & 2 deletions tests/kumparanian_ds_evaluate.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: python -m kumparanian ds evaluate [OPTIONS] MODEL FILE TESTFILE
Try 'python -m kumparanian ds evaluate --help' for help.
Usage: kumparanian ds evaluate [OPTIONS] MODEL FILE TESTFILE
Try 'kumparanian ds evaluate --help' for help.

Error: Missing argument 'MODEL'.
2 changes: 1 addition & 1 deletion tests/kumparanian_ds_evaluate_help.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: python -m kumparanian ds evaluate [OPTIONS] MODEL FILE TESTFILE
Usage: kumparanian ds evaluate [OPTIONS] MODEL FILE TESTFILE

Evaluate the model

Expand Down
4 changes: 2 additions & 2 deletions tests/kumparanian_ds_evaluate_model.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: python -m kumparanian ds evaluate [OPTIONS] MODEL FILE TESTFILE
Try 'python -m kumparanian ds evaluate --help' for help.
Usage: kumparanian ds evaluate [OPTIONS] MODEL FILE TESTFILE
Try 'kumparanian ds evaluate --help' for help.

Error: Missing argument 'TESTFILE'.
2 changes: 1 addition & 1 deletion tests/kumparanian_ds_help.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: python -m kumparanian ds [OPTIONS] COMMAND [ARGS]...
Usage: kumparanian ds [OPTIONS] COMMAND [ARGS]...

For Data Scientist role.

Expand Down
4 changes: 2 additions & 2 deletions tests/kumparanian_ds_verify.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: python -m kumparanian ds verify [OPTIONS] MODEL FILE
Try 'python -m kumparanian ds verify --help' for help.
Usage: kumparanian ds verify [OPTIONS] MODEL FILE
Try 'kumparanian ds verify --help' for help.

Error: Missing argument 'MODEL'.
2 changes: 1 addition & 1 deletion tests/kumparanian_ds_verify_help.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: python -m kumparanian ds verify [OPTIONS] MODEL FILE
Usage: kumparanian ds verify [OPTIONS] MODEL FILE

Verify the model

Expand Down
2 changes: 1 addition & 1 deletion tests/kumparanian_help.output
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: python -m kumparanian [OPTIONS] COMMAND [ARGS]...
Usage: kumparanian [OPTIONS] COMMAND [ARGS]...

Options:
--help Show this message and exit.
Expand Down

0 comments on commit e4c9b1d

Please sign in to comment.