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

Create a GudPy class #487

Merged
merged 300 commits into from
Mar 14, 2024
Merged

Create a GudPy class #487

merged 300 commits into from
Mar 14, 2024

Conversation

rhinoella
Copy link
Contributor

@rhinoella rhinoella commented Jan 29, 2024

Very large PR that serves to reduce bugs and create a distinction between the headless and GUI modes of gudpy.

Key goals of this PR:

  • Separate headless and GUI code
  • Remove nexus processing
  • Create a fully functioning headless mode
  • Refactor to avoid needing multiple functions for the same purpose of running processes
  • Improve safety in file management, run everything in context managers so that if there is an issue in execution the filesystem will not be modified
  • Remove responsibilities from GudPyMainWindow
  • Improve error handling and error reporting
  • Implement the new project-system

Implements three significant modules:

core/gudpy

The main backend module that handles all of the processing logic, made to be completely separate from Qt. Contains the following classes:

GudPy

Class to act as the main GudPy backend. Holds all the necessary data and implements all functions needed to run GudPy headlessly.

Process

Base class for all processes.

Implements a key function _outputChanged which is called on output of the underlying process, and allows the class to be subclassed by a QThread with this function to be overriden by a signal-emitting function- therefore removing the need to reimpliment the logic to be compatible with the GUI version.

Purge(Process), Gudrun(Process)

Classes to manage the running of purge_det and gudrun_dcs binaries.

Runs all processes inside a temporary directory using a context manager to avoid polluting the user's directory. Replaces the use of subprocess.run() with subprocess.Popen to allow simpler live-output capture.

GudrunIterator, CompositionIterator

Class to manage the iteration of gudrun_dcs.

Takes away logic/task queing responsibilities from the iteration dialog classes. Replaces using a queue with a list of Gudrun objects that are iterated over.

RunModes

Class that combines the old gudpy/core/run_containers_as_samples.py and gudpy/core/run_individual_files.py modules into one class that can manage different modes to run gudrun.

BatchProcessing

Class to manage the batch processing workflow, implementing all the newly refactored methods.

gui/widgets/core/worker

The module that provides GUI compatibility/Multithreading to the classes in core/gudpy.

Subclasses QThread and the processing classes in core/gudpy to implement slots and signals and extra logic needed for the GUI. Allows for the headless mode to maintain complete separation from Qt.

Replaces the previous use of QProcess with creating QThread workers for each process.

gui/widgets/core/control

Contains the class GudPyController to act as the controller between the GUI and the backend (GudPy) class.
Significantly removes responsibility from GudPyMainWindow and creates a separation between logic and GUI methods.

Reimplements functions from GudPy class to accomodate the GUI.

@rhinoella rhinoella requested a review from trisyoungs March 6, 2024 14:55
@rhinoella rhinoella mentioned this pull request Mar 6, 2024
Copy link

github-actions bot commented Mar 6, 2024

Test Results

  3 files    3 suites   51m 16s ⏱️
 92 tests  92 ✅ 0 💤 0 ❌
276 runs  276 ✅ 0 💤 0 ❌

Results for commit 76026cb.

♻️ This comment has been updated with latest results.

Copy link
Member

@trisyoungs trisyoungs left a comment

Choose a reason for hiding this comment

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

Huuuuuge!

It's hard to do anything other than a sweeping review on a PR of this size, but the overriding impression is that this makes things a lot more harmonious, a lot cleaner, and a lot easier to read and understand workflow-wise compared to what we had before. Fabulous job!

Some small comments and typo corrections, but basically ready to go in and move on.

gudpy/gui/widgets/dialogs/io.py Outdated Show resolved Hide resolved
gudpy/core/gudpy.py Outdated Show resolved Hide resolved
gudpy/core/gudrun_file.py Outdated Show resolved Hide resolved
gudpy/core/iterators.py Outdated Show resolved Hide resolved
gudpy/gui/widgets/core/control.py Outdated Show resolved Hide resolved
gudpy/gui/widgets/core/control.py Outdated Show resolved Hide resolved
gudpy/gui/widgets/core/control.py Outdated Show resolved Hide resolved
gudpy/gui/widgets/core/worker.py Outdated Show resolved Hide resolved
@rhinoella rhinoella merged commit ade4cd4 into develop Mar 14, 2024
4 checks passed
@rhinoella rhinoella deleted the gudpy-class branch March 14, 2024 12:36
This was referenced Mar 19, 2024
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.

2 participants