Skip to content

Commit

Permalink
add vizro-ai ci files
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna-Xiong committed Oct 31, 2023
1 parent 37a494c commit 93ce0d4
Show file tree
Hide file tree
Showing 8 changed files with 346 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/lint-vizro-ai.yml
Original file line number Diff line number Diff line change
@@ -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
54 changes: 54 additions & 0 deletions .github/workflows/test-integration-vizro-ai.yml
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions .github/workflows/test-unit-vizro-ai.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repos:
rev: v2.2.6
hooks:
- id: codespell
args: [-L sav]
additional_dependencies:
- tomli

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,6 @@ known-first-party = ["vizro"]

[tool.ruff.pydocstyle]
convention = "google"

[tool.ruff.pylint]
max-args = 6
12 changes: 12 additions & 0 deletions vizro-ai/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

<!-- All enhancements and patches to vizro will be documented
in this file. It adheres to the structure of http://keepachangelog.com/.
This project adheres to Semantic Versioning (http://semver.org/). -->

## Unreleased

See the fragment files in the [changelog.d directory](https://github.com/mckinsey/vizro/tree/main/vizro-ai/changelog.d).

<!-- scriv-insert-here -->
67 changes: 67 additions & 0 deletions vizro-ai/hatch.toml
Original file line number Diff line number Diff line change
@@ -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"
88 changes: 88 additions & 0 deletions vizro-ai/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 93ce0d4

Please sign in to comment.