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

Type and style for ensemble evaluator builder code #3219

Merged
merged 3 commits into from
Apr 8, 2022

Conversation

jondequinor
Copy link
Contributor

@jondequinor jondequinor commented Apr 6, 2022

Issue
Resolves #3188

Approach

  • Add type hinting/style fixes for ens. builder
    Move the ensemble evaluator builder code, along with some utility code, to ert/ and add type hinting and style fixes. Type hinting and style fixes have also been extended to code now under audit by virtue of the move to ert/. Some refactors, not strictly necessary, have been made to ease typing.
  • Stop file transformations from overwriting files
    A programming error was made that allowed unix jobs to overwrite output from other unix jobs, causing hard-to-debug test failures. A constraint on file transformations were introduced such that they cannot overwrite files from transforming from a record (to file).
  • Avoid sending failed event in the case of cancel
    For unknown reasons, I've made a flaky test more flaky. A piece of duct tape was applied. Proper fix will be Stop pickling RecordTransmitters and serialize its configuration instead #3013 and running prefect without multiprocessing.

Pre review checklist

  • Added appropriate release note label
  • PR title captures the intent of the changes, and is fitting for release notes.
  • Commit history is consistent and clean, in line with the contribution guidelines.

Adding labels helps the maintainers when writing release notes. This is the list of release note labels.

@jondequinor jondequinor self-assigned this Apr 6, 2022
@jondequinor jondequinor added enhancement maintenance Not a bug now but could be one day, repaying technical debt and removed enhancement labels Apr 6, 2022
@codecov-commenter
Copy link

codecov-commenter commented Apr 6, 2022

Codecov Report

Merging #3219 (8e59f9e) into main (1a84fa9) will decrease coverage by 0.01%.
The diff coverage is 91.87%.

@@            Coverage Diff             @@
##             main    #3219      +/-   ##
==========================================
- Coverage   65.60%   65.58%   -0.02%     
==========================================
  Files         614      619       +5     
  Lines       48982    49059      +77     
  Branches     4407     4407              
==========================================
+ Hits        32135    32177      +42     
- Misses      15374    15412      +38     
+ Partials     1473     1470       -3     
Impacted Files Coverage Δ
ert/ensemble_evaluator/identifiers.py 100.00% <ø> (ø)
ert/exceptions/__init__.py 100.00% <ø> (ø)
ert3/engine/_run.py 96.63% <ø> (-0.03%) ⬇️
ert_shared/status/utils.py 75.00% <ø> (-1.67%) ⬇️
...e_evaluator/builder/_prefect_forkserver_preload.py 33.33% <50.00%> (ø)
ert/ensemble_evaluator/state.py 91.30% <66.66%> (ø)
res/job_queue/queue.py 84.14% <81.48%> (-0.45%) ⬇️
ert/ensemble_evaluator/builder/_io_map.py 82.69% <83.33%> (ø)
..._shared/ensemble_evaluator/narratives/narrative.py 84.29% <86.95%> (-0.33%) ⬇️
ert/ensemble_evaluator/builder/_realization.py 88.76% <88.76%> (ø)
... and 53 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@jondequinor jondequinor changed the title Type and style for select ensemble evaluator code Type and style for ensemble evaluator builder code Apr 7, 2022
@jondequinor jondequinor marked this pull request as ready for review April 7, 2022 12:52
@jondequinor jondequinor enabled auto-merge (rebase) April 7, 2022 12:54
Move the ensemble evaluator builder code, along with some utility code,
to ert/ and add type hinting and style fixes.

Type hinting and style fixes have also been extended to code now under
audit by virtue of the move to ert/. Some refactors, not strictly
necessary, have been made to ease typing.
Comment on lines +2 to +7
from .builder._ensemble import _Ensemble
from .builder._ensemble_builder import _EnsembleBuilder
from .builder._io_ import _IO, _InputBuilder, _OutputBuilder
from .builder._job import _JobBuilder, _LegacyJobBuilder
from .builder._realization import _RealizationBuilder
from .builder._step import _StepBuilder
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Find arguments for why this is done like so

from ._realization import _Realization

if TYPE_CHECKING:
import ert
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unused?

@@ -89,7 +97,10 @@ def _evaluate(self):
# Get a fresh eventloop
asyncio.set_event_loop(asyncio.new_event_loop())

async def _evaluate_inner():
if self._config is None:
raise RuntimeError("no config")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ValueError

Comment on lines +144 to +148
for real in self.active_reals:
self._job_queue.add_ee_stage( # type: ignore
real.steps[0], callback_timeout=on_timeout
)
self._job_queue.submit_complete()
self._job_queue.submit_complete() # type: ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opted out of typing these.


finally:
await timeout_queue.put(None) # signal to exit timer
await send_timeout_future

# Dispatch final result from evaluator - FAILED, CANCEL or STOPPED
assert self._config # mypy
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Question @sondreso : ValueError or assertion here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is a ValueError

Copy link
Collaborator

@sondreso sondreso left a comment

Choose a reason for hiding this comment

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

Other than the minor comments above I think this looks good!
Very nice work! 👏

@jondequinor jondequinor merged commit 44577d8 into equinor:main Apr 8, 2022
@sondreso
Copy link
Collaborator

sondreso commented Apr 8, 2022

Ahh, I did not see the auto merge 😬

@sondreso sondreso added the release-notes:maintenance Automatically categorise as maintenance change in release notes label Apr 8, 2022
@jondequinor
Copy link
Contributor Author

My bad. Will do a follow up

@jondequinor jondequinor deleted the ee-builder-typing branch April 8, 2022 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Not a bug now but could be one day, repaying technical debt release-notes:maintenance Automatically categorise as maintenance change in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type ensemble builder ++
3 participants