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

Python raven #1685

Merged
merged 17 commits into from
Feb 14, 2022
Merged

Python raven #1685

merged 17 commits into from
Feb 14, 2022

Conversation

PaulTalbot-INL
Copy link
Collaborator

@PaulTalbot-INL PaulTalbot-INL commented Oct 19, 2021


Pull Request Description

What issue does this change request address? (Use "#" before the issue to link it, i.e., #42.)

Starts on #1682

What are the significant changes in functionality due to this change request?

Adds a Python "driver" instance that wraps RAVEN simulations.

NOTE does not currently support multiple subsequent runs on the same workflow without re-initializing.


For Change Control Board: Change Request Review

The following review must be completed by an authorized member of the Change Control Board.

  • 1. Review all computer code.
  • 2. If any changes occur to the input syntax, there must be an accompanying change to the user manual and xsd schema. If the input syntax change deprecates existing input files, a conversion script needs to be added (see Conversion Scripts).
  • 3. Make sure the Python code and commenting standards are respected (camelBack, etc.) - See on the wiki for details.
  • 4. Automated Tests should pass, including run_tests, pylint, manual building and xsd tests. If there are changes to Simulation.py or JobHandler.py the qsub tests must pass.
  • 5. If significant functionality is added, there must be tests added to check this. Tests should cover all possible options. Multiple short tests are preferred over one large test. If new development on the internal JobHandler parallel system is performed, a cluster test must be added setting, in XML block, the node <internalParallel> to True.
  • 6. If the change modifies or adds a requirement or a requirement based test case, the Change Control Board's Chair or designee also needs to approve the change. The requirements and the requirements test shall be in sync.
  • 7. The merge request must reference an issue. If the issue is closed, the issue close checklist shall be done.
  • 8. If an analytic test is changed/added is the the analytic documentation updated/added?
  • 9. If any test used as a basis for documentation examples (currently found in raven/tests/framework/user_guide and raven/docs/workshop) have been changed, the associated documentation must be reviewed and assured the text matches the example.

Perform Unit Tests for running RAVEN in Python workflows.
SQA Note: unittest requires all test methods start with test_, so we excercise SQA exception
SQA Note: ALL tests take no input and provide no output, so these are omitted in the
test_* method descriptions.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note these SQA notes ...

mandd
mandd previously requested changes Oct 19, 2021
@PaulTalbot-INL
Copy link
Collaborator Author

PaulTalbot-INL commented Oct 19, 2021

Apparently the ForwardSampling inputs from the Workshop are constructed, not in the repo.

I think I'll make a faster-running "basic" RAVEN framework test workflow to use instead of the workshop workflow.

Copy link
Collaborator

@Jimmy-INL Jimmy-INL left a comment

Choose a reason for hiding this comment

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

Why is 'dependencies.py' not included in the PR? I've added the following and it is working fine.
<rise/> <pandas>1.2.5</pandas> <pandas-profiling/>

import utils.TreeStructure as TS
from BaseClasses import MessageUser

class Raven:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to combine Driver and this class? I mean to create a class that be used by both.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's definitely some commonality that could be further abstracted; I think some utilities for drivers might be in order.

I initially was going to move Driver.py into a Drivers folder in framework, but that caused a lot of things to complain loudly, so for now it makes sense to have Driver where it's at until we are more sure of how we want the custom usage to go.

One of my next action items would be to abstract some of the library loading and checking so that it can be commonly used between the default driver and custom drivers such as this python-based one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added some utility abstraction in the latest push

@aalfonsi
Copy link
Collaborator

aalfonsi commented Oct 20, 2021

I will add my review tomorrow night if it is okay for you guys. From a quick check (not knowing the future plan for this "driver" system), I do not see what's the scope of this additional wrapper, since mostly it is a mirror of what the Driver.py does or can do.

What's the final goal of this development ? (I ask just to have some context for tailoring the review to what this will need to be and not what it is right now).

@PaulTalbot-INL
Copy link
Collaborator Author

Why is 'dependencies.py' not included in the PR? I've added the following and it is working fine. <rise/> <pandas>1.2.5</pandas> <pandas-profiling/>

The additions in this PR don't require any library changes. It's already on the table to do a lib update, and that would be a better time to consider doing Jupyter compatibility.

@PaulTalbot-INL
Copy link
Collaborator Author

PaulTalbot-INL commented Oct 20, 2021

I will add my review tomorrow night if it is okay for you guys. From a quick check (not knowing the future plan for this "driver" system), I do not see what's the scope of this additional wrapper, since mostly it is a mirror of what the Driver.py does or can do.

What's the final goal of this development ? (I ask just to have some context for tailoring the review to what this will need to be and not what it is right now).

It's quite a bit different from the Driver.py module, in that it offers an interface for handling RAVEN from within a Python environment such as a Jupyter notebook or as part of other Python-based workflows.

In the design meeting we had, we identified one of the most flexible and useful extension of RAVEN towards making it a part of cloud-based computing applications was to allow it to be accessed and integrated via a Python controller, rather than exclusively from the command line. This might have been possible for a dedicated individual before, but this establishes a straightforward API for doing so, and is the first step in making this feature fully-fledged.

This would also make possible something @aalfonsi and @crisrab talked about many times before: holding objects in memory after a run is complete so that the user can explore them, and maybe in the future add steps to do additional sampling, postprocessing, etc.

Copy link
Collaborator

@mandd mandd left a comment

Choose a reason for hiding this comment

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

@PaulTalbot-INL: I noticed several changes have been added since my last review. I have few comments here:

  1. I am not sure what is the real advantage by moving the content of Driver.py into DriverUtils.py (e.g., adding further abstractions). It appears to me i just adds more code
  2. the core of your PR are the methods getEntity and loadWorkflowFromFile which call directly methods of Simulation class. These methods can be actually part of the simulation class.
    I played a bit with you PR and I tried to make some changes on my local branch followed my observations in 2) in a workflow as follows:
    from Simulation import Simulation
    simulation = Simulation(frameworkDir)
    simulation.loadWorkflowFromFile(targetWorkflow)
    returnCode = simulation.run()
    results = simulation.getEntity('DataObjects', 'results')

