Skip to content

Commit

Permalink
initial commit for Vizro open source
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph-Perkins committed Sep 4, 2023
1 parent 9b2a728 commit fc34051
Show file tree
Hide file tree
Showing 247 changed files with 18,821 additions and 201 deletions.
232 changes: 232 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
version: 2.1

orbs:
browser-tools: circleci/[email protected]

parameters:
triggering-pipeline-id:
type: string
default: ""
branch:
type: string
default: ""
qa_branch:
type: string
default: ""
app_repo_name:
type: string
default: "vizro"
app_core_name:
type: string
default: "vizro-core"
qa_repo_name:
type: string
default: "vizx-qa"

commands:
approve-job-in-triggering-pipeline:
steps:
- run:
name: Ping CircleCI API to get workflow
command: |
echo << pipeline.parameters.triggering-pipeline-id >>
if ! [ -z "<< pipeline.parameters.triggering-pipeline-id >>" ]
then
workflow_id=$(curl --request GET \
--url https://circleci.com/api/v2/pipeline/<< pipeline.parameters.triggering-pipeline-id >>/workflow \
--header "Circle-Token: $CIRCLECI_API_KEY" \
--header "content-type: application/json" \
| jq -r '.items[0].id')
echo $workflow_id
waiting_job_id=$(curl --request GET \
--url https://circleci.com/api/v2/workflow/$workflow_id/job \
--header "Circle-Token: $CIRCLECI_API_KEY" \
--header "content-type: application/json" \
| jq -r '.items[] | select(.name == "wait-for-triggered-pipeline").id')
echo $waiting_job_id
curl --request POST \
--url https://circleci.com/api/v2/workflow/$workflow_id/approve/$waiting_job_id \
--header "Circle-Token: $CIRCLECI_API_KEY" \
--header "content-type: application/json"
fi
when: always

chromedriver_install:
description: Installation of Chrome and chromedriver
parameters:
version:
default: 114.0.5735.90
type: string
steps:
- run:
name: Install Google Chrome
command: |
cd ~
sudo apt-get update
sudo apt-get install libu2f-udev -y
wget "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_<< parameters.version >>-1_amd64.deb"
sudo apt-get install -y --allow-downgrades ~/google-chrome-stable_<< parameters.version >>-1_amd64.deb
rm ~/google-chrome-stable_<< parameters.version >>-1_amd64.deb
- browser-tools/install-chromedriver

custom_checkout:
steps:
- run:
name: Checkout logic for qa and app repos
command: |
touch ~/.ssh/known_hosts
ssh-keyscan github.com >> ~/.ssh/known_hosts
cd /home/circleci/
git clone -v "$TESTS_REPO_URL"
if ! [ -z "<< pipeline.parameters.qa_branch >>" ]
then
echo "from pipeline"
echo "<< pipeline.parameters.qa_repo_name >> branch:"
cd /home/circleci/<< pipeline.parameters.qa_repo_name >>
git switch "<< pipeline.parameters.qa_branch >>"
git rev-parse HEAD
cd /home/circleci/project/
existed_in_remote=$(git ls-remote --heads origin "<< pipeline.parameters.qa_branch >>")
if ! [[ -z ${existed_in_remote} ]]; then
echo "<< pipeline.parameters.app_repo_name >> branch:"
git switch "<< pipeline.parameters.branch >>"
git rev-parse HEAD
fi
elif ! [ -z "$CIRCLE_BRANCH" ]
then
echo "from git"
echo "<< pipeline.parameters.app_repo_name >> branch:"
cd /home/circleci/project/
git switch "$CIRCLE_BRANCH"
git rev-parse HEAD
cd /home/circleci/<< pipeline.parameters.qa_repo_name >>
existed_in_remote=$(git ls-remote --heads origin "$CIRCLE_BRANCH")
if ! [[ -z ${existed_in_remote} ]]; then
echo "<< pipeline.parameters.qa_repo_name >> branch:"
git switch "$CIRCLE_BRANCH"
git rev-parse HEAD
fi
fi
create_env_and_install_reqs:
description: Create environment and install requirements
steps:
- run:
name: Create qa environment
command: |
python3 -m venv ~/.venv/<< pipeline.parameters.qa_repo_name >>
echo "source ~/.venv/<< pipeline.parameters.qa_repo_name >>/bin/activate" >> $BASH_ENV
touch Pipfile.lock
- restore_cache:
keys:
- pip-packages-v1-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- pip-packages-v1-{{ .Branch }}-
- pip-packages-v1
- run:
name: Install requirements
command: |
sudo apt-get update
sudo apt-get install rsync -y
pip install -U pip
pip install -U setuptools wheel
pip install -r /home/circleci/<< pipeline.parameters.qa_repo_name >>/requirements.txt
cd /home/circleci/project/<< pipeline.parameters.app_core_name >>
hatch build
pip install dist/vizro*.tar.gz
- save_cache:
paths:
- ~/.venv/
key: pip-packages-v1-{{ .Branch }}-{{ checksum "Pipfile.lock" }}

