diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index d816f96..11c7f3a 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -25,6 +25,7 @@ pipeline { stage('Create venv'){ steps { sh 'python3 -m venv .venv' + sh 'exit 1' } } @@ -80,7 +81,6 @@ pipeline { withChecks('Static Type Checks'){ junit 'mypy-report.xml' } - } } } @@ -102,18 +102,32 @@ pipeline { withChecks('Integration Tests'){ junit 'pytest-report.xml' } - - cleanWs( - cleanWhenNotBuilt: false, - deleteDirs: true, - disableDeferredWipeout: true, - notFailBuild: true, - patterns: [[pattern: '.gitignore', type: 'INCLUDE'], - [pattern: '.propsfile', type: 'EXCLUDE']] - ) } } } - + } + post { + failure{ + sh 'python3 ci/modify_test_status.py --fail' + sh 'git add README.md' + sh 'git commit -m "test status updated"' + sh 'git push' + } + success{ + sh 'python3 ci/modify_test_status.py' + sh 'git add README.md' + sh 'git commit -m "test status updated"' + sh 'git push' + } + cleanup{ + cleanWs( + cleanWhenNotBuilt: false, + deleteDirs: true, + disableDeferredWipeout: true, + notFailBuild: true, + patterns: [[pattern: '.gitignore', type: 'INCLUDE'], + [pattern: '.propsfile', type: 'EXCLUDE']] + ) + } } } diff --git a/ci/modify_test_status.py b/ci/modify_test_status.py new file mode 100644 index 0000000..aafed35 --- /dev/null +++ b/ci/modify_test_status.py @@ -0,0 +1,22 @@ +import argparse + +if __name__ == '__main__': + + parser = argparse.ArgumentParser() + parser.add_argument('-f', '--fail', action='store_true') + args = parser.parse_args() + readme_path = 'README.md' # Path to your README file + + with open(readme_path, 'r') as file: + lines = file.readlines() + + for i, line in enumerate(lines): + if 'img.shields.io' in line and ('passing' in line or 'failing' in line): + if args.f: + lines[i] = line.replace('passing', 'failing').replace('darggreen', 'red') + else: + lines[i] = line.replace('failing', 'passing').replace('red', 'darggreen') + print('README file has been updated.') + + with open(readme_path, 'w') as file: + file.writelines(lines) diff --git a/cookbook/Basic-RAG/BasicRAG_ingest.py b/cookbook/Basic-RAG/BasicRAG_ingest.py index 00e8f0b..7f42b5e 100644 --- a/cookbook/Basic-RAG/BasicRAG_ingest.py +++ b/cookbook/Basic-RAG/BasicRAG_ingest.py @@ -1,5 +1,6 @@ """A cookbook demonstrating how to ingest pdf files for use with Basic RAG.""" +import asyncio from pathlib import Path from grag.components.multivec_retriever import Retriever @@ -7,9 +8,16 @@ # from grag.components.vectordb.chroma_client import ChromaClient +SYNC = True # Run synchronously (slow) +ASYNC = True # Run asynchronously + client = DeepLakeClient(collection_name="ci_test") # client = ChromaClient(collection_name="ci_test") retriever = Retriever(vectordb=client) dir_path = Path(__file__).parents[2] / "data/test/pdfs/new_papers" -retriever.ingest(dir_path) + +if SYNC: + retriever.ingest(dir_path) +elif ASYNC: + asyncio.run(retriever.aingest(dir_path)) diff --git a/src/grag/components/llm.py b/src/grag/components/llm.py index bf0665d..3f7a3f0 100644 --- a/src/grag/components/llm.py +++ b/src/grag/components/llm.py @@ -2,6 +2,7 @@ import os from pathlib import Path +from typing import Optional, Union import torch from langchain.callbacks.manager import CallbackManager @@ -38,18 +39,18 @@ class LLM: def __init__( self, - model_name=llm_conf["model_name"], - device_map=llm_conf["device_map"], - task=llm_conf["task"], - max_new_tokens=llm_conf["max_new_tokens"], - temperature=llm_conf["temperature"], - n_batch=llm_conf["n_batch_gpu_cpp"], - n_ctx=llm_conf["n_ctx_cpp"], - n_gpu_layers=llm_conf["n_gpu_layers_cpp"], - std_out=llm_conf["std_out"], - base_dir=llm_conf["base_dir"], - quantization=llm_conf["quantization"], - pipeline=llm_conf["pipeline"], + model_name: str = llm_conf["model_name"], + device_map: str = llm_conf["device_map"], + task: str = llm_conf["task"], + max_new_tokens: str = llm_conf["max_new_tokens"], + temperature: str = llm_conf["temperature"], + n_batch: str = llm_conf["n_batch_gpu_cpp"], + n_ctx: str = llm_conf["n_ctx_cpp"], + n_gpu_layers: str = llm_conf["n_gpu_layers_cpp"], + std_out: Union[bool, str] = llm_conf["std_out"], + base_dir: str = llm_conf["base_dir"], + quantization: str = llm_conf["quantization"], + pipeline: str = llm_conf["pipeline"], ): """Initialize the LLM class using the given parameters.""" self.base_dir = Path(base_dir) @@ -66,7 +67,7 @@ def __init__( if std_out: self.callback_manager = CallbackManager([StreamingStdOutCallbackHandler()]) else: - self.callback_manager = None + self.callback_manager = None # type: ignore @property def model_name(self): @@ -85,7 +86,7 @@ def model_path(self): self.base_dir / self.model_name / f"ggml-model-{self.quantization}.gguf" ) - def hf_pipeline(self, is_local=False): + def hf_pipeline(self, is_local: Optional[bool] = False): """Loads the model using Hugging Face transformers. Args: @@ -161,7 +162,8 @@ def llama_cpp(self): return llm def load_model( - self, model_name=None, pipeline=None, quantization=None, is_local=None + self, model_name: Optional[str] = None, pipeline: Optional[str] = None, quantization: Optional[str] = None, + is_local: Optional[bool] = None ): """Loads the model based on the specified pipeline and model name.