The methods getEntity and loadWorkflowFromFile were actually copied and pasted into theSimulation class. I think it is a simpler structure.

@PaulTalbot-INL
Copy link
Collaborator Author

PaulTalbot-INL commented Oct 25, 2021

in reply to @mandd ...

(1) was added on request from @wangcj05 above.

(2) the intent is to provide a protected, clean API for the user; Simulation is fairly involved and absolutely expects the workflow to be run once and from the command line. Building in an API layer in between will allow us to accelerate the use of RAVEN by simplifying the interactions and protecting the parts of RAVEN that really shouldn't be tinkered with for successful operation. This will also make documentation very easy; imagine documenting Simulation as an externally-importable object in generic Python right now!

@mandd
Copy link
Collaborator

mandd commented Oct 28, 2021

Apologies for the late reply; given my (poor) experience with Simulation.py, I had to do some homework and some testing. Would it suffice to create a class that wraps what we want a user to see?
I have played a bit and I have create a fake PR to better describe what I have in mind:
#1695
I am open to comments/suggestions.

@aalfonsi
Copy link
Collaborator

@mandd it seems we are on the same page...I was actually thinking the same thing and did something very similar locally (without changing the simulation)...Tonight (just for fun) I will try to post the code for you guys to discuss

@PaulTalbot-INL
Copy link
Collaborator Author

PaulTalbot-INL commented Oct 28, 2021

Apologies for the late reply; given my (poor) experience with Simulation.py, I had to do some homework and some testing. Would it suffice to create a class that wraps what we want a user to see? I have played a bit and I have create a fake PR to better describe what I have in mind: #1695 I am open to comments/suggestions.

Isn't that what we did here? I don't see a mechanical difference between what's in this PR and what you put down; maybe I missed something. I think we all have the same idea in mind.

@wangcj05
Copy link
Collaborator

wangcj05 commented Nov 3, 2021

@mandd it seems we are on the same page...I was actually thinking the same thing and did something very similar locally (without changing the simulation)...Tonight (just for fun) I will try to post the code for you guys to discuss

@aalfonsi Do you have any update on this? Are you still going to push your version of raven as library to the repository?

@aalfonsi
Copy link
Collaborator

aalfonsi commented Nov 3, 2021

@wangcj05 I added my modifications in here https://github.com/idaholab/raven/tree/test_simulation