jobs:
run_tests:
docker:
- image: cimg/python:3.8.17
steps:
- checkout
- custom_checkout
- create_env_and_install_reqs
- chromedriver_install
- run:
name: Run dashboards and tests
command: |
export PYTHONPATH="/home/circleci/<< pipeline.parameters.qa_repo_name >>:$PYTHONPATH"
cd /home/circleci/<< pipeline.parameters.qa_repo_name >>
python dashboards/run_all_dashboards.py
dashboards/wait_for_dashboard.sh
TEST_FILES=$(circleci tests glob "tests/test_*.py" | circleci tests split --split-by=timings)
python -m pytest -v --reruns 1 --junitxml=test-results/junit.xml --override-ini junit_family=xunit1 $TEST_FILES
- run:
name: Collecting failed screenshots
command: |
mkdir /home/circleci/<< pipeline.parameters.qa_repo_name >>/failed_screenshots/
cd /home/circleci/<< pipeline.parameters.qa_repo_name >>/
cp tests*.png failed_screenshots
when: on_fail
- store_test_results:
path: /home/circleci/<< pipeline.parameters.qa_repo_name >>/test-results
- store_artifacts:
path: /home/circleci/<< pipeline.parameters.qa_repo_name >>/failed_screenshots/

run_notebooks:
docker:
- image: cimg/python:3.8.17
steps:
- checkout
- custom_checkout
- create_env_and_install_reqs
- chromedriver_install
- run:
name: Run notebooks
command: |
export PYTHONPATH="/home/circleci/<< pipeline.parameters.qa_repo_name >>:$PYTHONPATH"
ipython kernel install --name "<< pipeline.parameters.qa_repo_name >>" --user
cd /home/circleci/project/<< pipeline.parameters.app_core_name >>
../../<< pipeline.parameters.qa_repo_name >>/scripts/run_notebooks.sh
- run:
name: Run notebooks as python scripts
command: |
export PYTHONPATH="/home/circleci/<< pipeline.parameters.qa_repo_name >>:$PYTHONPATH"
cd /home/circleci/project/<< pipeline.parameters.app_core_name >>
../../<< pipeline.parameters.qa_repo_name >>/scripts/convert_notebooks_to_python.sh
cd examples/jupyter
python app.py &
cd /home/circleci/<< pipeline.parameters.qa_repo_name >>
dashboards/wait_for_notebooks.sh
python -m pytest -v --reruns 1 --junitxml=test-results/junit.xml tests_notebooks
- run:
name: Collecting failed notebooks
command: |
mkdir /home/circleci/<< pipeline.parameters.qa_repo_name >>/failed_notebooks/
cd /home/circleci/project/<< pipeline.parameters.app_core_name >>
cp examples*.txt /home/circleci/<< pipeline.parameters.qa_repo_name >>/failed_notebooks/
when: on_fail
- run:
name: Collecting failed screenshots
command: |
mkdir /home/circleci/<< pipeline.parameters.qa_repo_name >>/failed_screenshots/
cd /home/circleci/<< pipeline.parameters.qa_repo_name >>/
cp tests*.png failed_screenshots
when: on_fail
- store_test_results:
path: /home/circleci/<< pipeline.parameters.qa_repo_name >>/test-results
- store_test_results:
path: /home/circleci/<< pipeline.parameters.qa_repo_name >>/failed_notebooks/
- store_artifacts:
path: /home/circleci/<< pipeline.parameters.qa_repo_name >>/failed_screenshots/

