Skip to content

ci: pre-commit hooks for static analysis#510

Merged
teocns merged 10 commits intomainfrom
githooks
Nov 16, 2024
Merged

ci: pre-commit hooks for static analysis#510
teocns merged 10 commits intomainfrom
githooks

Conversation

@teocns
Copy link
Copy Markdown
Contributor

@teocns teocns commented Nov 15, 2024

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

  • Update the contributor's guideline
  • Run hook on repository to fix all preexisting issues
  • Update pyproject.toml to conform with current rules and define new standards; we can decide to ignore rules that won't pass checks for now, and fix those issues on the run or Q5

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 15, 2024

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 ⚠️
agentops/llms/__init__.py 0.00% 11 Missing ⚠️
agentops/partners/langchain_callback_handler.py 0.00% 10 Missing ⚠️
agentops/llms/openai.py 12.50% 7 Missing ⚠️
agentops/client.py 40.00% 6 Missing ⚠️
agentops/llms/litellm.py 16.66% 5 Missing ⚠️
agentops/llms/ai21.py 25.00% 3 Missing ⚠️
agentops/time_travel.py 25.00% 3 Missing ⚠️
agentops/decorators.py 0.00% 2 Missing ⚠️
agentops/http_client.py 50.00% 2 Missing ⚠️
... and 7 more
Flag Coverage Δ
unittests 52.85% <40.51%> (-0.02%) ⬇️

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
Copy link
Copy Markdown
Contributor Author

teocns commented Nov 15, 2024

Ready for merge @areibman @the-praxs

image

@teocns teocns requested a review from areibman November 15, 2024 20:27
@teocns teocns changed the title chore: add pre-commit for ruff & black ci: pre-commit hooks for static analysis Nov 15, 2024
@teocns
Copy link
Copy Markdown
Contributor Author

teocns commented Nov 15, 2024

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

Copy link
Copy Markdown
Member

@dot-agi dot-agi left a comment

Choose a reason for hiding this comment

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

A-ok

@dot-agi
Copy link
Copy Markdown
Member

dot-agi commented Nov 15, 2024

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
Copy link
Copy Markdown
Contributor Author

teocns commented Nov 15, 2024

@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'

Copy link
Copy Markdown
Contributor

@areibman areibman left a comment

Choose a reason for hiding this comment

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

I <3 clean code. Good stuff

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.

Integrate black and ruff with pre-commit hooks in the CI

3 participants