-
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
Constant for large values in Cyclus/Cycamore #606
Conversation
Build Status Report - aa67f87 - 2024-07-21 21:20:28 +0000Build
|
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.
A question related to how this all fits together in the cyclus ecosystem
src/enrichment.h
Outdated
"range": [0.0, 1e299], \ | ||
"range": [0.0, "cyclus::cy_large_double"], \ |
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.
So this has me thinking about where else this metadata is used... If you have an installed build with this branch, can you run cyclus -m
and see what it reports as the range? Has the substitution happened at that point?
Other tools may read/parse this metadata without access to cyclus::cy_large_double
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.
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.
There are two issues here...
- on one hand it would be good to have expanded so that other users of this metadata know what it is
- if we want modules to be plug-an-play with different installs of Cyclus, maybe we want this to be substituted later??
It's possible we could do both, but performing the substitution before we publish the metadata? That might be a bigger project though!
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.
What if we substitute later and have a section of metadata (or a different cli flag perhaps) that shows users the values for constants in this install of cyclus? That way we don't need to modify the preprocessor, modules are plug-and-play, and users have a way to see what the constants are (as long as we put them in an intuitive place)
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.
Related - how is the substitution made under your current paradigm - when is it substituted and what can it be used 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.
Right now cyclus::cy_large_double
is a static const double
so it is evaluated at runtime and exists in the cyclus C++ namespace (and in the cyclus.lib
python library via cython wrapper). It is not evaluated before/by cycpp.py
. We could probably #define
the value instead so it is substituted by cpp
(though I'm still not sure there's a way to substitute it into the #pragma cyclus
statement to be evaluated before cycpp.py
is run). Does that answer your question?
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 trying to recall if there is any code on the Cyclus side that uses those values and were the substitution happens to use those values. For example, if the range
of a variable is set in these pragmas, I think it results in an XML grammar entry that requires the value to be within that range. Is the substitution done before generating the snippet of grammar so that XML only knows about the numerical value? Or is the substitution happening later?
It's also possible that the value is not actually used anywhere by Cyclus and only exists for other tools that use the metadata.
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.
KFacility
, Sink
, and Source
in cyclus use this value. When calling cyclus -m
the variable name is still included in metadata instead of the value. However, when viewing an agent's xml schema I don't see any reference at all. For example - capacity
in Source
is defined as so:
#pragma cyclus var { \
"doc": "amount of commodity that can be supplied at each time step", \
"uilabel": "Maximum Throughput", \
"uitype": "range", \
"range": [0.0, "cy_large_double"], \
"tooltip": "source capacity" \
}
double capacity;
But this is what I see when printing the agent schema via the cyclus cli (is this incomplete?):
root@a52714cb3b92:/cyclus# cyclus --agent-schema :agents:Source
<interleave>
<element name="commod">
<data type="token"/>
</element>
<optional>
<element name="recipe_name">
<data type="token"/>
</element>
</optional>
<element name="capacity">
<data type="double"/>
</element>
</interleave>
The section of JSON dedicated to Source
when calling cyclus -m
is:
":agents:Source": {
"all_parents": [
"cyclus::Agent",
"cyclus::Facility",
"cyclus::Ider",
"cyclus::StateWrangler",
"cyclus::TimeListener",
"cyclus::Trader"
],
"doc": "A minimum implementation source facility that provides a commodity with a given capacity",
"entity": "facility",
"name": "cyclus::Source",
"parents": ["cyclus::Facility"],
"vars": {
"capacity": {
"alias": "capacity",
"doc": "amount of commodity that can be supplied at each time step",
"index": 2,
"range": [0.0, "cy_large_double"],
"shape": [-1],
"tooltip": "source capacity",
"type": "double",
"uilabel": "Maximum Throughput",
"uitype": "range"
},
"commod": {
"alias": "commod",
"doc": "commodity that the source facility supplies",
"index": 0,
"schematype": "token",
"shape": [-1],
"tooltip": "source commodity",
"type": "std::string",
"uilabel": "Commodity",
"uitype": "outcommodity"
},
"recipe_name": {
"alias": "recipe_name",
"default": "",
"doc": "Recipe name for source facility's commodity.If empty, source supplies material with requested compositions.",
"index": 1,
"schematype": "token",
"shape": [-1],
"tooltip": "commodity recipe name",
"type": "std::string",
"uilabel": "Recipe",
"uitype": "recipe"
}
}
39510fb
to
29d0271
Compare
With some inspiration from the preprocessor docs, the substitution now takes place during the execution of CI in this PR will not pass since it is based on the published cyclus docker images - see cyclus/cyclus#1757 for CI status. Still failing on one test but not related to the new constants - need to resolve #611 then we should see CI pass in the cyclus PR EDIT: CI now passing in cyclus/cyclus#1757 |
Can you check whether any new large numbers crept in during recent PRs? A rebase and search, perhaps? |
I don't understand how this is passing? What cyclus version is it using to get the right values for the constants? |
I will check and make a comment after.
I'm seeing failures for all 8 builds... remember there are no "soft" failures in Github actions so we must refer to the bot's comment for the correct build statuses (unless I'm misunderstanding) |
I guess I already forgot our standard testing regimen - or perhaps more accurately was confused between cyclus and cycamore. (For my own benefit...) standard CI testing for cyclus/cyclus has hard failures and soft failures for downstream testing. Standard CI testing for cyclus/cycamore has ONLY soft failures because all testing uses some upstream repo whose state may or may not be consistent. Given that, in this particular case, what should we be reviewing in cycamore - just the code itself and ignoring the tests? |
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.
A couple of little things here - they aren't critical, but nice to have.
src/sink.h
Outdated
"doc": "When a random distribution is used to determine the " \ | ||
"frequency of the request, this is the upper bound. Default 1e299"} | ||
"frequency of the request, this is the upper bound. Default CY_LARGE_INT (1e299)"} |
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.
Can we get the actual value of the variable to appear here rather than hardcoding 1e299 in the string? Would this work?
"frequency of the request, this is the upper bound. Default CY_LARGE_INT (1e299)"} | |
"frequency of the request, this is the upper bound. Default CY_LARGE_INT (" + str(CY_LARGE_INT) + ")"} |
I think this is ultimately processed in python, so not sure how the value of this metadata is passed along.
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.
Good catch, this is now replaced at build time
Correct.
Yes, except since we have an associated PR in cyclus/cyclus we can use those CI tests as a reference. That's why I have the cyclus PR temporarily referencing this PR - we can see that CI passes when the two branches are in sync with each other |
a92a151
to
f7da6a3
Compare
Just went through and replaced a handful of instances of hardcoded constants. It looks like they were arbitrary small/large values, but someone else should go through and confirm. I also went through cyclus and replaced some hardcoded values. |
I'm ready to merge this - let me know if we need to coordinate @bennibbelink - or should I go ahead with this? |
I've changed the ref in cyclus/cyclus back to cyclus/cycamore, so they are both ready to be merged. I don't think we need to coordinate, regardless of how we do this there will be an intermediate state where the projects are out of sync. With that being said... maybe it makes sense to merge cyclus first then see CI pass on cycamore just since thats the typical workflow (of introducing features to cyclus then catching up downstream)? That may contradict a comment I made earlier about the appropriate merge procedure but I think this makes sense, what do you think? |
Re-ran CI and this is passing on the |
cyclus/cyclus#1757 updates some archetypes to use a new constant instead of
1e299
. This updates cycamore to use the same constants. CI will only pass when this PR and cyclus 1757 are tested together, so please refer to the cyclus PR for test status.