Skip to content

Commit

Permalink
[Style] Style with precommit hooks (#1315)
Browse files Browse the repository at this point in the history
* setup precommit ruff formatter and linter

* fmt

* update pipelines

* restore import trulens_eval before model_rebuild

* rm extraneous files

* rm test data

* fix explain pipeline

* install dev requirements

* revert trulens_explain

* revert trulens_explain

* pr fixes

* notebook formatting fixes

* docs authorship update

* fmt

* skip json cause it can't handle comments
  • Loading branch information
sfc-gh-chu authored Aug 1, 2024
1 parent ebe5675 commit 6875f59
Show file tree
Hide file tree
Showing 314 changed files with 135,631 additions and 135,392 deletions.
2 changes: 1 addition & 1 deletion .azure_pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ github pipelines. There are differences between these systems.

- [Triggers
documentation](https://learn.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops)
describes how to setup trigers (when a pipeline needs to run).
describes how to setup triggers (when a pipeline needs to run).
21 changes: 4 additions & 17 deletions .azure_pipelines/ci-eval-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,7 @@ jobs:
pip install -r requirements.dev.txt --verbose
yapf --version
isort --vn
./format.sh --eval
num_changed_files=`git ls-files --others -m --exclude-standard ./trulens_eval | wc -l`
if [ $num_changed_files -ne 0 ]; then
echo "The following files have changed after running format.sh. Please format your code and update the PR."
git ls-files --others -m --exclude-standard ./trulens_eval
echo "\n\nOutputting git diff for checked in files.\n"
git diff
exit 1
fi
pre-commit run --all-files --show-diff-on-failure
condition: eq(variables['python-version'], 3.12) # only run format check with latest python version
displayName: Format diffs
Expand All @@ -88,7 +76,7 @@ jobs:
set -e
source activate $(python-version)
pip install -r requirements.test.txt --verbose
pip install -r requirements.test.txt --verbose
displayName: Install testing packages
Expand All @@ -99,7 +87,7 @@ jobs:
python --version
pip --version
pip list --verbose
displayName: Describe python env
- bash: |
Expand Down Expand Up @@ -157,7 +145,7 @@ jobs:
env:
# enables optional tests, see tests/unit/test.py
TEST_OPTIONAL: true
# tests make use of various APIs:
OPENAI_API_KEY: $(OPENAI_API_KEY)
HUGGINGFACE_API_KEY: $(HUGGINGFACE_API_KEY)
Expand All @@ -166,4 +154,3 @@ jobs:
HUGGINGFACEHUB_API_TOKEN: $(HUGGINGFACEHUB_API_TOKEN)
displayName: Unit tests with optional packages

21 changes: 5 additions & 16 deletions .azure_pipelines/ci-eval.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
latest:
pythonVersion: "3.11"
condaEnvFileSuffix: "trulens-llm"


steps:
- checkout: self
Expand All @@ -50,7 +50,7 @@ jobs:
which python
python --version
displayName: Which Python
- bash: |
set -e
source activate $(condaEnvFileSuffix)
Expand All @@ -66,20 +66,9 @@ jobs:
- bash: |
set -e
source activate $(condaEnvFileSuffix)
echo Using $(yapf --version) isort $(isort --vn)
./format.sh --eval
pre-commit run --all-files --show-diff-on-failure
displayName: Format Code
- bash: |
num_changed_files=`git ls-files --others -m --exclude-standard ./trulens_eval | wc -l`
if [ $num_changed_files -ne 0 ]; then
echo "The following files have changed after running format.sh. Please format your code and update the PR."
git ls-files --others -m --exclude-standard ./trulens_eval
echo "\n\nOutputting git diff for checked in files.\n"
git diff
fi
displayName: NoDiffCheck
- bash: |
source activate $(condaEnvFileSuffix)
cd ./docs/trulens_eval
Expand All @@ -103,7 +92,7 @@ jobs:
- bash: |
source activate $(condaEnvFileSuffix)
cd ./trulens_eval
python -m pytest tests/e2e
displayName: Run e2e tests
Expand All @@ -117,7 +106,7 @@ jobs:
- bash: |
source activate $(condaEnvFileSuffix)
cd ./trulens_eval
python -m pytest tests/docs_notebooks
displayName: Run notebook tests
Expand Down
4 changes: 2 additions & 2 deletions .azure_pipelines/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
CONDA_FILENAME=$(condaEnvFileSuffix)
CONDA_YAML="trulens_explain/tools/conda_${CONDA_FILENAME}.yaml"
echo $CONDA
conda env create --force --quiet --file $CONDA_YAML
conda env create --yes --quiet --file $CONDA_YAML
conda init bash
displayName: Create Anaconda environment
- bash: |
Expand All @@ -86,11 +86,11 @@ jobs:
cd ./trulens_explain
pip install -r $(requirementsFile)
python -m ipykernel install --user --name $(condaEnvFileSuffix) --display-name "$(condaEnvFileSuffix)"
pip install -r requirements.dev.txt
displayName: Install pip package
- bash: |
set -e
source activate $(condaEnvFileSuffix)
echo Using $(yapf --version) isort $(isort --vn)
./format.sh --explain
displayName: Format Code
- bash: |
Expand Down
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ A clear and concise description of what you expected to happen.
Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. If the issue is related to the TruLens dashboard, please also include a screenshot.

**Environment:**
- OS: [e.g. MacOS, Windows]
- Python Version
- TruLens version
- Versions of other relevant installed libraries

- OS: [e.g. MacOS, Windows]
- Python Version
- TruLens version
- Versions of other relevant installed libraries

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ credentials.toml
# IDE
**/.vscode

# test files generated by benchmark experiments
# test files generated by benchmark experiments
**/tests/*.csv
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
exclude: trulens_explain
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: check-toml
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: debug-statements
- id: check-merge-conflict
- id: end-of-file-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
hooks:
# - id: ruff
# types_or: [ python, pyi, jupyter ]
# args: [ --fix ]
- id: ruff-format
types_or: [ python, pyi, jupyter ]
- repo: https://github.com/srstevenson/nb-clean
rev: 3.3.0
hooks:
- id: nb-clean
args: [--remove-empty-cells]
2 changes: 1 addition & 1 deletion .style.yapf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ based_on_style = google
DEDENT_CLOSING_BRACKETS=true
SPLIT_BEFORE_FIRST_ARGUMENT=true
SPLIT_COMPLEX_COMPREHENSION=true
COLUMN_LIMIT=80
COLUMN_LIMIT=80
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ community](https://communityinviter.com/apps/aiqualityforum/josh)!

**Don't just vibe-check your llm app!** Systematically evaluate and track your
LLM experiments with TruLens. As you develop your app including prompts, models,
retreivers, knowledge sources and more, *TruLens-Eval* is the tool you need to
retreivers, knowledge sources and more, _TruLens-Eval_ is the tool you need to
understand its performance.

Fine-grained, stack-agnostic instrumentation and comprehensive evaluations help
you to identify failure modes & systematically iterate to improve your
application.

Read more about the core concepts behind TruLens including [Feedback Functions](https://www.trulens.org/trulens_eval/getting_started/core_concepts/feedback_functions/),
Read more about the core concepts behind TruLens including [Feedback Functions](https://www.trulens.org/trulens_eval/getting_started/core_concepts/feedback_functions/),
[The RAG Triad](https://www.trulens.org/trulens_eval/getting_started/core_concepts/rag_triad/),
and [Honest, Harmless and Helpful Evals](https://www.trulens.org/trulens_eval/getting_started/core_concepts/honest_harmless_helpful_evals/).

Expand Down Expand Up @@ -92,7 +92,6 @@ guide](https://www.trulens.org/trulens_eval/contributing/) for more details.
end of trulens_eval/gh_top_intro.md
-->


<!---
start of trulens_explain/gh_top_intro.md
NOTE: This content is from trulens_explain/gh_top_intro.md and is merged into
Expand All @@ -112,19 +111,22 @@ These installation instructions assume that you have conda installed and added
to your path.

0. Create a virtual environment (or modify an existing one).

```bash
conda create -n "<my_name>" python=3 # Skip if using existing environment.
conda activate <my_name>
```

1. Install dependencies.

```bash
conda install tensorflow-gpu=1 # Or whatever backend you're using.
conda install keras # Or whatever backend you're using.
conda install matplotlib # For visualizations.
```

2. [Pip installation] Install the trulens pip package from PyPI.

```bash
pip install trulens
```
Expand Down
2 changes: 1 addition & 1 deletion docs/CNAME
Original file line number Diff line number Diff line change
@@ -1 +1 @@
www.trulens.org
www.trulens.org
36 changes: 18 additions & 18 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@
import os
import sys

os.environ['TRULENS_BACKEND'] = 'keras'
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../'))
os.environ["TRULENS_BACKEND"] = "keras"
sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath("../"))

# -- Project information -----------------------------------------------------

project = 'trulens'
copyright = '2023, TruEra'
author = 'TruEra'
project = "trulens"
copyright = "2024, Snowflake"
author = "Snowflake"

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'recommonmark',
'sphinx.ext.mathjax',
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"recommonmark",
"sphinx.ext.mathjax",
]

# napoleon_google_docstring = False
Expand All @@ -41,37 +41,37 @@


def skip(app, what, name, obj, would_skip, options):
if name == '__init__' or name == '__call__':
if name == "__init__" or name == "__call__":
return False
return would_skip


def setup(app):
app.connect('autodoc-skip-member', skip)
app.connect("autodoc-skip-member", skip)


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

from recommonmark.parser import CommonMarkParser

source_parsers = {'.md': CommonMarkParser}
source_parsers = {".md": CommonMarkParser}

source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]
2 changes: 1 addition & 1 deletion docs/img/trulens-diagram-mob.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/img/trulens-diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/img/trulens-hero-bg-image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/img/trulens-hero-image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
template: home.html
---

2 changes: 1 addition & 1 deletion docs/javascript/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ window.MathJax = {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};
};
2 changes: 1 addition & 1 deletion docs/javascript/tablesort.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ document$.subscribe(function() {
tables.forEach(function(table) {
new Tablesort(table)
})
})
})
2 changes: 1 addition & 1 deletion docs/javascript/tex-mml-chtml-3.0.0.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/robots.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
User-agent: *
Disallow:
Disallow:
Loading

0 comments on commit 6875f59

Please sign in to comment.