Skip to content

Commit

Permalink
Merge branch 'master' into skip-pt-test
Browse files Browse the repository at this point in the history
  • Loading branch information
benieric authored Mar 18, 2024
2 parents aa11985 + 434cba0 commit 95ee170
Show file tree
Hide file tree
Showing 115 changed files with 5,892 additions and 800 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/codebuild-ci-health.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: CI Health
on:
schedule:
- cron: "0 */3 * * *"
workflow_dispatch:

permissions:
id-token: write # This is required for requesting the JWT

jobs:
codestyle-doc-tests:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Codestyle & Doc Tests
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: sagemaker-python-sdk-ci-health-codestyle-doc-tests
unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["py38", "py39", "py310"]
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Unit Tests
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: sagemaker-python-sdk-ci-health-unit-tests
env-vars-for-codebuild: |
PY_VERSION
env:
PY_VERSION: ${{ matrix.python-version }}
integ-tests:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Integ Tests
uses: aws-actions/aws-codebuild-run-build@v1
id: codebuild
with:
project-name: sagemaker-python-sdk-ci-health-integ-tests
slow-tests:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Slow Tests
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: sagemaker-python-sdk-ci-health-slow-tests
localmode-tests:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Local Mode Tests
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: sagemaker-python-sdk-ci-health-localmode-tests
notebook-tests:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Notebook Tests
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: sagemaker-python-sdk-ci-health-notebook-tests
48 changes: 48 additions & 0 deletions .github/workflows/codebuild-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: PR Checks
on:
pull_request_target:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }}
cancel-in-progress: true

permissions:
id-token: write # This is required for requesting the JWT

jobs:
codestyle-doc-tests:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Codestyle & Doc Tests
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: sagemaker-python-sdk-ci-codestyle-doc-tests
source-version-override: 'pr/${{ github.event.pull_request.number }}'
unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["py38", "py39", "py310"]
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 10800
- name: Run Unit Tests
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: sagemaker-python-sdk-ci-unit-tests
source-version-override: 'pr/${{ github.event.pull_request.number }}'
env-vars-for-codebuild: |
PY_VERSION
env:
PY_VERSION: ${{ matrix.python-version }}
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## v2.213.0 (2024-03-15)

### Features

* Add support for Streaming Inference
* tgi optimum 0.0.19, 0.0.20 releases
* support JumpStart proprietary models
* Add ModelDataSource and SourceUri support for model package and while registering
* Accept user-defined env variables for the entry-point
* Add overriding logic in ModelBuilder when task is provided

### Bug Fixes and Other Changes

* Improvement of the tuner documentation
* Skip of tests which are long running and causing the ResourceLimitInUse exception
* Add AutoML -> AutoMLV2 mapper
* add ci-health checks
* split coverage out from testenv in tox.ini
* add PT 2.2 support for smdistributed, pytorchddp, and torch_distributed distributions
* sagemaker session region not being used
* chore: emit warning when no instance specific gated training env var is available, and raise exception when accept_eula flag is not supplied
* enable github actions for PRs
* Move sagemaker pysdk version check after bootstrap in remote job
* make unit tests compatible with pytest-xdist
* Update tblib constraint

## v2.212.0 (2024-03-06)

### Features
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ Before sending us a pull request, please ensure that:
1. Install coverage using `pip install .[test]`
1. cd into the sagemaker-python-sdk folder: `cd sagemaker-python-sdk` or `cd /environment/sagemaker-python-sdk`
1. Run the following tox command and verify that all code checks and unit tests pass: `tox tests/unit`

