Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) copy over quantum-viz.js source code #1973

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
wasm_bld = os.path.join(root_dir, "target", "wasm32", build_type)
samples_src = os.path.join(root_dir, "samples")
npm_src = os.path.join(root_dir, "npm", "qsharp")
circuit_vis_src = os.path.join(root_dir, "circuit_vis")
play_src = os.path.join(root_dir, "playground")
pip_src = os.path.join(root_dir, "pip")
widgets_src = os.path.join(root_dir, "widgets")
Expand Down Expand Up @@ -357,23 +358,6 @@ def run_ci_historic_benchmark():
step_end()


if build_widgets:
step_start("Building the Python widgets")

widgets_build_args = [
sys.executable,
"-m",
"pip",
"wheel",
"--no-deps",
"--wheel-dir",
wheels_dir,
widgets_src,
]
subprocess.run(widgets_build_args, check=True, text=True, cwd=widgets_src)

step_end()

if build_wasm:
step_start("Building the wasm crate")
# wasm-pack can't build for web and node in the same build, so need to run twice.
Expand All @@ -394,6 +378,17 @@ def run_ci_historic_benchmark():
)
step_end()

if build_npm:
step_start("Building the circuit_vis package")

npm_args = [npm_cmd, "install"]
subprocess.run(npm_args, check=True, text=True, cwd=circuit_vis_src)

npm_args = [npm_cmd, "run", "build:prod"]
subprocess.run(npm_args, check=True, text=True, cwd=circuit_vis_src)

step_end()

if build_npm:
step_start("Building the npm package")
# Copy the wasm build files over for web and node targets
Expand Down Expand Up @@ -422,6 +417,23 @@ def run_ci_historic_benchmark():
subprocess.run(npm_test_args, check=True, text=True, cwd=npm_src)
step_end()

if build_widgets:
step_start("Building the Python widgets")

widgets_build_args = [
sys.executable,
"-m",
"pip",
"wheel",
"--no-deps",
"--wheel-dir",
wheels_dir,
widgets_src,
]
subprocess.run(widgets_build_args, check=True, text=True, cwd=widgets_src)

step_end()

if build_play:
step_start("Building the playground")
play_args = [npm_cmd, "run", "build"]
Expand Down
62 changes: 62 additions & 0 deletions circuit_vis/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
*.sh text
*.md text

###############################################################################
# diff behavior for some non-binary formats
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.md diff=astextplain
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
30 changes: 30 additions & 0 deletions circuit_vis/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. If applicable, include a screenshot that showcase your changes.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

# Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] Any dependent changes have been merged and published in downstream modules
5 changes: 5 additions & 0 deletions circuit_vis/.github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pip==21.1.3
nox==2021.6.12
nox-poetry==0.8.6
poetry==1.1.7
virtualenv==20.6.0
52 changes: 52 additions & 0 deletions circuit_vis/.github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
# Triggers the workflow on all PRs and push events to the main branch
pull_request:
push:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Runs jobs in parallel
jobs:
build:
runs-on: ubuntu-latest

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Install dependencies
run: npm install

- name: Build TypeScript
run: npm run build

- name: Build package for production with Webpack
run: npm run build:prod

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: npm install

- name: Run tests with Jest
run: npm test

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: npm install

- name: Lint project with ESLint
run: npm run lint
129 changes: 129 additions & 0 deletions circuit_vis/.github/workflows/tests_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Python Tests

on:
# Triggers the workflow on all PRs and push events to the main branch
pull_request:
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
tests:
name: ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { python-version: 3.9, os: ubuntu-latest, session: "pre-commit" }
- { python-version: 3.9, os: ubuntu-latest, session: "flake8" }
- { python-version: 3.9, os: ubuntu-latest, session: "mypy" }
- { python-version: 3.9, os: ubuntu-latest, session: "safety" }
- { python-version: 3.9, os: ubuntu-latest, session: "typeguard" }
- { python-version: 3.9, os: ubuntu-latest, session: "tests" }
- { python-version: 3.8, os: ubuntu-latest, session: "tests" }
- { python-version: 3.9, os: windows-latest, session: "tests" }
- { python-version: 3.9, os: macos-latest, session: "tests" }
- { python-version: 3.9, os: ubuntu-latest, session: "build"}

env:
NOXSESSION: ${{ matrix.session }}

steps:
- name: Check out the repository
uses: actions/[email protected]

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version

- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version

- name: Compute pre-commit cache key
if: matrix.session == 'pre-commit'
id: pre-commit-cache
shell: python
run: |
import hashlib
import sys

python = "py{}.{}".format(*sys.version_info[:2])
payload = sys.version.encode() + sys.executable.encode()
digest = hashlib.sha256(payload).hexdigest()
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])

print("::set-output name=result::{}".format(result))

- name: Restore pre-commit cache
uses: actions/[email protected]
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.pre-commit-cache.outputs.result }}-

- name: Run Nox
if: matrix.session != 'build'
run: |
nox --force-color --python=${{ matrix.python-version }}
working-directory: quantum-viz

- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/[email protected]"
with:
name: coverage-data
path: "quantum-viz/.coverage.*"

- name: Combine coverage data and display human readable report
if: always() && matrix.session == 'tests'
run: |
nox --force-color --session=coverage
working-directory: quantum-viz

- name: Create coverage report
if: always() && matrix.session == 'tests'
run: |
nox --force-color --session=coverage -- xml
working-directory: quantum-viz

- name: Upload coverage report
if: always() && matrix.session == 'tests'
uses: codecov/[email protected]

- name: Bump version for developmental release
if: "matrix.session == 'build'"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%s)
working-directory: quantum-viz

- name: Build package
if: matrix.session == 'build'
run: |
poetry build --ansi
working-directory: quantum-viz

- name: Upload quantum-viz dist
if: matrix.session == 'build'
uses: actions/[email protected]
with:
name: dist
path: quantum-viz/dist/*
Loading
Loading