-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: tidy up graph analyzing #595
Changes from all commits
9e0ff32
f07b5aa
6093241
148a62a
dea573f
2076140
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
from datetime import datetime | ||
from pathlib import Path | ||
|
||
from lxml import etree | ||
from viztracer import VizTracer | ||
|
||
from dsp_tools.analyse_xml_data.construct_and_analyze_graph import ( | ||
create_info_from_xml_for_graph, | ||
generate_upload_order, | ||
make_graph, | ||
) | ||
from dsp_tools.utils.xml_utils import parse_and_clean_xml_file | ||
|
||
|
||
def analyse_circles_in_data(xml_filepath: Path, tracer_output_file: str, save_tracer: bool = False) -> None: | ||
|
@@ -30,19 +30,18 @@ def analyse_circles_in_data(xml_filepath: Path, tracer_output_file: str, save_tr | |
max_stack_depth=3, | ||
) | ||
tracer.start() | ||
tree = etree.parse(xml_filepath) | ||
root = tree.getroot() | ||
root = parse_and_clean_xml_file(xml_filepath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function transforms the special tags |
||
resptr_links, xml_links, all_resource_ids = create_info_from_xml_for_graph(root) | ||
print(f"Total Number of Resources: {len(all_resource_ids)}") | ||
print(f"Total Number of resptr Links: {len(resptr_links)}") | ||
print(f"Total Number of XML Texts with Links: {len(xml_links)}") | ||
print("=" * 80) | ||
graph, node_to_id, edges = make_graph(resptr_links, xml_links, all_resource_ids) | ||
_, _, stash_counter = generate_upload_order(graph, node_to_id, edges) | ||
print("Number of Links Stashed:", stash_counter) | ||
tracer.stop() | ||
if save_tracer: | ||
tracer.save(output_file=tracer_output_file) | ||
print("Number of Links Stashed:", stash_counter) | ||
print("=" * 80) | ||
print("Start time:", start) | ||
print("End time:", datetime.now()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I just improved the flow of information: It's not necessary for
_create_info_from_xml_for_graph_from_one_resource()
to returnsubject_id
. This can be extracted on the caller side.