Skip to content

Commit

Permalink
improved workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Herb committed Jul 25, 2024
1 parent 561c969 commit 5bb2928
Show file tree
Hide file tree
Showing 33 changed files with 1,203 additions and 698 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Code Quality with pylint, pytest, black

on: [push, pull_request]

jobs:
pylint:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run pylint
continue-on-error: true
run: |
find qDNA tools -type f -name "*.py" ! -name "__init__.py" | xargs pylint
pytest:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests with pytest
run: python -m pytest

black:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black
- name: Run black
continue-on-error: true
run: black --check .
8 changes: 2 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: Publish Python Package

on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types: [created]

jobs:
build-and-publish:
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/requirements.txt

This file was deleted.

45 changes: 23 additions & 22 deletions docs/sphinx_doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@

import os
import sys
sys.path.insert(0, os.path.abspath('../..'))

sys.path.insert(0, os.path.abspath("../.."))


# -- Project information -----------------------------------------------------

project = 'QuantumDNA'
copyright = '2024, Dennis Herb'
author = 'Dennis Herb'
project = "QuantumDNA"
copyright = "2024, Dennis Herb"
author = "Dennis Herb"

# The full version, including alpha/beta/rc tags
release = '0.1.0'
release = "0.1.0"


# -- General configuration ---------------------------------------------------
Expand All @@ -32,31 +33,31 @@
# ones.

extensions = [
'sphinx.ext.mathjax',
'matplotlib.sphinxext.plot_directive',
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.doctest',
'sphinx.ext.autosummary',
'numpydoc',
'sphinx.ext.extlinks',
'sphinx.ext.viewcode',
'sphinx.ext.ifconfig',
'sphinx.ext.napoleon',
"sphinx.ext.mathjax",
"matplotlib.sphinxext.plot_directive",
"sphinx.ext.autodoc",
"sphinx.ext.todo",
"sphinx.ext.doctest",
"sphinx.ext.autosummary",
"numpydoc",
"sphinx.ext.extlinks",
"sphinx.ext.viewcode",
"sphinx.ext.ifconfig",
"sphinx.ext.napoleon",
#'sphinx_gallery.gen_gallery',
'sphinxcontrib.bibtex',
"sphinxcontrib.bibtex",
]

bibtex_bibfiles = ['biblio.bib']
bibtex_bibfiles = ["biblio.bib"]
autosummary_generate = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------
Expand All @@ -69,4 +70,4 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
2 changes: 1 addition & 1 deletion gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
from .plotting_window import *
from .scrollable_console_frame import ScrollableConsoleFrame

from .qdna_app import *
from .qdna_app import *
37 changes: 23 additions & 14 deletions gui/config_frame.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
import customtkinter as ctk


class ConfigFrame(ctk.CTkFrame):
def __init__(self, master, **kwargs):
"""
Notes:
This frame is located in the main/ menu window. This means that the main window is its master.
The frame uses the commands open_custom_window() and open_github() from the master
Notes:
This frame is located in the main/ menu window. This means that the main window is its master.
The frame uses the commands open_custom_window() and open_github() from the master
Widgets with get() method:
appearance_mode_combo
"""

# initialization of the ctk.CTkFrame class
super().__init__(master)

# widgets
self.open_github_button = ctk.CTkButton(self, text="GitHub", command=master.open_github)
self.open_github_button = ctk.CTkButton(
self, text="GitHub", command=master.open_github
)
self.open_github_button.grid(row=8, column=0, pady=10, padx=10)

self.open_custom_window_button = ctk.CTkButton(self, text="Customize", command=master.open_custom_window)

self.open_custom_window_button = ctk.CTkButton(
self, text="Customize", command=master.open_custom_window
)
self.open_custom_window_button.grid(row=9, column=0, pady=10, padx=10)

self.appearance_mode_label = ctk.CTkLabel(self, text="Appearance Mode:", anchor="w")

self.appearance_mode_label = ctk.CTkLabel(
self, text="Appearance Mode:", anchor="w"
)
self.appearance_mode_label.grid(row=10, column=0, pady=10, padx=10)

self.appearance_mode_combo = ctk.CTkComboBox(self, values=["Light", "Dark", "System"], command=ctk.set_appearance_mode)

self.appearance_mode_combo = ctk.CTkComboBox(
self, values=["Light", "Dark", "System"], command=ctk.set_appearance_mode
)
self.appearance_mode_combo.grid(row=11, column=0, pady=10, padx=10)
self.appearance_mode_combo.set('System')
self.appearance_mode_combo.set("System")
67 changes: 40 additions & 27 deletions gui/custom_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,84 @@

from qDNA import wrap_save_tb_params


class CustomFrame(ctk.CTkFrame):
def __init__(self, master, configs):
"""
Notes:
This frame is located in the custom window. This means that the custom window is its master.
The frame uses the commands save() and cancel() from the master
Notes:
This frame is located in the custom window. This means that the custom window is its master.
The frame uses the commands save() and cancel() from the master
Widgets with get() method:
tb_params_entry, source_entry, particle_combobox, tb_model_combobox, unit_combobox, methylation_checkbox
"""

# initialization of the ctk.CTkFrame class
super().__init__(master)
self.configs = configs

# widgets
self.tb_params_label = ctk.CTkLabel(self, text="TB parameters:")
self.tb_params_label.grid(row=0, column=0, columnspan=2, pady=10, padx=10)

self.tb_params_entry = ctk.CTkEntry(self)
self.tb_params_entry.grid(row=1, column=0, columnspan=2, padx=10, pady=10)

self.source_label = ctk.CTkLabel(self, text="Source:")
self.source_label.grid(row=2, column=0, columnspan=2, padx=10, pady=10)

self.source_entry = ctk.CTkEntry(self)
self.source_entry.grid(row=3, column=0, columnspan=2, padx=10, pady=10)

self.particle_label = ctk.CTkLabel(self, text="Particle:")
self.particle_label.grid(row=4, column=0, columnspan=2, padx=10, pady=10)

self.particle_combobox = ctk.CTkComboBox(self, values=self.configs['PARTICLES'] )
self.particle_combobox = ctk.CTkComboBox(self, values=self.configs["PARTICLES"])
self.particle_combobox.grid(row=5, column=0, columnspan=2, padx=10, pady=10)

self.tb_model_label = ctk.CTkLabel(self, text="TB Model:")
self.tb_model_label.grid(row=6, column=0, columnspan=2, padx=10, pady=10)

self.tb_model_combobox = ctk.CTkComboBox(self, values=self.configs['TB_MODELS'] )
self.tb_model_combobox = ctk.CTkComboBox(self, values=self.configs["TB_MODELS"])
self.tb_model_combobox.grid(row=7, column=0, columnspan=2, padx=10, pady=10)

self.unit_label = ctk.CTkLabel(self, text="Unit:")
self.unit_label.grid(row=8, column=0, columnspan=2, padx=10, pady=10)

self.unit_combobox = ctk.CTkComboBox(self, values=self.configs['UNITS'] )
self.unit_combobox = ctk.CTkComboBox(self, values=self.configs["UNITS"])
self.unit_combobox.grid(row=9, column=0, columnspan=2, padx=10, pady=10)

check_var = ctk.BooleanVar(value=True)
self.methylation_checkbox = ctk.CTkCheckBox(self, text="Methylation", variable=check_var, onvalue=True, offvalue=False)
self.methylation_checkbox = ctk.CTkCheckBox(
self, text="Methylation", variable=check_var, onvalue=True, offvalue=False
)
self.methylation_checkbox.grid(row=10, column=0, columnspan=2, padx=10, pady=10)

self.save_button = ctk.CTkButton(self, text="Save", command=master.save)
self.save_button.grid(row=11, column=0, padx=10, pady=10)

self.cancel_button = ctk.CTkButton(self, text="Cancel", command=master.cancel)
self.cancel_button.grid(row=11, column=1, padx=10, pady=10)


class CustomWindow(ctk.CTkToplevel):
def __init__(self, master, configs):
def __init__(self, master, configs):
"""
Notes:
This window is a toplevel window of the main window. This means that the main window is its master.
The frame uses the commands save() and cancel() from the master
Notes:
This window is a toplevel window of the main window. This means that the main window is its master.
The frame uses the commands save() and cancel() from the master
"""

# initialization of the ctk.CTkToplevel class
super().__init__(master)
self.title("Customize")

# add a instance of CustomFrame to the window
self.custom_frame = CustomFrame(self, configs)
self.custom_frame.grid(row=0, column=0, columnspan=2, padx=10, pady=10, sticky="nsew")

self.custom_frame.grid(
row=0, column=0, columnspan=2, padx=10, pady=10, sticky="nsew"
)

def get_custom_frame_params(self):
"""
Makes all parameters of custom_frame available in this window.
Expand All @@ -85,18 +91,25 @@ def get_custom_frame_params(self):
self.tb_model_name = self.custom_frame.tb_model_combobox.get()
self.unit = self.custom_frame.unit_combobox.get()
self.methylated = self.custom_frame.methylation_checkbox.get()

def save(self):
"""
Saves the tight-binding parameters and closes the window.
"""
self.get_custom_frame_params()
notes = f"methlation {self.methylated}"
wrap_save_tb_params(self.tb_param_dict, self.source, self.particle, self.tb_model_name, self.unit, notes=notes)
wrap_save_tb_params(
self.tb_param_dict,
self.source,
self.particle,
self.tb_model_name,
self.unit,
notes=notes,
)
self.destroy()

def cancel(self):
"""
Closes the window.
"""
self.destroy()
self.destroy()
Loading

0 comments on commit 5bb2928

Please sign in to comment.