Skip to content

Commit

Permalink
Remove Global Logging Config from All Production Files (#13321)
Browse files Browse the repository at this point in the history
  • Loading branch information
solaoi committed May 7, 2024
1 parent c26ee76 commit f94dfdf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from llama_index.core.readers.base import BaseReader
from llama_index.core.schema import Document

logging.basicConfig(level=logging.ERROR)
logger = logging.getLogger(__name__)
logger.setLevel(logging.ERROR)


class OpenAlexReader(BaseReader):
Expand Down Expand Up @@ -46,11 +47,11 @@ def _search_openalex(self, query, fields):
raise ValueError(f"API returned error: {data['error']}")
return data
except requests.exceptions.HTTPError as http_error:
logging.error(f"HTTP error occurred: {http_error}")
logger.error(f"HTTP error occurred: {http_error}")
except requests.exceptions.RequestException as request_error:
logging.error(f"Error occurred: {request_error}")
logger.error(f"Error occurred: {request_error}")
except ValueError as value_error:
logging.error(value_error)
logger.error(value_error)
return None

def _fulltext_search_openalex(self, query, fields):
Expand All @@ -66,11 +67,11 @@ def _fulltext_search_openalex(self, query, fields):
raise ValueError(f"API returned error: {data['error']}")
return data
except requests.exceptions.HTTPError as http_error:
logging.error(f"HTTP error occurred: {http_error}")
logger.error(f"HTTP error occurred: {http_error}")
except requests.exceptions.RequestException as request_error:
logging.error(f"Error occurred: {request_error}")
logger.error(f"Error occurred: {request_error}")
except ValueError as value_error:
logging.error(value_error)
logger.error(value_error)
return None

def _invert_abstract(self, inv_index):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ license = "MIT"
maintainers = ["shauryr"]
name = "llama-index-readers-openalex"
readme = "README.md"
version = "0.1.3"
version = "0.1.4"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from datasets import Dataset

# Configure logging to output to the console, with messages of level DEBUG and above
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

from llama_index.core.llama_pack.base import BaseLlamaPack
from llama_index.core import SimpleDirectoryReader
Expand Down Expand Up @@ -199,14 +200,14 @@ def run(self) -> Any:
"""Run the pipeline."""
chunks = self.get_chunks(self.file_path, self.chunk_size)

logging.info(f"Number of chunks created: {len(chunks)}")
logger.info(f"Number of chunks created: {len(chunks)}")

self.num_distract_docs = (
min(self.num_distract_docs, len(chunks)) - 1
) # should be less than number of chunks/ nodes created

for index, chunk in enumerate(chunks):
logging.info(f"Processing chunk: {index}")
logger.info(f"Processing chunk: {index}")
self.add_chunk_to_dataset(
chunks, chunk, self.num_questions_per_chunk, self.num_distract_docs
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ license = "MIT"
maintainers = ["ravi-theja"]
name = "llama-index-packs-raft-dataset"
readme = "README.md"
version = "0.1.4"
version = "0.1.5"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
Expand Down

0 comments on commit f94dfdf

Please sign in to comment.