Remove references to "pickle" file and simply use "output" file
This commit is contained in:
parent
844a215156
commit
36b789dc6a
6 changed files with 34 additions and 33 deletions
|
@ -17,8 +17,8 @@
|
||||||
"#\n",
|
"#\n",
|
||||||
"# OR\n",
|
"# OR\n",
|
||||||
"#\n",
|
"#\n",
|
||||||
"# Use the provided sample pickle file, changing the path below to:\n",
|
"# Use the provided sample converted trace file, changing the path below to:\n",
|
||||||
"# 'sample_data/pickle_pingpong'"
|
"# 'sample_data/converted_pingpong'"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -27,8 +27,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"pickle_path = '~/.ros/tracing/pingpong/ust/pickle'\n",
|
"converted_file_path = '~/.ros/tracing/pingpong/ust/converted'\n",
|
||||||
"#pickle_path = 'sample_data/pickle_pingpong'"
|
"#converted_file_path = 'sample_data/converted_pingpong'"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
"import pandas as pd\n",
|
"import pandas as pd\n",
|
||||||
"\n",
|
"\n",
|
||||||
"from tracetools_analysis import utils\n",
|
"from tracetools_analysis import utils\n",
|
||||||
"from tracetools_analysis.loading import load_pickle\n",
|
"from tracetools_analysis.loading import load_file\n",
|
||||||
"from tracetools_analysis.processor.ros2 import Ros2Handler"
|
"from tracetools_analysis.processor.ros2 import Ros2Handler"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -68,8 +68,8 @@
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Process\n",
|
"# Process\n",
|
||||||
"pickle_path = os.path.expanduser(pickle_path)\n",
|
"converted_file_path = os.path.expanduser(converted_file_path)\n",
|
||||||
"events = load_pickle(pickle_path)\n",
|
"events = load_file(converted_file_path)\n",
|
||||||
"handler = Ros2Handler.process(events)\n",
|
"handler = Ros2Handler.process(events)\n",
|
||||||
"#handler.data.print_model()"
|
"#handler.data.print_model()"
|
||||||
]
|
]
|
||||||
|
|
|
@ -25,7 +25,7 @@ def ctf_to_pickle(trace_directory: str, target: Pickler) -> int:
|
||||||
Load CTF trace, convert events, and dump to a pickle file.
|
Load CTF trace, convert events, and dump to a pickle file.
|
||||||
|
|
||||||
:param trace_directory: the trace directory
|
:param trace_directory: the trace directory
|
||||||
:param target: the target pickle file to write to
|
:param target: the target file to write to
|
||||||
:return: the number of events written
|
:return: the number of events written
|
||||||
"""
|
"""
|
||||||
ctf_events = get_trace_ctf_events(trace_directory)
|
ctf_events = get_trace_ctf_events(trace_directory)
|
||||||
|
@ -43,15 +43,15 @@ def ctf_to_pickle(trace_directory: str, target: Pickler) -> int:
|
||||||
return count_written
|
return count_written
|
||||||
|
|
||||||
|
|
||||||
def convert(trace_directory: str, pickle_target_path: str) -> int:
|
def convert(trace_directory: str, output_file_path: str) -> int:
|
||||||
"""
|
"""
|
||||||
Convert CTF trace to pickle file.
|
Convert CTF trace to pickle file.
|
||||||
|
|
||||||
:param trace_directory: the trace directory
|
:param trace_directory: the trace directory
|
||||||
:param pickle_target_path: the path to the pickle file that will be created
|
:param output_file_path: the path to the output file that will be created
|
||||||
:return: the number of events written to the pickle file
|
:return: the number of events written to the output file
|
||||||
"""
|
"""
|
||||||
with open(pickle_target_path, 'wb') as f:
|
with open(output_file_path, 'wb') as f:
|
||||||
p = Pickler(f, protocol=4)
|
p = Pickler(f, protocol=4)
|
||||||
count = ctf_to_pickle(trace_directory, p)
|
count = ctf_to_pickle(trace_directory, p)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
"""Entrypoint/script to convert CTF trace data to a pickle file."""
|
"""Entrypoint/script to convert CTF trace data to a file."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
@ -24,15 +24,15 @@ from tracetools_analysis.conversion import ctf
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Convert CTF trace data to a pickle file.')
|
description='Convert CTF trace data to a file.')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'trace_directory', help='the path to the main CTF trace directory')
|
'trace_directory', help='the path to the main CTF trace directory')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--pickle-path', '-p',
|
'-o', '--output-file-path',
|
||||||
help='the path to the target pickle file to generate (default: $trace_directory/pickle)')
|
help='the path to the output file to generate (default: $trace_directory/converted)')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.pickle_path is None:
|
if args.output_file_path is None:
|
||||||
args.pickle_path = os.path.join(args.trace_directory, 'pickle')
|
args.output_file_path = os.path.join(args.trace_directory, 'converted')
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
trace_directory = args.trace_directory
|
trace_directory = args.trace_directory
|
||||||
pickle_target_path = args.pickle_path
|
output_file_path = args.output_file_path
|
||||||
|
|
||||||
print(f'importing trace directory: {trace_directory}')
|
print(f'importing trace directory: {trace_directory}')
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
count = ctf.convert(trace_directory, pickle_target_path)
|
count = ctf.convert(trace_directory, output_file_path)
|
||||||
time_diff = time.time() - start_time
|
time_diff = time.time() - start_time
|
||||||
print(f'converted {count} events in {time_diff * 1000:.2f} ms')
|
print(f'converted {count} events in {time_diff * 1000:.2f} ms')
|
||||||
print(f'pickle written to: {pickle_target_path}')
|
print(f'output written to: {output_file_path}')
|
||||||
|
|
|
@ -12,22 +12,22 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
"""Module for pickle loading."""
|
"""Module for converted trace file loading."""
|
||||||
|
|
||||||
import pickle
|
import pickle
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
def load_pickle(pickle_file_path: str) -> List[Dict]:
|
def load_file(file_path: str) -> List[Dict]:
|
||||||
"""
|
"""
|
||||||
Load pickle file containing converted trace events.
|
Load file containing converted trace events.
|
||||||
|
|
||||||
:param pickle_file_path: the path to the pickle file to load
|
:param file_path: the path to the converted file to load
|
||||||
:return: the list of events read from the file
|
:return: the list of events read from the file
|
||||||
"""
|
"""
|
||||||
events = []
|
events = []
|
||||||
with open(pickle_file_path, 'rb') as f:
|
with open(file_path, 'rb') as f:
|
||||||
p = pickle.Unpickler(f)
|
p = pickle.Unpickler(f)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -13,19 +13,20 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
"""Entrypoint/script to process events from a pickle file to build a ROS model."""
|
"""Entrypoint/script to process events from a converted file to build a ROS model."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from tracetools_analysis.loading import load_pickle
|
from tracetools_analysis.loading import load_file
|
||||||
from tracetools_analysis.processor.ros2 import Ros2Handler
|
from tracetools_analysis.processor.ros2 import Ros2Handler
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description='Process a pickle file generated '
|
parser = argparse.ArgumentParser(description='Process a file converted from a trace'
|
||||||
'from tracing and analyze the data.')
|
'directory and analyze the data.')
|
||||||
parser.add_argument('pickle_file', help='the pickle file to import')
|
parser.add_argument(
|
||||||
|
'output_file_path', help='the converted file to import')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-d', '--debug',
|
'-d', '--debug',
|
||||||
action='store_true', default=False,
|
action='store_true', default=False,
|
||||||
|
@ -35,12 +36,12 @@ def parse_args():
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
pickle_filename = args.pickle_file
|
output_file_path = args.output_file_path
|
||||||
debug = args.debug
|
debug = args.debug
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
events = load_pickle(pickle_filename)
|
events = load_file(output_file_path)
|
||||||
ros2_handler = Ros2Handler.process(events)
|
ros2_handler = Ros2Handler.process(events)
|
||||||
|
|
||||||
time_diff = time.time() - start_time
|
time_diff = time.time() - start_time
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue