Skip to content

Commit 94d8536

Browse files
committed
modification setup.py -> pyproject.toml + publish modif
1 parent 8964423 commit 94d8536

File tree

8 files changed

+54
-44
lines changed

8 files changed

+54
-44
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,11 @@ jobs:
2727
run: |
2828
python -m pip show setuptools wheel || python -m pip install setuptools wheel
2929
30-
- name: Extract package version
31-
run: echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
32-
33-
- name: Update version in setup.py
34-
run: sed -i "s/{{VERSION_PLACEHOLDER}}/${{ env.TAG_NAME }}/g" setup.py
3530
3631
- name: Build the package
3732
run: |
3833
python setup.py sdist bdist_wheel
39-
34+
4035
- name: Test with pytest
4136
run: |
4237
pytest -v

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.testing.pytestArgs": [
3+
"tests"
4+
],
5+
"python.testing.unittestEnabled": false,
6+
"python.testing.pytestEnabled": true
7+
}

memory.log

Whitespace-only changes.

pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "setuptools-scm"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "shortterm-memory"
7+
dynamic = ["version", "dependencies"]
8+
description = "Une approche pour la gestion de la mémoire à court terme dans les chatbots."
9+
readme = "README.md"
10+
requires-python = ">=3.9"
11+
license = { text = "MIT" }
12+
authors = [
13+
{ name = "Tadiello Sébastien", email = "[email protected]" }
14+
]
15+
urls = { Homepage = "https://github.com/stadiello/ShortTerm-memory" }
16+
classifiers = [
17+
"Programming Language :: Python :: 3",
18+
"License :: OSI Approved :: MIT License",
19+
"Operating System :: OS Independent"
20+
]
21+
22+
[tool.setuptools]
23+
packages = ["shortterm_memory"]
24+
package-dir = { "" = "src" }
25+
26+
[tool.setuptools.dynamic]
27+
dependencies = { file = ["requirements.txt"] }
28+
29+
[tool.setuptools_scm]
30+
version_scheme = "guess-next-dev"
31+
local_scheme = "no-local-version"

setup.py

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
"""Module providing a Memory Class for a Chatbot."""
2+
3+
import uuid
14
import torch
25
from transformers import BartTokenizer, BartForConditionalGeneration
36
from logs.logger import logging, logger_mem
4-
from datetime import date
5-
import uuid
67
from mem_db.vecto import get_or_create_collection
78

89

@@ -23,7 +24,7 @@ def __new__(cls):
2324
cls._instance = super(BartSingleton, cls).__new__(cls)
2425
cls._instance.tokenizer = BartTokenizer.from_pretrained('facebook/bart-large-cnn')
2526
cls._instance.model = BartForConditionalGeneration.from_pretrained('facebook/bart-large-cnn').to(device)
26-
return cls._instance
27+
return cls._instance
2728

2829
@classmethod
2930
def reset(cls):
-3.72 KB
Binary file not shown.

tests/memory_test.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
"""Mdoule de test pour la mémoire du chatbot"""
2+
3+
from unittest.mock import patch, MagicMock
4+
import pytest
15
import sys
26
import os
37
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../src')))
8+
from shortterm_memory.chatbot_memory import ChatbotMemory
49

5-
import pytest
6-
from unittest.mock import patch, MagicMock
7-
from shortterm_memory.ChatbotMemory import ChatbotMemory
810

911
@pytest.fixture
1012
def mock_tokenizer():
@@ -26,8 +28,8 @@ def mock_model():
2628
model.generate.return_value = [[0] * 10]
2729
return model
2830

29-
@patch("shortterm_memory.ChatbotMemory.BartTokenizer.from_pretrained")
30-
@patch("shortterm_memory.ChatbotMemory.BartForConditionalGeneration.from_pretrained")
31+
@patch("shortterm_memory.chatbot_memory.BartTokenizer.from_pretrained")
32+
@patch("shortterm_memory.chatbot_memory.BartForConditionalGeneration.from_pretrained")
3133
def test_update_and_get_memory(mock_bart_model, mock_bart_tokenizer, mock_tokenizer, mock_model):
3234
mock_bart_tokenizer.return_value = mock_tokenizer
3335
mock_bart_model.return_value = mock_model
@@ -43,8 +45,8 @@ def test_update_and_get_memory(mock_bart_model, mock_bart_tokenizer, mock_tokeni
4345
assert mem[0]['user'] == "Bonjour"
4446
assert mem[0]['bot'] == "Salut !"
4547

46-
@patch("shortterm_memory.ChatbotMemory.BartTokenizer.from_pretrained")
47-
@patch("shortterm_memory.ChatbotMemory.BartForConditionalGeneration.from_pretrained")
48+
@patch("shortterm_memory.chatbot_memory.BartTokenizer.from_pretrained")
49+
@patch("shortterm_memory.chatbot_memory.BartForConditionalGeneration.from_pretrained")
4850
def test_memory_counter(mock_bart_model, mock_bart_tokenizer, mock_tokenizer, mock_model):
4951
mock_bart_tokenizer.return_value = mock_tokenizer
5052
mock_bart_model.return_value = mock_model
@@ -56,8 +58,8 @@ def test_memory_counter(mock_bart_model, mock_bart_tokenizer, mock_tokenizer, mo
5658
token_count = chat_memory.memory_counter()
5759
assert token_count > 0
5860

59-
@patch("shortterm_memory.ChatbotMemory.BartTokenizer.from_pretrained")
60-
@patch("shortterm_memory.ChatbotMemory.BartForConditionalGeneration.from_pretrained")
61+
@patch("shortterm_memory.chatbot_memory.BartTokenizer.from_pretrained")
62+
@patch("shortterm_memory.chatbot_memory.BartForConditionalGeneration.from_pretrained")
6163
def test_compressed_memory(mock_bart_model, mock_bart_tokenizer, mock_tokenizer, mock_model):
6264
mock_bart_tokenizer.return_value = mock_tokenizer
6365
mock_bart_model.return_value = mock_model

0 commit comments

Comments
 (0)