Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

[Feature] Main Embedding and ConcretizedCallable logic #1

Draft
wants to merge 17 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
143 changes: 143 additions & 0 deletions .github/workflows/run-tests-and-mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Linting / Tests / Documentation

on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
workflow_dispatch: {}

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
name: Linting
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- name: Checkout main code and submodules
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: |
python -m pip install hatch
- name: Install main dependencies
run: |
python -m hatch -v -e tests
- name: Lint
run: |
python -m hatch -e tests run pre-commit run --all-files

unit_tests:
name: Unit testing
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8","3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout main code and submodules
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: |
python -m pip install hatch
- name: Install main dependencies
run: |
python -m hatch -v -e tests
- name: Lint
run: |
python -m hatch -e tests run pre-commit run --all-files
- name: Perform unit tests
run: |
python -m hatch -e tests run pytest -n auto

test_docs:
name: Documentation
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- name: Checkout main code and submodules
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: |
python -m pip install hatch
- name: Install main dependencies
run: |
python -m hatch -v -e docs
- name: Test docs
run: |
python -m hatch run docs:build

publish:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
needs: unit_tests
runs-on: ubuntu-latest
steps:
- name: Checkout main code and submodules
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Build and publish package
run: |
hatch build
hatch publish -u __token__ -a ${{ secrets.PYPI_API_TOKEN }}
- name: Confirm deployment
timeout-minutes: 5
run: |
VERSION=${GITHUB_REF#refs/tags/v}
until pip download qadence-embeddings==$VERSION
do
echo "Failed to download from PyPI, will wait for upload and retry."
sleep 1
done

deploy_docs:
name: Deploy documentation
if: startsWith(github.ref, 'refs/tags/v')
needs: unit_tests
runs-on: ubuntu-latest
steps:
- name: Checkout main code and submodules
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Hatch
run: |
pip install hatch
- name: Deploy docs
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git fetch origin gh-pages
hatch -v run docs:mike deploy --push --update-aliases ${{ github.ref_name }} latest
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/ambv/black
rev: 24.4.2
hooks:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.4.4"
hooks:
- id: ruff
args: [--fix]


- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
exclude: examples|docs
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# qadence-embeddings
# qadence-embeddings

**qadence-embeddings** is a engine-agnostic parameter embedding library.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**qadence-embeddings** is a engine-agnostic parameter embedding library.
**qadence-embeddings** is an engine-agnostic parameter embedding library.

2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
::: qadence_embeddings.callable.ConcretizedCallable
::: qadence_embeddings.embedding.Embedding
71 changes: 71 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
site_name: qadence-embeddings
repo_url: "https://github.com/pasqal-io/qadence-embeddings"
repo_name: "qadence-embeddings"

nav:

- Embeddings in a nutshell: index.md


theme:
name: material
features:
- content.code.annotate
- navigation.indexes
- navigation.sections

palette:
- media: "(prefers-color-scheme: light)"
scheme: default
primary: light green
accent: purple
toggle:
icon: material/weather-sunny
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: black
accent: light green
toggle:
icon: material/weather-night
name: Switch to light mode

markdown_extensions:
- admonition # for notes
- pymdownx.arithmatex: # for mathjax
generic: true
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences

plugins:
- search
- section-index
- mkdocstrings:
default_handler: python
handlers:
python:
selection:
filters:
- "!^_" # exlude all members starting with _
- "^__init__$" # but always include __init__ modules and methods

- mkdocs-jupyter:
theme: light
- markdown-exec

extra_css:
- extras/css/mkdocstrings.css
- extras/css/colors.css
- extras/css/home.css

# For mathjax
extra_javascript:
- extras/javascripts/mathjax.js
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

watch:
- qadence_embeddings
107 changes: 107 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "qadence-embeddings"
description = "a engine-agnostic parameter embedding library."
authors = [
{ name = "Dominik Seitz", email = "dominik.seitz@pasqal.com" },
]
requires-python = ">=3.8,<3.13"
license = {text = "Apache 2.0"}
version = "1.3.0"
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = ["torch", "numpy", "jax"]

[project.optional-dependencies]
dev = ["flaky","black", "pytest", "pytest-xdist", "pytest-cov", "flake8", "mypy", "pre-commit", "ruff", "nbconvert", "matplotlib", "qutip~=4.7.5"]

[tool.hatch.envs.tests]
features = [
"dev",
]

[tool.hatch.envs.tests.scripts]
test = "pytest -n auto {args}"
test-docs = "hatch -e docs run mkdocs build --clean --strict"
test-cov = "pytest -n auto --cov=qadence-embeddings tests/"

[tool.hatch.envs.docs]
dependencies = [
"mkdocs",
"mkdocs-material",
"mkdocstrings",
"mkdocstrings-python",
"mkdocs-section-index",
"mkdocs-jupyter",
"mkdocs-exclude",
"markdown-exec",
"mike",
"matplotlib",
]

[tool.hatch.envs.docs.scripts]
build = "mkdocs build --clean --strict"
serve = "mkdocs serve --dev-addr localhost:8000"

[tool.ruff]
lint.select = ["E", "F", "I", "Q"]
lint.extend-ignore = ["F841"]
line-length = 100

[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "E402"]

[tool.ruff.lint.mccabe]
max-complexity = 15

[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"

[lint.black]
line-length = 100
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''

[lint.isort]
line_length = 100
combine_as_imports = true
balanced_wrapping = true
lines_after_imports = 2
include_trailing_comma = true
multi_line_output = 5

[lint.mypy]
python_version = "3.10"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
no_implicit_optional = false
ignore_missing_imports = true
4 changes: 4 additions & 0 deletions qadence_embeddings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from __future__ import annotations

from .callable import ConcretizedCallable
from .embedding import Embedding
Loading
Loading