-
Notifications
You must be signed in to change notification settings - Fork 40
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
New feature for DeployInst #529
Conversation
…l cyclus::ManagerInst instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GREAT WORK! This is a valuable contribution on its own (likely for you and other users), but is also shockingly timely with my personal needs.
I left a few comments about, maybe some require discussion so I'll keep an eye out for replies.
There is one not-small change we need to discuss: the integration tests. I'd like some input from you, @gonuke, @nuclearkatie, and/or anyone else on if this should be tested in test_regression.py
or if we should make a new test file, test_integration.py
. Because this is upgrading DeployInst
behavior, I could see an argument for regression, but the original intention was an integration test ensuring DeployInst
and ManagerInst
play correctly together within GrowthRegion
.
Thanks so much for your hard work on this!
P.S. This was edited to delete some confusion over where the regression test input files live. There is a dir (tests/input/
) that has input files that aren't used for these tests (maybe they were once upon a time). The input files for the tests actually come from input/
.
src/manager_inst_tests.cc
Outdated
@@ -1,10 +1,10 @@ | |||
#include "manager_inst_tests.h" | |||
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |||
TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} | |||
//TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this line and line 7 are commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran cycamore_unit_tests
with and without these commented out and both times it ran 195 tests... I didn't do a clean build in between so maybe that's why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When these lines are included (not commented out) I got errors when building cycamore because of duplicate definitions. Removing this and line 7 removes the duplication. You most likely didn't run into this issue because it was happening on the build and not with the unit tests. I will remove the commented out lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see they were added in deploy_inst_tests.cc
(along with the corresponding class definition in deploy_inst_tests.h
) so that is where the TestProducer
class duplication is coming from, since it was also defined in manager_inst_tests.h
.
I'm not sure what these lines do/don't do. I'm guessing it needs to test DeployInst
as a commodity producer, which is needed, and further, it is likely needed for both ManagerInst
and DeployInst
.
I tried deleting the duplicated definition from deploy_inst_tests.h
, and including manager_inst_tests.h
in deploy_inst_tests.cc
. Not sure that's good practice, though, but it didn't work either way. I'll play around a little more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the tests in manager_insts_tests.cc
are being run without these lines. My guess is that the initialization of the function in deploy_insts_tests.cc
is still valid for this one.
<spec> <lib>cycamore</lib><name>Sink</name> </spec> | ||
</archetypes> | ||
|
||
<commodity> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this block is even needed for this simple simulation. At least, upon skimming the resulting DBs with and without it, I didn't see a difference. We can get someone more knowledgable to weigh in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt like it was good practice to include a sink in the simulation. Also, this way it matches more with the source_sink_linear.xml
file also in that directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I meant the commodity block with the priority, not the sink. I should have done a better job w that comment :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this is a comment of the lowest priority, btw)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was just a force of habit. If you really think it needs to be removed I can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends if we prefer the input file to be a good example or to be bare bones. I was reviewing from the bare bone perspective, which given the remaining questions in Issue #530 may or may not be valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely not a necessary block, but I would NOT require its remove for this to merge.
This reverts commit 3a98763.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes are looking good! I still have questions about the TestProducer class duplication issue and what exactly is happening, which hopefully @gonuke or @nuclearkatie can help with.
In my initial review I had raised a question about whether the "integration test" belongs in test_regression.py
or not....I'm fine with it there but would like others to also weigh in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow @abachma2 - this is a great deep dive into the dusty corners of Cyclus! Because you've done that dive, I think you can better answer any questions that arise. I'd be happy to jump on a call to discuss anything.
- Is testing exhaustive enough?
- Can a deploy inst still be used without a growth region? I guess that it can since there exist tests that do this. I'm just not sure how that is handled...
" list of prototypes for" \ | ||
" decommissioned at the end of their lifetime. Deployed and" \ | ||
" decommissioned agents are registered and unregistered with a" \ | ||
" region. The user specifies a list of prototypes for" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to specify that it's a Manager
region?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean by Manager
region.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just that it's important to document what kind of region these agents are registered with. I think that's important to note in the documentation, but maybe it's more generic??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is where she previously had "growth region" and I asked that "growth" be removed because in theory it could work within another region?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair - it probably shouldn't be limited to a growth region, specifically, but - on the other hand - GrowthRegion
is the only region that implements the toolkit to be useful for registration....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@opotowsky is correct, I removed the word growth to try and make it as region agnostic as possible. I thought that the growth region was the only one currently implemented that uses registration, but this wording would be flexible for if a new one was developed.
src/manager_inst.h
Outdated
private: | ||
/// register a child | ||
void Register_(cyclus::Agent* agent); | ||
|
||
/// unregister a child | ||
void Unregister_(cyclus::Agent* agent); | ||
|
||
|
||
protected: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? I don't see anything that requires it in the other changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why I did that. I can undo that change. Would you also recommend making these functions private in src/deploy_inst.h
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its good practice for them to be private unless we need them to be otherwise
src/manager_inst_tests.cc
Outdated
@@ -1,11 +1,5 @@ | |||
#include "manager_inst_tests.h" | |||
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |||
TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is probably necessary, but we may need to discuss some of the code structure because it is not potentially shared between two institutions.
In can probably be defined inline in the single place where the TestProducer
is declared.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
class TestProducer | ||
: public cyclus::Facility, | ||
public cyclus::toolkit::CommodityProducer { | ||
public: | ||
TestProducer(cyclus::Context* ctx); | ||
~TestProducer(); | ||
|
||
cyclus::Agent* Clone() { | ||
TestProducer* m = new TestProducer(context()); | ||
m->InitFrom(this); | ||
return m; | ||
} | ||
|
||
void InitFrom(TestProducer* m) { | ||
cyclus::Facility::InitFrom(m); | ||
} | ||
|
||
void InitInv(cyclus::Inventories& inv) {} | ||
|
||
cyclus::Inventories SnapshotInv() { return cyclus::Inventories(); } | ||
|
||
void Tock() {} | ||
void Tick() {} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might need to go into a separate header file to be included in both the manager_inst
and the deploy_inst
tests.
src/deploy_inst_tests.cc
Outdated
TestProducer::TestProducer(cyclus::Context* ctx) : cyclus::Facility(ctx) {} | ||
|
||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
TestProducer::~TestProducer() {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like these were moved from the manager_inst
- this is probably not the best place for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did move these lines from src/manager_inst_tests.cc
. As far as I can tell having these defined in both places breaks the linking to the unit tests when building. I understand the desire to define them somewhere else that does not feel that they are exclusive to just the one set of tests. Any recommendations on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They definitely need to be only defined in one place. If they are in two places, they get compiled twice and then the linker finds two copies when it tries to combine them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can create a file test_producer.h
that contains the definition of TestProducer
from deploy_inst_test.h
and defines these two functions inline in that header/class definition. That header can then be included in both of the institution header files.
<spec> <lib>cycamore</lib><name>Sink</name> </spec> | ||
</archetypes> | ||
|
||
<commodity> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely not a necessary block, but I would NOT require its remove for this to merge.
To answer both of your questions @gonuke, I have added a new integration test to test the function of the |
@gonuke suggested moving some of the duplicate definitions between Also, with the use of |
This PR adds a feature to the DeployInst: The facilities deployed by this institution are now registered with a GrowthRegion and how these facilities contribute to meeting any specified demand in the region.
I have added new tests to the DeployInst unit tests and a new input file to the regression tests to test how the DeployInst, GrowthRegion, and ManagerInst all interact with each other. Changes in the unit tests include some changes to the ManagerInst tests to prevent duplicate function definitions that threw errors when building.
All unit tests for DeployInst, GrowthRegion, and ManagerInst pass (although there were other errors in the unit tests, see #528), and the integration test passes.