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

Qa #45

Merged
merged 9 commits into from
Nov 15, 2024
Merged

Qa #45

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
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
ignore = E203, E266, W503, F403, F401
max-line-length = 88
max-complexity = 18
select = B,C,E,F,W,T4,B9
select = B,C,E,F,W,T4,B9
exclude = layouts
29 changes: 29 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Quality
on:
pull_request:
branches: [ "main" ]
workflow_call:
permissions:
contents: read
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'poetry'
- name: Install dependencies
run: poetry install --with dev
- name: Lint with flake8
run: |
poetry run flake8 app
# poetry run flake8 tests
- name: Running license check
run: poetry run licensecheck --zero --license mit
24 changes: 24 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Strobl"
given-names: "Melvin"
orcid: "https://orcid.org/0000-0003-0229-9897"
- family-names: "Franz"
given-names: "Maja"
orcid: "https://orcid.org/0000-0002-2801-7192"
- family-names: "Kuehn"
given-names: "Eileen"
orcid: "https://orcid.org/0000-0002-8034-8837"
- family-names: "Mauerer"
given-names: "Wolfgang"
orcid: "https://orcid.org/0000-0002-9765-8313"
- family-names: "Streit"
given-names: "Achim"
orcid: "https://orcid.org/0000-0002-5065-469X"

title: "MindTheQApp: An Application for Visualizing the Crux in Quantum Machine Learning "
version: 0.1.0
# doi: 10.5281/zenodo.1234
# date-released: 2024-11-25
# url: ""
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Contributing to MindTheQApp

Contributions are highly welcome! :hugging_face:

Start of by..
1. Creating an issue using one of the templates (Bug Report, Feature Request)
- let's discuss what's going wrong or what should be added
- can you contribute with code? Great! Go ahead! :rocket:
2. Forking the repository and working on your stuff. See the sections below for details on how to set things up.
3. Creating a pull request to the main repository

## Setup

Contributing to this project requires some more dependencies besides the "standard" packages.
Those are specified in the groups `dev` and `docs`.
```
poetry install --with dev,docs
```

Additionally, we have pre-commit hooks in place, which can be installed as follows:
```
poetry run pre-commit autoupdate
poetry run pre-commit install
```

Currently the only purpose of the hook is to run Black on commit which will do some code formatting for you.
However be aware, that this might reject your commit and you have to re-do the commit.

## Testing

We do our testing with Pytest. Corresponding tests can be triggered as follows:
```
poetry run pytest
```
There are Github action pipelines in place, that will do linting and testing once you open a pull request.
However, it's a good idea to run tests and linting (either Black or Flake8) locally before pushing.

## Documentation

There is no official documentation page.
You can find all the required information within the app or in the README.
159 changes: 15 additions & 144 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -1,151 +1,31 @@
from layouts.app_page_layout import sidebar_top, sidebar_bottom, content
import dash
import dash_bootstrap_components as dbc
from dash import Input, Output, dcc, html, callback, State
from qml_essentials.ansaetze import Ansaetze
from dash import Input, Output, html, callback, State
from typing import Any, Dict, Optional
import sys

import logging


app = dash.Dash(
external_stylesheets=[dbc.themes.BOOTSTRAP, dbc.icons.FONT_AWESOME], use_pages=True
external_stylesheets=[dbc.themes.BOOTSTRAP, dbc.icons.FONT_AWESOME],
use_pages=True,
)

app.title = "Favicon"
sidebar = html.Div(

sidebar_page_elements = dbc.Nav(
[
dcc.Store(id="main-storage", storage_type="session"),
html.Div(
[
html.H1(
"Mind",
),
html.H2(
"the",
style={
"padding-left": "6px",
},
),
html.Span(
[
html.Img(
src="assets/underground-sign.svg",
width="42",
style={
"display": "inline-block",
"padding-right": "5px",
"padding-bottom": "20px",
},
className="rotate45",
),
html.H1("App", style={"display": "inline-block"}),
]
),
],
className="infoBox",
),
html.Hr(),
dbc.Nav(
[
dbc.NavLink(page["name"], href=page["relative_path"], active="exact")
for page in dash.page_registry.values()
],
vertical=True,
pills=True,
fill=False,
),
html.Div(
[
html.Div(
[
dbc.Label("# of Qubits (0-10)"),
dbc.Input(
type="number",
min=0,
max=10,
step=1,
value=1,
id="main-qubits-input",
),
],
className="numeric-input",
),
html.Div(
[
dbc.Label("# of Layers (0-10)"),
dbc.Input(
type="number",
min=0,
max=10,
step=1,
value=1,
id="main-layers-input",
),
],
className="numeric-input",
),
html.Div(
[
dbc.Label("Circuit Type"),
dbc.Select(
options=[
{
"label": fct.__name__.replace("_", " ").title(),
"value": fct.__name__,
}
for fct in Ansaetze.get_available()
],
placeholder="No Ansatz",
required=True,
id="main-circuit-ident-select",
),
],
className="numeric-input",
),
html.Div(
[
dbc.Label("Data-Reupload"),
dbc.Switch(id="main-dru-switch", value=True, className="fs-4"),
],
),
# html.Div(
# [
# dbc.Label("Trainable Freqs."),
# dbc.Switch(id="switch-tffm", value=False),
# ],
# ),
html.Div(
[
dbc.Label("Seed"),
dbc.Input(
type="number",
min=100,
max=999,
step=1,
value=100,
id="main-seed-input",
),
],
className="numeric-input",
),
],
className="preferencesBox",
),
html.Hr(),
html.Div(
[
dbc.Spinner(
[html.H6("", id="main-loading-state")],
color="primary",
type="grow",
id="main-loading-spinner",
)
],
className="spinnerBox",
),
dbc.NavLink(page["name"], href=page["relative_path"], active="exact")
for page in dash.page_registry.values()
],
className="sidebar",
id="page-sidebar",
vertical=True,
pills=True,
fill=False,
)
sidebar_elements = sidebar_top + [sidebar_page_elements] + sidebar_bottom
sidebar = html.Div(sidebar_elements, className="sidebar", id="page-sidebar")


@callback(
Expand Down Expand Up @@ -198,15 +78,6 @@ def on_preference_changed(
return data


content = html.Div(
[
dash.page_container,
],
className="content",
id="page-content",
)


app.layout = html.Div([sidebar, content])


Expand Down
Loading
Loading