Merge pull request #11 from aimingmed/feature/github-workflow

fix ruff issues
This commit is contained in:
Hong Kai LEE 2025-03-06 11:42:09 +08:00 committed by GitHub
commit eebdef847c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 2 additions and 43 deletions

View File

@ -16,7 +16,7 @@ def go(args):
zip_path = os.path.join(args.path_document_folder, f"{args.document_folder}.zip") zip_path = os.path.join(args.path_document_folder, f"{args.document_folder}.zip")
shutil.make_archive(zip_path.replace('.zip', ''), 'zip', args.path_document_folder, args.document_folder) shutil.make_archive(zip_path.replace('.zip', ''), 'zip', args.path_document_folder, args.document_folder)
with mlflow.start_run(experiment_id=mlflow.get_experiment_by_name("development").experiment_id) as run: with mlflow.start_run(experiment_id=mlflow.get_experiment_by_name("development").experiment_id):
existing_params = mlflow.get_run(mlflow.active_run().info.run_id).data.params existing_params = mlflow.get_run(mlflow.active_run().info.run_id).data.params
if 'artifact_description' not in existing_params: if 'artifact_description' not in existing_params:

View File

@ -1,6 +1,4 @@
import wandb import wandb
import mlflow
def log_artifact(artifact_name, artifact_type, artifact_description, filename, wandb_run): def log_artifact(artifact_name, artifact_type, artifact_description, filename, wandb_run):
""" """

View File

@ -1,11 +1,8 @@
import json
import mlflow import mlflow
import tempfile import tempfile
import os import os
import hydra import hydra
from omegaconf import DictConfig from omegaconf import DictConfig
from decouple import config
_steps = [ _steps = [
"get_documents", "get_documents",
@ -27,7 +24,7 @@ def go(config: DictConfig):
active_steps = steps_par.split(",") if steps_par != "all" else _steps active_steps = steps_par.split(",") if steps_par != "all" else _steps
# Move to a temporary directory # Move to a temporary directory
with tempfile.TemporaryDirectory() as tmp_dir: with tempfile.TemporaryDirectory():
if "get_documents" in active_steps: if "get_documents" in active_steps:
# Download file and load in W&B # Download file and load in W&B

View File

@ -10,8 +10,6 @@ import shutil
import chromadb import chromadb
# from openai import OpenAI # from openai import OpenAI
from typing import List
import numpy as np
import pytesseract as pt import pytesseract as pt
from pdf2image import convert_from_path from pdf2image import convert_from_path
from langchain.schema import Document from langchain.schema import Document

View File

@ -1,31 +0,0 @@
import pytest
from unittest.mock import patch, MagicMock
import sys
sys.path.append("/Users/leehongkai/projects/aimingmed/aimingmed-ai/app/llmops")
from src.chain_of_thought import run
def test_go():
# Create mock arguments
args = MagicMock()
args.query = "test_query"
args.input_chromadb_artifact = "test_artifact"
args.embedding_model = "test_embedding_model"
args.chat_model_provider = "gemini"
# Mock wandb.init and other external dependencies
with patch("wandb.init") as mock_wandb_init, \
patch("chromadb.PersistentClient") as mock_chromadb_client, \
patch("sentence_transformers.SentenceTransformer") as mock_sentence_transformer, \
patch("langchain_google_genai.ChatGoogleGenerativeAI") as mock_chat_google_generative_ai:
# Configure the mocks
mock_wandb_init.return_value = MagicMock()
mock_chromadb_client.return_value = MagicMock()
mock_sentence_transformer.return_value = MagicMock()
mock_chat_google_generative_ai.return_value = MagicMock()
# Call the go function
run.go(args)
# Add assertions to validate the behavior of the go function
assert mock_wandb_init.called

View File

@ -1,7 +1,5 @@
import os
import pytest import pytest
import chromadb import chromadb
from langchain.prompts import PromptTemplate
from langchain_google_genai import ChatGoogleGenerativeAI from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_deepseek import ChatDeepSeek from langchain_deepseek import ChatDeepSeek
from langchain_community.llms.moonshot import Moonshot from langchain_community.llms.moonshot import Moonshot
@ -9,7 +7,6 @@ from langchain_community.llms.moonshot import Moonshot
import sys import sys
sys.path.append(".") sys.path.append(".")
import streamlit as st import streamlit as st
import pytest
from unittest.mock import patch from unittest.mock import patch
from Chatbot import CHAT_MODEL_PROVIDER, INPUT_CHROMADB_LOCAL, COLLECTION_NAME, cot_template, answer_template from Chatbot import CHAT_MODEL_PROVIDER, INPUT_CHROMADB_LOCAL, COLLECTION_NAME, cot_template, answer_template