Skip to content

App restructure#10

Merged
NCCU-Schultz-Lab merged 13 commits into
mainfrom
app-restructure
Apr 16, 2026
Merged

App restructure#10
NCCU-Schultz-Lab merged 13 commits into
mainfrom
app-restructure

Conversation

@NCCU-Schultz-Lab
Copy link
Copy Markdown
Collaborator

This pull request introduces significant improvements to project documentation, dependency management, and code robustness for the QuantUI-local project. The key changes include adding a comprehensive project context file for AI assistants, improving import safety and API exposure for the main app class, updating dependencies for molecule parsing, and enhancing error handling in geometry optimization. Additionally, minor build and test script updates were made to ensure the main app imports correctly.

Documentation and Project Context:

  • Added a detailed .github/copilot-instructions.md file describing the project's architecture, constraints, file structure, supported features, and development conventions, providing stable context for AI coding assistants and contributors.

Dependency and Import Improvements:

  • Added rdkit as a required dependency in environment.yml to support molecule parsing and PubChem integration.
  • Updated quantui/pubchem.py to import Descriptors directly from rdkit.Chem and use it for molecular weight calculations, improving clarity and reliability. [1] [2] [3]

API Exposure and Import Safety:

  • Moved QuantUIApp import to the end of quantui/__init__.py and added it to __all__, ensuring it's always available as a top-level import and preventing circular import issues. [1] [2]

Robustness and Error Handling:

  • Added an explicit check in quantui/optimizer.py to raise a RuntimeError if no Atoms object is attached to the calculator before running geometry optimization, preventing obscure downstream errors.

Build and Test Script Updates:

  • Updated Apptainer container build and test scripts to check that QuantUIApp imports successfully, ensuring container integrity. [1] [2]
  • Added notebooks/_inspect_nb.py utility script to inspect notebook structure for debugging or validation.

NCCU-Schultz-Lab and others added 3 commits April 11, 2026 23:40
Consolidates all notebook widget logic (cells 3–10) into a single
QuantUIApp class. Also adds None guard to optimizer.py calculate()
to satisfy mypy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add stable AI assistant context and developer test artifacts. Introduces .github/copilot-instructions.md describing repo structure, architecture, constraints, and development guidance for QuantUI-local. Adds notebooks/_inspect_nb.py (notebook inspector) and a temporary notebooks/app_test.ipynb to exercise the QuantUIApp UI, plus a pre-FR012 backup notebook (molecule_computations.pre-fr012.ipynb). Streamlines/updates notebooks/molecule_computations.ipynb in preparation for the FR-012 app refactor. Update apptainer/quantui-local.def to run import checks for QuantUIApp during build/runtime. Add tests/test_app.py and update tests/test_pubchem.py to support the new test coverage.
- app.py: QuantUIApp with all widget logic (FR-012 Phase 1-4)
- app.py: Errors now show clean card in Calculate tab; full traceback
  goes to Output tab and ~/.quantui/logs/error_log.txt
- app.py: clear_output fires synchronously on Run click (not in thread)
- app.py: Remove Dark Blue/Maroon themes (imperceptible hue shift)
- pubchem.py: Fix missing 'from rdkit.Chem import Descriptors' import
- environment.yml: Add rdkit>=2022.03.1
- tests/test_app.py: 38 new tests for QuantUIApp
- notebooks/molecule_computations.ipynb: Collapsed to 3-cell launcher
- apptainer/quantui-local.def: Add QuantUIApp import check
- planning/: Full TODO/ planning layout
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR restructures QuantUI-local by moving the notebook-implemented UI into a dedicated QuantUIApp class, tightening top-level API exposure, and updating dependencies/docs to support more robust molecule import and runtime behavior.

Changes:

  • Introduces quantui/app.py with a self-contained QuantUIApp and updates the student notebook to be a thin launcher.
  • Improves dependency/import robustness (RDKit descriptor import, conditional availability flags) and adds an optimizer precondition check.
  • Expands project documentation and updates container/build checks to validate the new app import.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/test_pubchem.py Skips a real-network RDKit-dependent test when RDKit isn’t installed.
tests/test_app.py Adds a new test suite for QuantUIApp construction and core behaviors.
quantui/pubchem.py Imports Descriptors directly and uses it for molecular weight metadata.
quantui/optimizer.py Raises a clear error if the ASE calculator has no attached Atoms.
quantui/app.py Adds the new application class (widgets, callbacks, dispatch, rendering).
quantui/__init__.py Exposes QuantUIApp as a top-level import and imports it last.
notebooks/molecule_computations.ipynb Replaces notebook logic with a thin QuantUIApp().display() launcher.
notebooks/_inspect_nb.py Adds a small helper script to inspect notebook structure.
local-setup/environment.yml Adds rdkit to the conda environment dependencies.
apptainer/quantui-local.def Adds container build/test checks to ensure QuantUIApp imports.
.github/copilot-instructions.md Adds comprehensive project context and development constraints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread quantui/app.py
Comment thread apptainer/quantui-local.def
Comment thread notebooks/_inspect_nb.py Outdated
Comment thread tests/test_app.py
Comment thread quantui/app.py Outdated
Comment thread quantui/app.py
Comment thread quantui/app.py
Comment thread quantui/app.py
NCCU-Schultz-Lab and others added 8 commits April 16, 2026 18:47
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…rresponding backend is unavailable

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…uction never fails due to telemetry/logging I/O

QuantUIApp.__init__ previously called _calc_log.log_event(...), which writes to ~/.quantui/logs/ and can raise OSError in read-only or sandboxed environments (including some CI runners).

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Move all display/rendering work back to the main thread (e.g., store the fetched molecule and schedule a UI update callback) and keep the background thread limited to pure data fetching/parsing.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…-thread-only rendering

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@NCCU-Schultz-Lab
Copy link
Copy Markdown
Collaborator Author

@copilot Please fix the following lint failure:

black....................................................................Failed

  • hook id: black
  • files were modified by this hook

reformatted tests/test_app.py

Agent-Logs-Url: https://github.com/The-Schultz-Lab/QuantUI-local/sessions/bf643eec-8667-4aba-90f5-68f761866167

Co-authored-by: NCCU-Schultz-Lab <230880974+NCCU-Schultz-Lab@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 16, 2026

@copilot Please fix the following lint failure:

black....................................................................Failed
...

Fixed in commit 4c31f91 — ran black tests/test_app.py to apply the required formatting.

Small cleanup across notebooks and package config:

- notebooks/molecule_computations.ipynb: add minor whitespace, simplify a warning print (remove unnecessary f-string) and add a blank line before QuantUIApp().display().
- notebooks/tutorials/02_basis_set_study.ipynb: reorder and simplify imports (keep Molecule and parse_xyz_input grouped, swap/run SessionResult and run_in_session order) and add a separating blank line.
- pyproject.toml: add UP045 to the ruff ignore list (allow using X | None instead of Optional[X]).
- quantui/app.py: adjust import grouping/parentheses for pubchem imports to fix formatting.

These are non-functional cleanups to improve readability and satisfy linting/style preferences.
@NCCU-Schultz-Lab NCCU-Schultz-Lab merged commit 626eb3d into main Apr 16, 2026
4 checks passed
@NCCU-Schultz-Lab NCCU-Schultz-Lab deleted the app-restructure branch April 16, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants