Add tests for HolisticTraceAnalysis/hta/common (#348)#348
Open
sijiaw-meta wants to merge 3 commits into
Open
Conversation
|
@sijiaw-meta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D104888486. |
90e64bf to
ce83265
Compare
Summary: **Purpose:** Add unit test coverage for HolisticTraceAnalysis/hta/configs to meet the >=90% per-file coverage target. Baseline was 95.2% overall but event_args_yaml_parser.py was at 84.2%. **Type:** Test infrastructure **Changes:** - Add 2 new tests in test_event_args_yaml_parser.py: test_parse_event_args_yaml_loads_local_file (covers the os.path.exists True branch that loads YAML from disk via mocked open) and test_main_runs_without_error (covers the main() function via captured stdout) - event_args_yaml_parser.py: 84.2% -> 94.7% (folder total: 96.3%) Differential Revision: D104876231
Summary: **Purpose:** Add unit test coverage for HolisticTraceAnalysis/hta/utils to meet the >=90% per-file coverage target. Baseline did not exercise checker.py or validate_trace.py at all; utils.py and test_utils.py had partial coverage from existing tests. **Type:** Test infrastructure **Changes:** - New tests/test_checker.py (8 tests): cover all branches of is_valid_directory and OperationOutcome - New tests/test_validate_trace.py (15 tests): cover get_argument_spec, get_expected_arguments, _get_argument_value_types, _check_args (skipped/violation/object/int-to-float branches), validate_trace_format (read failure, missing traceEvents, args-not-dict, skipped args not ignored, ok path, type violation), and the __main__ argparse block via runpy - New tests/test_utils_extra.py (34 tests): cover normalize_path (all branches), is_comm/memory/compute_kernel, get_kernel_type (all 4 branches), get_memory_kernel_type (Memset/DtoH/Unknown), merge_kernel_intervals, flatten_column_names, get_mp_pool_size, normalize_gpu_stream_numbers, get_value_from_dict, get_test_data_dir, and data_provider tuple/scalar branches - BUCK: register the 3 new test_unittest targets **Coverage:** - checker.py: 0% -> 100% - test_utils.py: 60.7% -> 100% - utils.py: 56.0% -> 100% - validate_trace.py: 0% -> 96.4% - Folder total: 56.5% -> 98.8% Differential Revision: D104876398
Summary: **Purpose:** Add unit test coverage for HolisticTraceAnalysis/hta/common to bring overall folder coverage from 73.4% baseline to 88.4%. The remaining gap (trace.py at 71.9%, trace_call_stack.py at 87.3%, trace_call_graph.py at 89.8%) requires real Trace fixtures via multiprocessing-based parsing which is out of scope for this diff. **Type:** Test infrastructure **Changes (9 new test files, 1 BUCK update):** - New test_types.py (15 tests): cover DeviceType, MemcpyType, GroupingPattern, to_grouping_pattern (string/list/Pattern/passthrough/invalid) - New test_trace_file_extra.py (14 tests): cover create_rank_to_trace_dict_from_dir (missing, empty, valid), create_rank_to_trace_dict (duplicate rank, no rank, default zero), get_trace_files, read/write_trace (json/gz roundtrip, invalid ext, makedirs), update_trace_rank - New test_trace_symbol_table.py (25 tests): cover symbol table basics, encode/decode_df, update_encoded_df, add_symbols_to_trace_df, get_operator_or_cuda_runtime_mask, get_runtime_launch_events_mask, get_events_mask (None/pattern), category helpers, csv roundtrip + missing/invalid, combine_symbol_tables, clone, create_from_df, create_from_symbol_id_map, decode_symbol_id_to_symbol_name (shorten/user_annotation/non-int) - New test_trace_filter_extra.py (42 tests): cover IterationFilter (int/list/invalid type/missing column), IterationIndexFilter (filtering, only -1, no match), FirstIterationFilter, RankFilter, TimeRangeFilter (invalid/missing column), NameStringColumnFilter, NameIdColumnFilter, NameFilter (string/id paths), QueryFilter, ZeroDurationFilter, GPUKernelFilter, CPUOperatorFilter, CompositeFilter (invalid type, ordering), MemCopyEventFilter (empty, no match, matches), Filter ABC - New test_trace_stack_filter.py (15 tests): cover get_matching_kernels, OperatorFilterMethod enum, OperatorFilter (Under/After/Before, op-not-found, unsupported method, no string columns, explicit name_column), AfterOperatorFilter, BeforeOperatorFilter, UnderOperatorFilter, CombinedOperatorFilter (with all ops, missing columns, stack_depths) - New test_call_stack_extra.py (27 tests): cover infer_device_type (GPU/CPU/empty/mixed), compare_events, CallStackIdentity, CallStackGraph (constructor, repr, get_nodes/parent/children/path_to_root, dfs_traverse, get_dataframe, get_depth, get_paths_to_leaves, get_leaf_nodes, missing index_correlation raises, GPU short-circuits), CallStackNode - New test_trace_call_stack_extra.py (22 tests): cover _cmp_events_with_zero_duration (all branches), _less_than (different time, same index, close before open, two open ends, two close ends, zero dur path), is_events_sorted, sort_events, CallStackIdentity, CallStackNode (defaults/explicit), CallStackGraph (CPU constructor + repr + get_nodes + get_parent + GPU short-circuit) - New test_trace_extra.py (17 tests): cover trace_event_timestamp_to_unixtime_ns (normal/missing-base/zero-ts), transform_correlation_to_index (no column / cpu-gpu pairs), get_cpu_gpu_correlation, add_iteration, add_fwd_bwd_links (no events / linked / empty merge), parse_trace_file (invalid ext), Trace.flow_event (start/end/with-args), Trace.convert_time_series_to_events (missing columns / required / optional name+id) - Append 1 test to test_trace_df.py (1 test): cover find_events_by_name_patterns_using_symbol_table and decoded_names paths - BUCK: register all 8 new test_unittest targets **Coverage results (per-file):** - types.py: 0% -> 100% - constants.py: 100% (unchanged) - trace_file.py: 78.4% -> 100% - trace_df.py: 65.6% -> 96.9% - trace_filter.py: 36.2% -> 97.5% - trace_stack_filter.py: 29.7% -> 95.6% - trace_symbol_table.py: 74.7% -> 95.5% - trace_parser.py: 91.9% (unchanged) - call_stack.py: 80.8% -> 90.2% - trace_call_graph.py: 89.8% (unchanged - requires Trace fixtures for further coverage) - trace_call_stack.py: 85.8% -> 87.3% - trace.py: 59.0% -> 71.9% (full coverage requires Trace fixtures with multiprocessing parse) - **Folder total: 73.4% -> 88.4%** Differential Revision: D104888486
ce83265 to
81d1c7f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Purpose: Add unit test coverage for HolisticTraceAnalysis/hta/common to bring overall folder coverage from 73.4% baseline to 88.4%. The remaining gap (trace.py at 71.9%, trace_call_stack.py at 87.3%, trace_call_graph.py at 89.8%) requires real Trace fixtures via multiprocessing-based parsing which is out of scope for this diff.
Type: Test infrastructure
Changes (9 new test files, 1 BUCK update):
Coverage results (per-file):
Differential Revision: D104888486