Add snapshot functionality to Artifacts #873
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix artifact bugs in offline mode
Issue: #870 , #871 , #872
Python Version(s) Tested: 3.10
Operating System(s): Ubuntu
📝 Summary
If using offline mode, and a file changes between when you called
save_fileand when the user actually uploads the file, the file will fail to upload because the checksum no longer matches. To fix this, have added a new 'snapshot' option toFileArtifactandsave_file, which will copy the file to be uploaded into the simvue cache before calculating the checksum etc. This means that if enabled, the file which is eventually uploaded by the sender will be the version of the file which existed whensave_filewas called.In the process of this, noticed that errors were not being thrown correctly if the ThreadPoolExecutor was being used to send objects to the server in parallel. Also discussed whether exceptions should be thrown at all, or just logged and continue on. So now any exceptions are logged as errors in the logging framework, but otherwise the sender continues as normal. The cache file is updated with
upload_failed = Trueto indicate an attempt has been made but failed. The next time the sender runs, it will try to pop this attribute from the cache file. IF it exists, itll then decide whether to try to upload it again based on the value of a newretry_failed_uploadsparameter insender().🔍 Diagnosis
Bug was identified during Remkit connector testing - Remkit updates a config file when it runs to set some keys as default blank values if the user omitted them. This means that in offline mode, the config file was not being uploaded due to the checksum issue, and no error was being reported due to the ThreadPoolExecutor issue. Hopefully this fix addresses both of those!
🔄 Changes
snapshotoption to file artifactsretry_failed_uploadsoption to sender✔️ Checklist