Skip to content

Finalize the ToolsAPI helper methods and classes #1887

@amahussein

Description

@amahussein

The API is coming closer to be finalized. I experimented with using metaclasses to eliminate most of the constructs that the user has to do to getting strated.
The idea that i provide quick helpers for the most common cases, and more sophisticated cases can still be done using the "internal" classes of the API.
Here is the usage of the latest version on my local:

  1. result_handlers can be constructed directly (no need to call build_handler() or APIHelpers inner classes)
  2. to construct a report on a single handler, there are short cuts (txt, csv, combined_csv, ..etc.)

Example with the new API to load the profile.log in the raw metrics folder:

    prof_handler = ProfWrapper('/output_folder/feature/prof_20250827130250_8CdbDa3c')
    with prof_handler.txt('appRawSummaryLog') as tuner_rep:
        for app_id, log_summary in tuner_rep.items():
            if not log_summary.success:
                print(f'Failed to decode log for App ID: {app_id}, error: {log_summary.get_fail_cause()}')
                continue
            print(app_id)
            print(log_summary.decode_txt())

Vs the implementation on dev branch (first 2 lines are the difference):

    prof_handler = APIHelpers.ProfWrapper.build_handler('/output_folder/feature/prof_20250827130250_8CdbDa3c')
    with TXTReport(prof_handler).table('appRawSummaryLog') as tuner_rep:
        for app_id, log_summary in tuner_rep.items():
            if not log_summary.success:
                print(f'Failed to decode log for App ID: {app_id}, error: {log_summary.get_fail_cause()}')
                continue
            print(app_id)
            print(log_summary.decode_txt())

Metadata

Metadata

Assignees

Labels

api_changeA change affecting the output (add/remove/rename files, add/remove/rename columns)

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions