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

test: add decorator test #122

Merged
merged 5 commits into from
Dec 6, 2023
Merged

test: add decorator test #122

merged 5 commits into from
Dec 6, 2023

Conversation

ajberdy
Copy link
Contributor

@ajberdy ajberdy commented Nov 13, 2023

Issue #, if available:

Description of changes:

Run braket test as decorator

Testing done:

Test passes

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.

@ajberdy ajberdy requested a review from krneta November 13, 2023 23:33
@@ -4,6 +4,7 @@ boto3==1.28.53
certifi>=2023.7.22
invoke==2.2.0
mock
pennylane
Copy link
Contributor Author

@ajberdy ajberdy Nov 13, 2023

Choose a reason for hiding this comment

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

Added because it is used in the entry point script. Not necessarily a new constraint from decorator jobs-- we'd need to do this if the entry point was a function for legacy jobs too (vs a file)

Copy link
Contributor

@krneta krneta Dec 1, 2023

Choose a reason for hiding this comment

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

Where is pennylane used in the entry point script? Do you mean the container entry point script or the actual customer script below? In either case, it shouldn't be required for running the test (pennylane will be included in the container itself).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pennylane is globally imported in the file defining the customer entry point function, meaning it needs to be installed when we import the function. We can prevent this by importing PL within the job scope (inside the entry point function), but that would be messier and involve refactoring some of our helpers. In practice it's incredibly unlikely imo that customers are writing PL jobs without having PL locally.

The reason we didn't need this previously is because we were using a whole file as an entry point script (__main__ method). Even with the old interface, if we had instead chosen a specific function to use for entry point, we would have run into this same issue.

@ajberdy
Copy link
Contributor Author

ajberdy commented Nov 14, 2023

Failing with access denied exception after rebasing latest changes from main (succeeded before)
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the PutMetricData operation: User: arn:aws:sts::318845237731:assumed-role/AmazonBraketJobsExecutionRole/Braket is not authorized to perform: cloudwatch:PutMetricData because no identity-based policy allows the cloudwatch:PutMetricData action

@@ -44,7 +44,7 @@ def record_test_metrics(metric, start_time, interface):
'Unit': 'Seconds',
'Value': time.time() - start_time
}],
Namespace='braket-container-metrics'
Namespace='/aws/braket'
Copy link
Contributor

@krneta krneta Nov 15, 2023

Choose a reason for hiding this comment

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

Can you change the type to "braket_container_tests" so we know what the metrics relate to? Or maybe we need a new dimension to make it clear this is not a regular aws braket service metric.

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you verified this got published to the right place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-12-01 at 12 06 45 PM Working as expected!

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, we'll need to update the dashboard CDK as well

from ..common.braket_jobs_util import job_test


def test_qaoa_circuit(account, role, s3_bucket, image_list):
@pytest.mark.parametrize("decorator", (False, True))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's overkill to test with and without decorators when we're just trying to see if the containers are valid.

@ajberdy ajberdy requested a review from krneta December 1, 2023 20:13
@@ -158,7 +150,3 @@ def cost_function(params):

record_test_metrics('Total', start_time, pl_interface)
print("Braket Container Run Success")


if __name__ == "__main__":
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're no longer running this module as a script, only importing entry_point from here. We only needed this before cause the script itself got run as "main".

@ajberdy ajberdy merged commit f3e53b2 into main Dec 6, 2023
6 checks passed
@ajberdy ajberdy deleted the dec-test branch December 6, 2023 18:02
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