AgentOps-AI / agentops

Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks like CrewAI, Langchain, and Autogen
https://agentops.ai
MIT License
2.26k stars 218 forks source link

ci: pre-commit hooks for static analysis #510

Closed teocns closed 1 week ago

teocns commented 1 week ago

Fixes #509

DISCLAIMER

Ruff's formatter is actually compatible with Black's style, so we get the best of both worlds. We can't have both or they will fight over each-other. Matter of fact, state-of-the-art repositories only go with ruff.

Usage

Install once

(agentops) ➜  agentops git:(githooks) pre-commit install        
pre-commit installed at .git/hooks/pre-commit

Run manually (will run automatically on commit)

(agentops) ➜  agentops git:(githooks) pre-commit run --all-files
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Installing environment for https://github.com/psf/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...

Todo

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 40.51724% with 69 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
agentops/llms/anthropic.py 7.69% 12 Missing :warning:
agentops/llms/__init__.py 0.00% 11 Missing :warning:
agentops/partners/langchain_callback_handler.py 0.00% 10 Missing :warning:
agentops/llms/openai.py 12.50% 7 Missing :warning:
agentops/client.py 40.00% 6 Missing :warning:
agentops/llms/litellm.py 16.66% 5 Missing :warning:
agentops/llms/ai21.py 25.00% 3 Missing :warning:
agentops/time_travel.py 25.00% 3 Missing :warning:
agentops/decorators.py 0.00% 2 Missing :warning:
agentops/http_client.py 50.00% 2 Missing :warning:
... and 7 more
Flag Coverage Δ
unittests 52.85% <40.51%> (-0.02%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
agentops/host_env.py 68.83% <100.00%> (ø)
agentops/llms/instrumented_provider.py 69.23% <100.00%> (ø)
agentops/meta_client.py 47.36% <100.00%> (ø)
agentops/singleton.py 100.00% <ø> (ø)
tests/test_canary.py 100.00% <100.00%> (ø)
tests/test_events.py 100.00% <100.00%> (ø)
tests/test_pre_init.py 100.00% <100.00%> (ø)
tests/test_record_action.py 98.80% <100.00%> (ø)
tests/test_record_tool.py 98.77% <100.00%> (ø)
tests/test_session.py 100.00% <100.00%> (ø)
... and 19 more
teocns commented 1 week ago

Ready for merge @areibman @the-praxs

image
teocns commented 1 week ago

for the sake of clarity and linear history this PR should not be squashed but git-merged with fast forward, so that the commit showing up on history (git blame) will be run ruff on pre-existing issues

image
the-praxs commented 1 week ago

Think we need to add pre-commit hooks in the repo and add relevant dependencies in the pyproject.toml file under a dev section.

teocns commented 1 week ago

@the-praxs Think we need to add pre-commit hooks in the repo and add relevant dependencies in the pyproject.toml file under a dev section.

tru, don'