Skip to content

Feature/yappi#441

Merged
andre-merzky merged 5 commits intodevelfrom
feature/yappi
Oct 31, 2025
Merged

Feature/yappi#441
andre-merzky merged 5 commits intodevelfrom
feature/yappi

Conversation

@andre-merzky
Copy link
Member

@andre-merzky andre-merzky commented Mar 20, 2025

Simplify performance profiling. This now profiles a part of code:

import radical.utils as ru

with ru.Yappi(name='sleeper'):
   sleep(1)

@codecov
Copy link

codecov bot commented Mar 20, 2025

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.19%. Comparing base (8d49419) to head (b5f8b59).
⚠️ Report is 6 commits behind head on devel.

Files with missing lines Patch % Lines
src/radical/utils/profile.py 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel     #441      +/-   ##
==========================================
- Coverage   61.23%   61.19%   -0.04%     
==========================================
  Files          66       66              
  Lines        7359     7363       +4     
==========================================
  Hits         4506     4506              
- Misses       2853     2857       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@mtitov mtitov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andre-merzky added several comments

self.__dict__['_data'].update(self._defaults)

self.update(from_dict)
if from_dict:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is duplication, we do check inside update if provided value is non empty

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but safes a function call. I am not trying to beautify, but try to optimize :-) Same for the other ones.


def __setitem__(self, k, v):
self._data[k] = self._verify_setter(k, v)
if self._check :
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplication, we do this check inside _verify_setter

return object.__setattr__(self, k, v)

self._data[k] = self._verify_setter(k, v)
if self._check :
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplication (it is checked inside of _verify_setter)

else:
self.update(self._defaults)
self.__dict__['_data'] = dict()
self.__dict__['_data'].update(self._defaults)
Copy link
Collaborator

@mtitov mtitov Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitant to call update on a dict level and not on TypedDict level (for both deep and non deep).

class NewTD(TypedDict):
    _schema = {'a': TypedDict}
    _defaults = {'a': {'level1': {'level2': 123}}}

ntd = NewTD({'a': TypedDict({'level1': {'level2B': 456}})})
print(ntd)
# default behavior: 
#    {'a': TypedDict: {'level1': TypedDict: {'level2': 123, 'level2B': 456}}}
# new behavior: 
#    {'a': {'level1': TypedDict: {'level2B': 456}}}

Our original (default) behavior is correct, so I would keep self.update(...)
but that's right to keep self.__dict__['_data'] = dict() here in the __init__

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, this needs work still.

@andre-merzky
Copy link
Member Author

@mtitov - I should have labeled that draft, sorry for not being clear, will do now. Some replies though inlined.

@andre-merzky andre-merzky marked this pull request as draft March 21, 2025 07:32
@andre-merzky
Copy link
Member Author

TODO AM: separate yappi and typed dict portions.

@andre-merzky
Copy link
Member Author

Due to the flux merge, this PR reduces to shielding the yappi import.

@andre-merzky andre-merzky requested a review from mtitov October 31, 2025 09:51
@andre-merzky andre-merzky marked this pull request as ready for review October 31, 2025 09:51
Copy link
Collaborator

@mtitov mtitov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@andre-merzky andre-merzky merged commit ba00900 into devel Oct 31, 2025
9 checks passed
@andre-merzky andre-merzky deleted the feature/yappi branch October 31, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants