-
Notifications
You must be signed in to change notification settings - Fork 337
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
Add ability to cache package payloads synchronously #1679
Add ability to cache package payloads synchronously #1679
Conversation
Adds a `package_cachy_async` flag which allows users to run caching synchronously (blocking) or asynchronously from the config. Signed-off-by: ttrently <41705925+ttrently@users.noreply.github.com>
Change _async to default True instead of False to mimic previous behavior. Signed-off-by: ttrently <41705925+ttrently@users.noreply.github.com>
Renamed `add_variants_async` to `add_variants` as this method can now run with an `_async` flag. Signed-off-by: ttrently <41705925+ttrently@users.noreply.github.com>
|
0df6d8a
to
a8e829f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1679 +/- ##
==========================================
+ Coverage 58.03% 58.39% +0.36%
==========================================
Files 127 126 -1
Lines 17069 17205 +136
Branches 3496 3519 +23
==========================================
+ Hits 9906 10047 +141
+ Misses 6496 6489 -7
- Partials 667 669 +2 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Ben Andersen <ben@isohedron.com.au>
a8e829f
to
9463a3b
Compare
Signed-off-by: Ben Andersen <ben@isohedron.com.au>
aa6b96f
to
5a55f51
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.
Thanks for creating this PR @isohedronpipeline! I left some comments, please let me know if you have questions.
Co-authored-by: Jean-Christophe Morin <38703886+JeanChristopheMorinPerso@users.noreply.github.com> Signed-off-by: Ben Andersen <156872503+isohedronpipeline@users.noreply.github.com>
Signed-off-by: Ben Andersen <ben@isohedron.com.au>
Signed-off-by: Jean-Christophe Morin <38703886+JeanChristopheMorinPerso@users.noreply.github.com>
Signed-off-by: Jean-Christophe Morin <38703886+JeanChristopheMorinPerso@users.noreply.github.com>
Signed-off-by: Ben Andersen <ben@isohedron.com.au>
I took a deeper look, and as things are in this PR, it's doesn't work as you would expect. If you were to Additionally, I still have to verify, but I think that we should really avoid using We should also consider adding a progress bar or some logs when using the sync mode. I anticipate that users will complain if |
I think it would be preferable to call
Yeah, I'm fine with that. I'll move some of the logic from the cli entry point into
We can have something print out in the |
I'm not too sure why we would use |
You could be right. I am worried that a previous sync process could have failed, leaving behind the .copying file, but no further updates to it will have been made. I would imagine that one use case for doing a package cache syncronously would be to force all of the caching operations to happen right now as possibly a way to restart a locked or frozen cache operation. I see that the copying file is updated every .2 seconds though, so we should be able to check that and continue to wait while that file is being updated. My hesitation to hit the disk repeatedly is maybe misplaced since the cache is on the local disk. In studio environments, I hesitate to hit network drives with something that could be run many times in parallel. Of course you're right and starting multiple large file transfers instead is madness. |
The package cache class already knows how to handle stalled packages. It should be able to handle the case where a variant is left in progress due to an error or whatever else and restart it. See Lines 830 to 835 in dc2c777
As for polling, I agree that polling a shared file system is not wanted. Though, caching is usually done on local disks. We could maybe use |
Reports progress while waiting for another package to finish copying Signed-off-by: Ben Andersen <ben@isohedron.com.au>
Signed-off-by: Ben Andersen <ben@isohedron.com.au>
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 a first read of your recent changes, but I have not yet reviewed them thoroughly. Hopefully that will allow me to think about it a little bit more.
Signed-off-by: Ben Andersen <ben@isohedron.com.au>
Hi @JeanChristopheMorinPerso I think all the outstanding issues have been addressed. Any other thoughts? |
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.
Thanks @isohedronpipeline. I think we are almost there. I left some small comments that should hopefully be quick to address.
It would be great if you could also update https://rez.readthedocs.io/en/stable/caching.html#package-caching. The behavior of the async caching is well documented. I think the behavior of the sync cache should also be documented in a similar way.
src/rez/package_cache.py
Outdated
spinner.next() | ||
time.sleep(self._COPYING_TIME_INC) | ||
status, rootpath = self._get_cached_root(variant) | ||
else: |
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 else is not needed and is redundant.
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 comment is till valid and should be addressed. https://docs.python.org/3/reference/compound_stmts.html#the-while-statement
This repeatedly tests the expression and, if it is true, executes the first suite; if the expression is false (which may be the first time it is tested) the suite of the else clause, if present, is executed and the loop terminates.
A break statement executed in the first suite terminates the loop without executing the else clause’s suite. A continue statement executed in the first suite skips the rest of the suite and goes back to testing the expression.
src/rez/package_cache.py
Outdated
@@ -371,28 +413,50 @@ def add_variants_async(self, variants): | |||
|
|||
This method is called when a context is created or sourced. Variants | |||
are then added to the cache in a separate process. | |||
|
|||
.. deprecated:: 3.1.0 |
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.
TODO for maintainers: Update with appropriate version number before merging.
@@ -116,7 +129,7 @@ def get_cached_root(self, variant): | |||
|
|||
return rootpath | |||
|
|||
def add_variant(self, variant, force=False): | |||
def add_variant(self, variant, force=False, wait_for_copying=False, logger=None): |
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 wait_for_copying
should be True by default.
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 would change the default behavior from async to sync, which I don't think we want to do, do we?
src/rez/rezconfig.py
Outdated
# Asynchronously cache packages. If this is false, resolves will block until | ||
# all packages are cached. | ||
# | ||
# .. versionadded:: 3.1.0 |
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.
TODO for maintainers: Update with appropriate version number before merging.
I'm delighted to see this pull request! We've been waiting for this feature, and it's great to see it implemented. At Fortiche, we've tested this branch, and it works exactly as expected. The synchronous package caching is a game-changer for our studio environments, where we often need to cache packages quickly and reliably. We're also happy to see that you've addressed the concerns about progress and logging in sync mode. It's essential to provide users with clear feedback when running long-running commands. Thanks again for your work on this feature! We're excited to see it merged and start using it in our production environments. |
Co-authored-by: Jean-Christophe Morin <38703886+JeanChristopheMorinPerso@users.noreply.github.com> Signed-off-by: Ben Andersen <156872503+isohedronpipeline@users.noreply.github.com>
Co-authored-by: Jean-Christophe Morin <38703886+JeanChristopheMorinPerso@users.noreply.github.com> Signed-off-by: Ben Andersen <156872503+isohedronpipeline@users.noreply.github.com>
changed wait_for_copying on run_caching_operation default to True Signed-off-by: Ben Andersen <ben@isohedron.com.au>
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.
Almost there!
src/rez/package_cache.py
Outdated
spinner.next() | ||
time.sleep(self._COPYING_TIME_INC) | ||
status, rootpath = self._get_cached_root(variant) | ||
else: |
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 comment is till valid and should be addressed. https://docs.python.org/3/reference/compound_stmts.html#the-while-statement
This repeatedly tests the expression and, if it is true, executes the first suite; if the expression is false (which may be the first time it is tested) the suite of the else clause, if present, is executed and the loop terminates.
A break statement executed in the first suite terminates the loop without executing the else clause’s suite. A continue statement executed in the first suite skips the rest of the suite and goes back to testing the expression.
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
b747bfa
to
a8d0439
Compare
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
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.
Thanks a lot @isohedronpipeline and @ttrently!
671e32f
into
AcademySoftwareFoundation:main
I just realized that we missed adding a CLI flag to the |
…oundation#1679) Adds a `package_cache_async` flag which allows users to run caching synchronously (blocking) or asynchronously from the config. Also adds CLI argument `--pkg-cache-mode` to manually override the caching mode. --- Signed-off-by: ttrently <41705925+ttrently@users.noreply.github.com> Signed-off-by: Ben Andersen <ben@isohedron.com.au> Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com> Co-authored-by: ttrently <41705925+ttrently@users.noreply.github.com> Co-authored-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
Fixes #1379
Carrying on the work from #1452
This adds support for synchronous/blocking package caching during the resolve process.