workflows:
version: 2
vizro-core:
jobs:
- run_tests:
post-steps:
- approve-job-in-triggering-pipeline
context:
- circleci-apix
- run_notebooks
13 changes: 13 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"customizations": {
"vscode": {
"extensions": ["vsls-contrib.codetour"]
}
},
"features": {
"ghcr.io/devcontainers-contrib/features/hatch:2": {}
},
"image": "mcr.microsoft.com/devcontainers/python:0-3.8",
"postAttachCommand": "cd vizro-core; hatch -v run example",
"postCreateCommand": "hatch -v env create; hatch run pre-commit install-hooks"
}
76 changes: 76 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Bug report
description: Something is not working correctly.
labels: "Status: Needs triage :mag:, Issue: Bug Report :bug:"

body:
- type: markdown
attributes:
value: >-
Hi there! Thank you so much for taking the time to fill in this bug form. It will be
a valuable contribution to Vizro.
We'd appreciate it if you could search on Vizro's existing issues prior to filing
a bug report to avoid any duplicate tickets, as we have limited maintainer capacity to triage
them. Thanks!
- type: textarea
attributes:
label: Description
description: >-
A clear and concise description of what the bug is.
validations:
required: true

- type: textarea
attributes:
label: Expected behavior
description: >-
A clear and concise description of what you expected to happen.
- type: input
attributes:
label: vizro version
validations:
required: true
- type: input
attributes:
label: Python version
validations:
required: true
- type: input
attributes:
label: OS
validations:
required: true

- type: textarea
attributes:
label: How to Reproduce
description: Please provide steps to reproduce this bug.
placeholder: |
1. Get package from '...'
2. Then run '...'
3. An error occurs.
validations:
required: true

- type: textarea
attributes:
label: Output
description: >-
Provide the output of the steps above, including the commands
themselves and Vizro's output/traceback etc. If possible,
please also provide a screenshot highlighting the issue.
If you want to present output from multiple commands, please prefix
the line containing the command with `$ `. Please also ensure that
the "How to reproduce" section contains matching instructions for
reproducing this.
- type: checkboxes
attributes:
label: Code of Conduct
options:
- label: >-
I agree to follow the [Code of Conduct](https://github.com/mckinsey/vizro/blob/main/CODE_OF_CONDUCT.md).
required: true
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Documentation for this file can be found at:
# https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository

blank_issues_enabled: false
contact_links:
- name: "(maintainers only) Blank issue"
url: https://github.com/mckinsey/vizro/issues/new
about: For maintainers only.
58 changes: 58 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Feature request
description: Suggest an idea for this project
labels: "Status: Needs triage :mag:, Issue: Feature Request :nerd_face:"

body:
- type: markdown
attributes:
value: >-
Hi there! Thank you so much for taking the time to fill in this feature request form.
It will be a valuable contribution to Vizro.
We'd appreciate it if you could search on Vizro's existing issues prior to filing
a feature request to avoid any duplicate tickets, as we have limited maintainer capacity to triage
them. Thanks!
- type: textarea
attributes:
label: What's the problem this feature will solve?
description: >-
What are you trying to do, that you are unable to achieve with Vizro as it
currently stands?
validations:
required: true

- type: textarea
attributes:
label: Describe the solution you'd like
description: >-
Clear and concise description of what you want to happen. Please use examples
of real world use cases that this would help with, and how it solves the
problem described above.
validations:
required: true

- type: textarea
attributes:
label: Alternative Solutions
description: >-
Have you tried to workaround the problem using Vizro or other tools? Or a
different approach to solving this issue? Please elaborate here.
validations:
required: true

- type: textarea
attributes:
label: Additional context
description: >-
Add any other context, links, etc. relevant to the feature request.
validations:
required: true

- type: checkboxes
attributes:
label: Code of Conduct
options:
- label: >-
I agree to follow the [Code of Conduct](https://github.com/mckinsey/vizro/blob/main/CODE_OF_CONDUCT.md).
required: true
Loading

0 comments on commit fc34051

Please sign in to comment.