You can also run a single test with the following command: `tox -e py310 -- -s -vv <path_to_file><file_name>::<test_function_name>`
1. You can also run a single test with the following command: `tox -e py310 -- -s -vv <path_to_file><file_name>::<test_function_name>`
1. You can run coverage via runcvoerage env : `tox -e runcoverage -- tests/unit` or `tox -e py310 -- tests/unit --cov=sagemaker --cov-append --cov-report xml`
* 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`
* Example: `export IGNORE_COVERAGE=- ; tox -e py310 -- -s -vv tests/unit/test_estimator.py::test_sagemaker_model_s3_uri_invalid ; unset IGNORE_COVERAGE`

Expand Down
9 changes: 6 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ SageMaker Python SDK
:target: https://sagemaker.readthedocs.io/en/stable/
:alt: Documentation Status

.. image:: https://github.com/benieric/sagemaker-python-sdk/actions/workflows/codebuild-ci-health.yml/badge.svg
:target: https://github.com/benieric/sagemaker-python-sdk/actions/workflows/codebuild-ci-health.yml
:alt: CI Health

SageMaker Python SDK is an open source library for training and deploying machine learning models on Amazon SageMaker.

With the SDK, you can train and deploy models using popular deep learning frameworks **Apache MXNet** and **TensorFlow**.
Expand Down Expand Up @@ -63,11 +67,10 @@ Table of Contents
Installing the SageMaker Python SDK
-----------------------------------

The SageMaker Python SDK is built to PyPI and can be installed with pip as follows:

The SageMaker Python SDK is built to PyPI and the latest version of the SageMaker Python SDK can be installed with pip as follows
::

pip install sagemaker
pip install sagemaker==<Latest version from pyPI from https://pypi.org/project/sagemaker/>

You can install from source by cloning this repository and running a pip install command in the root directory of the repository:

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.212.1.dev0
2.213.1.dev0
83 changes: 68 additions & 15 deletions doc/doc_utils/jumpstart_doc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ class Frameworks(str, Enum):

JUMPSTART_REGION = "eu-west-2"
SDK_MANIFEST_FILE = "models_manifest.json"
PROPRIETARY_SDK_MANIFEST_FILE = "proprietary-sdk-manifest.json"
JUMPSTART_BUCKET_BASE_URL = "https://jumpstart-cache-prod-{}.s3.{}.amazonaws.com".format(
JUMPSTART_REGION, JUMPSTART_REGION
)
PROPRIETARY_DOC_BUCKET = "https://jumpstart-cache-prod-us-west-2.s3.us-west-2.amazonaws.com"

TASK_MAP = {
Tasks.IC: ProblemTypes.IMAGE_CLASSIFICATION,
Tasks.IC_EMBEDDING: ProblemTypes.IMAGE_EMBEDDING,
Expand Down Expand Up @@ -152,18 +155,26 @@ class Frameworks(str, Enum):
}


def get_jumpstart_sdk_manifest():
url = "{}/{}".format(JUMPSTART_BUCKET_BASE_URL, SDK_MANIFEST_FILE)
def get_public_s3_json_object(url):
with request.urlopen(url) as f:
models_manifest = f.read().decode("utf-8")
return json.loads(models_manifest)


def get_jumpstart_sdk_spec(key):
url = "{}/{}".format(JUMPSTART_BUCKET_BASE_URL, key)
with request.urlopen(url) as f:
model_spec = f.read().decode("utf-8")
return json.loads(model_spec)
def get_jumpstart_sdk_manifest():
return get_public_s3_json_object(f"{JUMPSTART_BUCKET_BASE_URL}/{SDK_MANIFEST_FILE}")


def get_proprietary_sdk_manifest():
return get_public_s3_json_object(f"{PROPRIETARY_DOC_BUCKET}/{PROPRIETARY_SDK_MANIFEST_FILE}")


def get_jumpstart_sdk_spec(s3_key: str):
return get_public_s3_json_object(f"{JUMPSTART_BUCKET_BASE_URL}/{s3_key}")


def get_proprietary_sdk_spec(s3_key: str):
return get_public_s3_json_object(f"{PROPRIETARY_DOC_BUCKET}/{s3_key}")


def get_model_task(id):
Expand Down Expand Up @@ -196,6 +207,45 @@ def get_model_source(url):
return "Source"


def create_proprietary_model_table():
proprietary_content_intro = []
proprietary_content_intro.append("\n")
proprietary_content_intro.append(".. list-table:: Available Proprietary Models\n")
proprietary_content_intro.append(" :widths: 50 20 20 20 20\n")
proprietary_content_intro.append(" :header-rows: 1\n")
proprietary_content_intro.append(" :class: datatable\n")
proprietary_content_intro.append("\n")
proprietary_content_intro.append(" * - Model ID\n")
proprietary_content_intro.append(" - Fine Tunable?\n")
proprietary_content_intro.append(" - Supported Version\n")
proprietary_content_intro.append(" - Min SDK Version\n")
proprietary_content_intro.append(" - Source\n")

sdk_manifest = get_proprietary_sdk_manifest()
sdk_manifest_top_versions_for_models = {}

for model in sdk_manifest:
if model["model_id"] not in sdk_manifest_top_versions_for_models:
sdk_manifest_top_versions_for_models[model["model_id"]] = model
else:
if str(sdk_manifest_top_versions_for_models[model["model_id"]]["version"]) < str(
model["version"]
):
sdk_manifest_top_versions_for_models[model["model_id"]] = model

proprietary_content_entries = []
for model in sdk_manifest_top_versions_for_models.values():
model_spec = get_proprietary_sdk_spec(model["spec_key"])
proprietary_content_entries.append(" * - {}\n".format(model_spec["model_id"]))
proprietary_content_entries.append(" - {}\n".format(False)) # TODO: support training
proprietary_content_entries.append(" - {}\n".format(model["version"]))
proprietary_content_entries.append(" - {}\n".format(model["min_version"]))
proprietary_content_entries.append(
" - `{} <{}>`__ |external-link|\n".format("Source", model_spec.get("url"))
)
return proprietary_content_intro + proprietary_content_entries + ["\n"]


def create_jumpstart_model_table():
sdk_manifest = get_jumpstart_sdk_manifest()
sdk_manifest_top_versions_for_models = {}
Expand Down Expand Up @@ -249,19 +299,19 @@ def create_jumpstart_model_table():
file_content_intro.append(" - Source\n")

dynamic_table_files = []
file_content_entries = []
open_weight_content_entries = []

for model in sdk_manifest_top_versions_for_models.values():
model_spec = get_jumpstart_sdk_spec(model["spec_key"])
model_task = get_model_task(model_spec["model_id"])
string_model_task = get_string_model_task(model_spec["model_id"])
model_source = get_model_source(model_spec["url"])
file_content_entries.append(" * - {}\n".format(model_spec["model_id"]))
file_content_entries.append(" - {}\n".format(model_spec["training_supported"]))
file_content_entries.append(" - {}\n".format(model["version"]))
file_content_entries.append(" - {}\n".format(model["min_version"]))
file_content_entries.append(" - {}\n".format(model_task))
file_content_entries.append(
open_weight_content_entries.append(" * - {}\n".format(model_spec["model_id"]))
open_weight_content_entries.append(" - {}\n".format(model_spec["training_supported"]))
open_weight_content_entries.append(" - {}\n".format(model["version"]))
open_weight_content_entries.append(" - {}\n".format(model["min_version"]))
open_weight_content_entries.append(" - {}\n".format(model_task))
open_weight_content_entries.append(
" - `{} <{}>`__ |external-link|\n".format(model_source, model_spec["url"])
)

Expand Down Expand Up @@ -299,7 +349,10 @@ def create_jumpstart_model_table():
f.writelines(file_content_single_entry)
f.close()

proprietary_content_entries = create_proprietary_model_table()

f = open("doc_utils/pretrainedmodels.rst", "a")
f.writelines(file_content_intro)
f.writelines(file_content_entries)
f.writelines(open_weight_content_entries)
f.writelines(proprietary_content_entries)
f.close()
3 changes: 3 additions & 0 deletions src/sagemaker/accept_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from sagemaker.jumpstart import artifacts, utils as jumpstart_utils
from sagemaker.jumpstart.constants import DEFAULT_JUMPSTART_SAGEMAKER_SESSION
from sagemaker.jumpstart.enums import JumpStartModelType
from sagemaker.session import Session


Expand Down Expand Up @@ -75,6 +76,7 @@ def retrieve_default(
tolerate_vulnerable_model: bool = False,
tolerate_deprecated_model: bool = False,
sagemaker_session: Session = DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
model_type: JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS,
) -> str:
"""Retrieves the default accept type for the model matching the given arguments.
Expand Down Expand Up @@ -114,4 +116,5 @@ def retrieve_default(
tolerate_vulnerable_model,
tolerate_deprecated_model,
sagemaker_session=sagemaker_session,
model_type=model_type,
)
Loading

0 comments on commit 95ee170

Please sign in to comment.