-
Notifications
You must be signed in to change notification settings - Fork 1.2k
doc: Support for generation of Jumpstart model table on build #2888
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
Changes from all commits
ed7dce3
7a347c7
34b07c0
4d0bfed
1f9b88f
f94245c
90b0b0f
858a0dc
4886405
7203862
89b682f
7979d97
e5d785b
bb3d3fa
b0891fa
6987b5b
86b2b57
b0c1706
6cc1212
de88492
0b6fb78
57ade33
e3398d9
f05b04e
7932372
11aea41
44ad05e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Environment Variables | ||
--------------------- | ||
|
||
.. automodule:: sagemaker.environment_variables | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Hyperparameters | ||
--------------- | ||
|
||
.. automodule:: sagemaker.hyperparameters | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Model URIs | ||
---------- | ||
|
||
.. automodule:: sagemaker.model_uris | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Script URIs | ||
----------- | ||
|
||
.. automodule:: sagemaker.script_uris | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
from __future__ import absolute_import | ||
from urllib import request | ||
import json | ||
from packaging.version import Version | ||
|
||
JUMPSTART_REGION = "eu-west-2" | ||
SDK_MANIFEST_FILE = "models_manifest.json" | ||
JUMPSTART_BUCKET_BASE_URL = "https://jumpstart-cache-prod-{}.s3.{}.amazonaws.com".format( | ||
JUMPSTART_REGION, JUMPSTART_REGION | ||
) | ||
|
||
|
||
def get_jumpstart_sdk_manifest(): | ||
url = "{}/{}".format(JUMPSTART_BUCKET_BASE_URL, SDK_MANIFEST_FILE) | ||
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 create_jumpstart_model_table(): | ||
sdk_manifest = get_jumpstart_sdk_manifest() | ||
sdk_manifest_top_versions_for_models = {} | ||
|
||
for model in sdk_manifest: | ||
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. Future improvement (non-blocking): 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. I've seen this take a max of 5 minutes as it stands. I agree we should definitely look to optimize this call, but we wanted to get |
||
if model["model_id"] not in sdk_manifest_top_versions_for_models: | ||
sdk_manifest_top_versions_for_models[model["model_id"]] = model | ||
else: | ||
if Version( | ||
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. nit: can use |
||
sdk_manifest_top_versions_for_models[model["model_id"]]["version"] | ||
) < Version(model["version"]): | ||
sdk_manifest_top_versions_for_models[model["model_id"]] = model | ||
|
||
file_content = [] | ||
|
||
file_content.append("==================================\n") | ||
file_content.append("JumpStart Available Model Table\n") | ||
file_content.append("==================================\n") | ||
file_content.append( | ||
""" | ||
JumpStart for the SageMaker Python SDK uses model ids and model versions to access the necessary | ||
utilities. This table serves to provide the core material plus some extra information that can be useful | ||
in selecting the correct model id and corresponding parameters.\n | ||
""" | ||
) | ||
file_content.append( | ||
""" | ||
If you want to automatically use the latest version of the model, use "*" for the `model_version` attribute. | ||
We highly suggest pinning an exact model version however.\n | ||
""" | ||
) | ||
file_content.append("\n") | ||
file_content.append(".. list-table:: Available Models\n") | ||
file_content.append(" :widths: 50 20 20 20\n") | ||
file_content.append(" :header-rows: 1\n") | ||
file_content.append(" :class: datatable\n") | ||
file_content.append("\n") | ||
file_content.append(" * - Model ID\n") | ||
file_content.append(" - Fine Tunable?\n") | ||
file_content.append(" - Latest Version\n") | ||
file_content.append(" - Min SDK Version\n") | ||
|
||
for model in sorted(sdk_manifest, key=lambda elt: elt["model_id"]): | ||
model_spec = get_jumpstart_sdk_spec(model["spec_key"]) | ||
file_content.append(" * - {}\n".format(model["model_id"])) | ||
file_content.append(" - {}\n".format(model_spec["training_supported"])) | ||
file_content.append(" - {}\n".format(model["version"])) | ||
file_content.append(" - {}\n".format(model["min_version"])) | ||
|
||
f = open("doc_utils/jumpstart.rst", "w") | ||
f.writelines(file_content) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
sphinx==3.1.1 | ||
sphinx-rtd-theme==0.5.0 | ||
docutils==0.15.2 | ||
packaging==20.9 |
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.
non-blocking: if you have time, please add a comment as to why we use
DUB
so that someone doesn't just change it back tous-west-2
. Also, could you renameJUMPSTART_METADATA_REGION
?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.
+1