From 93ce0d44714aabb90299c1da077b6758ffc7f51f Mon Sep 17 00:00:00 2001 From: AnnaXiong Date: Tue, 31 Oct 2023 08:55:51 -0400 Subject: [PATCH] add vizro-ai ci files --- .github/workflows/lint-vizro-ai.yml | 73 +++++++++++++++ .../workflows/test-integration-vizro-ai.yml | 54 ++++++++++++ .github/workflows/test-unit-vizro-ai.yml | 48 ++++++++++ .pre-commit-config.yaml | 1 + pyproject.toml | 3 + vizro-ai/CHANGELOG.md | 12 +++ vizro-ai/hatch.toml | 67 ++++++++++++++ vizro-ai/mkdocs.yml | 88 +++++++++++++++++++ 8 files changed, 346 insertions(+) create mode 100644 .github/workflows/lint-vizro-ai.yml create mode 100644 .github/workflows/test-integration-vizro-ai.yml create mode 100644 .github/workflows/test-unit-vizro-ai.yml create mode 100644 vizro-ai/CHANGELOG.md create mode 100644 vizro-ai/hatch.toml create mode 100644 vizro-ai/mkdocs.yml diff --git a/.github/workflows/lint-vizro-ai.yml b/.github/workflows/lint-vizro-ai.yml new file mode 100644 index 000000000..95ac9e1a2 --- /dev/null +++ b/.github/workflows/lint-vizro-ai.yml @@ -0,0 +1,73 @@ +name: lint-vizro-ai +defaults: + run: + working-directory: vizro-ai + +on: + push: + branches: [main] + pull_request: + branches: + - "main" + +concurrency: + group: lint-${{ github.head_ref }} + cancel-in-progress: true + +env: + PYTHONUNBUFFERED: "1" + FORCE_COLOR: "1" + +jobs: + run: + name: Python ${{ matrix.python-version }} on Linux + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9"] + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: pip install --upgrade hatch + + - name: List dependencies + run: hatch run all.py${{ matrix.python-version }}:pip freeze + + - name: Lint + run: hatch run all.py${{ matrix.python-version }}:lint + + - name: Check requirements for Snyk are up to date + run: | + pwd + hatch run all.py${{ matrix.python-version }}:update-snyk-requirements --check + + - name: Find added changelog fragments + id: added-files + run: | + pwd + if ${{ github.event_name == 'pull_request' }}; then + echo "added_files=$(git diff --name-only --diff-filter=A -r HEAD^1 HEAD -- changelog.d/*.md | xargs)" >> $GITHUB_OUTPUT + else + echo "added_files=$(git diff --name-only --diff-filter=A ${{ github.event.before }} ${{ github.event.after }} -- changelog.d/*.md | xargs)" >> $GITHUB_OUTPUT + fi + + - name: Fail if no fragment added in PR + run: | + if [ -z "${{ steps.added-files.outputs.added_files }}" ]; + then + echo "No changelog fragment .md file within changelog.d was detected. Run 'hatch run docs:changelog' to create such a fragment."; + echo "If your PR contains changes that should be mentioned in the CHANGELOG in the next release, please uncomment the relevant section in your created fragment and describe the changes to the user." + echo "If your changes are not relevant for the CHANGELOG, please save and commit the file as." + exit 1 + else + echo "${{ steps.added-files.outputs.added_files }} was added - ready to go!"; + fi diff --git a/.github/workflows/test-integration-vizro-ai.yml b/.github/workflows/test-integration-vizro-ai.yml new file mode 100644 index 000000000..8ad161d63 --- /dev/null +++ b/.github/workflows/test-integration-vizro-ai.yml @@ -0,0 +1,54 @@ +#name: test-integration-vizro-ai +# +#defaults: +# run: +# working-directory: vizro-core +# +#on: +# # push: +# # branches: [main] +# pull_request: +# # branches: +# # - "main" +# +#concurrency: +# group: test-integration-${{ github.head_ref }} +# cancel-in-progress: true +# +#env: +# PYTHONUNBUFFERED: "1" +# FORCE_COLOR: "1" +# +#jobs: +# run: +# name: Python ${{ matrix.python-version }} on ${{ matrix.os }} +# runs-on: ${{ matrix.os }} +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-latest, windows-latest] +# python-version: ["3.9", "3.10", "3.11"] +# +# steps: +# - uses: actions/checkout@v4 +# - name: Get branch name +# id: branch-name +# uses: tj-actions/branch-names@v7 +# +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python-version }} +# +# - uses: actions/cache@v3 +# with: +# path: ${{ env.pythonLocation }} +# key: ${{ matrix.os }}-${{ matrix.python-version }}-${{ steps.branch-name.outputs.current_branch }}-pip-${{ hashFiles('hatch.toml') }}-${{ hashFiles('pyproject.toml') }} +# restore-keys: | +# ${{ matrix.os }}-${{ matrix.python-version }}-${{ steps.branch-name.outputs.current_branch }}-pip- +# +# - name: Run ubuntu integration tests +# if: ${{ matrix.os == 'ubuntu-latest' }} +# run: | +# pip install --upgrade hatch +# hatch run all.py${{ matrix.python-version }}:test-integration diff --git a/.github/workflows/test-unit-vizro-ai.yml b/.github/workflows/test-unit-vizro-ai.yml new file mode 100644 index 000000000..feaf9d826 --- /dev/null +++ b/.github/workflows/test-unit-vizro-ai.yml @@ -0,0 +1,48 @@ +name: test-unit-vizro-ai + +defaults: + run: + working-directory: vizro-ai + +on: + push: + branches: [main] + pull_request: + branches: + - "main" + +concurrency: + group: test-unit-${{ github.head_ref }} + cancel-in-progress: true + +env: + PYTHONUNBUFFERED: "1" + FORCE_COLOR: "1" + +jobs: + run: + name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python-version: ["3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: pip install --upgrade hatch + + - name: List dependencies + run: hatch run all.py${{ matrix.python-version }}:pip freeze + + - name: Run unit tests + run: | + hatch run all.py${{ matrix.python-version }}:cov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df8064356..5dece116e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,6 +32,7 @@ repos: rev: v2.2.6 hooks: - id: codespell + args: [-L sav] additional_dependencies: - tomli diff --git a/pyproject.toml b/pyproject.toml index 335ee25dd..e7af359ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,3 +74,6 @@ known-first-party = ["vizro"] [tool.ruff.pydocstyle] convention = "google" + +[tool.ruff.pylint] +max-args = 6 diff --git a/vizro-ai/CHANGELOG.md b/vizro-ai/CHANGELOG.md new file mode 100644 index 000000000..22dc5b0a8 --- /dev/null +++ b/vizro-ai/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog + + + +## Unreleased + +See the fragment files in the [changelog.d directory](https://github.com/mckinsey/vizro/tree/main/vizro-ai/changelog.d). + + diff --git a/vizro-ai/hatch.toml b/vizro-ai/hatch.toml new file mode 100644 index 000000000..5ec9d761c --- /dev/null +++ b/vizro-ai/hatch.toml @@ -0,0 +1,67 @@ +[envs.all] + +[[envs.all.matrix]] +python = ["3.9", "3.10", "3.11"] + +[envs.changelog] +dependencies = ["scriv"] +detached = true +scripts = {add = "scriv create --add"} + +[envs.default] +dependencies = [ + "devtools[pygments]", + "pre-commit", + "coverage[toml]>=6.5", + "pytest", + "toml", + "nbformat>=4.2.0" +] + +[envs.default.env-vars] +VIZRO_AI_LOG_LEVEL = "DEBUG" + +[envs.default.scripts] +cov = [ + "test-cov", + "cov-report" +] +cov-report = [ + "- coverage combine", + "coverage report" +] +lint = "SKIP=gitleaks pre-commit run {args} --all-files" +prep-release = [ + "hatch version release", + "hatch run changelog:scriv collect --add", + "hatch run lint || hatch run lint", + "hatch run changelog:add", + 'echo "Now raise a PR to merge into main with title: Release of vizro-ai $(hatch version)"' +] +pypath = "hatch run python -c 'import sys; print(sys.executable)'" +secrets = "pre-commit run gitleaks --all-files" +test = [ + "test-unit", + "test-integration" +] +test-cov = "coverage run -m pytest tests/unit {args}" +test-integration = [ + "pytest tests/integration {args}" +] +test-unit = "pytest tests/unit {args}" +update-snyk-requirements = "python ../tools/generate_snyk_requirements.py {args}" + +[envs.docs] +dependencies = [ + "mkdocs", + "mkdocs-material", + "mkdocs-git-revision-date-localized-plugin", + "mkdocstrings[python]" +] +detached = true + +[envs.docs.scripts] +serve = "mkdocs serve" + +[version] +path = "src/vizro_ai/__init__.py" diff --git a/vizro-ai/mkdocs.yml b/vizro-ai/mkdocs.yml new file mode 100644 index 000000000..7309329de --- /dev/null +++ b/vizro-ai/mkdocs.yml @@ -0,0 +1,88 @@ +site_name: Vizro-AI +site_url: https://mckinsey.github.io/vizro-ai/ +nav: + - Vizro-AI: index.md + - Get started: + - Quickstart: pages/tutorials/quickstart.md + - User Guides: + - Fundamentals: + - Installation: pages/user_guides/install.md + - API Setup: pages/user_guides/api_setup.md + - Run Methods: pages/user_guides/run_vizro_ai.md + - Model Configuration: pages/user_guides/model_config.md + - Explanation: + - Disclaimer: pages/explanation/disclaimer.md + - Safeguard Code Execution: pages/explanation/safeguard.md + - Safety in Vizro AI: pages/explanation/safety_in_vizro_ai.md + - Contribute: + # - Contributing: pages/contribute/contributing.md + - Authors: pages/contribute/authors.md + +repo_url: https://github.com/mckinsey/vizro/tree/main/vizro-ai +repo_name: mckinsey/vizro-ai #TODO: this infers the version number of the latest release... + +theme: + name: material + language: en + palette: + - scheme: default + font: + text: Roboto + code: Roboto Mono + icon: + repo: fontawesome/brands/github + features: + - navigation.instant + - navigation.tabs + - navigation.tabs.sticky + - navigation.sections + - navigation.tracking + - search.suggest + - search.highlight + - content.tabs.link + - content.code.annotation + - content.code.copy + - content.code.annotate + +watch: + - src + +markdown_extensions: + - pymdownx.highlight: + anchor_linenums: true + - pymdownx.inlinehilite + - pymdownx.snippets + - admonition + - pymdownx.arithmatex: + generic: true + - footnotes + - pymdownx.details + - pymdownx.superfences + - pymdownx.tabbed: + alternate_style: true + - pymdownx.mark + - attr_list + - md_in_html + +plugins: + - search + - autorefs + - mkdocstrings: + handlers: + python: + options: + show_source: false #currently doesn't show source at correct level, and not for pydantic models + docstring_style: google + merge_init_into_class: true + docstring_section_style: list + separate_signature: true + # filters: ["!^_"] + show_root_heading: true + docstring_options: + ignore_init_summary: true + paths: [src] + - git-revision-date-localized: + enable_creation_date: false + +extra_css: + - stylesheets/extra.css