Skip to content

Conversation

prncevince
Copy link

I got a little ambitious with this one. Understand it may never get merged. This tackles a few PRs / issues & topics of conversation all in one:

On the topic of skipping the post run save script, aka only restoring:

On the topic of reevaluating the primary cache key:

Being that I added new input variables, I had to do quite a bit to get all checks to pass. The goal was adding reevaluation of the primary key during the post run save script as a capability, which was accomplished. In a nut shell, for reevaluation, you need logic to handle when the primary key gets saved to the cache's state. This PR handles doing that.

The jest tests were edited bare minimally to pass. New jest tests were not added for say, testing setting boolean inputs of only-restore and reeval to either true or false. However, test utilities were added to be able to read these input boolean variables. Also, Inputs.Reeval was set to false throughout both save and restore jest tests to evaluate save & restore scripts appropriately with the default reeval action input value.

The 'Tests' workflow was however changed to begin to handle setting the boolean variables to either.

The new field of reeval was added to the job matrix of the test-save & test-restore jobs. In addition, matrices were added to the test-proxy-save & test-proxy-restore jobs to handle this input as well. To differentiate primary keys between matrix runs, a -${{ matrix.reeval }} partial was appended to these keys.

In addition, to handle the only-restore case, new jobs of test-only-restore & test-proxy-only-restore were created, each setting reeval to true, and their setting of the primary key follows the convention described above.

I created a tag on the main branch of my own repo with these features as well. I've also tested it in quite a few other repos where it's used within composite actions.

Examples using the prncevince/r-actions/setup-knitr-cache composite action:

I also added to the README.md & to examples.md. To the readme I added descriptions of the input variables with their defaults. To the examples I added an example for using knitr caching when rendering R Markdown, as well as detailed explanation of why you would want to use it, with links to examples mentioned above.

A lot of this implementation could be better. I think that the creation of the primary keys during the Tests workflow could be based on an actual file hashing. This could be checked into the repository - say the __test__/__fixtures__/helloWorld.txt). Then, edits to the file could be reflected in the primary key and indeed be tested upon reevaluation.

I'm sure better messaging could be implemented with only restoring (forgoing the post run save script). Not sure that I'm going to pursue this much. Full implementation works right now on my own tag. But if what's requested by reviewers is simple enough for me to have a go to get it merged, I may be interested.

Cheers

* implement only-restore within save
* add regular & proxy server jobs
* run job between save & restore jobs to test that only-restore option
  works with consecutive restores
* also format code with prettier
Add boolean inputs to:

* reevaluate cache's primary key
* only restore the cache (not save it)
* could be eliminated if primary key is generated differently,
  e.g. hashing of file paths on reevaluation
* add logic to not save state in restore step when setting `reeval` to true
* create infrastructure to set `Inputs.Reeval` input variable
  within tests
* `Inputs.Reeval` set to false for all save & restore tests
@prncevince prncevince requested a review from a team as a code owner June 20, 2022 06:15
@aparna-ravindra
Copy link
Contributor

Hi @prncevince 👋🏽
Thank you for the well-thought contribution..

We have had a few similar feature requests/ PRs in the past.
#571
#489
#474
#795
#46

We are trying to consolidate all such requests and come up with a common solution. Your contribution will definitely help move this request forward. Please allow us some time to circle back on this PR while we evaluate the possible solutions.

@prncevince
Copy link
Author

prncevince commented Jun 21, 2022

Thanks & Good luck!

@aparna-ravindra aparna-ravindra added the area:granular-control Issues related to granular control in saving or restoring cache label Aug 24, 2022
@kotewar kotewar assigned tanuj077 and kotewar and unassigned aparna-ravindra Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:granular-control Issues related to granular control in saving or restoring cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants