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 all 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
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ __pycache__/
.vscode-test-web/
.venv/
/allocator/
/circuit_vis/lib/
/circuit_vis/dist/
/compiler/
/jupyterlab/lib/
/jupyterlab/qsharp-jupyterlab/labextension/
Expand Down
86 changes: 59 additions & 27 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
)

parser.add_argument(
"--ci-bench",
action=argparse.BooleanOptionalAction,
default=False,
help="Run the benchmarking script that is run in CI (default is --no-ci-bench)",
"--ci-bench",
action=argparse.BooleanOptionalAction,
default=False,
help="Run the benchmarking script that is run in CI (default is --no-ci-bench)",
)

args = parser.parse_args()
Expand Down 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 @@ -303,25 +304,46 @@ def run_python_integration_tests(cwd, interpreter):
def run_ci_historic_benchmark():
branch = "main"
output = subprocess.check_output(
["git", "rev-list", "--since=1 week ago", "--pretty=format:%ad__%h", "--date=short", branch]
[
"git",
"rev-list",
"--since=1 week ago",
"--pretty=format:%ad__%h",
"--date=short",
branch,
]
).decode("utf-8")
print('\n'.join([line for i, line in enumerate(output.split('\n')) if i % 2 == 1]))
print("\n".join([line for i, line in enumerate(output.split("\n")) if i % 2 == 1]))

output = subprocess.check_output(
["git", "rev-list", "--since=1 week ago", "--pretty=format:%ad__%h", "--date=short", branch]
[
"git",
"rev-list",
"--since=1 week ago",
"--pretty=format:%ad__%h",
"--date=short",
branch,
]
).decode("utf-8")
date_and_commits = [line for i, line in enumerate(output.split('\n')) if i % 2 == 1]
date_and_commits = [line for i, line in enumerate(output.split("\n")) if i % 2 == 1]

for date_and_commit in date_and_commits:
print("benching commit", date_and_commit)
result = subprocess.run(
["cargo", "criterion", "--message-format=json", "--history-id", date_and_commit],
[
"cargo",
"criterion",
"--message-format=json",
"--history-id",
date_and_commit,
],
capture_output=True,
text=True
text=True,
)
with open(f"{date_and_commit}.json", "w") as f:
f.write(result.stdout)


if build_pip:
step_start("Building the pip package")

Expand Down Expand Up @@ -357,23 +379,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 +399,16 @@ 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 +437,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
156 changes: 156 additions & 0 deletions circuit_vis/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
## Ignore Node.js temporary files, build results, and
## files generated by popular Node.js add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/Node.gitignore

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env.test
.*[v]env/

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*


## Project-specific files ##

# NPM's package-lock.json
package-lock.json

# VSCode configuration
.vscode

# IntelliJ
.idea

# macOS metadata folder
.DS_Store

# Compiled files
lib
.tgz

# Python
.mypy_cache/
*/.coverage
*/.coverage.*
*/.nox/
*/.python-version
*/.pytype/
/dist/
*/docs/_build/
/src/*.egg-info/
__pycache__/
*/.cookiecutter.json
*-checkpoint.ipynb
*/*.xml
*.xml
17 changes: 17 additions & 0 deletions circuit_vis/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: true,
endOfLine: "lf",
printWidth: 120,
tabWidth: 4,
parser: "typescript",
overrides: [
{
files: ["*.md", "*.json", "*.yml", "*.yaml"],
options: {
tabWidth: 2,
},
},
],
};
Loading
Loading