Skip to content

Commit

Permalink
fixed flake8 in the github workflow ci, with custom config
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanehachcham committed Oct 21, 2023
1 parent 880296f commit f8382b3
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 15 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ jobs:
poetry install
- name: Run Flake8
run: |
poetry run flake8 mentor_mingle
- name: Run Pylint
run: |
poetry run pylint mentor_mingle
poetry run flake8 --max-line-length=120 mentor_mingle
- name: Run Tests
run: |
poetry run pytest
4 changes: 3 additions & 1 deletion mentor_mingle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from .config import CFGGpt, Config, Gpt
from .llm_handler import ChatHandler
from .config import Gpt, CFGGpt, Config

__all__ = ["ChatHandler", "Gpt", "CFGGpt", "Config"]
5 changes: 4 additions & 1 deletion mentor_mingle/llm_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def stream_chat(self, user_prompt: str) -> Generator[str, None, None]:
model=self.model.name,
messages=[
{"role": "system", "content": self.agent.persona},
{"role": "user", "content": f"User: {user_prompt}" f"\n{self.agent.answer_format}"},
{
"role": "user",
"content": f"User: {user_prompt}" f"\n{self.agent.answer_format}",
},
],
**self.model.config.model_dump(),
)
Expand Down
4 changes: 2 additions & 2 deletions mentor_mingle/persona/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from abc import ABC, abstractmethod

from ..tot.schema import Thought


Expand Down Expand Up @@ -65,4 +65,4 @@ def generate_case(self, next_case: Thought) -> Thought:
Returns:
Thought: generated Thought.
"""
pass
pass
30 changes: 24 additions & 6 deletions mentor_mingle/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import os


def find_project_root(filename=None):
def find_project_root(filename=None) -> str:
"""
Find the root folder of the project.
Args:
filename (str): The name of the file to look for in the root folder.
Returns:
str: The path of the root folder.
"""
# Get the path of the file that is being executed
current_file_path = os.path.abspath(os.getcwd())

Expand All @@ -16,9 +26,8 @@ def find_project_root(filename=None):
break

# Most common ways to identify a project root folder
if (
os.path.isfile(os.path.join(root_folder, "pyproject.toml"))
or os.path.isfile(os.path.join(root_folder, "config.toml"))
if os.path.isfile(os.path.join(root_folder, "pyproject.toml")) or os.path.isfile(
os.path.join(root_folder, "config.toml")
):
break

Expand All @@ -31,5 +40,14 @@ def find_project_root(filename=None):
return root_folder


def find_closest(filename):
return os.path.join(find_project_root(filename), filename)
def find_closest(filename: str) -> str:
"""
Find the closest file with the given name in the project root folder.
Args:
filename (str): The name of the file to look for in the root folder.
Returns:
str: The path of the file.
"""
return os.path.join(find_project_root(filename), filename)
80 changes: 79 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pytest = "^7.4.2"
pytest-mock = "^3.12.0"
flake8 = "^6.1.0"
pylint = "^3.0.1"
black = "^23.10.0"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit f8382b3

Please sign in to comment.