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

'Done' Button Implementation #2177

Merged
merged 20 commits into from
Sep 1, 2021
Merged

Conversation

jepietryga
Copy link
Contributor

This pull request implements a 'Done' button, specifically intended for iterative reconstruction algorithms that reach a desirable level of completion prior reaching the set number of iterations. Operators that are "Doneable" will be able to use this button to early terminate processing, but unlike cancel, the data will still be useable by subsequent operators (such as "Square Root") without restarting the pipeline.

Most changes are necessary for this functionality, but Recon_SIRT.py was changed simply to take advantage of it.

This addresses issue #2162.

@jepietryga jepietryga force-pushed the doneButton branch 2 times, most recently from e3cd470 to 4b9aa13 Compare June 4, 2021 15:43
@jtschwar jtschwar requested a review from cryos June 4, 2021 19:40
Copy link
Member

@cjh1 cjh1 left a comment

Choose a reason for hiding this comment

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

A few inline comments, would be happy to talk in person about them.

@@ -81,7 +81,23 @@ void ProgressDialogManager::operationStarted()
layout->addWidget(progressBar);
}
layout->addWidget(progressWidget);
if (op->supportsCancelingMidTransform()) {
if (op->supportsDoneingMidTransform()) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we come up with a better name I don't "Doneing" is a word :-) What about "early completion"

@@ -34,7 +34,8 @@ enum class OperatorState
Complete,
Canceled,
Error,
Edit
Edit,
Done
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a new state or can we just use Complete?

bool isCanceled() { return m_state == OperatorState::Canceled; }
bool isDone()
{
return m_state == OperatorState::Done || m_state == OperatorState::Complete;
Copy link
Member

Choose a reason for hiding this comment

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

For the look of this, Complete could be used without need to add another state.

@@ -144,6 +145,11 @@ OperatorPython::OperatorPython(DataSource* parentObject)
qCritical() << "Unable to locate is_cancelable.";
}

d->IsDoneableFunction = d->InternalModule.findFunction("is_doneable");
Copy link
Member

Choose a reason for hiding this comment

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

supports_early_completion?

@@ -144,6 +145,11 @@ OperatorPython::OperatorPython(DataSource* parentObject)
qCritical() << "Unable to locate is_cancelable.";
}

d->IsDoneableFunction = d->InternalModule.findFunction("is_doneable");
if (!d->IsDoneableFunction.isValid()) {
qCritical() << "Unable to locate is_doneable.";
Copy link
Member

Choose a reason for hiding this comment

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

You probably want a return, as the rest of the function is not going to work without the python function.

@cjh1
Copy link
Member

cjh1 commented Aug 18, 2021

@jepietryga Why was thirdparty/pybind11 changed?

@jepietryga
Copy link
Contributor Author

@jepietryga Why was thirdparty/pybind11 changed?

It shouldn't have been, I didn't make any modifications to the thirdparty/pybind11 when I ran "git commit *".

I have been having some git issues, so it's possible I accidentally pulled the most recent pybind11 while I was trying to fix things?

It may be necessary for me to drop this current pull request and set-up a new one once these things are fixed.

@Hovden
Copy link
Contributor

Hovden commented Aug 25, 2021

@jepietryga @cjh1 Is this one ready for merge?

@cjh1
Copy link
Member

cjh1 commented Aug 25, 2021

I think there are still some flake8 and clang format issues?

@jepietryga
Copy link
Contributor Author

jepietryga commented Aug 25, 2021

I'll finalize this.

There are some flake8 issues that I can't fix too easily, so some advice would be appreciated:
Recon_DFT.py is a file I hadn't manipulated, but has one really long line due to deep nesting and readability.
Recon_TV_Minimization.py has a complexity issue in the class' transform function. I added two additional conditionals to break out of loops if something is early_completed, but this seems to have pushed it into flake8's notice.

The other flake issues and one clang issue should be quickly fixed.

EDIT: The two above listed issues are the only remaining format concerns from flake8, clang is 100% good now!

@cjh1
Copy link
Member

cjh1 commented Aug 25, 2021

I'll finalize this.

There are some flake8 issues that I can't fix too easily, so some advice would be appreciated:
Recon_DFT.py is a file I hadn't manipulated, but has one really long line due to deep nesting and readability.
Recon_TV_Minimization.py has a complexity issue in the class' transform function. I added two additional conditionals to break out of loops if something is early_completed, but this seems to have pushed it into flake8's notice.

The other flake issues and one clang issue should be quickly fixed.

EDIT: The two above listed issues are the only remaining format concerns from flake8, clang is 100% good now!

We can add some #no qa comments for things that you haven't touched or don't want to tackle, but we want flake8 to be green otherwise other things will slip in.

Copy link
Member

@cjh1 cjh1 left a comment

Choose a reason for hiding this comment

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

@jepietryga We have fixed up the CI issues on our end of the CI is now clean ( along with you clang-format and flake8 fixes, thank you. I have one more suggestion and you can take it or leave it. Seeing earlyCompleted typed out makes me thing that is should just be completed and CompletableOperator, others feel free to chime in. I think we are close, I just want to get the naming right as this will be part of the interface.


/// Distinction between this and isFinished is necessary to prevent cascading
/// errors
bool isEarlyCompleted() { return m_state == OperatorState::Complete; }
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this just be isCompleted, more general and could be used else where.

@@ -58,9 +58,15 @@ def transform(self, dataset, Niter=1, Nupdates=0, beta=1.0):
counter = 1
for i in range(Niter):

if self.early_completed:
Copy link
Member

Choose a reason for hiding this comment

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

I think this should just be completed, if so we should make the change elsewhere as well.

@@ -4,7 +4,7 @@
import time


class ReconSirtOperator(tomviz.operators.CancelableOperator):
class ReconSirtOperator(tomviz.operators.EarlyCompletableOperator):
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to be a pain but seeing the names "written" down, may be this should just be CompletableOperator

@jepietryga
Copy link
Contributor Author

In process of making the recommended changes! I think the recommended naming makes sense.

@jepietryga
Copy link
Contributor Author

jepietryga commented Aug 28, 2021

@cjh1 Code should be working! The things I checked were using a sample dataset, then trying ART, SIRT, and TV Minimization. Part of the way through a reconstruction, I clicked the "Ok" button, then did some data transforms to ensure it didn't try to redo the pipeline

tomviz/python/Recon_DFT.py Outdated Show resolved Hide resolved
jepietryga and others added 11 commits September 1, 2021 09:53
…tive operators to be prematurely finished but still have their data used in a pipeline.

Signed-off-by: jepi <jacobpietryga@gmail.com>
Signed-off-by: Jacob Pietryga <jepi@umich.edu>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepi <jacobpietryga@gmail.com>
Signed-off-by: Jacob Pietryga <jepi@umich.edu>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepi <jacobpietryga@gmail.com>
Signed-off-by: Jacob Pietryga <jepi@umich.edu>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepi <jacobpietryga@gmail.com>
Signed-off-by: Jacob Pietryga <jepi@umich.edu>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepi <jacobpietryga@gmail.com>
Signed-off-by: Jacob Pietryga <jepi@umich.edu>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: Jacob Pietryga <jepi@umich.edu>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: Jacob Pietryga <jepi@umich.edu>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
…ators to be early cancelable

Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
jepietryga and others added 9 commits September 1, 2021 09:53
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Signed-off-by: jepietryga <jacobpietryga@gmail.com>
Copy link
Member

@cjh1 cjh1 left a comment

Choose a reason for hiding this comment

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

@jepietryga LGTM, thanks for sticking with it!

@cjh1 cjh1 merged commit 88f8395 into OpenChemistry:master Sep 1, 2021
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.

None yet

4 participants