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

Use Lock mechanism for forward_model_ok #8566

Merged
merged 1 commit into from
Aug 26, 2024
Merged

Conversation

xjules
Copy link
Contributor

@xjules xjules commented Aug 23, 2024

Issue
Resolves #8070

Approach
Make sure that we will not run more than 1 internalization job at a time.

(Screenshot of new behavior in GUI if applicable)

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure tests pass locally (after every commit!)

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Create Backport PR to latest release

@xjules xjules self-assigned this Aug 23, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.75%. Comparing base (31d3aa2) to head (317f167).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8566      +/-   ##
==========================================
- Coverage   90.76%   90.75%   -0.01%     
==========================================
  Files         342      342              
  Lines       20935    20940       +5     
==========================================
+ Hits        19001    19005       +4     
- Misses       1934     1935       +1     
Flag Coverage Δ
gui-tests 75.87% <100.00%> (+0.03%) ⬆️
integration-tests 53.95% <100.00%> (+<0.01%) ⬆️
unit-tests 68.77% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -275,6 +275,7 @@ async def execute(
scheduling_tasks.append(asyncio.create_task(self._update_avg_job_runtime()))

sem = asyncio.BoundedSemaphore(self._max_running or len(self._jobs))
self._fmok_sem = asyncio.BoundedSemaphore(value=10)
Copy link
Contributor

Choose a reason for hiding this comment

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

value=1 should be enough for everybody

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, when it is only 1 I can use lock instead 👍

@xjules xjules force-pushed the fmok_bs branch 4 times, most recently from f4b1d9c to d699199 Compare August 23, 2024 13:35
@@ -275,6 +276,9 @@ async def execute(
scheduling_tasks.append(asyncio.create_task(self._update_avg_job_runtime()))

sem = asyncio.BoundedSemaphore(self._max_running or len(self._jobs))
# this semaphore is to assure that no more than 1 task
# does internationalization at a time
Copy link
Contributor

Choose a reason for hiding this comment

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

internalization (not being international today)

@xjules xjules changed the title Use BoundedSemaphore for forward_model_ok Use Lock mechanism for forward_model_ok Aug 23, 2024
@xjules
Copy link
Contributor Author

xjules commented Aug 23, 2024

Tested on bigpoly (300 realz, max_running 200) both on LSF and LOCAL queues and it worked.

else:
assert callback_status == LoadStatus.LOAD_FAILURE
await self._send(JobState.FAILED)
if self._scheduler._fmok_lock:
Copy link
Contributor

Choose a reason for hiding this comment

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

You can do this with async with self._scheduler._fmok_lock:

Copy link
Contributor Author

@xjules xjules Aug 26, 2024

Choose a reason for hiding this comment

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

No, I can't unfortunately. This would need to be mocked for many tests as self._fmok_lock can thus be None

@@ -105,6 +105,7 @@ def __init__(
self._average_job_runtime: float = 0
self._completed_jobs_num: int = 0
self.completed_jobs: asyncio.Queue[int] = asyncio.Queue()
self._fmok_lock: Optional[asyncio.Lock] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be Optional, you can set it to asyncio.Lock() immediately I suppose (and allowing the async with syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, can try it, but that would alter some tests - can see how many this would be if way too many than can revert.

@berland
Copy link
Contributor

berland commented Aug 26, 2024

Recommend to use a longer name for this thing rather than fmok.

@xjules xjules force-pushed the fmok_bs branch 2 times, most recently from 7e9439b to 6437bb8 Compare August 26, 2024 11:16
@xjules
Copy link
Contributor Author

xjules commented Aug 26, 2024

Recommend to use a longer name for this thing rather than fmok.

Any suggestion? internalization_lock?

This makes sure that we will not run more than 1 internalization job at a time.
@xjules
Copy link
Contributor Author

xjules commented Aug 26, 2024

Recommend to use a longer name for this thing rather than fmok.

Any suggestion? internalization_lock?

changed to self._forward_model_ok_lock

@xjules xjules requested a review from berland August 26, 2024 13:35
Copy link
Contributor

@berland berland left a comment

Choose a reason for hiding this comment

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

nice and terse!

@xjules xjules merged commit 4bbfd5c into equinor:main Aug 26, 2024
35 checks passed
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.

Presumably finished realization displayed as pending in joblist view
3 participants