It is nothing special (mostly following Paul's idea, but without a new wrapper)....It would require cleaning, a better way to import the Driver (just to set up the right environment) and to scan the Simulation.py to protect the methods that can not be called from outside (basically making the Simulation the API for external integration).

@PaulTalbot-INL PaulTalbot-INL marked this pull request as draft November 3, 2021 15:01
@PaulTalbot-INL PaulTalbot-INL changed the title Python raven [WIP] Python raven Nov 3, 2021
@PaulTalbot-INL PaulTalbot-INL marked this pull request as ready for review February 10, 2022 21:31
@PaulTalbot-INL PaulTalbot-INL changed the title [WIP] Python raven Python raven Feb 10, 2022
@@ -1,78 +0,0 @@
# Copyright 2017 Battelle Energy Alliance, LLC
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test is redundant with the PythonRaven unit test now.

@moosebuild
Copy link

Job Test Fedora 32 on 5b5a400 : invalidated by @PaulTalbot-INL

Errored by Ray: "ValueError: Ray component metrics_export is trying to use a port number 52953 that is used by other components. Port information: {''gcs'': [], ''object_manager'': [], ''node_manager'': [], ''gcs_server'': [], ''client_server'': [], ''dashboard'': [], ''dashboard_agent'': [52953], ''metrics_export'': [52953], ''redis_shards'': [], ''worker_ports'': []} If you allocate ports, please make sure the same port is not used by multiple components."

@moosebuild
Copy link

Job Test qsubs sawtooth on 5b5a400 : invalidated by @PaulTalbot-INL

First 4 tests unexpectedly timed out, no others did.

@PaulTalbot-INL PaulTalbot-INL dismissed mandd’s stale review February 14, 2022 16:14

These review comments have been addressed in the RAVEN design meeting. Notes are being provided on individual comment resolutions.

Copy link
Collaborator

@wangcj05 wangcj05 left a comment

Choose a reason for hiding this comment

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

I have a couple of minor comments for your consideration. @PaulTalbot-INL

# See the License for the specific language governing permissions and
# limitations under the License.
"""
Demonstrate running RAVEN in Python workflows.
Copy link
Collaborator

@wangcj05 wangcj05 Feb 14, 2022

Choose a reason for hiding this comment

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

@PaulTalbot-INL I think we should keep this test for now. It tests the step by step execution capability. When you have a new design, you are very welcome to change or remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does not work now; I don't think it's worth maintaining since it's been replaced by the TestPythonRaven and DemoPythonRaven tests. I don't think it's worth our time fixing this test, since Andrea offered it as an alternative to having the driver wrapper (PythonRaven) and use Simulation directly, which we decided we didn't want to encourage as part of the design meeting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, it sounds good to me. By the way, I do not think it will take a lot of time to fix it.

Comment on lines +105 to +106
##TODO REMOVE PP3 WHEN RAY IS AVAILABLE FOR WINDOWS
utils.add_path_recursively(os.path.join(frameworkDir,'contrib','pp'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is just a question, are we still use 'pp' for windows or do we switched to ray? @joshua-cogliati-inl

@moosebuild
Copy link

Job Test qsubs sawtooth on c055921 : invalidated by @PaulTalbot-INL

unexpected test failure only in sawtooth checking consistency

@PaulTalbot-INL
Copy link
Collaborator Author

FYI @wangcj05 (as plugin developer notification) it appears this breaks something in the SR2ML and Logos tests, possibly the implicit importing of "Driver" to load the RAVEN environment. Examples of fixes for that can be seen in the unit test fixes in this PR.

@wangcj05
Copy link
Collaborator

FYI @wangcj05 (as plugin developer notification) it appears this breaks something in the SR2ML and Logos tests, possibly the implicit importing of "Driver" to load the RAVEN environment. Examples of fixes for that can be seen in the unit test fixes in this PR.

Thanks @PaulTalbot-INL, I will start to update the plugins after the merge of this PR.

@wangcj05
Copy link
Collaborator

checklist is good.

@wangcj05 wangcj05 merged commit 0022dc9 into idaholab:devel Feb 14, 2022
@wangcj05
Copy link
Collaborator

@PaulTalbot-INL I have merged your PR, thanks for your contributions!

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.

6 participants