Skip to content

Commit 150cc22

Browse files
wong-aca-nguyen
andauthored
chore: Fix tox not running locally (aws#134)
* chore: Fix tox not running locally * Added link to CONTRIBUTING guide in README.rst Co-authored-by: Carolyn Nguyen <[email protected]> Co-authored-by: Carolyn Nguyen <[email protected]>
1 parent 349fc11 commit 150cc22

6 files changed

+76
-7
lines changed

CONTRIBUTING.md

+42-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ information to effectively respond to your bug report or contribution.
1111

1212
* [Table of Contents](#table-of-contents)
1313
* [Reporting Bugs/Feature Requests](#reporting-bugsfeature-requests)
14-
* [Contributing via Pull Requests (PRs)](#contributing-via-pull-requests-prs)
14+
* [Contributing via Pull Requests (PRs)](#contributing-via-pull-requests-prs)
1515
* [Pulling Down the Code](#pulling-down-the-code)
1616
* [Running the Unit Tests](#running-the-unit-tests)
1717
* [Running the Integration Tests](#running-the-integration-tests)
@@ -61,20 +61,56 @@ Before sending us a pull request, please ensure that:
6161
1. Install test dependencies, including coverage, using `pip install ".[test]"`
6262
1. Run the following tox command and verify that all code checks and unit tests pass: `tox tests/unit`
6363

64-
You can also run a single test with the following command: `tox -e py36 -- -s -vv <path_to_file><file_name>::<test_function_name>`
64+
You can also run a single test with the following command: `tox -e py36 -- -s -vv <path_to_file><file_name>::<test_function_name>`
6565
* Note that the coverage test will fail if you only run a single test, so make sure to surround the command with `export IGNORE_COVERAGE=-` and `unset IGNORE_COVERAGE`
6666
* Example: `export IGNORE_COVERAGE=- ; tox -e py36 -- -s -vv tests/unit/test_sagemaker_steps.py::test_training_step_creation_with_model ; unset IGNORE_COVERAGE`
6767

6868

6969
### Running the Integration Tests
7070

71-
Our CI system runs integration tests (the ones in the `tests/integ` directory), in parallel, for every Pull Request.
72-
You should only worry about manually running any new integration tests that you write, or integration tests that test an area of code that you've modified.
71+
Our CI system runs integration tests (the ones in the `tests/integ` directory), in parallel, for every Pull Request.
72+
You should only worry about manually running any new integration tests that you write, or integration tests that test an area of code that you've modified.
73+
#### Setup
7374

74-
1. Follow the instructions at [Set Up the AWS Command Line Interface (AWS CLI)](https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html).
75+
If you haven't done so already, install tox and test dependencies:
76+
1. `pip install tox`
77+
1. `pip install .[test]`
78+
79+
#### AWS Credentials
80+
Follow the instructions at [Set Up the AWS Command Line Interface (AWS CLI)](https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html).
81+
#### Create IAM Roles
82+
83+
The tests use two IAM roles to give Step Functions and SageMaker permissions to access AWS resources in your account. Use the following commands in the root directory of this repository:
84+
85+
```bash
86+
aws iam create-role \
87+
--role-name StepFunctionsMLWorkflowExecutionFullAccess \
88+
--assume-role-policy-document file://tests/integ/resources/StepFunctionsMLWorkflowExecutionFullAccess-TrustPolicy.json
89+
```
90+
91+
```bash
92+
aws iam put-role-policy \
93+
--role-name StepFunctionsMLWorkflowExecutionFullAccess \
94+
--policy-name StepFunctionsMLWorkflowExecutionFullAccess \
95+
--policy-document file://tests/integ/resources/StepFunctionsMLWorkflowExecutionFullAccess-Policy.json
96+
```
97+
98+
```bash
99+
aws iam create-role \
100+
--role-name SageMakerRole \
101+
--assume-role-policy-document file://tests/integ/resources/SageMaker-TrustPolicy.json
102+
```
103+
104+
```bash
105+
aws iam attach-role-policy \
106+
--role-name SageMakerRole \
107+
--policy-arn arn:aws:iam::aws:policy/AmazonSageMakerFullAccess
108+
```
109+
#### Execute the tests
75110
1. To run a test, specify the test file and method you want to run per the following command: `tox -e py36 -- -s -vv <path_to_file><file_name>::<test_function_name>`
76111
* Note that the coverage test will fail if you only run a single test, so make sure to surround the command with `export IGNORE_COVERAGE=-` and `unset IGNORE_COVERAGE`
77112
* Example: `export IGNORE_COVERAGE=- ; tox -e py36 -- -s -vv tests/integ/test_state_machine_definition.py::test_wait_state_machine_creation ; unset IGNORE_COVERAGE`
113+
1. To run all integration tests, run the following command: `tox tests/integ`
78114

79115
### Making and Testing Your Change
80116

@@ -88,7 +124,7 @@ You should only worry about manually running any new integration tests that you
88124
1. Guard against future breaking changes to lower the maintenance cost.
89125
1. Please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
90126
1. Run all the unit tests as per [Running the Unit Tests](#running-the-unit-tests), and verify that all checks and tests pass.
91-
1. Note that this also runs tools that may be necessary for the automated build to pass (ex: code reformatting by 'black').
127+
1. Note that this also runs tools that may be necessary for the automated build to pass (ex: code reformatting by 'black').
92128

93129

94130
### Committing Your Change

README.rst

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Table of Contents
2727
- `Getting Started With Sample Jupyter Notebooks <#getting-started-with-sample-jupyter-notebooks>`__
2828
- `Installing the AWS Step Functions Data Science SDK <#installing-the-aws-step-functions-data-science-sdk>`__
2929
- `Overview of SDK <#overview-of-sdk>`__
30+
- `Contributing <#contributing>`__
3031
- `AWS Permissions <#aws-permissions>`__
3132
- `Licensing <#licensing>`__
3233
- `Verifying the Signature <#verifying-the-signature>`__
@@ -309,6 +310,12 @@ the CloudFormation template in a different region, please make sure to update
309310
the region specific AWS resources (such as the Lambda ARN and Training Image)
310311
in the StateMachine definition.
311312

313+
Contributing
314+
------------
315+
We welcome community contributions and pull requests. See
316+
`CONTRIBUTING.md <https://github.com/aws/aws-step-functions-data-science-sdk-python/blob/main/CONTRIBUTING.md>`__ for
317+
information on how to set up a development environment, run tests and submit code.
318+
312319
AWS Permissions
313320
---------------
314321
As a managed service, AWS Step Functions performs operations on your behalf on
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Sid": "",
6+
"Effect": "Allow",
7+
"Principal": {
8+
"Service": "sagemaker.amazonaws.com"
9+
},
10+
"Action": "sts:AssumeRole"
11+
}
12+
]
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Sid": "",
6+
"Effect": "Allow",
7+
"Principal": {
8+
"Service": "states.amazonaws.com"
9+
},
10+
"Action": "sts:AssumeRole"
11+
}
12+
]
13+
}

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ envlist = python3.6
99
skip_missing_interpreters = False
1010

1111
[testenv]
12-
install_command = pip install {opts} {packages} {env:PWD}[test]
12+
deps = .[test]
1313
passenv =
1414
AWS_ACCESS_KEY_ID
1515
AWS_SECRET_ACCESS_KEY

0 commit comments

Comments
 (0)