text stringlengths 0 93.6k |
|---|
logging.info("Step 1: Understanding question") |
logging.info("Step 2: Generating search queries") |
queries = self.generate_search_queries() |
logging.info("Step 3: Processing search queries in parallel") |
with ThreadPoolExecutor(max_workers=5) as executor: |
futures = [ |
executor.submit(self.process_search_query, query) for query in queries |
] |
all_results = [future.result() for future in futures] |
logging.info("Step 4: Collecting all outputs") |
logging.info("Step 5: Printing graph structure") |
self.print_graph() |
return all_results |
def print_graph(self): |
"""Print the graph structure""" |
logging.info("\nGraph Summary:") |
print(f"Number of nodes: {self.graph.number_of_nodes()}") |
print(f"Number of edges: {self.graph.number_of_edges()}") |
logging.debug("\nNodes:") |
for node in self.graph.nodes(data=True): |
logging.debug(f"Node: {node[0]}") |
if "content" in node[1]: |
logging.debug(f"Content preview: {node[1]['content'][:100]}...") |
logging.debug("\nEdges:") |
for edge in self.graph.edges(data=True): |
logging.debug( |
f"Edge: {edge[0]} -> {edge[1]} (weight: {edge[2].get('weight', 1)})" |
) |
def setup_logging(verbosity): |
logging_level = logging.WARNING |
if verbosity == 1: |
logging_level = logging.INFO |
elif verbosity >= 2: |
logging_level = logging.DEBUG |
logging.basicConfig( |
handlers=[ |
logging.StreamHandler(), |
], |
format="%(asctime)s - %(filename)s:%(lineno)d - %(message)s", |
datefmt="%Y-%m-%d %H:%M:%S", |
level=logging_level, |
) |
logging.captureWarnings(capture=True) |
def parse_args(): |
parser = ArgumentParser( |
description=__doc__, formatter_class=RawDescriptionHelpFormatter |
) |
parser.add_argument( |
"-v", |
"--verbose", |
action="count", |
default=0, |
dest="verbose", |
help="Increase verbosity of logging output", |
) |
parser.add_argument( |
"-q", |
"--question", |
type=str, |
required=True, |
help="The question to process", |
) |
parser.add_argument( |
"-o", |
"--output", |
type=str, |
default="search_graph.html", |
help="Output HTML file for visualization (default: search_graph.html)", |
) |
return parser.parse_args() |
def main(args): |
start_time = time.time() |
search_graph = SearchGraph(args.question) |
search_graph.process_question() |
search_graph.visualize_graph(args.output) |
end_time = time.time() |
logging.info(f"Total processing time: {end_time - start_time:.2f} seconds") |
logging.info(f"Visualization saved to: {args.output}") |
if __name__ == "__main__": |
args = parse_args() |
setup_logging(args.verbose) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.