Skip to content

Conversation

@wk9874
Copy link
Collaborator

@wk9874 wk9874 commented Oct 2, 2025

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_file and 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 to FileArtifact and save_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 when save_file was 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 = True to 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 new retry_failed_uploads parameter in sender().

🔍 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

  • Added snapshot option to file artifacts
  • Added retry_failed_uploads option to sender
  • Sender now logs exceptions as errors but does not throw them to make it more resilient, and not block all subsequent sender runs failing if one object fails to upload
  • Added tests for sender
  • Added tests for snapshot functionality in both online and offline mode

✔️ Checklist

  • Unit and integration tests passing.
  • Pre-commit hooks passing.
  • Quality checks passing.

@kzscisoft kzscisoft self-requested a review October 3, 2025 10:28
@kzscisoft kzscisoft merged commit 5ad9989 into dev Oct 3, 2025
20 checks passed
@kzscisoft kzscisoft deleted the wk9874/artifact_snapshot branch October 3, 2025 10:29
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.

3 participants