Skip to content

Commit c9d8ced

Browse files
authored
Merge branch 'master' into MLX-1269
2 parents eb186cc + e747b03 commit c9d8ced

File tree

595 files changed

+69640
-14129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

595 files changed

+69640
-14129
lines changed

.githooks/pre-push

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ start_time=`date +%s`
1212
tox -e sphinx,doc8 --parallel all
1313
./ci-scripts/displaytime.sh 'sphinx,doc8' $start_time
1414
start_time=`date +%s`
15-
tox -e py38,py39,py310 --parallel all -- tests/unit
16-
./ci-scripts/displaytime.sh 'py38,py39,py310 unit' $start_time
15+
tox -e py39,py310,py311,py312 --parallel all -- tests/unit
16+
./ci-scripts/displaytime.sh 'py39,py310,py311,py312 unit' $start_time

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ _Put an `x` in the boxes that apply. You can also fill these out after creating
2222
- [ ] I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
2323
- [ ] I have checked that my tests are not configured for a specific region or account (if appropriate)
2424
- [ ] I have used [`unique_name_from_base`](https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/utils.py#L77) to create resource names in integ tests (if appropriate)
25+
- [ ] If adding any dependency in requirements.txt files, I have spell checked and ensured they exist in PyPi
2526

2627
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Canaries
2+
on:
3+
schedule:
4+
- cron: "0 */3 * * *"
5+
workflow_dispatch:
6+
7+
permissions:
8+
id-token: write # This is required for requesting the JWT
9+
10+
jobs:
11+
tests:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Configure AWS Credentials
15+
uses: aws-actions/configure-aws-credentials@v4
16+
with:
17+
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
18+
aws-region: us-west-2
19+
role-duration-seconds: 10800
20+
- name: Run Integ Tests
21+
uses: aws-actions/aws-codebuild-run-build@v1
22+
id: codebuild
23+
with:
24+
project-name: sagemaker-python-sdk-canaries

.github/workflows/codebuild-ci-health.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
python-version: ["py38", "py39", "py310", "py311"]
29+
python-version: ["py39", "py310", "py311","py312"]
3030
steps:
3131
- name: Configure AWS Credentials
3232
uses: aws-actions/configure-aws-credentials@v4

.github/workflows/codebuild-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ jobs:
5555
- name: Run Codestyle & Doc Tests
5656
uses: aws-actions/aws-codebuild-run-build@v1
5757
with:
58-
project-name: sagemaker-python-sdk-ci-codestyle-doc-tests
58+
project-name: ${{ github.event.repository.name }}-ci-codestyle-doc-tests
5959
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
6060
unit-tests:
6161
runs-on: ubuntu-latest
6262
needs: [wait-for-approval]
6363
strategy:
6464
fail-fast: false
6565
matrix:
66-
python-version: ["py38","py39","py310","py311"]
66+
python-version: ["py39","py310","py311","py312"]
6767
steps:
6868
- name: Configure AWS Credentials
6969
uses: aws-actions/configure-aws-credentials@v4
@@ -74,7 +74,7 @@ jobs:
7474
- name: Run Unit Tests
7575
uses: aws-actions/aws-codebuild-run-build@v1
7676
with:
77-
project-name: sagemaker-python-sdk-ci-unit-tests
77+
project-name: ${{ github.event.repository.name }}-ci-unit-tests
7878
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'
7979
env-vars-for-codebuild: |
8080
PY_VERSION
@@ -93,5 +93,5 @@ jobs:
9393
- name: Run Integ Tests
9494
uses: aws-actions/aws-codebuild-run-build@v1
9595
with:
96-
project-name: sagemaker-python-sdk-ci-integ-tests
96+
project-name: ${{ github.event.repository.name }}-ci-integ-tests
9797
source-version-override: 'refs/pull/${{ github.event.pull_request.number }}/head^{${{ github.event.pull_request.head.sha }}}'

.github/workflows/codeql.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "CodeQL"
2+
on:
3+
push:
4+
branches: [ "master" ]
5+
pull_request:
6+
branches: [ "master" ]
7+
schedule:
8+
- cron: '30 15 * * *'
9+
jobs:
10+
analyze:
11+
name: Analyze (${{ matrix.language }})
12+
runs-on: ${{ 'ubuntu-latest' }}
13+
permissions:
14+
security-events: write
15+
packages: read
16+
17+
strategy:
18+
matrix:
19+
include:
20+
- language: python
21+
build-mode: none
22+
- language: java-kotlin
23+
build-mode: none
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@6ccd57f4c5d15bdc2fef309bd9fb6cc9db2ef1c6
27+
- name: Initialize CodeQL
28+
uses: github/codeql-action/init@4b1d7da102ff94aca014c0245062b1a463356d72
29+
with:
30+
languages: ${{ matrix.language }}
31+
build-mode: ${{ matrix.build-mode }}
32+
- name: Perform CodeQL Analysis
33+
uses: github/codeql-action/analyze@4b1d7da102ff94aca014c0245062b1a463356d72
34+
with:
35+
category: "/language:${{matrix.language}}"
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Security Monitoring
2+
3+
on:
4+
schedule:
5+
- cron: '0 16 * * *'
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.run_id }}
9+
cancel-in-progress: true
10+
11+
permissions:
12+
id-token: write
13+
14+
jobs:
15+
check-code-scanning-alerts:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
code_scanning_alert_status: ${{ steps.check-code-scanning-alerts.outputs.code_scanning_alert_status }}
19+
steps:
20+
- name: Check for security alerts
21+
id: check-code-scanning-alerts
22+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
23+
with:
24+
github-token: ${{ secrets.GH_PAT }}
25+
script: |
26+
async function checkAlerts() {
27+
const owner = '${{ github.repository_owner }}';
28+
const repo = '${{ github.event.repository.name }}';
29+
const ref = 'refs/heads/master';
30+
31+
const codeScanningAlerts = await github.rest.codeScanning.listAlertsForRepo({
32+
owner,
33+
repo,
34+
ref: ref
35+
});
36+
const activeCodeScanningAlerts = codeScanningAlerts.data.filter(alert => alert.state === 'open');
37+
core.setOutput('code_scanning_alert_status', activeCodeScanningAlerts.length > 0 ? '1': '0');
38+
}
39+
await checkAlerts();
40+
41+
check-dependabot-alerts:
42+
runs-on: ubuntu-latest
43+
outputs:
44+
dependabot_alert_status: ${{ steps.check-dependabot-alerts.outputs.dependabot_alert_status }}
45+
steps:
46+
- name: Check for dependabot alerts
47+
id: check-dependabot-alerts
48+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
49+
with:
50+
github-token: ${{ secrets.GH_PAT }}
51+
script: |
52+
async function checkAlerts() {
53+
const owner = '${{ github.repository_owner }}';
54+
const repo = '${{ github.event.repository.name }}';
55+
56+
const dependabotAlerts = await github.rest.dependabot.listAlertsForRepo({
57+
owner,
58+
repo,
59+
headers: {
60+
'accept': 'applications/vnd.github+json'
61+
}
62+
});
63+
const activeDependabotAlerts = dependabotAlerts.data.filter(alert => alert.state === 'open');
64+
core.setOutput('dependabot_alert_status', activeDependabotAlerts.length > 0 ? '1': '0');
65+
}
66+
await checkAlerts();
67+
68+
check-secret-scanning-alerts:
69+
runs-on: ubuntu-latest
70+
outputs:
71+
secret_scanning_alert_status: ${{ steps.check-secret-scanning-alerts.outputs.secret_scanning_alert_status }}
72+
steps:
73+
- name: Check for secret scanning alerts
74+
id: check-secret-scanning-alerts
75+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
76+
with:
77+
github-token: ${{ secrets.GH_PAT }}
78+
script: |
79+
async function checkAlerts() {
80+
const owner = '${{ github.repository_owner }}';
81+
const repo = '${{ github.event.repository.name }}';
82+
83+
const secretScanningAlerts = await github.rest.secretScanning.listAlertsForRepo({
84+
owner,
85+
repo,
86+
});
87+
const activeSecretScanningAlerts = secretScanningAlerts.data.filter(alert => alert.state === 'open');
88+
core.setOutput('secret_scanning_alert_status', activeSecretScanningAlerts.length > 0 ? '1': '0');
89+
}
90+
await checkAlerts();
91+
92+
put-metric-data:
93+
runs-on: ubuntu-latest
94+
needs: [check-code-scanning-alerts, check-dependabot-alerts, check-secret-scanning-alerts]
95+
steps:
96+
- name: Configure AWS Credentials
97+
uses: aws-actions/configure-aws-credentials@12e3392609eaaceb7ae6191b3f54bbcb85b5002b
98+
with:
99+
role-to-assume: ${{ secrets.MONITORING_ROLE_ARN }}
100+
aws-region: us-west-2
101+
- name: Put Code Scanning Alert Metric Data
102+
run: |
103+
if [ "${{ needs.check-code-scanning-alerts.outputs.code_scanning_alert_status }}" == "1" ]; then
104+
aws cloudwatch put-metric-data --metric-name CodeScanningAlert --namespace SecurityMonitoringMetrics --value 1 --unit Count --dimensions ProjectName=sagemaker-python-sdk
105+
else
106+
aws cloudwatch put-metric-data --metric-name CodeScanningAlert --namespace SecurityMonitoringMetrics --value 0 --unit Count --dimensions ProjectName=sagemaker-python-sdk
107+
fi
108+
- name: Put Dependabot Alert Metric Data
109+
run: |
110+
if [ "${{ needs.check-dependabot-alerts.outputs.dependabot_alert_status }}" == "1" ]; then
111+
aws cloudwatch put-metric-data --metric-name DependabotAlert --namespace SecurityMonitoringMetrics --value 1 --unit Count --dimensions ProjectName=sagemaker-python-sdk
112+
else
113+
aws cloudwatch put-metric-data --metric-name DependabotAlert --namespace SecurityMonitoringMetrics --value 0 --unit Count --dimensions ProjectName=sagemaker-python-sdk
114+
fi
115+
- name: Put Secret Scanning Alert Metric Data
116+
run: |
117+
if [ "${{ needs.check-secret-scanning-alerts.outputs.secret_scanning_alert_status }}" == "1" ]; then
118+
aws cloudwatch put-metric-data --metric-name SecretScanningAlert --namespace SecurityMonitoringMetrics --value 1 --unit Count --dimensions ProjectName=sagemaker-python-sdk
119+
else
120+
aws cloudwatch put-metric-data --metric-name SecretScanningAlert --namespace SecurityMonitoringMetrics --value 0 --unit Count --dimensions ProjectName=sagemaker-python-sdk
121+
fi

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ env/
3232
.python-version
3333
*.html
3434
**/_repack_script_launcher.sh
35+
src/sagemaker/modules/train/container_drivers/sm_train.sh
36+
src/sagemaker/modules/train/container_drivers/sourcecode.json
37+
src/sagemaker/modules/train/container_drivers/distributed.json
3538
tests/data/**/_repack_model.py
3639
tests/data/experiment/sagemaker-dev-1.0.tar.gz
3740
src/sagemaker/serve/tmp_workspace

.pydocstylerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
inherit = false
33
ignore = D104,D107,D202,D203,D213,D214,D400,D401,D404,D406,D407,D411,D413,D414,D415,D417
44
match = (?!record_pb2).*\.py
5+
match-dir = (?!.*test).*

.pylintrc

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,24 @@ disable=
9494
useless-object-inheritance, # TODO: Enable this check and fix code once Python 2 is no longer supported.
9595
super-with-arguments,
9696
raise-missing-from,
97-
E1136,
97+
C0116, # Missing function or method docstring
98+
C0209, # Use f-string instead of format
99+
E0015, # Unrecognized option found in config
100+
E0702, # Raising a string instead of an exception
101+
E1101, # Module has no member (likely dynamic attr)
102+
E1136, # Value assigned to something inferred as None
103+
R0022, # Useless option value in config
104+
R1710, # Inconsistent return statements
105+
R1714, # Consider using `in` with comparisons
106+
R1729, # Use a generator
107+
R1732,
108+
R1735, # Consider using a dict or list literal
109+
W0237, # Argument renamed in override
110+
W0613, # Unused argument
111+
W0621, # Redefining name from outer scope
112+
W0719
113+
W1404, # Implicit string concatenation
114+
W1514, # `open()` used without encoding
98115

99116
[REPORTS]
100117
# Set the output format. Available formats are text, parseable, colorized, msvs
@@ -310,7 +327,7 @@ ignore-mixin-members=yes
310327
# (useful for modules/projects where namespaces are manipulated during runtime
311328
# and thus existing member attributes cannot be deduced by static analysis. It
312329
# supports qualified module names, as well as Unix pattern matching.
313-
ignored-modules=distutils
330+
ignored-modules=
314331

315332
# List of class names for which member attributes should not be checked (useful
316333
# for classes with dynamically set attributes). This supports the use of
@@ -384,7 +401,7 @@ max-returns=6
384401
max-branches=12
385402

386403
# Maximum number of statements in function / method body
387-
max-statements=100
404+
max-statements=105
388405

389406
# Maximum number of parents for a class (see R0901).
390407
max-parents=7
@@ -436,4 +453,4 @@ analyse-fallback-blocks=no
436453

437454
# Exceptions that will emit a warning when being caught. Defaults to
438455
# "Exception"
439-
overgeneral-exceptions=Exception
456+
overgeneral-exceptions=builtins.Exception

.readthedocs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
version: 2
66

77
build:
8-
os: ubuntu-20.04
8+
os: ubuntu-22.04
99
tools:
10-
python: "3.9"
10+
python: "3.12"
1111

1212

1313
python:

0 commit comments

Comments
 (0)