Skip to content

Python scraper based on AI

refactoring of the code according to pylint style

Marco Vinciguerra8b8d8f09b717
diff --git a/scrapegraphai/helpers/models_tokens.py b/scrapegraphai/helpers/models_tokens.py
index 5703db60..29d4b257 100644
--- a/scrapegraphai/helpers/models_tokens.py
+++ b/scrapegraphai/helpers/models_tokens.py
@@ -1,3 +1,7 @@
+"""
+List of model tokens
+"""
+
models_tokens = {
"openai": {
"gpt-3.5-turbo-0125": 16385,
diff --git a/scrapegraphai/nodes/base_node.py b/scrapegraphai/nodes/base_node.py
index 26fc44c4..aa7d2853 100644
--- a/scrapegraphai/nodes/base_node.py
+++ b/scrapegraphai/nodes/base_node.py
@@ -5,13 +5,13 @@ BaseNode Module
import re
from abc import ABC, abstractmethod
from typing import List, Optional
-
from ..utils import get_logger
class BaseNode(ABC):
"""
- An abstract base class for nodes in a graph-based workflow, designed to perform specific actions when executed.
+ An abstract base class for nodes in a graph-based workflow,
+ designed to perform specific actions when executed.
Attributes:
node_name (str): The unique identifier name for the node.
diff --git a/scrapegraphai/nodes/fetch_node.py b/scrapegraphai/nodes/fetch_node.py
index 16ad92dd..b60c3652 100644
--- a/scrapegraphai/nodes/fetch_node.py
+++ b/scrapegraphai/nodes/fetch_node.py
@@ -1,7 +1,6 @@
""""
FetchNode Module
"""
-
import json
from typing import List, Optional
from langchain_openai import ChatOpenAI, AzureChatOpenAI
@@ -16,10 +15,6 @@ from ..utils.convert_to_md import convert_to_md
from ..utils.logging import get_logger
from .base_node import BaseNode
-
-""""
-FetchNode Module
-"""
class FetchNode(BaseNode):
"""
A node responsible for fetching the HTML content of a specified URL and updating
@@ -218,7 +213,7 @@ class FetchNode(BaseNode):
self.logger.info(f"--- (Fetching HTML from: {source}) ---")
if not source.strip():
raise ValueError("No HTML body content found in the local source.")
-
+
parsed_content = source
if (isinstance(self.llm_model, ChatOpenAI) or isinstance(self.llm_model, AzureChatOpenAI)) and not self.script_creator or self.force and not self.script_creator:
diff --git a/scrapegraphai/nodes/generate_answer_csv_node.py b/scrapegraphai/nodes/generate_answer_csv_node.py
index 4f3efefd..b7d7471a 100644
--- a/scrapegraphai/nodes/generate_answer_csv_node.py
+++ b/scrapegraphai/nodes/generate_answer_csv_node.py
@@ -1,5 +1,4 @@
"""
-gg
Module for generating the answer node
"""
@@ -10,8 +9,7 @@ from langchain_core.runnables import RunnableParallel
from tqdm import tqdm
from ..utils.logging import get_logger
from .base_node import BaseNode
-from ..prompts.generate_answer_node_csv_prompts import template_chunks_csv, template_no_chunks_csv, template_merge_csv
-
+from ..prompts.generate_answer_node_csv_prompts import TEMPLATE_CHUKS_CSV, TEMPLATE_NO_CHUKS_CSV, TEMPLATE_MERGE_CSV
class GenerateAnswerCSVNode(BaseNode):
"""
@@ -97,14 +95,14 @@ class GenerateAnswerCSVNode(BaseNode):
else:
output_parser = JsonOutputParser()
- template_no_chunks_csv_prompt = template_no_chunks_csv
- template_chunks_csv_prompt = template_chunks_csv
- template_merge_csv_prompt = template_merge_csv
+ TEMPLATE_NO_CHUKS_CSV_prompt = TEMPLATE_NO_CHUKS_CSV
+ TEMPLATE_CHUKS_CSV_prompt = TEMPLATE_CHUKS_CSV
+ TEMPLATE_MERGE_CSV_prompt = TEMPLATE_MERGE_CSV
if self.additional_info is not None:
- template_no_chunks_csv_prompt = self.additional_info + template_no_chunks_csv
- template_chunks_csv_prompt = self.additional_info + template_chunks_csv
- template_merge_csv_prompt = self.additional_info + template_merge_csv
+ TEMPLATE_NO_CHUKS_CSV_prompt = self.additional_info + TEMPLATE_NO_CHUKS_CSV
+ TEMPLATE_CHUKS_CSV_prompt = self.additional_info + TEMPLATE_CHUKS_CSV
+ TEMPLATE_MERGE_CSV_prompt = self.additional_info + TEMPLATE_MERGE_CSV
format_instructions = output_parser.get_format_instructions()
@@ -112,7 +110,7 @@ class GenerateAnswerCSVNode(BaseNode):
if len(doc) == 1:
prompt = PromptTemplate(
- template=template_no_chunks_csv_prompt,
+ template=TEMPLATE_NO_CHUKS_CSV_prompt,
input_variables=["question"],
partial_variables={
"context": doc,
@@ -129,7 +127,7 @@ class GenerateAnswerCSVNode(BaseNode):
tqdm(doc, desc="Processing chunks", disable=not self.verbose)
):
prompt = PromptTemplate(
- template=template_chunks_csv_prompt,
+ template=TEMPLATE_CHUKS_CSV_prompt,
input_variables=["question"],
partial_variables={
"context": chunk,
@@ -146,7 +144,7 @@ class GenerateAnswerCSVNode(BaseNode):
batch_results = async_runner.invoke({"question": user_prompt})
merge_prompt = PromptTemplate(
- template = template_merge_csv_prompt,
+ template = TEMPLATE_MERGE_CSV_prompt,
input_variables=["context", "question"],
partial_variables={"format_instructions": format_instructions},
)
diff --git a/scrapegraphai/nodes/generate_answer_node.py b/scrapegraphai/nodes/generate_answer_node.py
index d01b50d2..b0935383 100644
--- a/scrapegraphai/nodes/generate_answer_node.py
+++ b/scrapegraphai/nodes/generate_answer_node.py
@@ -10,7 +10,7 @@ from langchain_community.chat_models import ChatOllama
from tqdm import tqdm
from ..utils.logging import get_logger
from .base_node import BaseNode
-from ..prompts import template_chunks, template_no_chunks, template_merge, template_chunks_md, template_no_chunks_md, template_merge_md
+from ..prompts import TEMPLATE_CHUNKS, TEMPLATE_NO_CHUNKS, TEMPLATE_MERGE, TEMPLATE_CHUNKS_MD, TEMPLATE_NO_CHUNKS_MD, TEMPLATE_MERGE_MD
class GenerateAnswerNode(BaseNode):
"""
@@ -94,22 +94,22 @@ class GenerateAnswerNode(BaseNode):
format_instructions = output_parser.get_format_instructions()
if isinstance(self.llm_model, ChatOpenAI) and not self.script_creator or self.force and not self.script_creator or self.is_md_scraper:
- template_no_chunks_prompt = template_no_chunks_md
- template_chunks_prompt = template_chunks_md
- template_merge_prompt = template_merge_md
+ TEMPLATE_NO_CHUNKS_prompt = TEMPLATE_NO_CHUNKS_MD
+ TEMPLATE_CHUNKS_prompt = TEMPLATE_CHUNKS_MD
+ TEMPLATE_MERGE_prompt = TEMPLATE_MERGE_MD
else:
- template_no_chunks_prompt = template_no_chunks
- template_chunks_prompt = template_chunks
- template_merge_prompt = template_merge
+ TEMPLATE_NO_CHUNKS_prompt = TEMPLATE_NO_CHUNKS
+ TEMPLATE_CHUNKS_prompt = TEMPLATE_CHUNKS
+ TEMPLATE_MERGE_prompt = TEMPLATE_MERGE
if self.additional_info is not None:
- template_no_chunks_prompt = self.additional_info + template_no_chunks_prompt
- template_chunks_prompt = self.additional_info + template_chunks_prompt
- template_merge_prompt = self.additional_info + template_merge_prompt
+ TEMPLATE_NO_CHUNKS_prompt = self.additional_info + TEMPLATE_NO_CHUNKS_prompt
+ TEMPLATE_CHUNKS_prompt = self.additional_info + TEMPLATE_CHUNKS_prompt
+ TEMPLATE_MERGE_prompt = self.additional_info + TEMPLATE_MERGE_prompt
if len(doc) == 1:
prompt = PromptTemplate(
- template=template_no_chunks_prompt,
+ template=TEMPLATE_NO_CHUNKS_prompt,
input_variables=["question"],
partial_variables={"context": doc,
"format_instructions": format_instructions})
@@ -123,7 +123,7 @@ class GenerateAnswerNode(BaseNode):
for i, chunk in enumerate(tqdm(doc, desc="Processing chunks", disable=not self.verbose)):
prompt = PromptTemplate(
- template=template_chunks,
+ template=TEMPLATE_CHUNKS,
input_variables=["question"],
partial_variables={"context": chunk,
"chunk_id": i + 1,
@@ -136,7 +136,7 @@ class GenerateAnswerNode(BaseNode):
batch_results = async_runner.invoke({"question": user_prompt})
merge_prompt = PromptTemplate(
- template = template_merge_prompt,
+ template = TEMPLATE_MERGE_prompt,
input_variables=["context", "question"],
partial_variables={"format_instructions": format_instructions},
)
diff --git a/scrapegraphai/nodes/generate_answer_omni_node.py b/scrapegraphai/nodes/generate_answer_omni_node.py
index 1919f32d..34ee3e87 100644
--- a/scrapegraphai/nodes/generate_answer_omni_node.py
+++ b/scrapegraphai/nodes/generate_answer_omni_node.py
@@ -8,8 +8,7 @@ from langchain_core.runnables import RunnableParallel
from tqdm import tqdm
from langchain_community.chat_models import ChatOllama
from .base_node import BaseNode
-from ..prompts.generate_answer_node_omni_prompts import template_no_chunk_omni, template_chunks_omni, template_merge_omni
-
+from ..prompts.generate_answer_node_omni_prompts import TEMPLATE_NO_CHUNKS_OMNI, TEMPLATE_CHUNKS_OMNI, TEMPLATE_MERGE_OMNI
class GenerateAnswerOmniNode(BaseNode):
"""
@@ -82,14 +81,14 @@ class GenerateAnswerOmniNode(BaseNode):
output_parser = JsonOutputParser(pydantic_object=self.node_config["schema"])
else:
output_parser = JsonOutputParser()
- template_no_chunk_omni_prompt = template_no_chunk_omni
- template_chunks_omni_prompt = template_chunks_omni
- template_merge_omni_prompt= template_merge_omni
+ TEMPLATE_NO_CHUNKS_OMNI_prompt = TEMPLATE_NO_CHUNKS_OMNI
+ TEMPLATE_CHUNKS_OMNI_prompt = TEMPLATE_CHUNKS_OMNI
+ TEMPLATE_MERGE_OMNI_prompt= TEMPLATE_MERGE_OMNI
if self.additional_info is not None:
- template_no_chunk_omni_prompt = self.additional_info + template_no_chunk_omni_prompt
- template_chunks_omni_prompt = self.additional_info + template_chunks_omni_prompt
- template_merge_omni_prompt = self.additional_info + template_merge_omni_prompt
+ TEMPLATE_NO_CHUNKS_OMNI_prompt = self.additional_info + TEMPLATE_NO_CHUNKS_OMNI_prompt
+ TEMPLATE_CHUNKS_OMNI_prompt = self.additional_info + TEMPLATE_CHUNKS_OMNI_prompt
+ TEMPLATE_MERGE_OMNI_prompt = self.additional_info + TEMPLATE_MERGE_OMNI_prompt
format_instructions = output_parser.get_format_instructions()
@@ -97,7 +96,7 @@ class GenerateAnswerOmniNode(BaseNode):
chains_dict = {}
if len(doc) == 1:
prompt = PromptTemplate(
- template=template_no_chunk_omni_prompt,
+ template=TEMPLATE_NO_CHUNKS_OMNI_prompt,
input_variables=["question"],
partial_variables={
"context": doc,
@@ -116,7 +115,7 @@ class GenerateAnswerOmniNode(BaseNode):
tqdm(doc, desc="Processing chunks", disable=not self.verbose)
):
prompt = PromptTemplate(
- template=template_chunks_omni_prompt,
+ template=TEMPLATE_CHUNKS_OMNI_prompt,
input_variables=["question"],
partial_variables={
"context": chunk,
@@ -134,7 +133,7 @@ class GenerateAnswerOmniNode(BaseNode):
batch_results = async_runner.invoke({"question": user_prompt})
merge_prompt = PromptTemplate(
- template = template_merge_omni_prompt,
+ template = TEMPLATE_MERGE_OMNI_prompt,
input_variables=["context", "question"],
partial_variables={"format_instructions": format_instructions},
)
diff --git a/scrapegraphai/nodes/generate_answer_pdf_node.py b/scrapegraphai/nodes/generate_answer_pdf_node.py
index b906a86b..f3e68eab 100644
--- a/scrapegraphai/nodes/generate_answer_pdf_node.py
+++ b/scrapegraphai/nodes/generate_answer_pdf_node.py
@@ -1,7 +1,6 @@
"""
Module for generating the answer node
"""
-
from typing import List, Optional
from langchain.prompts import PromptTemplate
from langchain_core.output_parsers import JsonOutputParser
@@ -10,8 +9,7 @@ from tqdm import tqdm
from langchain_community.chat_models import ChatOllama
from ..utils.logging import get_logger
from .base_node import BaseNode
-from ..prompts.generate_answer_node_pdf_prompts import template_chunks_pdf, template_no_chunks_pdf, template_merge_pdf
-
+from ..prompts.generate_answer_node_pdf_prompts import TEMPLATE_CHUNKS_PDF, TEMPLATE_NO_CHUNKS_PDF, TEMPLATE_MERGE_PDF
class GenerateAnswerPDFNode(BaseNode):
"""
@@ -98,20 +96,20 @@ class GenerateAnswerPDFNode(BaseNode):
output_parser = JsonOutputParser(pydantic_object=self.node_config["schema"])
else:
output_parser = JsonOutputParser()
- template_no_chunks_pdf_prompt = template_no_chunks_pdf
- template_chunks_pdf_prompt = template_chunks_pdf
- template_merge_pdf_prompt = template_merge_pdf
+ TEMPLATE_NO_CHUNKS_PDF_prompt = TEMPLATE_NO_CHUNKS_PDF
+ TEMPLATE_CHUNKS_PDF_prompt = TEMPLATE_CHUNKS_PDF
+ TEMPLATE_MERGE_PDF_prompt = TEMPLATE_MERGE_PDF
if self.additional_info is not None:
- template_no_chunks_pdf_prompt = self.additional_info + template_no_chunks_pdf_prompt
- template_chunks_pdf_prompt = self.additional_info + template_chunks_pdf_prompt
- template_merge_pdf_prompt = self.additional_info + template_merge_pdf_prompt
+ TEMPLATE_NO_CHUNKS_PDF_prompt = self.additional_info + TEMPLATE_NO_CHUNKS_PDF_prompt
+ TEMPLATE_CHUNKS_PDF_prompt = self.additional_info + TEMPLATE_CHUNKS_PDF_prompt
+ TEMPLATE_MERGE_PDF_prompt = self.additional_info + TEMPLATE_MERGE_PDF_prompt
format_instructions = output_parser.get_format_instructions()
if len(doc) == 1:
prompt = PromptTemplate(
- template=template_no_chunks_pdf_prompt,
+ template=TEMPLATE_NO_CHUNKS_PDF_prompt,
input_variables=["question"],
partial_variables={
"context": doc,
@@ -130,7 +128,7 @@ class GenerateAnswerPDFNode(BaseNode):
for i, chunk in enumerate(
tqdm(doc, desc="Processing chunks", disable=not self.verbose)):
prompt = PromptTemplate(
- template=template_chunks_pdf_prompt,
+ template=TEMPLATE_CHUNKS_PDF_prompt,
input_variables=["question"],
partial_variables={
"context":chunk,
@@ -147,7 +145,7 @@ class GenerateAnswerPDFNode(BaseNode):
batch_results = async_runner.invoke({"question": user_prompt})
merge_prompt = PromptTemplate(
- template = template_merge_pdf_prompt,
+ template = TEMPLATE_MERGE_PDF_prompt,
input_variables=["context", "question"],
partial_variables={"format_instructions": format_instructions},
)
diff --git a/scrapegraphai/nodes/generate_scraper_node.py b/scrapegraphai/nodes/generate_scraper_node.py
index fbd47a34..4f077091 100644
--- a/scrapegraphai/nodes/generate_scraper_node.py
+++ b/scrapegraphai/nodes/generate_scraper_node.py
@@ -1,8 +1,6 @@
"""
GenerateScraperNode Module
"""
-
-# Imports from standard library
from typing import List, Optional
from langchain.prompts import PromptTemplate
from langchain_core.output_parsers import StrOutputParser, JsonOutputParser
@@ -85,7 +83,7 @@ class GenerateScraperNode(BaseNode):
format_instructions = output_schema.get_format_instructions()
- template_no_chunks = """
+ TEMPLATE_NO_CHUNKS = """
PROMPT:
You are a website scraper script creator and you have just scraped the
following content from a website.
@@ -103,14 +101,14 @@ class GenerateScraperNode(BaseNode):
SCHEMA INSTRUCTIONS: {schema_instructions}
"""
if self.additional_info is not None:
- template_no_chunks += self.additional_info
+ TEMPLATE_NO_CHUNKS += self.additional_info
if len(doc) > 1:
raise NotImplementedError(
"Currently GenerateScraperNode cannot handle more than 1 context chunks"
)
else:
- template = template_no_chunks
+ template = TEMPLATE_NO_CHUNKS
prompt = PromptTemplate(
template=template,
diff --git a/scrapegraphai/nodes/get_probable_tags_node.py b/scrapegraphai/nodes/get_probable_tags_node.py
index 38c2ba15..4d12b985 100644
--- a/scrapegraphai/nodes/get_probable_tags_node.py
+++ b/scrapegraphai/nodes/get_probable_tags_node.py
@@ -7,7 +7,6 @@ from langchain.prompts import PromptTemplate
from ..utils.logging import get_logger
from .base_node import BaseNode
-
class GetProbableTagsNode(BaseNode):
"""
A node that utilizes a language model to identify probable HTML tags within a document that
diff --git a/scrapegraphai/nodes/graph_iterator_node.py b/scrapegraphai/nodes/graph_iterator_node.py
index db7d8f02..cd71b8e1 100644
--- a/scrapegraphai/nodes/graph_iterator_node.py
+++ b/scrapegraphai/nodes/graph_iterator_node.py
@@ -1,7 +1,6 @@
"""
GraphIterator Module
"""
-
import asyncio
import copy
from typing import List, Optional
diff --git a/scrapegraphai/nodes/image_to_text_node.py b/scrapegraphai/nodes/image_to_text_node.py
index c1a69390..934710ef 100644
--- a/scrapegraphai/nodes/image_to_text_node.py
+++ b/scrapegraphai/nodes/image_to_text_node.py
@@ -1,12 +1,10 @@
"""
ImageToTextNode Module
"""
-
from typing import List, Optional
from ..utils.logging import get_logger
from .base_node import BaseNode
-
class ImageToTextNode(BaseNode):
"""
Retrieve images from a list of URLs and return a description of
diff --git a/scrapegraphai/nodes/merge_answers_node.py b/scrapegraphai/nodes/merge_answers_node.py
index 4d356623..f00880e9 100644
--- a/scrapegraphai/nodes/merge_answers_node.py
+++ b/scrapegraphai/nodes/merge_answers_node.py
@@ -1,13 +1,12 @@
"""
MergeAnswersNode Module
"""
-
from typing import List, Optional
from langchain.prompts import PromptTemplate
from langchain_core.output_parsers import JsonOutputParser
from ..utils.logging import get_logger
from .base_node import BaseNode
-from ..prompts import template_combined
+from ..prompts import TEMPLATE_COMBINED
class MergeAnswersNode(BaseNode):
"""
@@ -80,7 +79,7 @@ class MergeAnswersNode(BaseNode):
format_instructions = output_parser.get_format_instructions()
prompt_template = PromptTemplate(
- template=template_combined,
+ template=TEMPLATE_COMBINED,
input_variables=["user_prompt"],
partial_variables={
"format_instructions": format_instructions,
diff --git a/scrapegraphai/nodes/merge_generated_scripts.py b/scrapegraphai/nodes/merge_generated_scripts.py
index bf8f7f4a..ffc2b2fd 100644
--- a/scrapegraphai/nodes/merge_generated_scripts.py
+++ b/scrapegraphai/nodes/merge_generated_scripts.py
@@ -1,8 +1,6 @@
"""
MergeAnswersNode Module
"""
-
-# Imports from standard library
from typing import List, Optional
from tqdm import tqdm
from langchain.prompts import PromptTemplate
@@ -80,7 +78,7 @@ class MergeGeneratedScriptsNode(BaseNode):
# format_instructions = output_schema.get_format_instructions()
- template_merge = """
+ TEMPLATE_MERGE = """
You are a python expert in web scraping and you have just generated multiple scripts to scrape different URLs.\n
The scripts are generated based on a user question and the content of the websites.\n
You need to create one single script that merges the scripts generated for each URL.\n
@@ -93,7 +91,7 @@ class MergeGeneratedScriptsNode(BaseNode):
"""
prompt_template = PromptTemplate(
- template=template_merge,
+ template=TEMPLATE_MERGE,
input_variables=["user_prompt"],
partial_variables={
"scripts": scripts_str,
diff --git a/scrapegraphai/nodes/parse_node.py b/scrapegraphai/nodes/parse_node.py
index db7f8518..f7a60bc2 100644
--- a/scrapegraphai/nodes/parse_node.py
+++ b/scrapegraphai/nodes/parse_node.py
@@ -1,7 +1,6 @@
"""
ParseNode Module
"""
-
from typing import List, Optional
from semchunk import chunk
from langchain_community.document_transformers import Html2TextTransformer
diff --git a/scrapegraphai/nodes/rag_node.py b/scrapegraphai/nodes/rag_node.py
index fcacac99..ea5efe7a 100644
--- a/scrapegraphai/nodes/rag_node.py
+++ b/scrapegraphai/nodes/rag_node.py
@@ -1,10 +1,8 @@
"""
RAGNode Module
"""
-
-from typing import List, Optional
import os
-
+from typing import List, Optional
from langchain.docstore.document import Document
from langchain.retrievers import ContextualCompressionRetriever
from langchain.retrievers.document_compressors import (
diff --git a/scrapegraphai/nodes/robots_node.py b/scrapegraphai/nodes/robots_node.py
index 072f0fef..b33d49c1 100644
--- a/scrapegraphai/nodes/robots_node.py
+++ b/scrapegraphai/nodes/robots_node.py
@@ -1,7 +1,6 @@
"""
RobotsNode Module
"""
-
from typing import List, Optional
from urllib.parse import urlparse
from langchain_community.document_loaders import AsyncChromiumLoader
@@ -10,7 +9,7 @@ from langchain.output_parsers import CommaSeparatedListOutputParser
from ..helpers import robots_dictionary
from ..utils.logging import get_logger
from .base_node import BaseNode
-from ..prompts import template_robot
+from ..prompts import TEMPLATE_ROBOT
class RobotsNode(BaseNode):
"""
@@ -105,7 +104,7 @@ class RobotsNode(BaseNode):
agent = model
prompt = PromptTemplate(
- template=template_robot,
+ template=TEMPLATE_ROBOT,
input_variables=["path"],
partial_variables={"context": document, "agent": agent},
)
diff --git a/scrapegraphai/nodes/search_internet_node.py b/scrapegraphai/nodes/search_internet_node.py
index 17ec08aa..b23e8e8b 100644
--- a/scrapegraphai/nodes/search_internet_node.py
+++ b/scrapegraphai/nodes/search_internet_node.py
@@ -8,7 +8,7 @@ from langchain_community.chat_models import ChatOllama
from ..utils.logging import get_logger
from ..utils.research_web import search_on_web
from .base_node import BaseNode
-from ..prompts import template_search_internet
+from ..prompts import TEMPLATE_SEARCH_INTERNET
class SearchInternetNode(BaseNode):
"""
@@ -75,7 +75,7 @@ class SearchInternetNode(BaseNode):
output_parser = CommaSeparatedListOutputParser()
search_prompt = PromptTemplate(
- template=template_search_internet,
+ template=TEMPLATE_SEARCH_INTERNET,
input_variables=["user_prompt"],
)
diff --git a/scrapegraphai/nodes/search_link_node.py b/scrapegraphai/nodes/search_link_node.py
index ffcd259a..8b601e5a 100644
--- a/scrapegraphai/nodes/search_link_node.py
+++ b/scrapegraphai/nodes/search_link_node.py
@@ -1,7 +1,6 @@
"""
SearchLinkNode Module
"""
-
from typing import List, Optional
import re
from tqdm import tqdm
@@ -10,7 +9,7 @@ from langchain_core.output_parsers import JsonOutputParser
from langchain_core.runnables import RunnableParallel
from ..utils.logging import get_logger
from .base_node import BaseNode
-from ..prompts import template_relevant_links
+from ..prompts import TEMPLATE_RELEVANT_LINKS
class SearchLinkNode(BaseNode):
@@ -86,7 +85,7 @@ class SearchLinkNode(BaseNode):
self.logger.error(f"Error extracting links: {e}. Falling back to LLM.")
merge_prompt = PromptTemplate(
- template=template_relevant_links,
+ template=TEMPLATE_RELEVANT_LINKS,
input_variables=["content", "user_prompt"],
)
merge_chain = merge_prompt | self.llm_model | output_parser
diff --git a/scrapegraphai/nodes/search_node_with_context.py b/scrapegraphai/nodes/search_node_with_context.py
index 223a3466..37a05d0f 100644
--- a/scrapegraphai/nodes/search_node_with_context.py
+++ b/scrapegraphai/nodes/search_node_with_context.py
@@ -1,17 +1,13 @@
"""
SearchInternetNode Module
"""
-
from typing import List, Optional
-
from langchain.output_parsers import CommaSeparatedListOutputParser
from langchain.prompts import PromptTemplate
from tqdm import tqdm
-from ..prompts import template_search_with_context_chunks, template_search_with_context_no_chunks
-
+from ..prompts import TEMPLATE_SEARCH_WITH_CONTEXT_CHUNKS, TEMPLATE_SEARCH_WITH_CONTEXT_NO_CHUNKS
from .base_node import BaseNode
-
class SearchLinksWithContext(BaseNode):
"""
A node that generates a search query based on the user's input and searches the internet
@@ -81,7 +77,7 @@ class SearchLinksWithContext(BaseNode):
):
if len(doc) == 1:
prompt = PromptTemplate(
- template=template_search_with_context_chunks,
+ template=TEMPLATE_SEARCH_WITH_CONTEXT_CHUNKS,
input_variables=["question"],
partial_variables={
"context": chunk.page_content,
@@ -90,7 +86,7 @@ class SearchLinksWithContext(BaseNode):
)
else:
prompt = PromptTemplate(
- template=template_search_with_context_no_chunks,
+ template=TEMPLATE_SEARCH_WITH_CONTEXT_NO_CHUNKS,
input_variables=["question"],
partial_variables={
"context": chunk.page_content,
diff --git a/scrapegraphai/prompts/__init__.py b/scrapegraphai/prompts/__init__.py
index 6d3c3b08..f5b72f3e 100644
--- a/scrapegraphai/prompts/__init__.py
+++ b/scrapegraphai/prompts/__init__.py
@@ -2,12 +2,12 @@
__init__.py for the prompts folder
"""
-from .generate_answer_node_prompts import template_chunks, template_no_chunks, template_merge, template_chunks_md, template_no_chunks_md, template_merge_md
-from .generate_answer_node_csv_prompts import template_chunks_csv, template_no_chunks_csv, template_merge_csv
-from .generate_answer_node_pdf_prompts import template_chunks_pdf, template_no_chunks_pdf, template_merge_pdf
-from .generate_answer_node_omni_prompts import template_chunks_omni, template_no_chunk_omni, template_merge_omni
-from .merge_answer_node_prompts import template_combined
-from .robots_node_prompts import template_robot
-from .search_internet_node_prompts import template_search_internet
-from .search_link_node_prompts import template_relevant_links
-from .search_node_with_context_prompts import template_search_with_context_chunks, template_search_with_context_no_chunks
\ No newline at end of file
+from .generate_answer_node_prompts import TEMPLATE_CHUNKS, TEMPLATE_NO_CHUNKS, TEMPLATE_MERGE, TEMPLATE_CHUNKS_MD, TEMPLATE_NO_CHUNKS_MD, TEMPLATE_MERGE_MD
+from .generate_answer_node_csv_prompts import TEMPLATE_CHUKS_CSV, TEMPLATE_NO_CHUKS_CSV, TEMPLATE_MERGE_CSV
+from .generate_answer_node_pdf_prompts import TEMPLATE_CHUNKS_PDF, TEMPLATE_NO_CHUNKS_PDF, TEMPLATE_MERGE_PDF
+from .generate_answer_node_omni_prompts import TEMPLATE_CHUNKS_OMNI, TEMPLATE_NO_CHUNKS_OMNI, TEMPLATE_MERGE_OMNI
+from .merge_answer_node_prompts import TEMPLATE_COMBINED
+from .robots_node_prompts import TEMPLATE_ROBOT
+from .search_internet_node_prompts import TEMPLATE_SEARCH_INTERNET
+from .search_link_node_prompts import TEMPLATE_RELEVANT_LINKS
+from .search_node_with_context_prompts import TEMPLATE_SEARCH_WITH_CONTEXT_CHUNKS, TEMPLATE_SEARCH_WITH_CONTEXT_NO_CHUNKS
diff --git a/scrapegraphai/prompts/generate_answer_node_csv_prompts.py b/scrapegraphai/prompts/generate_answer_node_csv_prompts.py
index 18f02775..8df8bde3 100644
--- a/scrapegraphai/prompts/generate_answer_node_csv_prompts.py
+++ b/scrapegraphai/prompts/generate_answer_node_csv_prompts.py
@@ -1,7 +1,7 @@
"""
Generate answer csv schema
"""
-template_chunks_csv = """
+TEMPLATE_CHUKS_CSV = """
You are a scraper and you have just scraped the
following content from a csv.
You are now asked to answer a user question about the content you have scraped.\n
@@ -13,7 +13,7 @@ Output instructions: {format_instructions}\n
Content of {chunk_id}: {context}. \n
"""
-template_no_chunks_csv = """
+TEMPLATE_NO_CHUKS_CSV = """
You are a csv scraper and you have just scraped the
following content from a csv.
You are now asked to answer a user question about the content you have scraped.\n
@@ -25,7 +25,7 @@ User question: {question}\n
csv content: {context}\n
"""
-template_merge_csv = """
+TEMPLATE_MERGE_CSV = """
You are a csv scraper and you have just scraped the
following content from a csv.
You are now asked to answer a user question about the content you have scraped.\n
diff --git a/scrapegraphai/prompts/generate_answer_node_omni_prompts.py b/scrapegraphai/prompts/generate_answer_node_omni_prompts.py
index 8104be28..9185f462 100644
--- a/scrapegraphai/prompts/generate_answer_node_omni_prompts.py
+++ b/scrapegraphai/prompts/generate_answer_node_omni_prompts.py
@@ -2,7 +2,7 @@
Generate answer node omni prompts helper
"""
-template_chunks_omni = """
+TEMPLATE_CHUNKS_OMNI = """
You are a website scraper and you have just scraped the
following content from a website.
You are now asked to answer a user question about the content you have scraped.\n
@@ -14,7 +14,7 @@ Output instructions: {format_instructions}\n
Content of {chunk_id}: {context}. \n
"""
-template_no_chunk_omni = """
+TEMPLATE_NO_CHUNKS_OMNI = """
You are a website scraper and you have just scraped the
following content from a website.
You are now asked to answer a user question about the content you have scraped.\n
@@ -28,7 +28,7 @@ Website content: {context}\n
Image descriptions: {img_desc}\n
"""
-template_merge_omni = """
+TEMPLATE_MERGE_OMNI = """
You are a website scraper and you have just scraped the
following content from a website.
You are now asked to answer a user question about the content you have scraped.\n
diff --git a/scrapegraphai/prompts/generate_answer_node_pdf_prompts.py b/scrapegraphai/prompts/generate_answer_node_pdf_prompts.py
index 0ff9b9f7..a3ea9bef 100644
--- a/scrapegraphai/prompts/generate_answer_node_pdf_prompts.py
+++ b/scrapegraphai/prompts/generate_answer_node_pdf_prompts.py
@@ -1,7 +1,7 @@
"""
Generate anwer node pdf prompt
"""
-template_chunks_pdf = """
+TEMPLATE_CHUNKS_PDF = """
You are a scraper and you have just scraped the
following content from a PDF.
You are now asked to answer a user question about the content you have scraped.\n
@@ -13,7 +13,7 @@ Output instructions: {format_instructions}\n
Content of {chunk_id}: {context}. \n
"""
-template_no_chunks_pdf = """
+TEMPLATE_NO_CHUNKS_PDF = """
You are a PDF scraper and you have just scraped the
following content from a PDF.
You are now asked to answer a user question about the content you have scraped.\n
@@ -25,7 +25,7 @@ User question: {question}\n
PDF content: {context}\n
"""
-template_merge_pdf = """
+TEMPLATE_MERGE_PDF = """
You are a PDF scraper and you have just scraped the
following content from a PDF.
You are now asked to answer a user question about the content you have scraped.\n
diff --git a/scrapegraphai/prompts/generate_answer_node_prompts.py b/scrapegraphai/prompts/generate_answer_node_prompts.py
index e6a1eb47..189a665c 100644
--- a/scrapegraphai/prompts/generate_answer_node_prompts.py
+++ b/scrapegraphai/prompts/generate_answer_node_prompts.py
@@ -2,7 +2,7 @@
Generate answer node prompts
"""
-template_chunks_md = """
+TEMPLATE_CHUNKS_MD = """
You are a website scraper and you have just scraped the
following content from a website converted in markdown format.
You are now asked to answer a user question about the content you have scraped.\n
@@ -14,7 +14,7 @@ Output instructions: {format_instructions}\n
Content of {chunk_id}: {context}. \n
"""
-template_no_chunks_md = """
+TEMPLATE_NO_CHUNKS_MD = """
You are a website scraper and you have just scraped the
following content from a website converted in markdown format.
You are now asked to answer a user question about the content you have scraped.\n
@@ -26,7 +26,7 @@ User question: {question}\n
Website content: {context}\n
"""
-template_merge_md = """
+TEMPLATE_MERGE_MD = """
You are a website scraper and you have just scraped the
following content from a website converted in markdown format.
You are now asked to answer a user question about the content you have scraped.\n
@@ -38,7 +38,7 @@ User question: {question}\n
Website content: {context}\n
"""
-template_chunks = """
+TEMPLATE_CHUNKS = """
You are a website scraper and you have just scraped the
following content from a website.
You are now asked to answer a user question about the content you have scraped.\n
@@ -50,7 +50,7 @@ Output instructions: {format_instructions}\n
Content of {chunk_id}: {context}. \n
"""
-template_no_chunks = """
+TEMPLATE_NO_CHUNKS = """
You are a website scraper and you have just scraped the
following content from a website.
You are now asked to answer a user question about the content you have scraped.\n
@@ -62,7 +62,7 @@ User question: {question}\n
Website content: {context}\n
"""
-template_merge = """
+TEMPLATE_MERGE = """
You are a website scraper and you have just scraped the
following content from a website.
You are now asked to answer a user question about the content you have scraped.\n
diff --git a/scrapegraphai/prompts/merge_answer_node_prompts.py b/scrapegraphai/prompts/merge_answer_node_prompts.py
index 87e029a5..9e50fc14 100644
--- a/scrapegraphai/prompts/merge_answer_node_prompts.py
+++ b/scrapegraphai/prompts/merge_answer_node_prompts.py
@@ -2,7 +2,7 @@
Merge answer node prompts
"""
-template_combined = """
+TEMPLATE_COMBINED = """
You are a website scraper and you have just scraped some content from multiple websites.\n
You are now asked to provide an answer to a USER PROMPT based on the content you have scraped.\n
You need to merge the content from the different websites into a single answer without repetitions (if there are any). \n
diff --git a/scrapegraphai/prompts/robots_node_prompts.py b/scrapegraphai/prompts/robots_node_prompts.py
index 501c67f9..c367fd34 100644
--- a/scrapegraphai/prompts/robots_node_prompts.py
+++ b/scrapegraphai/prompts/robots_node_prompts.py
@@ -2,7 +2,7 @@
Robot node prompts helper
"""
-template_robot = """
+TEMPLATE_ROBOT= """
You are a website scraper and you need to scrape a website.
You need to check if the website allows scraping of the provided path. \n
You are provided with the robots.txt file of the website and you must reply if it is legit to scrape or not the website. \n
diff --git a/scrapegraphai/prompts/search_internet_node_prompts.py b/scrapegraphai/prompts/search_internet_node_prompts.py
index 9547355d..d786647b 100644
--- a/scrapegraphai/prompts/search_internet_node_prompts.py
+++ b/scrapegraphai/prompts/search_internet_node_prompts.py
@@ -2,7 +2,7 @@
Search internet node prompts helper
"""
-template_search_internet = """
+TEMPLATE_SEARCH_INTERNET = """
PROMPT:
You are a search engine and you need to generate a search query based on the user's prompt. \n
Given the following user prompt, return a query that can be
@@ -11,4 +11,4 @@ You should return only the query string without any additional sentences. \n
For example, if the user prompt is "What is the capital of France?",
you should return "capital of France". \n
If you return something else, you will get a really bad grade. \n
-USER PROMPT: {user_prompt}"""
\ No newline at end of file
+USER PROMPT: {user_prompt}"""
diff --git a/scrapegraphai/prompts/search_link_node_prompts.py b/scrapegraphai/prompts/search_link_node_prompts.py
index c207c923..760261ae 100644
--- a/scrapegraphai/prompts/search_link_node_prompts.py
+++ b/scrapegraphai/prompts/search_link_node_prompts.py
@@ -2,7 +2,7 @@
Search link node prompts helper
"""
-template_relevant_links = """
+TEMPLATE_RELEVANT_LINKS = """
You are a website scraper and you have just scraped the following content from a website.
Content: {content}
diff --git a/scrapegraphai/prompts/search_node_with_context_prompts.py b/scrapegraphai/prompts/search_node_with_context_prompts.py
index 9841f46a..8b997550 100644
--- a/scrapegraphai/prompts/search_node_with_context_prompts.py
+++ b/scrapegraphai/prompts/search_node_with_context_prompts.py
@@ -2,7 +2,7 @@
Search node with context prompts helper
"""
-template_search_with_context_chunks = """
+TEMPLATE_SEARCH_WITH_CONTEXT_CHUNKS = """
You are a website scraper and you have just scraped the
following content from a website.
You are now asked to extract all the links that they have to do with the asked user question.\n
@@ -13,7 +13,7 @@ User question: {question}\n
Content of {chunk_id}: {context}. \n
"""
-template_search_with_context_no_chunks = """
+TEMPLATE_SEARCH_WITH_CONTEXT_NO_CHUNKS = """
You are a website scraper and you have just scraped the
following content from a website.
You are now asked to extract all the links that they have to do with the asked user question.\n
diff --git a/scrapegraphai/telemetry/telemetry.py b/scrapegraphai/telemetry/telemetry.py
index c68c0d08..655b2cc5 100644
--- a/scrapegraphai/telemetry/telemetry.py
+++ b/scrapegraphai/telemetry/telemetry.py
@@ -82,7 +82,7 @@ def _check_config_and_environ_for_telemetry_flag(
config = _load_config(DEFAULT_CONFIG_LOCATION)
g_telemetry_enabled = _check_config_and_environ_for_telemetry_flag(True, config)
g_anonymous_id = config["DEFAULT"]["anonymous_id"]
-call_counter = 0
+CALL_COUNTER = 0
MAX_COUNT_SESSION = 1000
BASE_PROPERTIES = {
@@ -96,21 +96,27 @@ BASE_PROPERTIES = {
def disable_telemetry():
+ """
+ function for disabling the telemetries
+ """
global g_telemetry_enabled
g_telemetry_enabled = False
def is_telemetry_enabled() -> bool:
+ """
+ function for checking if a telemetry is enables
+ """
if g_telemetry_enabled:
- global call_counter
- if call_counter == 0:
+ global CALL_COUNTER
+ if CALL_COUNTER == 0:
logger.debug(
"Note: ScrapeGraphAI collects anonymous usage data to improve the library. "
"You can disable telemetry by setting SCRAPEGRAPHAI_TELEMETRY_ENABLED=false or "
"by editing ~/.scrapegraphai.conf."
)
- call_counter += 1
- if call_counter > MAX_COUNT_SESSION:
+ CALL_COUNTER += 1
+ if CALL_COUNTER > MAX_COUNT_SESSION:
return False
return True
else:
@@ -137,6 +143,9 @@ def _send_event_json(event_json: dict):
def send_event_json(event_json: dict):
+ """
+ fucntion for sending event json
+ """
if not g_telemetry_enabled:
raise RuntimeError("Telemetry tracking is disabled!")
try:
@@ -147,6 +156,9 @@ def send_event_json(event_json: dict):
def log_event(event: str, properties: Dict[str, any]):
+ """
+ function for logging the events
+ """
if is_telemetry_enabled():
event_json = {
"api_key": API_KEY,
@@ -156,7 +168,13 @@ def log_event(event: str, properties: Dict[str, any]):
send_event_json(event_json)
-def log_graph_execution(graph_name: str, source: str, prompt:str, schema:dict, llm_model: str, embedder_model: str, source_type: str, execution_time: float, content: str = None, response: dict = None, error_node: str = None, exception: str = None, total_tokens: int = None):
+def log_graph_execution(graph_name: str, source: str, prompt:str, schema:dict,
+ llm_model: str, embedder_model: str, source_type: str,
+ execution_time: float, content: str = None, response: dict = None,
+ error_node: str = None, exception: str = None, total_tokens: int = None):
+ """
+ function for logging the graph execution
+ """
properties = {
"graph_name": graph_name,
"source": source,
diff --git a/scrapegraphai/utils/convert_to_json.py b/scrapegraphai/utils/convert_to_json.py
index 57618fc1..45b1ea55 100644
--- a/scrapegraphai/utils/convert_to_json.py
+++ b/scrapegraphai/utils/convert_to_json.py
@@ -12,7 +12,8 @@ def convert_to_json(data: dict, filename: str, position: str = None) -> None:
Args:
data (dict): The data to be converted into JSON format.
filename (str): The name of the output JSON file, without the '.json' extension.
- position (str, optional): The file path where the JSON file should be saved. Defaults to the directory of the caller script if not provided.
+ position (str, optional): The file path where the JSON file should be saved.
+ Defaults to the directory of the caller script if not provided.
Returns:
None: The function does not return anything.
diff --git a/scrapegraphai/utils/logging.py b/scrapegraphai/utils/logging.py
index b40c2cd8..335bcbf1 100644
--- a/scrapegraphai/utils/logging.py
+++ b/scrapegraphai/utils/logging.py
@@ -1,6 +1,12 @@
-"""A centralized logging system for any library
+"""
+A centralized logging system for any library.
+
+This module provides functions to manage logging for a library. It includes
+functions to get and set the verbosity level, add and remove handlers, and
+control propagation. It also includes a function to set formatting for all
+handlers bound to the root logger.
-source code inspired by https://gist.github.com/DiTo97/9a0377f24236b66134eb96da1ec1693f
+Source code inspired by: https://gist.github.com/DiTo97/9a0377f24236b66134eb96da1ec1693f
"""
import logging
@@ -13,15 +19,27 @@ from typing import Optional
_library_name = __name__.split(".", maxsplit=1)[0]
DEFAULT_HANDLER = None
-_default_logging_level = logging.WARNING
+_DEFAULT_LOGGING_LEVEL = logging.WARNING
_semaphore = threading.Lock()
def _get_library_root_logger() -> logging.Logger:
- return logging.getLogger(_library_name)
+ """
+ Get the root logger for the library.
+ Returns:
+ logging.Logger: The root logger for the library.
+ """
+ return logging.getLogger(_library_name)
def _set_library_root_logger() -> None:
+ """
+ Set up the root logger for the library.
+
+ This function sets up the default handler for the root logger,
+ if it has not already been set up.
+ It also sets the logging level and propagation for the root logger.
+ """
global DEFAULT_HANDLER
with _semaphore:
@@ -38,83 +56,129 @@ def _set_library_root_logger() -> None:
library_root_logger = _get_library_root_logger()
library_root_logger.addHandler(DEFAULT_HANDLER)
- library_root_logger.setLevel(_default_logging_level)
+ library_root_logger.setLevel(_DEFAULT_LOGGING_LEVEL)
library_root_logger.propagate = False
-
def get_logger(name: Optional[str] = None) -> logging.Logger:
+ """
+ Get a logger with the specified name.
+
+ If no name is provided, the root logger for the library is returned.
+
+ Args:
+ name (Optional[str]): The name of the logger. If None, the root logger for the library is returned.
+
+ Returns:
+ logging.Logger: The logger with the specified name.
+ """
_set_library_root_logger()
return logging.getLogger(name or _library_name)
-
def get_verbosity() -> int:
+ """
+ Get the current verbosity level of the root logger for the library.
+
+ Returns:
+ int: The current verbosity level of the root logger for the library.
+ """
_set_library_root_logger()
return _get_library_root_logger().getEffectiveLevel()
-
def set_verbosity(verbosity: int) -> None:
+ """
+ Set the verbosity level of the root logger for the library.
+
+ Args:
+ verbosity (int): The verbosity level to set.
+ """
_set_library_root_logger()
_get_library_root_logger().setLevel(verbosity)
-
def set_verbosity_debug() -> None:
+ """
+ Set the verbosity level of the root logger for the library to DEBUG.
+ """
set_verbosity(logging.DEBUG)
-
def set_verbosity_info() -> None:
+ """
+ Set the verbosity level of the root logger for the library to INFO.
+ """
set_verbosity(logging.INFO)
-
def set_verbosity_warning() -> None:
+ """
+ Set the verbosity level of the root logger for the library to WARNING.
+ """
set_verbosity(logging.WARNING)
-
def set_verbosity_error() -> None:
+ """
+ Set the verbosity level of the root logger for the library to ERROR.
+ """
set_verbosity(logging.ERROR)
-
def set_verbosity_fatal() -> None:
+ """
+ Set the verbosity level of the root logger for the library to FATAL.
+ """
set_verbosity(logging.FATAL)
-
def set_handler(handler: logging.Handler) -> None:
+ """
+ Add a handler to the root logger for the library.
+
+ Args:
+ handler (logging.Handler): The handler to add.
+ """
_set_library_root_logger()
assert handler is not None
_get_library_root_logger().addHandler(handler)
-
def setDEFAULT_HANDLER() -> None:
+ """
+ Add the default handler to the root logger for the library.
+ """
set_handler(DEFAULT_HANDLER)
-
def unset_handler(handler: logging.Handler) -> None:
+ """
+ Remove a handler from the root logger for the library.
+
+ Args:
+ handler (logging.Handler): The handler to remove.
+ """
_set_library_root_logger()
assert handler is not None
_get_library_root_logger().removeHandler(handler)
-
def unsetDEFAULT_HANDLER() -> None:
+ """
+ Remove the default handler from the root logger for the library.
+ """
unset_handler(DEFAULT_HANDLER)
-
def set_propagation() -> None:
+ """
+ Enable propagation of the root logger for the library.
+ """
_get_library_root_logger().propagate = True
-
def unset_propagation() -> None:
+ """
+ Disable propagation of the root logger for the library.
+ """
_get_library_root_logger().propagate = False
-
def set_formatting() -> None:
- """sets formatting for all handlers bound to the root logger
+ """
+ Set formatting for all handlers bound to the root logger for the library.
- ```
- [levelname|filename|line number] time >> message
- ```
+ The formatting is set to: "[levelname|filename:lineno] time >> message"
"""
formatter = logging.Formatter(
"[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s"
@@ -123,16 +187,25 @@ def set_formatting() -> None:
for handler in _get_library_root_logger().handlers:
handler.setFormatter(formatter)
-
def unset_formatting() -> None:
+ """
+ Remove formatting for all handlers bound to the root logger for the library.
+ """
for handler in _get_library_root_logger().handlers:
handler.setFormatter(None)
-
@lru_cache(None)
def warning_once(self, *args, **kwargs):
- """emits warning logs with the same message only once"""
- self.warning(*args, **kwargs)
+ """
+ Emit a warning log with the same message only once.
+
+ This function is added as a method to the logging.Logger class. It emits a warning log with the same message only once,
+ even if it is called multiple times with the same message.
+ Args:
+ *args: The arguments to pass to the logging.Logger.warning method.
+ **kwargs: The keyword arguments to pass to the logging.Logger.warning method.
+ """
+ self.warning(*args, **kwargs)
logging.Logger.warning_once = warning_once
diff --git a/scrapegraphai/utils/sys_dynamic_import.py b/scrapegraphai/utils/sys_dynamic_import.py
index 4d1511a2..8905ed5f 100644
--- a/scrapegraphai/utils/sys_dynamic_import.py
+++ b/scrapegraphai/utils/sys_dynamic_import.py
@@ -1,4 +1,5 @@
-"""high-level module for dynamic importing of python modules at runtime
+"""
+high-level module for dynamic importing of python modules at runtime
source code inspired by https://gist.github.com/DiTo97/46f4b733396b8d7a8f1d4d22db902cfc
"""