-
Notifications
You must be signed in to change notification settings - Fork 225
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 getting started for jobs. #418
Open
krneta
wants to merge
2
commits into
main
Choose a base branch
from
job_test_fix_1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,17 @@ def pre_run_inject(mock_utils): | |
] | ||
} | ||
]) | ||
mocker.set_create_job_result({ | ||
"jobArn" : f"arn:aws:braket:{mocker.region_name}:000000:job/testJob" | ||
}) | ||
if mocker.mock_level == 'ALL': | ||
# All full mocking is done in us-west-2 | ||
mocker.set_create_job_result({ | ||
"jobArn" : f"arn:aws:braket:{mocker.region_name}:000000:job/testJob" | ||
}) | ||
else: | ||
# When running on QPU, the job arn is based on the device arn region, even when mocking. | ||
mocker.set_create_job_side_effect([ | ||
{ "jobArn" : f"arn:aws:braket:{mocker.region_name}:000000:job/testJob"}, | ||
{ "jobArn" : f"arn:aws:braket:us-west-1:000000:job/testJob"} | ||
]) | ||
mocker.set_get_job_result({ | ||
"instanceConfig" : { | ||
"instanceCount" : 1 | ||
|
@@ -36,6 +44,19 @@ def pre_run_inject(mock_utils): | |
mocker.set_log_streams_result({ | ||
"logStreams": [] | ||
}) | ||
mocker.set_start_query_result({ | ||
"queryId": "TestId" | ||
}) | ||
mocker.set_get_query_results_result({ | ||
"status": "Complete", | ||
"results": [ | ||
[ | ||
{"field": "@message", "value": "iteration_number=0;expval=10;"}, | ||
{"field": "@timestamp", "value": "0"} | ||
], | ||
] | ||
}) | ||
mocker.set_batch_get_image_result({"images": [{"imageId": {"imageDigest": "my-digest", "imageTag": "-py310-"}}]}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this needs to depend on the currently running python version |
||
global default_job_results | ||
default_job_results = mock_utils.read_file("../job_results.json", __file__) | ||
with open("results.json", "w") as f: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Do we really need a branch here? Why not just always mock the second way? (I think I was getting errors when I was trying that, so I believe there's an answer, I just don't know it)
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.
Yes, that's the reason. I tried to add those comments to explain why it's different between the two ways of mocking. We could change the way we do that, or we can add this branch here.
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 the reason the second mocking doesn't work for all mocking is because
AwsSession.copy_session(region)
doesn't create a mock in the proper region. I've isolated this issue down toboto3.Session(region_name=new_region)
not doing anything withregion_name
. Can we update the wrapper to fix this?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 thought it was because the all mocking wrapper always returns us-west-2: https://github.com/amazon-braket/amazon-braket-examples/blob/main/test/integ_tests/mock_utils.py#L174
No?
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.
Correct, though because of where the region was being pulled from, the specific line of code was a few lines up