-
Notifications
You must be signed in to change notification settings - Fork 108
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
Refactor the everest run model #9575
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #9575 +/- ##
==========================================
- Coverage 91.89% 91.88% -0.01%
==========================================
Files 433 432 -1
Lines 26813 26805 -8
==========================================
- Hits 24639 24629 -10
- Misses 2174 2176 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
06e3cb9
to
6143dd0
Compare
CodSpeed Performance ReportMerging #9575 will improve performances by 11.53%Comparing Summary
Benchmarks breakdown
|
247f315
to
6185ee6
Compare
7142c89
to
f989ecf
Compare
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 the changes looks good, but I think we should split it into different commits, I had a hard time following some of the changes. For example using pattern matching could be a separate commit, I also added some other examples.
config.queue_config, | ||
status_queue, | ||
queue.SimpleQueue(), |
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.
Think in the next step we want to use this to forward the events from the base run model, so think it might be better to leave it as it was.
|
2fbbcac
to
e18edbf
Compare
fab8972
to
4a7a667
Compare
Path(everest_config.log_dir).mkdir(parents=True, exist_ok=True) | ||
Path(everest_config.optimization_output_dir).mkdir(parents=True, exist_ok=True) | ||
|
||
assert everest_config.environment is not None | ||
logging.getLogger(EVEREST).info( |
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.
Should this logging maybe also be moved to the environment config as it relates to the seed? Semi-related but I think the two logging statements could be merged into one, if it seems sensible to do in this PR
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 the logging is appropriate here, since it is basically announcing that we are going to run optimization with e given seed. We could move it to the config, then it would be more like: logging that we modified the configuration to fill in a defaulted value. We generally don't seem to do that.
I will merge 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.
➕
@@ -703,3 +716,42 @@ def _handle_errors( | |||
self._fm_errors[error_hash]["ids"].append(fm_id) | |||
error_id = self._fm_errors[error_hash]["error_id"] | |||
fm_logger.error(err_msg.format(error_id, "")) | |||
|
|||
|
|||
class SimulatorCache: |
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 a general question maybe not related to this PR: Do we still need a simulator cache? It stores some controls and resulting constraints/objectives. I guess also when we have everest storage we could get it from there 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.
Yes, we do need it, some optimizers may repeatedly ask for the same value. It would be a good idea to get is somehow from storage. Let's look into that when the storage has stabilized.
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.
Hmm okay, this is probably scoped for another issue/PR, but:
Q1: It seems kind of general, lru_cache
around a single method could maybe do the same thing as this?
Q2: Also we use the control vector to do a lookup, guessing there is some kind of ID that lets us just give that instead of having to look up on controls? Also the kind of realization that goes in is interesting, if we need to have a set of controls it implies we are searching through perturbations of [one realization/geoid that has multiple perturbations, that are in ERT, just more realizations]
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.
The controls are vectors of float values, so not hashable, hence lru_cache
is not straigtforward to use. They do not have some kind of hashable ID, I think numpy arrays don't have that.
For each control vector we will have multiple evaluations, i.e. the different realizations, hence the additional use of the realization names in the cache.
|
||
def add( | ||
self, | ||
realization_id: int, |
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 kind of realization is realization_id
? Would comment or make more explicit name if possible
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.
Agreed: realization_id
-> realization_name
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.
In the ERT codebase otherwise it is mostly called realization
, maybe we shouldn't add yet another synonym, and just use what is mostly used already? There is also iens
but imo that is a bit cryptic 😅 Unless this is specific to Everest somehow?
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.
Reason I used name is that they are strings, and I also use sometimes indices to realizations. I will rename things differently, making sure indices are names appropriately, and go to realizations for the names.
8fc0602
to
3cde5a4
Compare
fcc8ac8
to
d483532
Compare
d483532
to
7318071
Compare
@@ -775,11 +781,9 @@ def add( | |||
) | |||
|
|||
def get( | |||
self, realization_id: int, controls: NDArray[np.float64] | |||
self, realization: int, controls: NDArray[np.float64] |
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.
Because there was some confusion regarding this, would perhaps to add a docstring to this to describe what realization means here?
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.
^agree
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.
Done
I had one final small comment, but other than that, looks good from my side 👍 Thanks for splitting up, made it much easier to read through for me at least. Just keep the history as is and dont squash on merge. |
7318071
to
720f79c
Compare
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.
LGTM 💯
Issue
Refactoring of the everest run model code.
Approach
Short description of the approach
(Screenshot of new behavior in GUI if applicable)
git rebase -i main --exec 'pytest tests/ert/unit_tests -n logical -m "not integration_test"'
)When applicable