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

Fix: Invalidate importlib cache for decorator job #783

Merged
merged 1 commit into from
Nov 3, 2023

Conversation

shpface
Copy link
Contributor

@shpface shpface commented Nov 3, 2023

Issue #, if available:

Description of changes:

This change will make a call to invalidate the internal caches in importlib when using decorator jobs. From imprortlib docs,

This function should be called if any modules are created/installed while your program is running to guarantee all finders will notice the new module’s existence.

This is the situation when the hybrid job decorator creates a new source module to create a new job while the program is running.

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@shpface shpface requested a review from a team as a code owner November 3, 2023 20:13
Copy link
Contributor

@krneta krneta left a comment

Choose a reason for hiding this comment

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

The thing is that the issue also goes away if I put a time.sleep() in the loop. So it could be that all removing the cache does is slow it down enough that it doesn't reproduce. But we may as well try it and see if it comes back.

Copy link

codecov bot commented Nov 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dc2ac56) 100.00% compared to head (493c0a0) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #783   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          129       129           
  Lines         8362      8363    +1     
  Branches      1862      1862           
=========================================
+ Hits          8362      8363    +1     
Files Coverage Δ
src/braket/jobs/quantum_job_creation.py 100.00% <100.00%> (ø)

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

@shpface shpface merged commit 4446f4b into main Nov 3, 2023
22 checks passed
@shpface shpface deleted the job_test_fix_ubuntu_2 branch November 3, 2023 20:22
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.

2 participants