Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: make silverback --help faster #162

Merged
merged 4 commits into from
Nov 4, 2024
Merged

Conversation

antazoey
Copy link
Member

What I did

Cuts the time down. It is twice as fast for me now to run silverback --help.

How I did it

  • Any CLI module has to be more careful on its top-level imports
  • Root init file of package needs to also be careful, using a __getattr__ there.

How to verify it

time silverback --help

Before:

silverback  4.13s user 0.83s system 93% cpu 5.280 total

After:

silverback  1.63s user 0.28s system 83% cpu 2.297 total

Results may vary.

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

fubuloubu
fubuloubu previously approved these changes Oct 30, 2024
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

@dtdang if you can just verify the CLI all works well still, we can merge

from .exceptions import CircuitBreaker, SilverbackException
from .main import SilverbackBot
from .state import StateSnapshot
def __getattr__(name: str):
Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't look like you are, but one thing to be aware of is autodoc won'tt work for lazy modules like this.
However, it isn't that hard to just add in the docs manually. Example: https://github.com/ApeWorX/ape/blob/main/docs/methoddocs/ape.md

@dtdang
Copy link
Contributor

dtdang commented Oct 30, 2024

Looks like some of the CLI commands that depend on ApePay are causing errors in the new PR since we refactored BaseInterfaceModel to utils so we'll need to fix this first before merging the PR.

ImportError: cannot import name 'BaseInterfaceModel' from 'ape.types'

@antazoey
Copy link
Member Author

antazoey commented Oct 30, 2024

ImportError: cannot import name 'BaseInterfaceModel' from 'ape.types'

BaseInterfaceModel was never exported in ape.types; this was a mistake
it was only coincidentally imported there

@dtdang
Copy link
Contributor

dtdang commented Oct 30, 2024

ImportError: cannot import name 'BaseInterfaceModel' from 'ape.types'

BaseInterfaceModel was never exported in ape.types; this was a mistake it was only coincidentally imported there

Looks like I just needed to update the repo on my end, my bad. Testing the rest of the commands now but everything is looking good since pulling the latest repos.

@dtdang
Copy link
Contributor

dtdang commented Oct 30, 2024

LGTM no issues with the commands since updating other repos.

dtdang
dtdang previously approved these changes Oct 30, 2024
@antazoey
Copy link
Member Author

Well I am moving all the base model stuff to types since that is where yall went lookin for it: ApeWorX/ape#2353
And so in 0.9 youll have to put that back or wait for the release of Ape where itll work in both

@antazoey antazoey dismissed stale reviews from dtdang and fubuloubu via 31a0cc1 November 2, 2024 02:54
@antazoey antazoey enabled auto-merge (squash) November 2, 2024 02:55
fubuloubu
fubuloubu previously approved these changes Nov 2, 2024
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

Need to double check this all still works before merging

@antazoey
Copy link
Member Author

antazoey commented Nov 4, 2024

Need to double check this all still works before merging

OK but all I did was remove an import that no longer used.

@dtdang
Copy link
Contributor

dtdang commented Nov 4, 2024

CLI is still working as intended

@antazoey antazoey merged commit 83663af into ApeWorX:main Nov 4, 2024
13 checks passed
@antazoey antazoey deleted the perf/cli-load branch November 4, 2024 16:05
@fubuloubu
Copy link
Member

Need to double check this all still works before merging

OK but all I did was remove an import that no longer used.

The type annotation PlatformClient was something I was using internally, we don't really have the CLI tested here so I want to make sure nothing was breaking

@antazoey
Copy link
Member Author

antazoey commented Nov 4, 2024

The type annotation PlatformClient was something I was using internally, we don't really have the CLI tested here so I want to make sure nothing was breaking

I am quite tempted to add more tests to silverback.

@fubuloubu
Copy link
Member

The type annotation PlatformClient was something I was using internally, we don't really have the CLI tested here so I want to make sure nothing was breaking

I am quite tempted to add more tests to silverback.

Once I figure out how to do the whole backtesting thing, it'll be a lot easier. But testing the CLI would be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants