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

Vtk refactor #1229

Merged
merged 4 commits into from May 6, 2015
Merged

Vtk refactor #1229

merged 4 commits into from May 6, 2015

Conversation

alliepiper
Copy link
Contributor

Refactor VTKPlots.plot2D.

@doutriaux1 @chaosphere2112 Please read the following, and test/review the patch. I'll be asking specific questions inline, as there are some conventions used that I couldn't quite figure out from just reading the code/comments.

This change should neither affect nor improve external behavior at this point, but just organizes the code and separates the logic for different plot types to make the implementations more robust to changes and easier to read/follow/modify/debug.

The Pipeline class is an interface for interacting with VTK. At this point, it defines a single virtual method, plot(...), which takes arguments similar to VTKPlots.plot(...).

Eventually, the interface can grow to include methods for e.g. animation update, but for now it still just returns the map of objects, so that code should continue to function as before.

This patch:

  • Creates initial Pipeline interface.
  • Add shared logic from Plot2D into Pipeline2D subclass.
  • Adds specific implementations as Boxfill-, Isoline-, Isofill-, and MeshfillPipeline subclasses.
  • Cleans up style to conform to PEP 8. I will be enforcing this in future patches to the vcsvtk submodule, so please become familiar with the conventions: https://www.python.org/dev/peps/pep-0008/
  • Creates vcs2vtk.isTrue(...) to perform consistent user_input-->bool conversions.
    -- Sometimes we check if a variable is true with if var == 'y', sometimes with if var == 1, sometimes with if var in ('y', 1, True), and sometimes with just if var:. Let's start using this function to keep things consistent and working right the first time. This also adds the advantage of being able to fix bugs more easily -- for example, if all non-zero integers should mean true (rather than just 1), we can easily update all usages by just changing the function's definition.

Feel free to ask questions or make suggestions if there's something you don't like.

This will break several pending branches on UV-CDAT. Ping me on them if you want help porting them to the new framework after this topic lands in master.

# other cases users may enter. What about:
# - Non-zero integers other than 1?
# - "yes", "Yes", "Y"?
return x in ("y", 1, True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@doutriaux1 Should we be allowing these other cases to mean 'true'? They're fairly standard conventions, but I'm not sure what VCS expects. Is this information in the documentation?

Copy link
Contributor

Choose a reason for hiding this comment

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

@dlonie most attribute setting go through VCSValidationFunction which takes any of the has an input and sets it to True anyway. I know of one case where somehow VisTrails bypass this and sets directly the _attribute and we endup with "False" (string not boolean) but this wouldn't cover it anyway. I think we should remove this test, and if anything breaks, make sure the attribute is actually set via VCSValidation function.

Copy link
Contributor

Choose a reason for hiding this comment

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

as far as doc goes if we use VCSValidation functions, then a "bad" value triggers an error that list "correct" possible values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds far more preferable to me. I seem to recall a lot of patches going in that would add explicit checks for these cases, but if all of that is handled by the validator, then awesome! I'll change these to just check if the variable is True and any issues that pop up will be treated a validation bugs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like this will fail after just checking for True:

https://github.com/UV-CDAT/uvcdat/blob/master/Packages/vcs/Lib/VTKPlots.py#L889

Copy link
Contributor

Choose a reason for hiding this comment

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

@dlonie you're right let's assume it is sanatize at nput time. If something breaks it's better anyway to fix the part where it should have been sanitized

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks -- just what I was looking for.

Right now we have:

checkTrueFalse
checkOnOff
checkYesNo

Would it make sense to replace all of these with a standard checkBoolean that tests all of these cases and sets to True/False?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not as part of this patch, but as a later issue? It seems these all do the same thing but in slightly different ways.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not touch these functions per say, we might need these for something else that really just need yesno (and not boolean) But you're right let's create an issue to create a unifying function that understands all these and sets to True/False, checkBoolean should really only check if the input is a boolean, let's think of a better name, I liked checkOnOff but that's already used.Maybe checkTrigger ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add that when I make this change, and leave the other functions as-is. We can always port usages of them later as needed.

I'll add a checkBoolean that strictly checks True/False, and a checkFuzzyBoolean that permits the other representations.

@aashish24 aashish24 added this to the 2.2 milestone Apr 23, 2015
@aashish24
Copy link
Contributor

@doutriaux1 will provide comments after we tag 2.2 today. @dlonie we would like to have it merged as soon as possible.

@doutriaux1 doutriaux1 modified the milestones: 2.3, 2.2 Apr 28, 2015
@alliepiper
Copy link
Contributor Author

Any progress on this?

@doutriaux1
Copy link
Contributor

Looks like this is the week @dlonie

"""Implementation of the Pipeline interface for VCS boxfill plots.

Internal variables:
- self._legend: Contour labels.
Copy link
Contributor

Choose a reason for hiding this comment

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

legend actually has another meaning in VCS vs "labels" the legend is used to display which lines represent what. If think "labels" or "ContourLabels" might be better here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, this is the variable named legend in the original plot2D, so I just kept the name. I'll rename it.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh I see we're in boxfill... yes this is probably the strings/labels to draw on the legend, user-specified. I guess it's an ok name in this case, since we're talking about labels on legend....

@doutriaux1
Copy link
Contributor

@dlonie I'm going to test it a bit now that I have commented on your questions. LOTS of conflicts with master/release now... Are you going to bring everything back in?
@aashish24 I would like to merge this soon, but not in master until 2.2 is out. Where should this be merged though? It would be nice to start new development from this now.

@alliepiper
Copy link
Contributor Author

@doutriaux1 Don't worry too much about testing or resolving conficts at this point. I'll merge the changes in master back into this, and then we can do testing. After I get this resync'd with master, let's merge ASAP so we don't diverge too much again.

@doutriaux1
Copy link
Contributor

@dlonie ok, but where to merge to? There's conflict with master and I don't think we want master to get this right now as it has not been thoroughly tested. release is not an option, @aashish24 is it time to create a "devel"/"experimental" branch (off off master/release) ?

@alliepiper
Copy link
Contributor Author

Definitely not release. I'd say testing and merging to master should be sufficient. There isn't any new behavior or changes to functionality here, all I've done is separate out the implementations and strip out the bits that would never execute for a given plot type.

I've specifically kept significant changes out of this branch to preserve the behavior of master to make sure that we can get it in quickly. I'd rather not put this into a long-term branch off of master, as that is going to just keep diverging and require manual updating.

Let's get this into master and then we can work on this going forward. VTKPlots.plot2d really needs to go away ASAP before any more bugs spawn from it :P

@doutriaux1
Copy link
Contributor

@dlonie fine by me but @aashish24 didn't even want the release bits to go into master... I'm not quite sure what he has in mind for master... Can you please merge master AND release into this one (or a new branch) for now so that we can really test it. I really don't want master to get dirty that's what people clone right out of git. Thanks.

@alliepiper
Copy link
Contributor Author

Hmm. I'll just do master at the moment, and release when we merge release in. I wasn't aware that release was diverging from master like that. Typically changes that go into a release branch also go into master. @aashish24 What's going on with master?

@doutriaux1
Copy link
Contributor

@dlonie @aashish24 tried to explained it to me there: #1259

This should probably replace the other similar functions for
consistency on the backend, but this works for now.
David C. Lonie added 3 commits May 5, 2015 15:19
This change shouldn't affect external behavior at this point, but
just organizes the code and separates the logic for different plot
types to make the implementations more robust to changes and easier
to read/follow/debug.

The Pipeline class is an interface for interacting with VTK. At this
point, it defines a single virtual method, plot(...), which takes
arguments similar to VTKPlots.plot(...). It still returns the
undocumented map with objects that are reused for animations, so
that code should continue to function as before.

This patch:

- Creates initial Pipeline interface.
- Add shared logic from Plot2D into Pipeline2D subclass.
- Adds specific implementations as Boxfill-, Isoline-, Isofill-, and
  MeshfillPipeline subclasses.
- Cleans up style to conform to PEP 8.
- Reraise exception in new boxfill test when it makes sense (made it
  easier to track down why the test was failing.)
- Creates vcs2vtk.isTrue(...) to perform consistent user_input-->bool
  conversions.
@alliepiper
Copy link
Contributor Author

Ok, new version is rebased on current master and incorporates feedback from @doutriaux1 👍 After review/testing, this should be ready to merge...somewhere, as soon as we figure out where that somewhere is!

I still believe this should go into master. We don't want to merge this into release, as it shouldn't go into 2.2 -- it should go into the master branch as that's the target for non-release development. At least, this is how it typically works in other projects.

Otherwise, we're essentially freezing master while we stabilize the release, which more or less defeats the purpose of the release branch.

@aashish24 Can you clarify what goes where?

@aashish24
Copy link
Contributor

this change should not go into release. This is a major change and should only be merged into master. Earlier, I have merged relevant changes into master from release to make sure that we have all the bug fixes in master as well. After this branch goes into master, any changes to these files will have to target particular branch. So in summary:

  1. Merge this branch into master only if @doutriaux1 approved it
  2. Merge any relevant changes from release into master (I can do it)
  3. Do not merge master into release anymore
  4. We should plan from 2.3 from master in next month or so.

@alliepiper
Copy link
Contributor Author

@aashish24 Thanks, sounds good.

@doutriaux1
Copy link
Contributor

@aashish24 ok we all agree it should go into master only.
@aashish24 is everything from release into master as well? I would like to create a release branch on uvcdat-testdata before things get too crazy.

@doutriaux1
Copy link
Contributor

ok all test pass for me let's do this!
https://open.cdash.org/buildSummary.php?buildid=3801982

doutriaux1 added a commit that referenced this pull request May 6, 2015
@doutriaux1 doutriaux1 merged commit 538cf4b into CDAT:master May 6, 2015
@aashish24
Copy link
Contributor

thanks @doutriaux1. @dlonie if we setup a mechanism to follow branch when we checkout testdata would that break anything?

@doutriaux1 I will make sure that everything in release is in master as well.

@doutriaux1
Copy link
Contributor

thanks @aashish24

@chaosphere2112 chaosphere2112 mentioned this pull request May 7, 2015
@aashish24 aashish24 mentioned this pull request May 22, 2015
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

3 participants