Profile wrapper object#65
Merged
Merged
Conversation
Introduces a Profile class that provides snake_case property getters and setters over the camelCase ProfileData/SerializedProfile dicts. This makes programmatic profile construction much cleaner compared to manually building nested TypedDicts. Key features: - Properties for all profile fields with validation on axis scales - Convenience methods: pin_scalar, pin_histogram, pin_image, add_superimposed_card, select_runs - serialize() to produce SerializedProfile dicts - write(logdir) to serialize and write to disk in one call - from_serialized() and load() classmethods for round-tripping - run_colors/group_colors exposed as plain dicts instead of list[RunColorEntry]/list[GroupColorEntry] Also: - Adds missing symlogLinearThreshold and tagSymlogLinearThresholds fields to the ProfileData TypedDict (they were already being written but not declared) - Updates write_profile to accept Profile instances directly - 30 new tests covering construction, mutation, serialization, round-trips, and the builder workflow Co-authored-by: Samuel <samuel@knutsen.co>
|
Cursor Agent can help with this pull request. Just |
create_profile and set_default_profile now delegate to Profile(...).serialize() instead of duplicating the dict-building logic. The two small type mismatches are bridged at the call site: group_colors list[GroupColorEntry] -> dict[str,int], and symlog_linear_threshold 1.0-means-default -> None-means-default. Co-authored-by: Samuel <samuel@knutsen.co>
- create_profile now returns a Profile object (the primary API). write_profile and set_default_profile still accept it seamlessly. - Profile.update(other) and a | b merge two profiles: dicts merged, lists extended, regex filters combined with alternation, optional scalars only overridden if non-None. - Updated tests for the new return type (65 → 68 tests). - Updated NEW.md, AGENTS_DEV.md, AGENTS_DOC.md, README.md to show create_profile / Profile as the primary workflow. Co-authored-by: Samuel <samuel@knutsen.co>
Co-authored-by: Samuel <samuel@knutsen.co>
Preview Deployment
Details
|
Co-authored-by: Samuel <samuel@knutsen.co>
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.
Motivation for features / changes
The existing profile management (
SerializedProfile,ProfileData) uses nested dictionaries with camelCase keys, making programmatic modification of profiles cumbersome and error-prone. This change introduces a high-levelProfilewrapper object to provide a clean, Pythonic API for creating and modifying profiles.Technical description of changes
Profileclass: Addedtensorbored/plugins/core/profile_writer.pywhich provides a Pythonic interface for profile data.@propertygetters and setters for typed and validated access to profile fields.run_colors,y_axis_scale) to the underlying camelCase JSON fields.run_colorsandgroup_colorsas plain dictionaries for easier manipulation.pin_scalar,add_superimposed_card, andselect_runs.Profile.from_serialized,Profile.load,profile.serialize,profile.write).create_profile,set_default_profile, andwrite_profilecontinue to function as before.write_profilenow also acceptsProfileinstances directly.ProfileDatafix: CorrectedProfileDataTypedDict to includesymlogLinearThresholdandtagSymlogLinearThresholds.Profileclass.Screenshots of UI changes (or N/A)
N/A
Detailed steps to verify changes work correctly (as executed by you)
python -m pytest tensorbored/plugins/core/profile_writer_test.pyProfileClassTesttests + 26 existing tests).Alternate designs / implementations considered (or N/A)
N/A