aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-05-12 12:25:10 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-05-12 12:25:10 +0300
commit242ed6b08b9edde490fb7a16a6063e0bad8ccc88 (patch)
tree905ee9509e06949fb489ee0532ce5db7d2ea9c29 /contrib/python
parent64d1f1262fd0f33992ff184fef10d806d64f74da (diff)
downloadydb-242ed6b08b9edde490fb7a16a6063e0bad8ccc88.tar.gz
intermediate changes
ref:0fbe94d885cb5449f7ff351c063c77f8b4f47715
Diffstat (limited to 'contrib/python')
-rw-r--r--contrib/python/boto3/py3/.dist-info/METADATA4
-rw-r--r--contrib/python/boto3/py3/boto3/__init__.py2
-rw-r--r--contrib/python/botocore/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/botocore/py3/botocore/__init__.py2
-rw-r--r--contrib/python/botocore/py3/botocore/compat.py170
-rw-r--r--contrib/python/botocore/py3/botocore/data/amplify/2017-07-25/service-2.json10
-rw-r--r--contrib/python/botocore/py3/botocore/data/chime-sdk-media-pipelines/2021-07-15/paginators-1.json3
-rw-r--r--contrib/python/botocore/py3/botocore/data/chime-sdk-media-pipelines/2021-07-15/service-2.json762
-rw-r--r--contrib/python/botocore/py3/botocore/data/cloudtrail/2013-11-01/service-2.json64
-rw-r--r--contrib/python/botocore/py3/botocore/data/iotwireless/2020-11-22/service-2.json594
-rw-r--r--contrib/python/botocore/py3/botocore/data/lookoutequipment/2020-12-15/service-2.json449
-rw-r--r--contrib/python/botocore/py3/botocore/data/rekognition/2016-06-27/service-2.json332
-rw-r--r--contrib/python/botocore/py3/botocore/data/sagemaker/2017-07-24/service-2.json362
-rw-r--r--contrib/python/botocore/py3/patches/01-unvendor-six.patch44
-rw-r--r--contrib/python/botocore/py3/patches/02-fix-for-arcadia.patch2
-rw-r--r--contrib/python/pyparsing/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/__init__.py4
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/actions.py2
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/core.py130
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/diagram/__init__.py61
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/diagram/template.jinja226
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/exceptions.py4
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/helpers.py27
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/results.py8
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/testing.py10
-rw-r--r--contrib/python/pyparsing/py3/pyparsing/unicode.py30
-rw-r--r--contrib/python/traitlets/py3/.dist-info/METADATA71
-rw-r--r--contrib/python/traitlets/py3/COPYING.md6
-rw-r--r--contrib/python/traitlets/py3/README.md47
-rw-r--r--contrib/python/traitlets/py3/patches/01-fix-tests.patch65
-rw-r--r--contrib/python/traitlets/py3/traitlets/__init__.py11
-rw-r--r--contrib/python/traitlets/py3/traitlets/_version.py7
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/__init__.py2
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/application.py561
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/configurable.py188
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/loader.py237
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/manager.py12
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py58
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/tests/test_application.py445
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/tests/test_configurable.py424
-rw-r--r--contrib/python/traitlets/py3/traitlets/config/tests/test_loader.py348
-rw-r--r--contrib/python/traitlets/py3/traitlets/log.py4
-rw-r--r--contrib/python/traitlets/py3/traitlets/py.typed0
-rw-r--r--contrib/python/traitlets/py3/traitlets/tests/_warnings.py38
-rw-r--r--contrib/python/traitlets/py3/traitlets/tests/test_traitlets.py1321
-rw-r--r--contrib/python/traitlets/py3/traitlets/tests/test_traitlets_enum.py106
-rw-r--r--contrib/python/traitlets/py3/traitlets/tests/utils.py16
-rw-r--r--contrib/python/traitlets/py3/traitlets/traitlets.py1022
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/__init__.py9
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/bunch.py9
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/decorators.py15
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/descriptions.py37
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/getargspec.py19
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/importstring.py4
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/nested_update.py38
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/sentinel.py5
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/tests/test_bunch.py14
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/tests/test_decorators.py84
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/tests/test_importstring.py15
-rw-r--r--contrib/python/traitlets/py3/traitlets/utils/text.py6
60 files changed, 5500 insertions, 2850 deletions
diff --git a/contrib/python/boto3/py3/.dist-info/METADATA b/contrib/python/boto3/py3/.dist-info/METADATA
index 3309e5d8ce..b29c2cf313 100644
--- a/contrib/python/boto3/py3/.dist-info/METADATA
+++ b/contrib/python/boto3/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: boto3
-Version: 1.22.1
+Version: 1.22.2
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
@@ -22,7 +22,7 @@ Classifier: Programming Language :: Python :: 3.10
Requires-Python: >= 3.6
License-File: LICENSE
License-File: NOTICE
-Requires-Dist: botocore (<1.26.0,>=1.25.1)
+Requires-Dist: botocore (<1.26.0,>=1.25.2)
Requires-Dist: jmespath (<2.0.0,>=0.7.1)
Requires-Dist: s3transfer (<0.6.0,>=0.5.0)
Provides-Extra: crt
diff --git a/contrib/python/boto3/py3/boto3/__init__.py b/contrib/python/boto3/py3/boto3/__init__.py
index e6f5b2aac0..76dad7b973 100644
--- a/contrib/python/boto3/py3/boto3/__init__.py
+++ b/contrib/python/boto3/py3/boto3/__init__.py
@@ -17,7 +17,7 @@ from boto3.compat import _warn_deprecated_python
from boto3.session import Session
__author__ = 'Amazon Web Services'
-__version__ = '1.22.1'
+__version__ = '1.22.2'
# The default Boto3 session; autoloaded when needed.
diff --git a/contrib/python/botocore/py3/.dist-info/METADATA b/contrib/python/botocore/py3/.dist-info/METADATA
index 5534f5023b..e0561cf3d1 100644
--- a/contrib/python/botocore/py3/.dist-info/METADATA
+++ b/contrib/python/botocore/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: botocore
-Version: 1.25.1
+Version: 1.25.2
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
diff --git a/contrib/python/botocore/py3/botocore/__init__.py b/contrib/python/botocore/py3/botocore/__init__.py
index f7074c161f..33b9786ef6 100644
--- a/contrib/python/botocore/py3/botocore/__init__.py
+++ b/contrib/python/botocore/py3/botocore/__init__.py
@@ -16,7 +16,7 @@ import logging
import os
import re
-__version__ = '1.25.1'
+__version__ = '1.25.2'
class NullHandler(logging.Handler):
diff --git a/contrib/python/botocore/py3/botocore/compat.py b/contrib/python/botocore/py3/botocore/compat.py
index bedcab26bd..23ef7ec8d9 100644
--- a/contrib/python/botocore/py3/botocore/compat.py
+++ b/contrib/python/botocore/py3/botocore/compat.py
@@ -21,6 +21,8 @@ import logging
import shlex
import re
import os
+from collections import OrderedDict
+from collections.abc import MutableMapping
from math import floor
import six
@@ -31,121 +33,58 @@ from urllib3 import exceptions
logger = logging.getLogger(__name__)
-if six.PY3:
- from six.moves import http_client
-
- class HTTPHeaders(http_client.HTTPMessage):
- pass
-
- from urllib.parse import quote
- from urllib.parse import urlencode
- from urllib.parse import unquote
- from urllib.parse import unquote_plus
- from urllib.parse import urlparse
- from urllib.parse import urlsplit
- from urllib.parse import urlunsplit
- from urllib.parse import urljoin
- from urllib.parse import parse_qsl
- from urllib.parse import parse_qs
- from http.client import HTTPResponse
- from io import IOBase as _IOBase
- from base64 import encodebytes
- from email.utils import formatdate
- from itertools import zip_longest
- file_type = _IOBase
- zip = zip
-
- # In python3, unquote takes a str() object, url decodes it,
- # then takes the bytestring and decodes it to utf-8.
- # Python2 we'll have to do this ourself (see below).
- unquote_str = unquote_plus
-
- def set_socket_timeout(http_response, timeout):
- """Set the timeout of the socket from an HTTPResponse.
-
- :param http_response: An instance of ``httplib.HTTPResponse``
-
- """
- http_response._fp.fp.raw._sock.settimeout(timeout)
-
- def accepts_kwargs(func):
- # In python3.4.1, there's backwards incompatible
- # changes when using getargspec with functools.partials.
- return inspect.getfullargspec(func)[2]
-
- def ensure_unicode(s, encoding=None, errors=None):
- # NOOP in Python 3, because every string is already unicode
- return s
+from six.moves import http_client
+
+class HTTPHeaders(http_client.HTTPMessage):
+ pass
+
+from urllib.parse import (
+ quote,
+ urlencode,
+ unquote,
+ unquote_plus,
+ urlparse,
+ urlsplit,
+ urlunsplit,
+ urljoin,
+ parse_qsl,
+ parse_qs,
+)
+from http.client import HTTPResponse
+from io import IOBase as _IOBase
+from base64 import encodebytes
+from email.utils import formatdate
+from itertools import zip_longest
+file_type = _IOBase
+zip = zip
+
+# In python3, unquote takes a str() object, url decodes it,
+# then takes the bytestring and decodes it to utf-8.
+unquote_str = unquote_plus
+
+def set_socket_timeout(http_response, timeout):
+ """Set the timeout of the socket from an HTTPResponse.
+
+ :param http_response: An instance of ``httplib.HTTPResponse``
- def ensure_bytes(s, encoding='utf-8', errors='strict'):
- if isinstance(s, str):
- return s.encode(encoding, errors)
- if isinstance(s, bytes):
- return s
- raise ValueError("Expected str or bytes, received %s." % type(s))
-
-else:
- from urllib import quote
- from urllib import urlencode
- from urllib import unquote
- from urllib import unquote_plus
- from urlparse import urlparse
- from urlparse import urlsplit
- from urlparse import urlunsplit
- from urlparse import urljoin
- from urlparse import parse_qsl
- from urlparse import parse_qs
- from email.message import Message
- from email.Utils import formatdate
- file_type = file
- from itertools import izip as zip
- from itertools import izip_longest as zip_longest
- from httplib import HTTPResponse
- from base64 import encodestring as encodebytes
-
- class HTTPHeaders(Message):
-
- # The __iter__ method is not available in python2.x, so we have
- # to port the py3 version.
- def __iter__(self):
- for field, value in self._headers:
- yield field
-
- def unquote_str(value, encoding='utf-8'):
- # In python2, unquote() gives us a string back that has the urldecoded
- # bits, but not the unicode parts. We need to decode this manually.
- # unquote has special logic in which if it receives a unicode object it
- # will decode it to latin1. This is hard coded. To avoid this, we'll
- # encode the string with the passed in encoding before trying to
- # unquote it.
- byte_string = value.encode(encoding)
- return unquote_plus(byte_string).decode(encoding)
-
- def set_socket_timeout(http_response, timeout):
- """Set the timeout of the socket from an HTTPResponse.
-
- :param http_response: An instance of ``httplib.HTTPResponse``
-
- """
- http_response._fp.fp._sock.settimeout(timeout)
-
- def accepts_kwargs(func):
- return inspect.getargspec(func)[2]
-
- def ensure_unicode(s, encoding='utf-8', errors='strict'):
- if isinstance(s, six.text_type):
- return s
- return unicode(s, encoding, errors)
-
- def ensure_bytes(s, encoding='utf-8', errors='strict'):
- if isinstance(s, unicode):
- return s.encode(encoding, errors)
- if isinstance(s, str):
- return s
- raise ValueError("Expected str or unicode, received %s." % type(s))
+ """
+ http_response._fp.fp.raw._sock.settimeout(timeout)
+def accepts_kwargs(func):
+ # In python3.4.1, there's backwards incompatible
+ # changes when using getargspec with functools.partials.
+ return inspect.getfullargspec(func)[2]
-from collections import OrderedDict
+def ensure_unicode(s, encoding=None, errors=None):
+ # NOOP in Python 3, because every string is already unicode
+ return s
+
+def ensure_bytes(s, encoding='utf-8', errors='strict'):
+ if isinstance(s, str):
+ return s.encode(encoding, errors)
+ if isinstance(s, bytes):
+ return s
+ raise ValueError(f"Expected str or bytes, received {type(s)}.")
try:
@@ -322,7 +261,7 @@ def _windows_shell_split(s):
# Quotes must be terminated.
if is_quoted:
- raise ValueError('No closing quotation in string: %s' % s)
+ raise ValueError(f"No closing quotation in string: {s}")
# There may be some leftover backslashes, so we need to add them in.
# There's no quote so we add the exact number.
@@ -347,11 +286,6 @@ def get_tzinfo_options():
return (tzlocal,)
-try:
- from collections.abc import MutableMapping
-except ImportError:
- from collections import MutableMapping
-
# Detect if CRT is available for use
try:
import awscrt.auth
diff --git a/contrib/python/botocore/py3/botocore/data/amplify/2017-07-25/service-2.json b/contrib/python/botocore/py3/botocore/data/amplify/2017-07-25/service-2.json
index 65b0b2252e..5157ed6b08 100644
--- a/contrib/python/botocore/py3/botocore/data/amplify/2017-07-25/service-2.json
+++ b/contrib/python/botocore/py3/botocore/data/amplify/2017-07-25/service-2.json
@@ -745,7 +745,7 @@
},
"repositoryCloneMethod":{
"shape":"RepositoryCloneMethod",
- "documentation":"<p>The authentication protocol to use to access the Git repository for an Amplify app. For a GitHub repository, specify <code>TOKEN</code>. For an Amazon Web Services CodeCommit repository, specify <code>SIGV4</code>. For GitLab and Bitbucket repositories, specify <code>SSH</code>.</p>"
+ "documentation":"<note> <p>This is for internal use.</p> </note> <p>The Amplify service uses this parameter to specify the authentication protocol to use to access the Git repository for an Amplify app. Amplify specifies <code>TOKEN</code> for a GitHub repository, <code>SIGV4</code> for an Amazon Web Services CodeCommit repository, and <code>SSH</code> for GitLab and Bitbucket repositories.</p>"
}
},
"documentation":"<p> Represents the different branches of a repository for building, deploying, and hosting an Amplify app. </p>"
@@ -1150,11 +1150,11 @@
},
"oauthToken":{
"shape":"OauthToken",
- "documentation":"<p> The OAuth token for a third-party source control system for an Amplify app. The OAuth token is used to create a webhook and a read-only deploy key. The OAuth token is not stored. </p>"
+ "documentation":"<p>The OAuth token for a third-party source control system for an Amplify app. The OAuth token is used to create a webhook and a read-only deploy key using SSH cloning. The OAuth token is not stored.</p> <p>Use <code>oauthToken</code> for repository providers other than GitHub, such as Bitbucket or CodeCommit. To authorize access to GitHub as your repository provider, use <code>accessToken</code>.</p> <p>You must specify either <code>oauthToken</code> or <code>accessToken</code> when you create a new app.</p> <p>Existing Amplify apps deployed from a GitHub repository using OAuth continue to work with CI/CD. However, we strongly recommend that you migrate these apps to use the GitHub App. For more information, see <a href=\"https://docs.aws.amazon.com/amplify/latest/UserGuide/setting-up-GitHub-access.html#migrating-to-github-app-auth\">Migrating an existing OAuth app to the Amplify GitHub App</a> in the <i>Amplify User Guide</i> .</p>"
},
"accessToken":{
"shape":"AccessToken",
- "documentation":"<p> The personal access token for a third-party source control system for an Amplify app. The personal access token is used to create a webhook and a read-only deploy key. The token is not stored. </p>"
+ "documentation":"<p>The personal access token for a GitHub repository for an Amplify app. The personal access token is used to authorize access to a GitHub repository using the Amplify GitHub App. The token is not stored.</p> <p>Use <code>accessToken</code> for GitHub repositories only. To authorize access to a repository provider such as Bitbucket or CodeCommit, use <code>oauthToken</code>.</p> <p>You must specify either <code>accessToken</code> or <code>oauthToken</code> when you create a new app.</p> <p>Existing Amplify apps deployed from a GitHub repository using OAuth continue to work with CI/CD. However, we strongly recommend that you migrate these apps to use the GitHub App. For more information, see <a href=\"https://docs.aws.amazon.com/amplify/latest/UserGuide/setting-up-GitHub-access.html#migrating-to-github-app-auth\">Migrating an existing OAuth app to the Amplify GitHub App</a> in the <i>Amplify User Guide</i> .</p>"
},
"environmentVariables":{
"shape":"EnvironmentVariables",
@@ -3181,11 +3181,11 @@
},
"oauthToken":{
"shape":"OauthToken",
- "documentation":"<p> The OAuth token for a third-party source control system for an Amplify app. The token is used to create a webhook and a read-only deploy key. The OAuth token is not stored. </p>"
+ "documentation":"<p>The OAuth token for a third-party source control system for an Amplify app. The OAuth token is used to create a webhook and a read-only deploy key using SSH cloning. The OAuth token is not stored.</p> <p>Use <code>oauthToken</code> for repository providers other than GitHub, such as Bitbucket or CodeCommit.</p> <p>To authorize access to GitHub as your repository provider, use <code>accessToken</code>.</p> <p>You must specify either <code>oauthToken</code> or <code>accessToken</code> when you update an app.</p> <p>Existing Amplify apps deployed from a GitHub repository using OAuth continue to work with CI/CD. However, we strongly recommend that you migrate these apps to use the GitHub App. For more information, see <a href=\"https://docs.aws.amazon.com/amplify/latest/UserGuide/setting-up-GitHub-access.html#migrating-to-github-app-auth\">Migrating an existing OAuth app to the Amplify GitHub App</a> in the <i>Amplify User Guide</i> .</p>"
},
"accessToken":{
"shape":"AccessToken",
- "documentation":"<p> The personal access token for a third-party source control system for an Amplify app. The token is used to create webhook and a read-only deploy key. The token is not stored. </p>"
+ "documentation":"<p>The personal access token for a GitHub repository for an Amplify app. The personal access token is used to authorize access to a GitHub repository using the Amplify GitHub App. The token is not stored.</p> <p>Use <code>accessToken</code> for GitHub repositories only. To authorize access to a repository provider such as Bitbucket or CodeCommit, use <code>oauthToken</code>.</p> <p>You must specify either <code>accessToken</code> or <code>oauthToken</code> when you update an app.</p> <p>Existing Amplify apps deployed from a GitHub repository using OAuth continue to work with CI/CD. However, we strongly recommend that you migrate these apps to use the GitHub App. For more information, see <a href=\"https://docs.aws.amazon.com/amplify/latest/UserGuide/setting-up-GitHub-access.html#migrating-to-github-app-auth\">Migrating an existing OAuth app to the Amplify GitHub App</a> in the <i>Amplify User Guide</i> .</p>"
}
},
"documentation":"<p> The request structure for the update app request. </p>"
diff --git a/contrib/python/botocore/py3/botocore/data/chime-sdk-media-pipelines/2021-07-15/paginators-1.json b/contrib/python/botocore/py3/botocore/data/chime-sdk-media-pipelines/2021-07-15/paginators-1.json
new file mode 100644
index 0000000000..ea142457a6
--- /dev/null
+++ b/contrib/python/botocore/py3/botocore/data/chime-sdk-media-pipelines/2021-07-15/paginators-1.json
@@ -0,0 +1,3 @@
+{
+ "pagination": {}
+}
diff --git a/contrib/python/botocore/py3/botocore/data/chime-sdk-media-pipelines/2021-07-15/service-2.json b/contrib/python/botocore/py3/botocore/data/chime-sdk-media-pipelines/2021-07-15/service-2.json
new file mode 100644
index 0000000000..234bf08075
--- /dev/null
+++ b/contrib/python/botocore/py3/botocore/data/chime-sdk-media-pipelines/2021-07-15/service-2.json
@@ -0,0 +1,762 @@
+{
+ "version":"2.0",
+ "metadata":{
+ "apiVersion":"2021-07-15",
+ "endpointPrefix":"media-pipelines-chime",
+ "protocol":"rest-json",
+ "serviceFullName":"Amazon Chime SDK Media Pipelines",
+ "serviceId":"Chime SDK Media Pipelines",
+ "signatureVersion":"v4",
+ "signingName":"chime",
+ "uid":"chime-sdk-media-pipelines-2021-07-15"
+ },
+ "operations":{
+ "CreateMediaCapturePipeline":{
+ "name":"CreateMediaCapturePipeline",
+ "http":{
+ "method":"POST",
+ "requestUri":"/sdk-media-capture-pipelines",
+ "responseCode":201
+ },
+ "input":{"shape":"CreateMediaCapturePipelineRequest"},
+ "output":{"shape":"CreateMediaCapturePipelineResponse"},
+ "errors":[
+ {"shape":"BadRequestException"},
+ {"shape":"ForbiddenException"},
+ {"shape":"UnauthorizedClientException"},
+ {"shape":"ThrottledClientException"},
+ {"shape":"ResourceLimitExceededException"},
+ {"shape":"ServiceUnavailableException"},
+ {"shape":"ServiceFailureException"}
+ ],
+ "documentation":"<p>Creates a media capture pipeline.</p>"
+ },
+ "DeleteMediaCapturePipeline":{
+ "name":"DeleteMediaCapturePipeline",
+ "http":{
+ "method":"DELETE",
+ "requestUri":"/sdk-media-capture-pipelines/{mediaPipelineId}",
+ "responseCode":204
+ },
+ "input":{"shape":"DeleteMediaCapturePipelineRequest"},
+ "errors":[
+ {"shape":"BadRequestException"},
+ {"shape":"ForbiddenException"},
+ {"shape":"ThrottledClientException"},
+ {"shape":"NotFoundException"},
+ {"shape":"UnauthorizedClientException"},
+ {"shape":"ServiceUnavailableException"},
+ {"shape":"ServiceFailureException"}
+ ],
+ "documentation":"<p>Deletes the media capture pipeline.</p>"
+ },
+ "GetMediaCapturePipeline":{
+ "name":"GetMediaCapturePipeline",
+ "http":{
+ "method":"GET",
+ "requestUri":"/sdk-media-capture-pipelines/{mediaPipelineId}",
+ "responseCode":200
+ },
+ "input":{"shape":"GetMediaCapturePipelineRequest"},
+ "output":{"shape":"GetMediaCapturePipelineResponse"},
+ "errors":[
+ {"shape":"BadRequestException"},
+ {"shape":"ForbiddenException"},
+ {"shape":"UnauthorizedClientException"},
+ {"shape":"ThrottledClientException"},
+ {"shape":"NotFoundException"},
+ {"shape":"ServiceUnavailableException"},
+ {"shape":"ServiceFailureException"}
+ ],
+ "documentation":"<p>Gets an existing media capture pipeline.</p>"
+ },
+ "ListMediaCapturePipelines":{
+ "name":"ListMediaCapturePipelines",
+ "http":{
+ "method":"GET",
+ "requestUri":"/sdk-media-capture-pipelines",
+ "responseCode":200
+ },
+ "input":{"shape":"ListMediaCapturePipelinesRequest"},
+ "output":{"shape":"ListMediaCapturePipelinesResponse"},
+ "errors":[
+ {"shape":"BadRequestException"},
+ {"shape":"ForbiddenException"},
+ {"shape":"UnauthorizedClientException"},
+ {"shape":"ThrottledClientException"},
+ {"shape":"ResourceLimitExceededException"},
+ {"shape":"ServiceUnavailableException"},
+ {"shape":"ServiceFailureException"}
+ ],
+ "documentation":"<p>Returns a list of media capture pipelines.</p>"
+ },
+ "ListTagsForResource":{
+ "name":"ListTagsForResource",
+ "http":{
+ "method":"GET",
+ "requestUri":"/tags",
+ "responseCode":200
+ },
+ "input":{"shape":"ListTagsForResourceRequest"},
+ "output":{"shape":"ListTagsForResourceResponse"},
+ "errors":[
+ {"shape":"NotFoundException"},
+ {"shape":"BadRequestException"},
+ {"shape":"ForbiddenException"},
+ {"shape":"UnauthorizedClientException"},
+ {"shape":"ThrottledClientException"},
+ {"shape":"ServiceUnavailableException"},
+ {"shape":"ServiceFailureException"}
+ ],
+ "documentation":"<p>Lists the tags applied to an Amazon Chime SDK media capture pipeline.</p>"
+ },
+ "TagResource":{
+ "name":"TagResource",
+ "http":{
+ "method":"POST",
+ "requestUri":"/tags?operation=tag-resource",
+ "responseCode":204
+ },
+ "input":{"shape":"TagResourceRequest"},
+ "output":{"shape":"TagResourceResponse"},
+ "errors":[
+ {"shape":"NotFoundException"},
+ {"shape":"BadRequestException"},
+ {"shape":"ForbiddenException"},
+ {"shape":"UnauthorizedClientException"},
+ {"shape":"ThrottledClientException"},
+ {"shape":"ServiceUnavailableException"},
+ {"shape":"ServiceFailureException"}
+ ],
+ "documentation":"<p>Applies the specified tags to the specified Amazon Chime SDK media capture pipeline.</p>"
+ },
+ "UntagResource":{
+ "name":"UntagResource",
+ "http":{
+ "method":"POST",
+ "requestUri":"/tags?operation=untag-resource",
+ "responseCode":204
+ },
+ "input":{"shape":"UntagResourceRequest"},
+ "output":{"shape":"UntagResourceResponse"},
+ "errors":[
+ {"shape":"NotFoundException"},
+ {"shape":"BadRequestException"},
+ {"shape":"ForbiddenException"},
+ {"shape":"UnauthorizedClientException"},
+ {"shape":"ThrottledClientException"},
+ {"shape":"ServiceUnavailableException"},
+ {"shape":"ServiceFailureException"}
+ ],
+ "documentation":"<p>Removes the specified tags from the specified Amazon Chime SDK media capture pipeline.</p>"
+ }
+ },
+ "shapes":{
+ "AmazonResourceName":{
+ "type":"string",
+ "max":1011,
+ "min":1,
+ "pattern":"^arn[\\/\\:\\-\\_\\.a-zA-Z0-9]+$"
+ },
+ "Arn":{
+ "type":"string",
+ "max":1024,
+ "min":1,
+ "pattern":"^arn[\\/\\:\\-\\_\\.a-zA-Z0-9]+$",
+ "sensitive":true
+ },
+ "ArtifactsConfiguration":{
+ "type":"structure",
+ "required":[
+ "Audio",
+ "Video",
+ "Content"
+ ],
+ "members":{
+ "Audio":{
+ "shape":"AudioArtifactsConfiguration",
+ "documentation":"<p>The configuration for the audio artifacts.</p>"
+ },
+ "Video":{
+ "shape":"VideoArtifactsConfiguration",
+ "documentation":"<p>The configuration for the video artifacts.</p>"
+ },
+ "Content":{
+ "shape":"ContentArtifactsConfiguration",
+ "documentation":"<p>The configuration for the content artifacts.</p>"
+ }
+ },
+ "documentation":"<p>The configuration for the artifacts.</p>"
+ },
+ "ArtifactsState":{
+ "type":"string",
+ "enum":[
+ "Enabled",
+ "Disabled"
+ ]
+ },
+ "AttendeeIdList":{
+ "type":"list",
+ "member":{"shape":"GuidString"},
+ "min":1
+ },
+ "AudioArtifactsConfiguration":{
+ "type":"structure",
+ "required":["MuxType"],
+ "members":{
+ "MuxType":{
+ "shape":"AudioMuxType",
+ "documentation":"<p>The MUX type of the audio artifact configuration object.</p>"
+ }
+ },
+ "documentation":"<p>The audio artifact configuration object.</p>"
+ },
+ "AudioMuxType":{
+ "type":"string",
+ "enum":[
+ "AudioOnly",
+ "AudioWithActiveSpeakerVideo"
+ ]
+ },
+ "BadRequestException":{
+ "type":"structure",
+ "members":{
+ "Code":{"shape":"ErrorCode"},
+ "Message":{"shape":"String"},
+ "RequestId":{
+ "shape":"String",
+ "documentation":"<p>The request id associated with the call responsible for the exception.</p>"
+ }
+ },
+ "documentation":"<p>The input parameters don't match the service's restrictions.</p>",
+ "error":{"httpStatusCode":400},
+ "exception":true
+ },
+ "ChimeSdkMeetingConfiguration":{
+ "type":"structure",
+ "members":{
+ "SourceConfiguration":{
+ "shape":"SourceConfiguration",
+ "documentation":"<p>The source configuration for a specified media capture pipline.</p>"
+ },
+ "ArtifactsConfiguration":{
+ "shape":"ArtifactsConfiguration",
+ "documentation":"<p>The configuration for the artifacts in an Amazon Chime SDK meeting.</p>"
+ }
+ },
+ "documentation":"<p>The configuration object of the Amazon Chime SDK meeting for a specified media capture pipeline. <code>SourceType</code> must be <code>ChimeSdkMeeting</code>.</p>"
+ },
+ "ClientRequestToken":{
+ "type":"string",
+ "max":64,
+ "min":2,
+ "pattern":"[-_a-zA-Z0-9]*",
+ "sensitive":true
+ },
+ "ContentArtifactsConfiguration":{
+ "type":"structure",
+ "required":["State"],
+ "members":{
+ "State":{
+ "shape":"ArtifactsState",
+ "documentation":"<p>Indicates whether the content artifact is enabled or disabled.</p>"
+ },
+ "MuxType":{
+ "shape":"ContentMuxType",
+ "documentation":"<p>The MUX type of the artifact configuration.</p>"
+ }
+ },
+ "documentation":"<p>The content artifact object.</p>"
+ },
+ "ContentMuxType":{
+ "type":"string",
+ "enum":["ContentOnly"]
+ },
+ "CreateMediaCapturePipelineRequest":{
+ "type":"structure",
+ "required":[
+ "SourceType",
+ "SourceArn",
+ "SinkType",
+ "SinkArn"
+ ],
+ "members":{
+ "SourceType":{
+ "shape":"MediaPipelineSourceType",
+ "documentation":"<p>Source type from which the media artifacts are captured. A Chime SDK Meeting is the only supported source.</p>"
+ },
+ "SourceArn":{
+ "shape":"Arn",
+ "documentation":"<p>ARN of the source from which the media artifacts are captured.</p>"
+ },
+ "SinkType":{
+ "shape":"MediaPipelineSinkType",
+ "documentation":"<p>Destination type to which the media artifacts are saved. You must use an S3 bucket. </p>"
+ },
+ "SinkArn":{
+ "shape":"Arn",
+ "documentation":"<p>The ARN of the sink type.</p>"
+ },
+ "ClientRequestToken":{
+ "shape":"ClientRequestToken",
+ "documentation":"<p>The token assigned to the client making the pipeline request.</p>",
+ "idempotencyToken":true
+ },
+ "ChimeSdkMeetingConfiguration":{
+ "shape":"ChimeSdkMeetingConfiguration",
+ "documentation":"<p>The configuration for a specified media capture pipeline. <code>SourceType</code> must be <code>ChimeSdkMeeting</code>.</p>"
+ },
+ "Tags":{
+ "shape":"TagList",
+ "documentation":"<p>The list of tags.</p>"
+ }
+ }
+ },
+ "CreateMediaCapturePipelineResponse":{
+ "type":"structure",
+ "members":{
+ "MediaCapturePipeline":{
+ "shape":"MediaCapturePipeline",
+ "documentation":"<p>A media capture pipeline object, the ID, source type, source ARN, sink type, and sink ARN of a media capture pipeline object.</p>"
+ }
+ }
+ },
+ "DeleteMediaCapturePipelineRequest":{
+ "type":"structure",
+ "required":["MediaPipelineId"],
+ "members":{
+ "MediaPipelineId":{
+ "shape":"GuidString",
+ "documentation":"<p>The ID of the media capture pipeline being deleted. </p>",
+ "location":"uri",
+ "locationName":"mediaPipelineId"
+ }
+ }
+ },
+ "ErrorCode":{
+ "type":"string",
+ "enum":[
+ "BadRequest",
+ "Forbidden",
+ "NotFound",
+ "ResourceLimitExceeded",
+ "ServiceFailure",
+ "ServiceUnavailable",
+ "Throttling"
+ ]
+ },
+ "ExternalUserIdList":{
+ "type":"list",
+ "member":{"shape":"ExternalUserIdType"},
+ "min":1
+ },
+ "ExternalUserIdType":{
+ "type":"string",
+ "max":64,
+ "min":2,
+ "sensitive":true
+ },
+ "ForbiddenException":{
+ "type":"structure",
+ "members":{
+ "Code":{"shape":"ErrorCode"},
+ "Message":{"shape":"String"},
+ "RequestId":{
+ "shape":"String",
+ "documentation":"<p>The request id associated with the call responsible for the exception.</p>"
+ }
+ },
+ "documentation":"<p>The client is permanently forbidden from making the request.</p>",
+ "error":{"httpStatusCode":403},
+ "exception":true
+ },
+ "GetMediaCapturePipelineRequest":{
+ "type":"structure",
+ "required":["MediaPipelineId"],
+ "members":{
+ "MediaPipelineId":{
+ "shape":"GuidString",
+ "documentation":"<p>The ID of the pipeline that you want to get.</p>",
+ "location":"uri",
+ "locationName":"mediaPipelineId"
+ }
+ }
+ },
+ "GetMediaCapturePipelineResponse":{
+ "type":"structure",
+ "members":{
+ "MediaCapturePipeline":{
+ "shape":"MediaCapturePipeline",
+ "documentation":"<p>The media capture pipeline object.</p>"
+ }
+ }
+ },
+ "GuidString":{
+ "type":"string",
+ "max":36,
+ "min":36,
+ "pattern":"[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}"
+ },
+ "Iso8601Timestamp":{
+ "type":"timestamp",
+ "timestampFormat":"iso8601"
+ },
+ "ListMediaCapturePipelinesRequest":{
+ "type":"structure",
+ "members":{
+ "NextToken":{
+ "shape":"String",
+ "documentation":"<p>The token used to retrieve the next page of results.</p>",
+ "location":"querystring",
+ "locationName":"next-token"
+ },
+ "MaxResults":{
+ "shape":"ResultMax",
+ "documentation":"<p>The maximum number of results to return in a single call. Valid Range: 1 - 99.</p>",
+ "location":"querystring",
+ "locationName":"max-results"
+ }
+ }
+ },
+ "ListMediaCapturePipelinesResponse":{
+ "type":"structure",
+ "members":{
+ "MediaCapturePipelines":{
+ "shape":"MediaCapturePipelineSummaryList",
+ "documentation":"<p>The media capture pipeline objects in the list.</p>"
+ },
+ "NextToken":{
+ "shape":"String",
+ "documentation":"<p>The token used to retrieve the next page of results. </p>"
+ }
+ }
+ },
+ "ListTagsForResourceRequest":{
+ "type":"structure",
+ "required":["ResourceARN"],
+ "members":{
+ "ResourceARN":{
+ "shape":"AmazonResourceName",
+ "documentation":"<p>The resource ARN.</p>",
+ "location":"querystring",
+ "locationName":"arn"
+ }
+ }
+ },
+ "ListTagsForResourceResponse":{
+ "type":"structure",
+ "members":{
+ "Tags":{
+ "shape":"TagList",
+ "documentation":"<p>The tag key-value pairs.</p>"
+ }
+ }
+ },
+ "MediaCapturePipeline":{
+ "type":"structure",
+ "members":{
+ "MediaPipelineId":{
+ "shape":"GuidString",
+ "documentation":"<p>The ID of a media capture pipeline.</p>"
+ },
+ "MediaPipelineArn":{
+ "shape":"AmazonResourceName",
+ "documentation":"<p>The ARN of a media capture pipeline.</p>"
+ },
+ "SourceType":{
+ "shape":"MediaPipelineSourceType",
+ "documentation":"<p>Source type from which media artifacts are saved. You must use <code>ChimeMeeting</code>.</p>"
+ },
+ "SourceArn":{
+ "shape":"Arn",
+ "documentation":"<p>ARN of the source from which the media artifacts are saved.</p>"
+ },
+ "Status":{
+ "shape":"MediaPipelineStatus",
+ "documentation":"<p>The status of the media capture pipeline.</p>"
+ },
+ "SinkType":{
+ "shape":"MediaPipelineSinkType",
+ "documentation":"<p>Destination type to which the media artifacts are saved. You must use an S3 Bucket.</p>"
+ },
+ "SinkArn":{
+ "shape":"Arn",
+ "documentation":"<p>ARN of the destination to which the media artifacts are saved.</p>"
+ },
+ "CreatedTimestamp":{
+ "shape":"Iso8601Timestamp",
+ "documentation":"<p>The time at which the capture pipeline was created, in ISO 8601 format.</p>"
+ },
+ "UpdatedTimestamp":{
+ "shape":"Iso8601Timestamp",
+ "documentation":"<p>The time at which the capture pipeline was updated, in ISO 8601 format.</p>"
+ },
+ "ChimeSdkMeetingConfiguration":{
+ "shape":"ChimeSdkMeetingConfiguration",
+ "documentation":"<p>The configuration for a specified media capture pipeline. <code>SourceType</code> must be <code>ChimeSdkMeeting</code>.</p>"
+ }
+ },
+ "documentation":"<p>A media capture pipeline object consisting of an ID, source type, source ARN, a sink type, a sink ARN, and a configuration object.</p>"
+ },
+ "MediaCapturePipelineSummary":{
+ "type":"structure",
+ "members":{
+ "MediaPipelineId":{
+ "shape":"GuidString",
+ "documentation":"<p>The ID of a media capture pipeline.</p>"
+ },
+ "MediaPipelineArn":{
+ "shape":"AmazonResourceName",
+ "documentation":"<p>The ARN of a media capture pipeline.</p>"
+ }
+ },
+ "documentation":"<p>A summary of a media capture pipeline.</p>"
+ },
+ "MediaCapturePipelineSummaryList":{
+ "type":"list",
+ "member":{"shape":"MediaCapturePipelineSummary"}
+ },
+ "MediaPipelineSinkType":{
+ "type":"string",
+ "enum":["S3Bucket"]
+ },
+ "MediaPipelineSourceType":{
+ "type":"string",
+ "enum":["ChimeSdkMeeting"]
+ },
+ "MediaPipelineStatus":{
+ "type":"string",
+ "enum":[
+ "Initializing",
+ "InProgress",
+ "Failed",
+ "Stopping",
+ "Stopped"
+ ]
+ },
+ "NotFoundException":{
+ "type":"structure",
+ "members":{
+ "Code":{"shape":"ErrorCode"},
+ "Message":{"shape":"String"},
+ "RequestId":{
+ "shape":"String",
+ "documentation":"<p>The request id associated with the call responsible for the exception.</p>"
+ }
+ },
+ "documentation":"<p>One or more of the resources in the request does not exist in the system.</p>",
+ "error":{"httpStatusCode":404},
+ "exception":true
+ },
+ "ResourceLimitExceededException":{
+ "type":"structure",
+ "members":{
+ "Code":{"shape":"ErrorCode"},
+ "Message":{"shape":"String"},
+ "RequestId":{
+ "shape":"String",
+ "documentation":"<p>The request id associated with the call responsible for the exception.</p>"
+ }
+ },
+ "documentation":"<p>The request exceeds the resource limit.</p>",
+ "error":{"httpStatusCode":400},
+ "exception":true
+ },
+ "ResultMax":{
+ "type":"integer",
+ "max":100,
+ "min":1
+ },
+ "SelectedVideoStreams":{
+ "type":"structure",
+ "members":{
+ "AttendeeIds":{
+ "shape":"AttendeeIdList",
+ "documentation":"<p>The attendee IDs of the streams selected for a media capture pipeline. </p>"
+ },
+ "ExternalUserIds":{
+ "shape":"ExternalUserIdList",
+ "documentation":"<p>The external user IDs of the streams selected for a media capture pipeline.</p>"
+ }
+ },
+ "documentation":"<p>The video streams to capture for a specified media capture pipeline. The total number of video streams can't exceed 25.</p>"
+ },
+ "ServiceFailureException":{
+ "type":"structure",
+ "members":{
+ "Code":{"shape":"ErrorCode"},
+ "Message":{"shape":"String"},
+ "RequestId":{
+ "shape":"String",
+ "documentation":"<p>The request id associated with the call responsible for the exception.</p>"
+ }
+ },
+ "documentation":"<p>The service encountered an unexpected error.</p>",
+ "error":{"httpStatusCode":500},
+ "exception":true,
+ "fault":true
+ },
+ "ServiceUnavailableException":{
+ "type":"structure",
+ "members":{
+ "Code":{"shape":"ErrorCode"},
+ "Message":{"shape":"String"},
+ "RequestId":{
+ "shape":"String",
+ "documentation":"<p>The request id associated with the call responsible for the exception.</p>"
+ }
+ },
+ "documentation":"<p>The service is currently unavailable.</p>",
+ "error":{"httpStatusCode":503},
+ "exception":true,
+ "fault":true
+ },
+ "SourceConfiguration":{
+ "type":"structure",
+ "members":{
+ "SelectedVideoStreams":{
+ "shape":"SelectedVideoStreams",
+ "documentation":"<p>The selected video streams to capture for a specified media capture pipeline. The number of video streams can't exceed 25.</p>"
+ }
+ },
+ "documentation":"<p>Source configuration for a specified media capture pipeline.</p>"
+ },
+ "String":{
+ "type":"string",
+ "max":4096,
+ "pattern":".*"
+ },
+ "Tag":{
+ "type":"structure",
+ "required":[
+ "Key",
+ "Value"
+ ],
+ "members":{
+ "Key":{
+ "shape":"TagKey",
+ "documentation":"<p>The key of the tag.</p>"
+ },
+ "Value":{
+ "shape":"TagValue",
+ "documentation":"<p>The value of the tag.</p>"
+ }
+ },
+ "documentation":"<p>Describes a tag applied to a resource.</p>"
+ },
+ "TagKey":{
+ "type":"string",
+ "max":128,
+ "min":1
+ },
+ "TagKeyList":{
+ "type":"list",
+ "member":{"shape":"TagKey"},
+ "max":50,
+ "min":1
+ },
+ "TagList":{
+ "type":"list",
+ "member":{"shape":"Tag"},
+ "max":50,
+ "min":1
+ },
+ "TagResourceRequest":{
+ "type":"structure",
+ "required":[
+ "ResourceARN",
+ "Tags"
+ ],
+ "members":{
+ "ResourceARN":{
+ "shape":"AmazonResourceName",
+ "documentation":"<p>The resource ARN.</p>"
+ },
+ "Tags":{
+ "shape":"TagList",
+ "documentation":"<p>The tag key-value pairs.</p>"
+ }
+ }
+ },
+ "TagResourceResponse":{
+ "type":"structure",
+ "members":{
+ }
+ },
+ "TagValue":{
+ "type":"string",
+ "max":256,
+ "min":0
+ },
+ "ThrottledClientException":{
+ "type":"structure",
+ "members":{
+ "Code":{"shape":"ErrorCode"},
+ "Message":{"shape":"String"},
+ "RequestId":{
+ "shape":"String",
+ "documentation":"<p>The request id associated with the call responsible for the exception.</p>"
+ }
+ },
+ "documentation":"<p>The client exceeded its request rate limit.</p>",
+ "error":{"httpStatusCode":429},
+ "exception":true
+ },
+ "UnauthorizedClientException":{
+ "type":"structure",
+ "members":{
+ "Code":{"shape":"ErrorCode"},
+ "Message":{"shape":"String"},
+ "RequestId":{
+ "shape":"String",
+ "documentation":"<p>The request id associated with the call responsible for the exception.</p>"
+ }
+ },
+ "documentation":"<p>The client is not currently authorized to make the request.</p>",
+ "error":{"httpStatusCode":401},
+ "exception":true
+ },
+ "UntagResourceRequest":{
+ "type":"structure",
+ "required":[
+ "ResourceARN",
+ "TagKeys"
+ ],
+ "members":{
+ "ResourceARN":{
+ "shape":"AmazonResourceName",
+ "documentation":"<p>The resource ARN.</p>"
+ },
+ "TagKeys":{
+ "shape":"TagKeyList",
+ "documentation":"<p>The tag keys.</p>"
+ }
+ }
+ },
+ "UntagResourceResponse":{
+ "type":"structure",
+ "members":{
+ }
+ },
+ "VideoArtifactsConfiguration":{
+ "type":"structure",
+ "required":["State"],
+ "members":{
+ "State":{
+ "shape":"ArtifactsState",
+ "documentation":"<p>Indicates whether the video artifact is enabled or disabled.</p>"
+ },
+ "MuxType":{
+ "shape":"VideoMuxType",
+ "documentation":"<p>The MUX type of the video artifact configuration object.</p>"
+ }
+ },
+ "documentation":"<p>The video artifact configuration object.</p>"
+ },
+ "VideoMuxType":{
+ "type":"string",
+ "enum":["VideoOnly"]
+ }
+ },
+ "documentation":"<p>The Amazon Chime SDK media pipeline APIs in this section allow software developers to create Amazon Chime SDK media pipelines and capture audio, video, events, and data messages from Amazon Chime SDK meetings. For more information about media pipleines, see <a href=\"https://docs.aws.amazon.com/chime/latest/APIReference/API_Operations_Amazon_Chime_SDK_Media_Pipelines.html\">Amzon Chime SDK media pipelines</a>. </p>"
+}
diff --git a/contrib/python/botocore/py3/botocore/data/cloudtrail/2013-11-01/service-2.json b/contrib/python/botocore/py3/botocore/data/cloudtrail/2013-11-01/service-2.json
index d33ba93806..4519bb0a76 100644
--- a/contrib/python/botocore/py3/botocore/data/cloudtrail/2013-11-01/service-2.json
+++ b/contrib/python/botocore/py3/botocore/data/cloudtrail/2013-11-01/service-2.json
@@ -35,7 +35,7 @@
{"shape":"NotOrganizationMasterAccountException"},
{"shape":"ConflictException"}
],
- "documentation":"<p>Adds one or more tags to a trail, up to a limit of 50. Overwrites an existing tag's value when a new value is specified for an existing tag key. Tag key names must be unique for a trail; you cannot have two keys with the same name but different values. If you specify a key without a value, the tag will be created with the specified key and a value of null. You can tag a trail that applies to all Amazon Web Services Regions only from the Region in which the trail was created (also known as its home region).</p>",
+ "documentation":"<p>Adds one or more tags to a trail or event data store, up to a limit of 50. Overwrites an existing tag's value when a new value is specified for an existing tag key. Tag key names must be unique for a trail; you cannot have two keys with the same name but different values. If you specify a key without a value, the tag will be created with the specified key and a value of null. You can tag a trail or event data store that applies to all Amazon Web Services Regions only from the Region in which the trail or event data store was created (also known as its home region).</p>",
"idempotent":true
},
"CancelQuery":{
@@ -387,7 +387,7 @@
{"shape":"OperationNotPermittedException"},
{"shape":"InvalidTokenException"}
],
- "documentation":"<p>Lists the tags for the trail in the current region.</p>",
+ "documentation":"<p>Lists the tags for the trail or event data store in the current region.</p>",
"idempotent":true
},
"ListTrails":{
@@ -490,7 +490,7 @@
{"shape":"OperationNotPermittedException"},
{"shape":"NotOrganizationMasterAccountException"}
],
- "documentation":"<p>Removes the specified tags from a trail.</p>",
+ "documentation":"<p>Removes the specified tags from a trail or event data store.</p>",
"idempotent":true
},
"RestoreEventDataStore":{
@@ -654,14 +654,14 @@
"members":{
"ResourceId":{
"shape":"String",
- "documentation":"<p>Specifies the ARN of the trail to which one or more tags will be added. The format of a trail ARN is:</p> <p> <code>arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail</code> </p>"
+ "documentation":"<p>Specifies the ARN of the trail or event data store to which one or more tags will be added. The format of a trail ARN is:</p> <p> <code>arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail</code> </p>"
},
"TagsList":{
"shape":"TagsList",
"documentation":"<p>Contains a list of tags, up to a limit of 50</p>"
}
},
- "documentation":"<p>Specifies the tags to add to a trail.</p>"
+ "documentation":"<p>Specifies the tags to add to a trail or event data store.</p>"
},
"AddTagsResponse":{
"type":"structure",
@@ -796,7 +796,7 @@
"type":"structure",
"members":{
},
- "documentation":"<p>This exception is thrown when the specified resource is not ready for an operation. This can occur when you try to run an operation on a trail before CloudTrail has time to fully load the trail. If this exception occurs, wait a few minutes, and then try the operation again.</p>",
+ "documentation":"<p>This exception is thrown when the specified resource is not ready for an operation. This can occur when you try to run an operation on a resource before CloudTrail has time to fully load the resource. If this exception occurs, wait a few minutes, and then try the operation again.</p>",
"exception":true
},
"CreateEventDataStoreRequest":{
@@ -1176,35 +1176,51 @@
},
"TerminationProtectionEnabled":{
"shape":"TerminationProtectionEnabled",
- "documentation":"<p>Indicates whether the event data store is protected from termination.</p>"
+ "documentation":"<p>This field is being deprecated. Indicates whether the event data store is protected from termination.</p>",
+ "deprecated":true,
+ "deprecatedMessage":"TerminationProtectionEnabled is no longer returned by ListEventDataStores"
},
"Status":{
"shape":"EventDataStoreStatus",
- "documentation":"<p>The status of an event data store. Values are <code>ENABLED</code> and <code>PENDING_DELETION</code>.</p>"
+ "documentation":"<p>This field is being deprecated. The status of an event data store. Values are <code>ENABLED</code> and <code>PENDING_DELETION</code>.</p>",
+ "deprecated":true,
+ "deprecatedMessage":"Status is no longer returned by ListEventDataStores"
},
"AdvancedEventSelectors":{
"shape":"AdvancedEventSelectors",
- "documentation":"<p>The advanced event selectors that were used to select events for the data store.</p>"
+ "documentation":"<p>This field is being deprecated. The advanced event selectors that were used to select events for the data store.</p>",
+ "deprecated":true,
+ "deprecatedMessage":"AdvancedEventSelectors is no longer returned by ListEventDataStores"
},
"MultiRegionEnabled":{
"shape":"Boolean",
- "documentation":"<p>Indicates whether the event data store includes events from all regions, or only from the region in which it was created.</p>"
+ "documentation":"<p>This field is being deprecated. Indicates whether the event data store includes events from all regions, or only from the region in which it was created.</p>",
+ "deprecated":true,
+ "deprecatedMessage":"MultiRegionEnabled is no longer returned by ListEventDataStores"
},
"OrganizationEnabled":{
"shape":"Boolean",
- "documentation":"<p>Indicates that an event data store is collecting logged events for an organization.</p>"
+ "documentation":"<p>This field is being deprecated. Indicates that an event data store is collecting logged events for an organization.</p>",
+ "deprecated":true,
+ "deprecatedMessage":"OrganizationEnabled is no longer returned by ListEventDataStores"
},
"RetentionPeriod":{
"shape":"RetentionPeriod",
- "documentation":"<p>The retention period, in days.</p>"
+ "documentation":"<p>This field is being deprecated. The retention period, in days.</p>",
+ "deprecated":true,
+ "deprecatedMessage":"RetentionPeriod is no longer returned by ListEventDataStores"
},
"CreatedTimestamp":{
"shape":"Date",
- "documentation":"<p>The timestamp of the event data store's creation.</p>"
+ "documentation":"<p>This field is being deprecated. The timestamp of the event data store's creation.</p>",
+ "deprecated":true,
+ "deprecatedMessage":"CreatedTimestamp is no longer returned by ListEventDataStores"
},
"UpdatedTimestamp":{
"shape":"Date",
- "documentation":"<p>The timestamp showing when an event data store was updated, if applicable. <code>UpdatedTimestamp</code> is always either the same or newer than the time shown in <code>CreatedTimestamp</code>.</p>"
+ "documentation":"<p>This field is being deprecated. The timestamp showing when an event data store was updated, if applicable. <code>UpdatedTimestamp</code> is always either the same or newer than the time shown in <code>CreatedTimestamp</code>.</p>",
+ "deprecated":true,
+ "deprecatedMessage":"UpdatedTimestamp is no longer returned by ListEventDataStores"
}
},
"documentation":"<p>A storage lake of event data against which you can run complex SQL-based queries. An event data store can include events that you have logged on your account from the last 90 to 2555 days (about three months to up to seven years). To select events for an event data store, use <a href=\"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#creating-data-event-selectors-advanced\">advanced event selectors</a>.</p>"
@@ -1562,7 +1578,7 @@
"type":"structure",
"members":{
},
- "documentation":"<p>The event data store against which you ran your query is inactive.</p>",
+ "documentation":"<p>The event data store is inactive.</p>",
"exception":true
},
"InactiveQueryException":{
@@ -1604,7 +1620,7 @@
"type":"structure",
"members":{
},
- "documentation":"<p>This exception is thrown when the IAM user or role that is used to create the organization trail is lacking one or more required permissions for creating an organization trail in a required service. For more information, see <a href=\"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-an-organizational-trail-prepare.html\">Prepare For Creating a Trail For Your Organization</a>.</p>",
+ "documentation":"<p>This exception is thrown when the IAM user or role that is used to create the organization resource lacks one or more required permissions for creating an organization resource in a required service.</p>",
"exception":true
},
"InsufficientEncryptionPolicyException":{
@@ -1647,7 +1663,7 @@
"type":"structure",
"members":{
},
- "documentation":"<p>A date range for the query was specified that is not valid. For more information about writing a query, see <a href=\"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/query-create-edit-query.html\">Create or edit a query</a> in the <i>CloudTrail User Guide</i>.</p>",
+ "documentation":"<p>A date range for the query was specified that is not valid. Be sure that the start time is chronologically before the end time. For more information about writing a query, see <a href=\"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/query-create-edit-query.html\">Create or edit a query</a> in the <i>CloudTrail User Guide</i>.</p>",
"exception":true
},
"InvalidEventCategoryException":{
@@ -1929,14 +1945,14 @@
"members":{
"ResourceIdList":{
"shape":"ResourceIdList",
- "documentation":"<p>Specifies a list of trail ARNs whose tags will be listed. The list has a limit of 20 ARNs. The following is the format of a trail ARN.</p> <p> <code>arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail</code> </p>"
+ "documentation":"<p>Specifies a list of trail and event data store ARNs whose tags will be listed. The list has a limit of 20 ARNs.</p>"
},
"NextToken":{
"shape":"String",
"documentation":"<p>Reserved for future use.</p>"
}
},
- "documentation":"<p>Specifies a list of trail tags to return.</p>"
+ "documentation":"<p>Specifies a list of tags to return.</p>"
},
"ListTagsResponse":{
"type":"structure",
@@ -2083,7 +2099,7 @@
"type":"structure",
"members":{
},
- "documentation":"<p>This exception is thrown when the Amazon Web Services account making the request to create or update an organization trail is not the management account for an organization in Organizations. For more information, see <a href=\"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-an-organizational-trail-prepare.html\">Prepare For Creating a Trail For Your Organization</a>.</p>",
+ "documentation":"<p>This exception is thrown when the Amazon Web Services account making the request to create or update an organization trail or event data store is not the management account for an organization in Organizations. For more information, see <a href=\"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-an-organizational-trail-prepare.html\">Prepare For Creating a Trail For Your Organization</a> or <a href=\"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/query-event-data-store.html\">Create an event data store</a>.</p>",
"exception":true
},
"OperationNotPermittedException":{
@@ -2108,7 +2124,7 @@
"type":"structure",
"members":{
},
- "documentation":"<p>This exception is thrown when Organizations is not configured to support all features. All features must be enabled in Organizations to support creating an organization trail. For more information, see <a href=\"https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-an-organizational-trail-prepare.html\">Prepare For Creating a Trail For Your Organization</a>.</p>",
+ "documentation":"<p>This exception is thrown when Organizations is not configured to support all features. All features must be enabled in Organizations to support creating an organization trail or event data store.</p>",
"exception":true
},
"OrganizationsNotInUseException":{
@@ -2337,14 +2353,14 @@
"members":{
"ResourceId":{
"shape":"String",
- "documentation":"<p>Specifies the ARN of the trail from which tags should be removed. The format of a trail ARN is:</p> <p> <code>arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail</code> </p>"
+ "documentation":"<p>Specifies the ARN of the trail or event data store from which tags should be removed.</p> <p> Example trail ARN format: <code>arn:aws:cloudtrail:us-east-2:123456789012:trail/MyTrail</code> </p> <p>Example event data store ARN format: <code>arn:aws:cloudtrail:us-east-2:12345678910:eventdatastore/EXAMPLE-f852-4e8f-8bd1-bcf6cEXAMPLE</code> </p>"
},
"TagsList":{
"shape":"TagsList",
"documentation":"<p>Specifies a list of tags to be removed.</p>"
}
},
- "documentation":"<p>Specifies the tags to remove from a trail.</p>"
+ "documentation":"<p>Specifies the tags to remove from a trail or event data store.</p>"
},
"RemoveTagsResponse":{
"type":"structure",
@@ -2464,7 +2480,7 @@
},
"RetentionPeriod":{
"type":"integer",
- "max":2555,
+ "max":2557,
"min":7
},
"S3BucketDoesNotExistException":{
diff --git a/contrib/python/botocore/py3/botocore/data/iotwireless/2020-11-22/service-2.json b/contrib/python/botocore/py3/botocore/data/iotwireless/2020-11-22/service-2.json
index d1eb778900..57cdcc0961 100644
--- a/contrib/python/botocore/py3/botocore/data/iotwireless/2020-11-22/service-2.json
+++ b/contrib/python/botocore/py3/botocore/data/iotwireless/2020-11-22/service-2.json
@@ -236,6 +236,25 @@
],
"documentation":"<p>Creates a multicast group.</p>"
},
+ "CreateNetworkAnalyzerConfiguration":{
+ "name":"CreateNetworkAnalyzerConfiguration",
+ "http":{
+ "method":"POST",
+ "requestUri":"/network-analyzer-configurations",
+ "responseCode":201
+ },
+ "input":{"shape":"CreateNetworkAnalyzerConfigurationRequest"},
+ "output":{"shape":"CreateNetworkAnalyzerConfigurationResponse"},
+ "errors":[
+ {"shape":"ValidationException"},
+ {"shape":"ResourceNotFoundException"},
+ {"shape":"AccessDeniedException"},
+ {"shape":"ConflictException"},
+ {"shape":"InternalServerException"},
+ {"shape":"ThrottlingException"}
+ ],
+ "documentation":"<p>Creates a new network analyzer configuration.</p>"
+ },
"CreateServiceProfile":{
"name":"CreateServiceProfile",
"http":{
@@ -404,6 +423,25 @@
],
"documentation":"<p>Deletes a multicast group if it is not in use by a fuota task.</p>"
},
+ "DeleteNetworkAnalyzerConfiguration":{
+ "name":"DeleteNetworkAnalyzerConfiguration",
+ "http":{
+ "method":"DELETE",
+ "requestUri":"/network-analyzer-configurations/{ConfigurationName}",
+ "responseCode":204
+ },
+ "input":{"shape":"DeleteNetworkAnalyzerConfigurationRequest"},
+ "output":{"shape":"DeleteNetworkAnalyzerConfigurationResponse"},
+ "errors":[
+ {"shape":"ValidationException"},
+ {"shape":"ResourceNotFoundException"},
+ {"shape":"AccessDeniedException"},
+ {"shape":"InternalServerException"},
+ {"shape":"ConflictException"},
+ {"shape":"ThrottlingException"}
+ ],
+ "documentation":"<p>Deletes a network analyzer configuration.</p>"
+ },
"DeleteQueuedMessages":{
"name":"DeleteQueuedMessages",
"http":{
@@ -420,7 +458,7 @@
{"shape":"InternalServerException"},
{"shape":"AccessDeniedException"}
],
- "documentation":"<p> The operation to delete queued messages. </p>"
+ "documentation":"<p>Remove queued messages from the downlink queue.</p>"
},
"DeleteServiceProfile":{
"name":"DeleteServiceProfile",
@@ -675,6 +713,21 @@
],
"documentation":"<p>Gets information about a device profile.</p>"
},
+ "GetEventConfigurationByResourceTypes":{
+ "name":"GetEventConfigurationByResourceTypes",
+ "http":{
+ "method":"GET",
+ "requestUri":"/event-configurations-resource-types"
+ },
+ "input":{"shape":"GetEventConfigurationByResourceTypesRequest"},
+ "output":{"shape":"GetEventConfigurationByResourceTypesResponse"},
+ "errors":[
+ {"shape":"AccessDeniedException"},
+ {"shape":"ThrottlingException"},
+ {"shape":"InternalServerException"}
+ ],
+ "documentation":"<p>Get the event configuration by resource types.</p>"
+ },
"GetFuotaTask":{
"name":"GetFuotaTask",
"http":{
@@ -760,7 +813,7 @@
{"shape":"InternalServerException"},
{"shape":"ThrottlingException"}
],
- "documentation":"<p>Get NetworkAnalyzer configuration.</p>"
+ "documentation":"<p>Get network analyzer configuration.</p>"
},
"GetPartnerAccount":{
"name":"GetPartnerAccount",
@@ -1016,6 +1069,22 @@
],
"documentation":"<p>Lists the device profiles registered to your AWS account.</p>"
},
+ "ListEventConfigurations":{
+ "name":"ListEventConfigurations",
+ "http":{
+ "method":"GET",
+ "requestUri":"/event-configurations"
+ },
+ "input":{"shape":"ListEventConfigurationsRequest"},
+ "output":{"shape":"ListEventConfigurationsResponse"},
+ "errors":[
+ {"shape":"ValidationException"},
+ {"shape":"AccessDeniedException"},
+ {"shape":"ThrottlingException"},
+ {"shape":"InternalServerException"}
+ ],
+ "documentation":"<p>List event configurations where at least one event topic has been enabled.</p>"
+ },
"ListFuotaTasks":{
"name":"ListFuotaTasks",
"http":{
@@ -1065,6 +1134,22 @@
],
"documentation":"<p>List all multicast groups associated with a fuota task.</p>"
},
+ "ListNetworkAnalyzerConfigurations":{
+ "name":"ListNetworkAnalyzerConfigurations",
+ "http":{
+ "method":"GET",
+ "requestUri":"/network-analyzer-configurations"
+ },
+ "input":{"shape":"ListNetworkAnalyzerConfigurationsRequest"},
+ "output":{"shape":"ListNetworkAnalyzerConfigurationsResponse"},
+ "errors":[
+ {"shape":"ValidationException"},
+ {"shape":"AccessDeniedException"},
+ {"shape":"InternalServerException"},
+ {"shape":"ThrottlingException"}
+ ],
+ "documentation":"<p>Lists the network analyzer configurations.</p>"
+ },
"ListPartnerAccounts":{
"name":"ListPartnerAccounts",
"http":{
@@ -1096,7 +1181,7 @@
{"shape":"ThrottlingException"},
{"shape":"AccessDeniedException"}
],
- "documentation":"<p>The operation to list queued messages. </p>"
+ "documentation":"<p>List queued messages in the downlink queue.</p>"
},
"ListServiceProfiles":{
"name":"ListServiceProfiles",
@@ -1415,6 +1500,23 @@
],
"documentation":"<p>Updates properties of a destination.</p>"
},
+ "UpdateEventConfigurationByResourceTypes":{
+ "name":"UpdateEventConfigurationByResourceTypes",
+ "http":{
+ "method":"PATCH",
+ "requestUri":"/event-configurations-resource-types",
+ "responseCode":204
+ },
+ "input":{"shape":"UpdateEventConfigurationByResourceTypesRequest"},
+ "output":{"shape":"UpdateEventConfigurationByResourceTypesResponse"},
+ "errors":[
+ {"shape":"ValidationException"},
+ {"shape":"AccessDeniedException"},
+ {"shape":"ThrottlingException"},
+ {"shape":"InternalServerException"}
+ ],
+ "documentation":"<p>Update the event configuration by resource types.</p>"
+ },
"UpdateFuotaTask":{
"name":"UpdateFuotaTask",
"http":{
@@ -1488,7 +1590,7 @@
{"shape":"InternalServerException"},
{"shape":"ThrottlingException"}
],
- "documentation":"<p>Update NetworkAnalyzer configuration.</p>"
+ "documentation":"<p>Update network analyzer configuration.</p>"
},
"UpdatePartnerAccount":{
"name":"UpdatePartnerAccount",
@@ -1574,6 +1676,10 @@
"SessionKeys":{
"shape":"SessionKeysAbpV1_0_x",
"documentation":"<p>Session keys for ABP v1.0.x</p>"
+ },
+ "FCntStart":{
+ "shape":"FCntStart",
+ "documentation":"<p>The FCnt init value.</p>"
}
},
"documentation":"<p>ABP device object for LoRaWAN specification v1.0.x</p>"
@@ -1588,6 +1694,10 @@
"SessionKeys":{
"shape":"SessionKeysAbpV1_1",
"documentation":"<p>Session keys for ABP v1.1</p>"
+ },
+ "FCntStart":{
+ "shape":"FCntStart",
+ "documentation":"<p>The FCnt init value.</p>"
}
},
"documentation":"<p>ABP device object for LoRaWAN specification v1.1</p>"
@@ -1901,6 +2011,30 @@
"Disconnected"
]
},
+ "ConnectionStatusEventConfiguration":{
+ "type":"structure",
+ "members":{
+ "LoRaWAN":{
+ "shape":"LoRaWANConnectionStatusEventNotificationConfigurations",
+ "documentation":"<p>Connection status event configuration object for enabling or disabling LoRaWAN related event topics.</p>"
+ },
+ "WirelessGatewayIdEventTopic":{
+ "shape":"EventNotificationTopicStatus",
+ "documentation":"<p>Enum to denote whether the wireless gateway id connection status event topic is enabled or disabled .</p>"
+ }
+ },
+ "documentation":"<p>Connection status event configuration object for enabling or disabling topic.</p>"
+ },
+ "ConnectionStatusResourceTypeEventConfiguration":{
+ "type":"structure",
+ "members":{
+ "LoRaWAN":{
+ "shape":"LoRaWANConnectionStatusResourceTypeEventConfiguration",
+ "documentation":"<p>Connection status resource type event configuration object for enabling or disabling LoRaWAN related event topics.</p>"
+ }
+ },
+ "documentation":"<p>Connection status resource type event configuration object for enabling or disabling topic.</p>"
+ },
"Crc":{
"type":"long",
"max":4294967295,
@@ -2045,6 +2179,38 @@
"Id":{"shape":"MulticastGroupId"}
}
},
+ "CreateNetworkAnalyzerConfigurationRequest":{
+ "type":"structure",
+ "required":["Name"],
+ "members":{
+ "Name":{"shape":"NetworkAnalyzerConfigurationName"},
+ "TraceContent":{"shape":"TraceContent"},
+ "WirelessDevices":{
+ "shape":"WirelessDeviceList",
+ "documentation":"<p>Wireless device resources to add to the network analyzer configuration. Provide the <code>WirelessDeviceId</code> of the resource to add in the input array.</p>"
+ },
+ "WirelessGateways":{
+ "shape":"WirelessGatewayList",
+ "documentation":"<p>Wireless gateway resources to add to the network analyzer configuration. Provide the <code>WirelessGatewayId</code> of the resource to add in the input array.</p>"
+ },
+ "Description":{"shape":"Description"},
+ "Tags":{"shape":"TagList"},
+ "ClientRequestToken":{
+ "shape":"ClientRequestToken",
+ "idempotencyToken":true
+ }
+ }
+ },
+ "CreateNetworkAnalyzerConfigurationResponse":{
+ "type":"structure",
+ "members":{
+ "Arn":{
+ "shape":"NetworkAnalyzerConfigurationArn",
+ "documentation":"<p>The Amazon Resource Name of the new resource.</p>"
+ },
+ "Name":{"shape":"NetworkAnalyzerConfigurationName"}
+ }
+ },
"CreateServiceProfileRequest":{
"type":"structure",
"members":{
@@ -2313,6 +2479,22 @@
"members":{
}
},
+ "DeleteNetworkAnalyzerConfigurationRequest":{
+ "type":"structure",
+ "required":["ConfigurationName"],
+ "members":{
+ "ConfigurationName":{
+ "shape":"NetworkAnalyzerConfigurationName",
+ "location":"uri",
+ "locationName":"ConfigurationName"
+ }
+ }
+ },
+ "DeleteNetworkAnalyzerConfigurationResponse":{
+ "type":"structure",
+ "members":{
+ }
+ },
"DeleteQueuedMessagesRequest":{
"type":"structure",
"required":[
@@ -2322,19 +2504,19 @@
"members":{
"Id":{
"shape":"WirelessDeviceId",
- "documentation":"<p>Id of a given wireless device which messages will be deleted </p>",
+ "documentation":"<p>The ID of a given wireless device for which downlink messages will be deleted.</p>",
"location":"uri",
"locationName":"Id"
},
"MessageId":{
"shape":"MessageId",
- "documentation":"<p>if messageID==\"*\", the queue for a particular wireless deviceId will be purged, otherwise, the specific message with messageId will be deleted </p>",
+ "documentation":"<p>If message ID is <code>\"*\"</code>, it cleares the entire downlink queue for a given device, specified by the wireless device ID. Otherwise, the downlink message with the specified message ID will be deleted.</p>",
"location":"querystring",
"locationName":"messageId"
},
"WirelessDeviceType":{
"shape":"WirelessDeviceType",
- "documentation":"<p>The wireless device type, it is either Sidewalk or LoRaWAN. </p>",
+ "documentation":"<p>The wireless device type, which can be either Sidewalk or LoRaWAN.</p>",
"location":"querystring",
"locationName":"WirelessDeviceType"
}
@@ -2530,10 +2712,24 @@
"Sidewalk":{
"shape":"SidewalkEventNotificationConfigurations",
"documentation":"<p>Device registration state event configuration object for enabling or disabling Sidewalk related event topics.</p>"
+ },
+ "WirelessDeviceIdEventTopic":{
+ "shape":"EventNotificationTopicStatus",
+ "documentation":"<p>Enum to denote whether the wireless device id device registration state event topic is enabled or disabled.</p>"
}
},
"documentation":"<p>Device registration state event configuration object for enabling and disabling relevant topics.</p>"
},
+ "DeviceRegistrationStateResourceTypeEventConfiguration":{
+ "type":"structure",
+ "members":{
+ "Sidewalk":{
+ "shape":"SidewalkResourceTypeEventConfiguration",
+ "documentation":"<p>Device registration resource type state event configuration object for enabling or disabling Sidewalk related event topics.</p>"
+ }
+ },
+ "documentation":"<p>Device registration state resource type event configuration object for enabling or disabling topic.</p>"
+ },
"DeviceState":{
"type":"string",
"documentation":"<p>Device state defines the device status of sidewalk device.</p>",
@@ -2734,19 +2930,19 @@
"members":{
"MessageId":{
"shape":"MessageId",
- "documentation":"<p> The messageId allocated by IoT Wireless for tracing purpose</p>"
+ "documentation":"<p> The message ID assigned by IoT Wireless to each downlink message, which helps identify the message.</p>"
},
"TransmitMode":{
"shape":"TransmitMode",
- "documentation":"<p>The transmit mode to use to send data to the wireless device. Can be: <code>0</code> for UM (unacknowledge mode) or <code>1</code> for AM (acknowledge mode).</p>"
+ "documentation":"<p>The transmit mode to use for sending data to the wireless device. This can be <code>0</code> for UM (unacknowledge mode) or <code>1</code> for AM (acknowledge mode).</p>"
},
"ReceivedAt":{
"shape":"ISODateTimeString",
- "documentation":"<p>The timestamp that Iot Wireless received the message.</p>"
+ "documentation":"<p>The time at which Iot Wireless received the downlink message.</p>"
},
"LoRaWAN":{"shape":"LoRaWANSendDataToDevice"}
},
- "documentation":"<p>The message in downlink queue.</p>"
+ "documentation":"<p>The message in the downlink queue.</p>"
},
"DownlinkQueueMessagesList":{
"type":"list",
@@ -2778,10 +2974,63 @@
"passthrough"
]
},
+ "EventConfigurationItem":{
+ "type":"structure",
+ "members":{
+ "Identifier":{
+ "shape":"Identifier",
+ "documentation":"<p>Resource identifier opted in for event messaging.</p>"
+ },
+ "IdentifierType":{
+ "shape":"IdentifierType",
+ "documentation":"<p>Identifier type of the particular resource identifier for event configuration.</p>"
+ },
+ "PartnerType":{
+ "shape":"EventNotificationPartnerType",
+ "documentation":"<p>Partner type of the resource if the identifier type is PartnerAccountId.</p>"
+ },
+ "Events":{"shape":"EventNotificationItemConfigurations"}
+ },
+ "documentation":"<p>Event configuration object for a single resource.</p>"
+ },
+ "EventConfigurationsList":{
+ "type":"list",
+ "member":{"shape":"EventConfigurationItem"}
+ },
+ "EventNotificationItemConfigurations":{
+ "type":"structure",
+ "members":{
+ "DeviceRegistrationState":{
+ "shape":"DeviceRegistrationStateEventConfiguration",
+ "documentation":"<p>Device registration state event configuration for an event configuration item.</p>"
+ },
+ "Proximity":{
+ "shape":"ProximityEventConfiguration",
+ "documentation":"<p>Proximity event configuration for an event configuration item.</p>"
+ },
+ "Join":{
+ "shape":"JoinEventConfiguration",
+ "documentation":"<p>Join event configuration for an event configuration item.</p>"
+ },
+ "ConnectionStatus":{
+ "shape":"ConnectionStatusEventConfiguration",
+ "documentation":"<p>Connection status event configuration for an event configuration item.</p>"
+ }
+ },
+ "documentation":"<p>Object of all event configurations and the status of the event topics.</p>"
+ },
"EventNotificationPartnerType":{
"type":"string",
"enum":["Sidewalk"]
},
+ "EventNotificationResourceType":{
+ "type":"string",
+ "enum":[
+ "SidewalkAccount",
+ "WirelessDevice",
+ "WirelessGateway"
+ ]
+ },
"EventNotificationTopicStatus":{
"type":"string",
"enum":[
@@ -2800,6 +3049,12 @@
"MqttTopic"
]
},
+ "FCntStart":{
+ "type":"integer",
+ "documentation":"<p>The FCnt init value.</p>",
+ "max":65535,
+ "min":0
+ },
"FNwkSIntKey":{
"type":"string",
"pattern":"[a-fA-F0-9]{32}"
@@ -2983,6 +3238,32 @@
}
}
},
+ "GetEventConfigurationByResourceTypesRequest":{
+ "type":"structure",
+ "members":{
+ }
+ },
+ "GetEventConfigurationByResourceTypesResponse":{
+ "type":"structure",
+ "members":{
+ "DeviceRegistrationState":{
+ "shape":"DeviceRegistrationStateResourceTypeEventConfiguration",
+ "documentation":"<p>Resource type event configuration for the device registration state event</p>"
+ },
+ "Proximity":{
+ "shape":"ProximityResourceTypeEventConfiguration",
+ "documentation":"<p>Resource type event configuration for the proximity event</p>"
+ },
+ "Join":{
+ "shape":"JoinResourceTypeEventConfiguration",
+ "documentation":"<p>Resource type event configuration for the join event</p>"
+ },
+ "ConnectionStatus":{
+ "shape":"ConnectionStatusResourceTypeEventConfiguration",
+ "documentation":"<p>Resource type event configuration for the connection status event</p>"
+ }
+ }
+ },
"GetFuotaTaskRequest":{
"type":"structure",
"required":["Id"],
@@ -3078,12 +3359,18 @@
"TraceContent":{"shape":"TraceContent"},
"WirelessDevices":{
"shape":"WirelessDeviceList",
- "documentation":"<p>List of WirelessDevices in the NetworkAnalyzerConfiguration.</p>"
+ "documentation":"<p>List of wireless gateway resources that have been added to the network analyzer configuration.</p>"
},
"WirelessGateways":{
"shape":"WirelessGatewayList",
- "documentation":"<p>List of WirelessGateways in the NetworkAnalyzerConfiguration.</p>"
- }
+ "documentation":"<p>List of wireless gateway resources that have been added to the network analyzer configuration.</p>"
+ },
+ "Description":{"shape":"Description"},
+ "Arn":{
+ "shape":"NetworkAnalyzerConfigurationArn",
+ "documentation":"<p>The Amazon Resource Name of the new resource.</p>"
+ },
+ "Name":{"shape":"NetworkAnalyzerConfigurationName"}
}
},
"GetPartnerAccountRequest":{
@@ -3157,6 +3444,14 @@
"Proximity":{
"shape":"ProximityEventConfiguration",
"documentation":"<p>Event configuration for the Proximity event</p>"
+ },
+ "Join":{
+ "shape":"JoinEventConfiguration",
+ "documentation":"<p>Event configuration for the join event.</p>"
+ },
+ "ConnectionStatus":{
+ "shape":"ConnectionStatusEventConfiguration",
+ "documentation":"<p>Event configuration for the connection status event.</p>"
}
}
},
@@ -3191,7 +3486,7 @@
"members":{
"ServiceType":{
"shape":"WirelessGatewayServiceType",
- "documentation":"<p>The service type for which to get endpoint information about. Can be <code>CUPS</code> for the Configuration and Update Server endpoint, or <code>LNS</code> for the LoRaWAN Network Server endpoint.</p>",
+ "documentation":"<p>The service type for which to get endpoint information about. Can be <code>CUPS</code> for the Configuration and Update Server endpoint, or <code>LNS</code> for the LoRaWAN Network Server endpoint or <code>CLAIM</code> for the global endpoint.</p>",
"location":"querystring",
"locationName":"serviceType"
}
@@ -3556,7 +3851,13 @@
},
"IdentifierType":{
"type":"string",
- "enum":["PartnerAccountId"]
+ "enum":[
+ "PartnerAccountId",
+ "DevEui",
+ "GatewayEui",
+ "WirelessDeviceId",
+ "WirelessGatewayId"
+ ]
},
"Integer":{"type":"integer"},
"InternalServerException":{
@@ -3591,6 +3892,30 @@
"max":2,
"min":2
},
+ "JoinEventConfiguration":{
+ "type":"structure",
+ "members":{
+ "LoRaWAN":{
+ "shape":"LoRaWANJoinEventNotificationConfigurations",
+ "documentation":"<p>Join event configuration object for enabling or disabling LoRaWAN related event topics.</p>"
+ },
+ "WirelessDeviceIdEventTopic":{
+ "shape":"EventNotificationTopicStatus",
+ "documentation":"<p>Enum to denote whether the wireless device id join event topic is enabled or disabled.</p>"
+ }
+ },
+ "documentation":"<p>Join event configuration object for enabling or disabling topic.</p>"
+ },
+ "JoinResourceTypeEventConfiguration":{
+ "type":"structure",
+ "members":{
+ "LoRaWAN":{
+ "shape":"LoRaWANJoinResourceTypeEventConfiguration",
+ "documentation":"<p>Join resource type event configuration object for enabling or disabling LoRaWAN related event topics.</p>"
+ }
+ },
+ "documentation":"<p>Join resource type event configuration object for enabling or disabling topic.</p>"
+ },
"ListDestinationsRequest":{
"type":"structure",
"members":{
@@ -3651,6 +3976,42 @@
}
}
},
+ "ListEventConfigurationsRequest":{
+ "type":"structure",
+ "required":["ResourceType"],
+ "members":{
+ "ResourceType":{
+ "shape":"EventNotificationResourceType",
+ "documentation":"<p>Resource type to filter event configurations.</p>",
+ "location":"querystring",
+ "locationName":"resourceType"
+ },
+ "MaxResults":{
+ "shape":"MaxResults",
+ "location":"querystring",
+ "locationName":"maxResults"
+ },
+ "NextToken":{
+ "shape":"NextToken",
+ "documentation":"<p>To retrieve the next set of results, the <code>nextToken</code> value from a previous response; otherwise <b>null</b> to receive the first set of results.</p>",
+ "location":"querystring",
+ "locationName":"nextToken"
+ }
+ }
+ },
+ "ListEventConfigurationsResponse":{
+ "type":"structure",
+ "members":{
+ "NextToken":{
+ "shape":"NextToken",
+ "documentation":"<p>To retrieve the next set of results, the <code>nextToken</code> value from a previous response; otherwise <b>null</b> to receive the first set of results.</p>"
+ },
+ "EventConfigurationsList":{
+ "shape":"EventConfigurationsList",
+ "documentation":"<p>Event configurations of all events for a single resource.</p>"
+ }
+ }
+ },
"ListFuotaTasksRequest":{
"type":"structure",
"members":{
@@ -3735,6 +4096,35 @@
"MulticastGroupList":{"shape":"MulticastGroupList"}
}
},
+ "ListNetworkAnalyzerConfigurationsRequest":{
+ "type":"structure",
+ "members":{
+ "MaxResults":{
+ "shape":"MaxResults",
+ "location":"querystring",
+ "locationName":"maxResults"
+ },
+ "NextToken":{
+ "shape":"NextToken",
+ "documentation":"<p>To retrieve the next set of results, the <code>nextToken</code> value from a previous response; otherwise <b>null</b> to receive the first set of results.</p>",
+ "location":"querystring",
+ "locationName":"nextToken"
+ }
+ }
+ },
+ "ListNetworkAnalyzerConfigurationsResponse":{
+ "type":"structure",
+ "members":{
+ "NextToken":{
+ "shape":"NextToken",
+ "documentation":"<p>The token to use to get the next set of results, or <b>null</b> if there are no additional results.</p>"
+ },
+ "NetworkAnalyzerConfigurationList":{
+ "shape":"NetworkAnalyzerConfigurationList",
+ "documentation":"<p>The list of network analyzer configurations.</p>"
+ }
+ }
+ },
"ListPartnerAccountsRequest":{
"type":"structure",
"members":{
@@ -3771,7 +4161,7 @@
"members":{
"Id":{
"shape":"WirelessDeviceId",
- "documentation":"<p>Id of a given wireless device which the downlink packets are targeted </p>",
+ "documentation":"<p>The ID of a given wireless device which the downlink message packets are being sent.</p>",
"location":"uri",
"locationName":"Id"
},
@@ -3789,7 +4179,7 @@
},
"WirelessDeviceType":{
"shape":"WirelessDeviceType",
- "documentation":"<p>The wireless device type, it is either Sidewalk or LoRaWAN.</p>",
+ "documentation":"<p>The wireless device type, whic can be either Sidewalk or LoRaWAN.</p>",
"location":"querystring",
"locationName":"WirelessDeviceType"
}
@@ -3804,7 +4194,7 @@
},
"DownlinkQueueMessagesList":{
"shape":"DownlinkQueueMessagesList",
- "documentation":"<p>The messages in downlink queue.</p>"
+ "documentation":"<p>The messages in the downlink queue.</p>"
}
}
},
@@ -3989,6 +4379,26 @@
}
}
},
+ "LoRaWANConnectionStatusEventNotificationConfigurations":{
+ "type":"structure",
+ "members":{
+ "GatewayEuiEventTopic":{
+ "shape":"EventNotificationTopicStatus",
+ "documentation":"<p>Enum to denote whether the gateway eui connection status event topic is enabled or disabled.</p>"
+ }
+ },
+ "documentation":"<p>Object for LoRaWAN connection status resource type event configuration.</p>"
+ },
+ "LoRaWANConnectionStatusResourceTypeEventConfiguration":{
+ "type":"structure",
+ "members":{
+ "WirelessGatewayEventTopic":{
+ "shape":"EventNotificationTopicStatus",
+ "documentation":"<p>Enum to denote whether the wireless gateway connection status event topic is enabled or disabled.</p>"
+ }
+ },
+ "documentation":"<p>Object for LoRaWAN connection status resource type event configuration.</p>"
+ },
"LoRaWANDevice":{
"type":"structure",
"members":{
@@ -4300,6 +4710,26 @@
},
"documentation":"<p>LoRaWANGetServiceProfileInfo object.</p>"
},
+ "LoRaWANJoinEventNotificationConfigurations":{
+ "type":"structure",
+ "members":{
+ "DevEuiEventTopic":{
+ "shape":"EventNotificationTopicStatus",
+ "documentation":"<p>Enum to denote whether the dev eui join event topic is enabled or disabled.</p>"
+ }
+ },
+ "documentation":"<p>Object for LoRaWAN join resource type event configuration.</p>"
+ },
+ "LoRaWANJoinResourceTypeEventConfiguration":{
+ "type":"structure",
+ "members":{
+ "WirelessDeviceEventTopic":{
+ "shape":"EventNotificationTopicStatus",
+ "documentation":"<p>Enum to denote whether the wireless device join event topic is enabled or disabled.</p>"
+ }
+ },
+ "documentation":"<p>Object for LoRaWAN join resource type event configuration.</p>"
+ },
"LoRaWANListDevice":{
"type":"structure",
"members":{
@@ -4379,6 +4809,14 @@
"ServiceProfileId":{
"shape":"ServiceProfileId",
"documentation":"<p>The ID of the service profile.</p>"
+ },
+ "AbpV1_1":{
+ "shape":"UpdateAbpV1_1",
+ "documentation":"<p>ABP device object for update APIs for v1.1</p>"
+ },
+ "AbpV1_0_x":{
+ "shape":"UpdateAbpV1_0_x",
+ "documentation":"<p>ABP device object for update APIs for v1.0.x</p>"
}
},
"documentation":"<p>LoRaWAN object for update functions.</p>"
@@ -4421,7 +4859,7 @@
},
"LogLevel":{
"type":"string",
- "documentation":"<p>The log level for a log message.</p>",
+ "documentation":"<p>The log level for a log message. The log levels can be disabled, or set to <code>ERROR</code> to display less verbose logs containing only error information, or to <code>INFO</code> for more detailed logs.</p>",
"enum":[
"INFO",
"ERROR",
@@ -4553,12 +4991,31 @@
"max":10,
"min":0
},
+ "NetworkAnalyzerConfigurationArn":{
+ "type":"string",
+ "max":1124
+ },
+ "NetworkAnalyzerConfigurationList":{
+ "type":"list",
+ "member":{"shape":"NetworkAnalyzerConfigurations"}
+ },
"NetworkAnalyzerConfigurationName":{
"type":"string",
- "documentation":"<p>NetworkAnalyzer configuration name.</p>",
+ "documentation":"<p>Name of the network analyzer configuration.</p>",
"max":1024,
"min":1,
- "pattern":"NetworkAnalyzerConfig_Default"
+ "pattern":"[a-zA-Z0-9-_]+"
+ },
+ "NetworkAnalyzerConfigurations":{
+ "type":"structure",
+ "members":{
+ "Arn":{
+ "shape":"NetworkAnalyzerConfigurationArn",
+ "documentation":"<p>The Amazon Resource Name of the new resource.</p>"
+ },
+ "Name":{"shape":"NetworkAnalyzerConfigurationName"}
+ },
+ "documentation":"<p>Network analyzer configurations.</p>"
},
"NextToken":{
"type":"string",
@@ -4668,10 +5125,24 @@
"Sidewalk":{
"shape":"SidewalkEventNotificationConfigurations",
"documentation":"<p>Proximity event configuration object for enabling or disabling Sidewalk related event topics.</p>"
+ },
+ "WirelessDeviceIdEventTopic":{
+ "shape":"EventNotificationTopicStatus",
+ "documentation":"<p>Enum to denote whether the wireless device id proximity event topic is enabled or disabled.</p>"
}
},
"documentation":"<p>Proximity event configuration object for enabling and disabling relevant topics.</p>"
},
+ "ProximityResourceTypeEventConfiguration":{
+ "type":"structure",
+ "members":{
+ "Sidewalk":{
+ "shape":"SidewalkResourceTypeEventConfiguration",
+ "documentation":"<p>Proximity resource type event configuration object for enabling and disabling wireless device topic.</p>"
+ }
+ },
+ "documentation":"<p>Proximity resource type event configuration object for enabling or disabling topic.</p>"
+ },
"PutResourceLogLevelRequest":{
"type":"structure",
"required":[
@@ -5066,6 +5537,16 @@
"type":"string",
"max":64
},
+ "SidewalkResourceTypeEventConfiguration":{
+ "type":"structure",
+ "members":{
+ "WirelessDeviceEventTopic":{
+ "shape":"EventNotificationTopicStatus",
+ "documentation":"<p>Enum to denote whether the wireless device join event topic is enabled or disabled.</p>"
+ }
+ },
+ "documentation":"<p>Sidewalk resource type event configuration object for enabling or disabling topic.</p>"
+ },
"SidewalkSendDataToDevice":{
"type":"structure",
"members":{
@@ -5326,7 +5807,7 @@
"WirelessDeviceFrameInfo":{"shape":"WirelessDeviceFrameInfo"},
"LogLevel":{"shape":"LogLevel"}
},
- "documentation":"<p>Trace Content for resources.</p>"
+ "documentation":"<p>Trace content for your wireless gateway and wireless device resources.</p>"
},
"TransmitMode":{
"type":"integer",
@@ -5373,6 +5854,26 @@
"members":{
}
},
+ "UpdateAbpV1_0_x":{
+ "type":"structure",
+ "members":{
+ "FCntStart":{
+ "shape":"FCntStart",
+ "documentation":"<p>The FCnt init value.</p>"
+ }
+ },
+ "documentation":"<p>ABP device object for LoRaWAN specification v1.0.x</p>"
+ },
+ "UpdateAbpV1_1":{
+ "type":"structure",
+ "members":{
+ "FCntStart":{
+ "shape":"FCntStart",
+ "documentation":"<p>The FCnt init value.</p>"
+ }
+ },
+ "documentation":"<p>ABP device object for LoRaWAN specification v1.1</p>"
+ },
"UpdateDataSource":{
"type":"string",
"max":4096,
@@ -5411,6 +5912,32 @@
"members":{
}
},
+ "UpdateEventConfigurationByResourceTypesRequest":{
+ "type":"structure",
+ "members":{
+ "DeviceRegistrationState":{
+ "shape":"DeviceRegistrationStateResourceTypeEventConfiguration",
+ "documentation":"<p>Device registration state resource type event configuration object for enabling and disabling wireless gateway topic.</p>"
+ },
+ "Proximity":{
+ "shape":"ProximityResourceTypeEventConfiguration",
+ "documentation":"<p>Proximity resource type event configuration object for enabling and disabling wireless gateway topic.</p>"
+ },
+ "Join":{
+ "shape":"JoinResourceTypeEventConfiguration",
+ "documentation":"<p>Join resource type event configuration object for enabling and disabling wireless device topic.</p>"
+ },
+ "ConnectionStatus":{
+ "shape":"ConnectionStatusResourceTypeEventConfiguration",
+ "documentation":"<p>Connection status resource type event configuration object for enabling and disabling wireless gateway topic.</p>"
+ }
+ }
+ },
+ "UpdateEventConfigurationByResourceTypesResponse":{
+ "type":"structure",
+ "members":{
+ }
+ },
"UpdateFuotaTaskRequest":{
"type":"structure",
"required":["Id"],
@@ -5476,20 +6003,21 @@
"TraceContent":{"shape":"TraceContent"},
"WirelessDevicesToAdd":{
"shape":"WirelessDeviceList",
- "documentation":"<p>WirelessDevices to add into NetworkAnalyzerConfiguration.</p>"
+ "documentation":"<p>Wireless device resources to add to the network analyzer configuration. Provide the <code>WirelessDeviceId</code> of the resource to add in the input array.</p>"
},
"WirelessDevicesToRemove":{
"shape":"WirelessDeviceList",
- "documentation":"<p>WirelessDevices to remove from NetworkAnalyzerConfiguration.</p>"
+ "documentation":"<p>Wireless device resources to remove from the network analyzer configuration. Provide the <code>WirelessDeviceId</code> of the resources to remove in the input array.</p>"
},
"WirelessGatewaysToAdd":{
"shape":"WirelessGatewayList",
- "documentation":"<p>WirelessGateways to add into NetworkAnalyzerConfiguration.</p>"
+ "documentation":"<p>Wireless gateway resources to add to the network analyzer configuration. Provide the <code>WirelessGatewayId</code> of the resource to add in the input array.</p>"
},
"WirelessGatewaysToRemove":{
"shape":"WirelessGatewayList",
- "documentation":"<p>WirelessGateways to remove from NetworkAnalyzerConfiguration.</p>"
- }
+ "documentation":"<p>Wireless gateway resources to remove from the network analyzer configuration. Provide the <code>WirelessGatewayId</code> of the resources to remove in the input array.</p>"
+ },
+ "Description":{"shape":"Description"}
}
},
"UpdateNetworkAnalyzerConfigurationResponse":{
@@ -5560,6 +6088,14 @@
"Proximity":{
"shape":"ProximityEventConfiguration",
"documentation":"<p>Event configuration for the Proximity event</p>"
+ },
+ "Join":{
+ "shape":"JoinEventConfiguration",
+ "documentation":"<p>Event configuration for the join event</p>"
+ },
+ "ConnectionStatus":{
+ "shape":"ConnectionStatusEventConfiguration",
+ "documentation":"<p>Event configuration for the connection status event</p>"
}
}
},
@@ -5709,7 +6245,7 @@
},
"WirelessDeviceFrameInfo":{
"type":"string",
- "documentation":"<p>WirelessDevice FrameInfo for trace content.</p>",
+ "documentation":"<p>FrameInfo of your wireless device resources for the trace content. Use FrameInfo to debug the communication between your LoRaWAN end devices and the network server.</p>",
"enum":[
"ENABLED",
"DISABLED"
diff --git a/contrib/python/botocore/py3/botocore/data/lookoutequipment/2020-12-15/service-2.json b/contrib/python/botocore/py3/botocore/data/lookoutequipment/2020-12-15/service-2.json
index be46376416..5eb9be6ca6 100644
--- a/contrib/python/botocore/py3/botocore/data/lookoutequipment/2020-12-15/service-2.json
+++ b/contrib/python/botocore/py3/botocore/data/lookoutequipment/2020-12-15/service-2.json
@@ -133,7 +133,7 @@
{"shape":"AccessDeniedException"},
{"shape":"InternalServerException"}
],
- "documentation":"<p>Provides information on a specific data ingestion job such as creation time, dataset ARN, status, and so on. </p>"
+ "documentation":"<p>Provides information on a specific data ingestion job such as creation time, dataset ARN, and status.</p>"
},
"DescribeDataset":{
"name":"DescribeDataset",
@@ -150,7 +150,7 @@
{"shape":"AccessDeniedException"},
{"shape":"InternalServerException"}
],
- "documentation":"<p>Provides a JSON description of the data that is in each time series dataset, including names, column names, and data types.</p>"
+ "documentation":"<p>Provides a JSON description of the data in each time series dataset, including names, column names, and data types.</p>"
},
"DescribeInferenceScheduler":{
"name":"DescribeInferenceScheduler",
@@ -267,6 +267,23 @@
],
"documentation":"<p>Generates a list of all models in the account, including model name and ARN, dataset, and status. </p>"
},
+ "ListSensorStatistics":{
+ "name":"ListSensorStatistics",
+ "http":{
+ "method":"POST",
+ "requestUri":"/"
+ },
+ "input":{"shape":"ListSensorStatisticsRequest"},
+ "output":{"shape":"ListSensorStatisticsResponse"},
+ "errors":[
+ {"shape":"ValidationException"},
+ {"shape":"ResourceNotFoundException"},
+ {"shape":"ThrottlingException"},
+ {"shape":"AccessDeniedException"},
+ {"shape":"InternalServerException"}
+ ],
+ "documentation":"<p> Lists statistics about the data collected for each of the sensors that have been successfully ingested in the particular dataset. Can also be used to retreive Sensor Statistics for a previous ingestion job. </p>"
+ },
"ListTagsForResource":{
"name":"ListTagsForResource",
"http":{
@@ -407,12 +424,34 @@
"max":1011,
"min":1
},
+ "Boolean":{"type":"boolean"},
"BoundedLengthString":{
"type":"string",
"max":5000,
"min":1,
"pattern":"[\\P{M}\\p{M}]{1,5000}"
},
+ "CategoricalValues":{
+ "type":"structure",
+ "required":["Status"],
+ "members":{
+ "Status":{
+ "shape":"StatisticalIssueStatus",
+ "documentation":"<p> Indicates whether there is a potential data issue related to categorical values. </p>"
+ },
+ "NumberOfCategory":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the number of categories in the data. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises information on categorical values in data. </p>"
+ },
+ "ComponentName":{
+ "type":"string",
+ "max":200,
+ "min":1,
+ "pattern":"^[0-9a-zA-Z._\\-]{1,200}$"
+ },
"ComponentTimestampDelimiter":{
"type":"string",
"max":1,
@@ -428,11 +467,28 @@
"documentation":"<p> The request could not be completed due to a conflict with the current state of the target resource. </p>",
"exception":true
},
+ "CountPercent":{
+ "type":"structure",
+ "required":[
+ "Count",
+ "Percentage"
+ ],
+ "members":{
+ "Count":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the count of occurences of the given statistic. </p>"
+ },
+ "Percentage":{
+ "shape":"Float",
+ "documentation":"<p> Indicates the percentage of occurances of the given statistic. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises information of count and percentage. </p>"
+ },
"CreateDatasetRequest":{
"type":"structure",
"required":[
"DatasetName",
- "DatasetSchema",
"ClientToken"
],
"members":{
@@ -654,7 +710,7 @@
},
"IngestionInputConfiguration":{
"shape":"IngestionInputConfiguration",
- "documentation":"<p> Specifies information for the input data for the data inference job, including data S3 location parameters. </p>"
+ "documentation":"<p> Specifies information for the input data for the data inference job, including data Amazon S3 location parameters. </p>"
},
"Status":{
"shape":"IngestionJobStatus",
@@ -673,6 +729,43 @@
},
"documentation":"<p>The configuration is the <code>TargetSamplingRate</code>, which is the sampling rate of the data after post processing by Amazon Lookout for Equipment. For example, if you provide data that has been collected at a 1 second level and you want the system to resample the data at a 1 minute rate before training, the <code>TargetSamplingRate</code> is 1 minute.</p> <p>When providing a value for the <code>TargetSamplingRate</code>, you must attach the prefix \"PT\" to the rate you want. The value for a 1 second rate is therefore <i>PT1S</i>, the value for a 15 minute rate is <i>PT15M</i>, and the value for a 1 hour rate is <i>PT1H</i> </p>"
},
+ "DataQualitySummary":{
+ "type":"structure",
+ "required":[
+ "InsufficientSensorData",
+ "MissingSensorData",
+ "InvalidSensorData",
+ "UnsupportedTimestamps",
+ "DuplicateTimestamps"
+ ],
+ "members":{
+ "InsufficientSensorData":{
+ "shape":"InsufficientSensorData",
+ "documentation":"<p> Parameter that gives information about insufficient data for sensors in the dataset. This includes information about those sensors that have complete data missing and those with a short date range. </p>"
+ },
+ "MissingSensorData":{
+ "shape":"MissingSensorData",
+ "documentation":"<p> Parameter that gives information about data that is missing over all the sensors in the input data. </p>"
+ },
+ "InvalidSensorData":{
+ "shape":"InvalidSensorData",
+ "documentation":"<p> Parameter that gives information about data that is invalid over all the sensors in the input data. </p>"
+ },
+ "UnsupportedTimestamps":{
+ "shape":"UnsupportedTimestamps",
+ "documentation":"<p> Parameter that gives information about unsupported timestamps in the input data. </p>"
+ },
+ "DuplicateTimestamps":{
+ "shape":"DuplicateTimestamps",
+ "documentation":"<p> Parameter that gives information about duplicate timestamps in the input data. </p>"
+ }
+ },
+ "documentation":"<p> DataQualitySummary gives aggregated statistics over all the sensors about a completed ingestion job. It primarily gives more information about statistics over different incorrect data like MissingCompleteSensorData, MissingSensorData, UnsupportedDateFormats, InsufficientSensorData, DuplicateTimeStamps. </p>"
+ },
+ "DataSizeInBytes":{
+ "type":"long",
+ "min":0
+ },
"DataUploadFrequency":{
"type":"string",
"enum":[
@@ -816,6 +909,27 @@
"FailedReason":{
"shape":"BoundedLengthString",
"documentation":"<p>Specifies the reason for failure when a data ingestion job has failed. </p>"
+ },
+ "DataQualitySummary":{
+ "shape":"DataQualitySummary",
+ "documentation":"<p> Gives statistics about a completed ingestion job. These statistics primarily relate to quantifying incorrect data such as MissingCompleteSensorData, MissingSensorData, UnsupportedDateFormats, InsufficientSensorData, and DuplicateTimeStamps. </p>"
+ },
+ "IngestedFilesSummary":{"shape":"IngestedFilesSummary"},
+ "StatusDetail":{
+ "shape":"BoundedLengthString",
+ "documentation":"<p> Provides details about status of the ingestion job that is currently in progress. </p>"
+ },
+ "IngestedDataSize":{
+ "shape":"DataSizeInBytes",
+ "documentation":"<p> Indicates the size of the ingested dataset. </p>"
+ },
+ "DataStartTime":{
+ "shape":"Timestamp",
+ "documentation":"<p> Indicates the earliest timestamp corresponding to data that was successfully ingested during this specific ingestion job. </p>"
+ },
+ "DataEndTime":{
+ "shape":"Timestamp",
+ "documentation":"<p> Indicates the latest timestamp corresponding to data that was successfully ingested during this specific ingestion job. </p>"
}
}
},
@@ -864,6 +978,26 @@
"IngestionInputConfiguration":{
"shape":"IngestionInputConfiguration",
"documentation":"<p>Specifies the S3 location configuration for the data input for the data ingestion job. </p>"
+ },
+ "DataQualitySummary":{
+ "shape":"DataQualitySummary",
+ "documentation":"<p> Gives statistics associated with the given dataset for the latest successful associated ingestion job id. These statistics primarily relate to quantifying incorrect data such as MissingCompleteSensorData, MissingSensorData, UnsupportedDateFormats, InsufficientSensorData, and DuplicateTimeStamps. </p>"
+ },
+ "IngestedFilesSummary":{
+ "shape":"IngestedFilesSummary",
+ "documentation":"<p> IngestedFilesSummary associated with the given dataset for the latest successful associated ingestion job id. </p>"
+ },
+ "RoleArn":{
+ "shape":"IamRoleArn",
+ "documentation":"<p> The Amazon Resource Name (ARN) of the IAM role that you are using for this the data ingestion job. </p>"
+ },
+ "DataStartTime":{
+ "shape":"Timestamp",
+ "documentation":"<p> Indicates the earliest timestamp corresponding to data that was successfully ingested during the most recent ingestion of this particular dataset. </p>"
+ },
+ "DataEndTime":{
+ "shape":"Timestamp",
+ "documentation":"<p> Indicates the latest timestamp corresponding to data that was successfully ingested during the most recent ingestion of this particular dataset. </p>"
}
}
},
@@ -1035,10 +1169,22 @@
}
}
},
+ "DuplicateTimestamps":{
+ "type":"structure",
+ "required":["TotalNumberOfDuplicateTimestamps"],
+ "members":{
+ "TotalNumberOfDuplicateTimestamps":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the total number of duplicate timestamps. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises information abount duplicate timestamps in the dataset. </p>"
+ },
"FileNameTimestampFormat":{
"type":"string",
"pattern":"^EPOCH|yyyy-MM-dd-HH-mm-ss|yyyyMMddHHmmss$"
},
+ "Float":{"type":"float"},
"IamRoleArn":{
"type":"string",
"max":2048,
@@ -1100,7 +1246,7 @@
},
"DataOutputConfiguration":{
"shape":"InferenceOutputConfiguration",
- "documentation":"<p> Specifies configuration information for the output results from for the inference execution, including the output S3 location. </p>"
+ "documentation":"<p> Specifies configuration information for the output results from for the inference execution, including the output Amazon S3 location. </p>"
},
"CustomerResultObject":{
"shape":"S3Object",
@@ -1122,18 +1268,18 @@
"members":{
"S3InputConfiguration":{
"shape":"InferenceS3InputConfiguration",
- "documentation":"<p> Specifies configuration information for the input data for the inference, including S3 location of input data.. </p>"
+ "documentation":"<p> Specifies configuration information for the input data for the inference, including Amazon S3 location of input data.</p>"
},
"InputTimeZoneOffset":{
"shape":"TimeZoneOffset",
- "documentation":"<p>Indicates the difference between your time zone and Greenwich Mean Time (GMT). </p>"
+ "documentation":"<p>Indicates the difference between your time zone and Coordinated Universal Time (UTC).</p>"
},
"InferenceInputNameConfiguration":{
"shape":"InferenceInputNameConfiguration",
"documentation":"<p>Specifies configuration information for the input data for the inference, including timestamp format and delimiter. </p>"
}
},
- "documentation":"<p>Specifies configuration information for the input data for the inference, including S3 location of input data.. </p>"
+ "documentation":"<p>Specifies configuration information for the input data for the inference, including Amazon S3 location of input data.. </p>"
},
"InferenceInputNameConfiguration":{
"type":"structure",
@@ -1259,6 +1405,28 @@
},
"documentation":"<p>Contains information about the specific inference scheduler, including data delay offset, model name and ARN, status, and so on. </p>"
},
+ "IngestedFilesSummary":{
+ "type":"structure",
+ "required":[
+ "TotalNumberOfFiles",
+ "IngestedNumberOfFiles"
+ ],
+ "members":{
+ "TotalNumberOfFiles":{
+ "shape":"Integer",
+ "documentation":"<p>Indicates the total number of files that were submitted for ingestion.</p>"
+ },
+ "IngestedNumberOfFiles":{
+ "shape":"Integer",
+ "documentation":"<p>Indicates the number of files that were successfully ingested.</p>"
+ },
+ "DiscardedFiles":{
+ "shape":"ListOfDiscardedFiles",
+ "documentation":"<p>Indicates the number of files that were discarded. A file could be discarded because its format is invalid (for example, a jpg or pdf) or not readable.</p>"
+ }
+ },
+ "documentation":"<p>Gives statistics about how many files have been ingested, and which files have not been ingested, for a particular ingestion job.</p>"
+ },
"IngestionInputConfiguration":{
"type":"structure",
"required":["S3InputConfiguration"],
@@ -1294,6 +1462,10 @@
"Prefix":{
"shape":"S3Prefix",
"documentation":"<p>The prefix for the S3 location being used for the input data for the data ingestion. </p>"
+ },
+ "KeyPattern":{
+ "shape":"KeyPattern",
+ "documentation":"<p> Pattern for matching the Amazon S3 files which will be used for ingestion. If no KeyPattern is provided, we will use the default hierarchy file structure, which is same as KeyPattern {prefix}/{component_name}/* </p>"
}
},
"documentation":"<p> Specifies S3 configuration information for the input data for the data ingestion job. </p>"
@@ -1303,6 +1475,25 @@
"max":1000000,
"min":1
},
+ "InsufficientSensorData":{
+ "type":"structure",
+ "required":[
+ "MissingCompleteSensorData",
+ "SensorsWithShortDateRange"
+ ],
+ "members":{
+ "MissingCompleteSensorData":{
+ "shape":"MissingCompleteSensorData",
+ "documentation":"<p> Parameter that describes the total number of sensors that have data completely missing for it. </p>"
+ },
+ "SensorsWithShortDateRange":{
+ "shape":"SensorsWithShortDateRange",
+ "documentation":"<p> Parameter that describes the total number of sensors that have a short date range of less than 90 days of data overall. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises aggregated information on sensors having insufficient data. </p>"
+ },
+ "Integer":{"type":"integer"},
"InternalServerException":{
"type":"structure",
"required":["Message"],
@@ -1313,6 +1504,29 @@
"exception":true,
"fault":true
},
+ "InvalidSensorData":{
+ "type":"structure",
+ "required":[
+ "AffectedSensorCount",
+ "TotalNumberOfInvalidValues"
+ ],
+ "members":{
+ "AffectedSensorCount":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the number of sensors that have at least some invalid values. </p>"
+ },
+ "TotalNumberOfInvalidValues":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the total number of invalid values across all the sensors. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises aggregated information on sensors having insufficient data. </p>"
+ },
+ "KeyPattern":{
+ "type":"string",
+ "max":2048,
+ "min":1
+ },
"KmsKeyArn":{
"type":"string",
"max":1024,
@@ -1345,6 +1559,25 @@
},
"documentation":"<p>The location information (prefix and bucket name) for the s3 location being used for label data. </p>"
},
+ "LargeTimestampGaps":{
+ "type":"structure",
+ "required":["Status"],
+ "members":{
+ "Status":{
+ "shape":"StatisticalIssueStatus",
+ "documentation":"<p> Indicates whether there is a potential data issue related to large gaps in timestamps. </p>"
+ },
+ "NumberOfLargeTimestampGaps":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the number of large timestamp gaps, if there are any. </p>"
+ },
+ "MaxTimestampGapInDays":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the size of the largest timestamp gap, in days. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises information on large gaps between consecutive timestamps in data. </p>"
+ },
"ListDataIngestionJobsRequest":{
"type":"structure",
"members":{
@@ -1524,6 +1757,46 @@
}
}
},
+ "ListOfDiscardedFiles":{
+ "type":"list",
+ "member":{"shape":"S3Object"},
+ "min":0
+ },
+ "ListSensorStatisticsRequest":{
+ "type":"structure",
+ "required":["DatasetName"],
+ "members":{
+ "DatasetName":{
+ "shape":"DatasetName",
+ "documentation":"<p> The name of the dataset associated with the list of Sensor Statistics. </p>"
+ },
+ "IngestionJobId":{
+ "shape":"IngestionJobId",
+ "documentation":"<p> The ingestion job id associated with the list of Sensor Statistics. To get sensor statistics for a particular ingestion job id, both dataset name and ingestion job id must be submitted as inputs. </p>"
+ },
+ "MaxResults":{
+ "shape":"MaxResults",
+ "documentation":"<p> Specifies the maximum number of sensors for which to retrieve statistics. </p>"
+ },
+ "NextToken":{
+ "shape":"NextToken",
+ "documentation":"<p> An opaque pagination token indicating where to continue the listing of sensor statistics. </p>"
+ }
+ }
+ },
+ "ListSensorStatisticsResponse":{
+ "type":"structure",
+ "members":{
+ "SensorStatisticsSummaries":{
+ "shape":"SensorStatisticsSummaries",
+ "documentation":"<p> Provides ingestion-based statistics regarding the specified sensor with respect to various validation types, such as whether data exists, the number and percentage of missing values, and the number and percentage of duplicate timestamps. </p>"
+ },
+ "NextToken":{
+ "shape":"NextToken",
+ "documentation":"<p> An opaque pagination token indicating where to continue the listing of sensor statistics. </p>"
+ }
+ }
+ },
"ListTagsForResourceRequest":{
"type":"structure",
"required":["ResourceArn"],
@@ -1548,6 +1821,35 @@
"max":500,
"min":1
},
+ "MissingCompleteSensorData":{
+ "type":"structure",
+ "required":["AffectedSensorCount"],
+ "members":{
+ "AffectedSensorCount":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the number of sensors that have data missing completely. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises information on sensors that have sensor data completely missing. </p>"
+ },
+ "MissingSensorData":{
+ "type":"structure",
+ "required":[
+ "AffectedSensorCount",
+ "TotalNumberOfMissingValues"
+ ],
+ "members":{
+ "AffectedSensorCount":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the number of sensors that have atleast some data missing. </p>"
+ },
+ "TotalNumberOfMissingValues":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the total number of missing values across all the sensors. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises aggregated information on sensors having missing data. </p>"
+ },
"ModelArn":{
"type":"string",
"max":2048,
@@ -1607,6 +1909,40 @@
},
"documentation":"<p>Provides information about the specified ML model, including dataset and model names and ARNs, as well as status. </p>"
},
+ "MonotonicValues":{
+ "type":"structure",
+ "required":["Status"],
+ "members":{
+ "Status":{
+ "shape":"StatisticalIssueStatus",
+ "documentation":"<p> Indicates whether there is a potential data issue related to having monotonic values. </p>"
+ },
+ "Monotonicity":{
+ "shape":"Monotonicity",
+ "documentation":"<p> Indicates the monotonicity of values. Can be INCREASING, DECREASING, or STATIC. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises information on monotonic values in the data. </p>"
+ },
+ "Monotonicity":{
+ "type":"string",
+ "enum":[
+ "DECREASING",
+ "INCREASING",
+ "STATIC"
+ ]
+ },
+ "MultipleOperatingModes":{
+ "type":"structure",
+ "required":["Status"],
+ "members":{
+ "Status":{
+ "shape":"StatisticalIssueStatus",
+ "documentation":"<p> Indicates whether there is a potential data issue related to having multiple operating modes. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises information on operating modes in data. </p>"
+ },
"NameOrArn":{
"type":"string",
"max":2048,
@@ -1668,6 +2004,85 @@
"min":0,
"pattern":"(^$)|([\\P{M}\\p{M}]{1,1023}/$)"
},
+ "SensorName":{
+ "type":"string",
+ "max":200,
+ "min":1,
+ "pattern":"^[0-9a-zA-Z:#$.\\-_]{1,200}$"
+ },
+ "SensorStatisticsSummaries":{
+ "type":"list",
+ "member":{"shape":"SensorStatisticsSummary"}
+ },
+ "SensorStatisticsSummary":{
+ "type":"structure",
+ "members":{
+ "ComponentName":{
+ "shape":"ComponentName",
+ "documentation":"<p> Name of the component to which the particular sensor belongs for which the statistics belong to. </p>"
+ },
+ "SensorName":{
+ "shape":"SensorName",
+ "documentation":"<p> Name of the sensor that the statistics belong to. </p>"
+ },
+ "DataExists":{
+ "shape":"Boolean",
+ "documentation":"<p> Parameter that indicates whether data exists for the sensor that the statistics belong to. </p>"
+ },
+ "MissingValues":{
+ "shape":"CountPercent",
+ "documentation":"<p> Parameter that describes the total number of, and percentage of, values that are missing for the sensor that the statistics belong to. </p>"
+ },
+ "InvalidValues":{
+ "shape":"CountPercent",
+ "documentation":"<p> Parameter that describes the total number of, and percentage of, values that are invalid for the sensor that the statistics belong to. </p>"
+ },
+ "InvalidDateEntries":{
+ "shape":"CountPercent",
+ "documentation":"<p> Parameter that describes the total number of invalid date entries associated with the sensor that the statistics belong to. </p>"
+ },
+ "DuplicateTimestamps":{
+ "shape":"CountPercent",
+ "documentation":"<p> Parameter that describes the total number of duplicate timestamp records associated with the sensor that the statistics belong to. </p>"
+ },
+ "CategoricalValues":{
+ "shape":"CategoricalValues",
+ "documentation":"<p> Parameter that describes potential risk about whether data associated with the sensor is categorical. </p>"
+ },
+ "MultipleOperatingModes":{
+ "shape":"MultipleOperatingModes",
+ "documentation":"<p> Parameter that describes potential risk about whether data associated with the sensor has more than one operating mode. </p>"
+ },
+ "LargeTimestampGaps":{
+ "shape":"LargeTimestampGaps",
+ "documentation":"<p> Parameter that describes potential risk about whether data associated with the sensor contains one or more large gaps between consecutive timestamps. </p>"
+ },
+ "MonotonicValues":{
+ "shape":"MonotonicValues",
+ "documentation":"<p> Parameter that describes potential risk about whether data associated with the sensor is mostly monotonic. </p>"
+ },
+ "DataStartTime":{
+ "shape":"Timestamp",
+ "documentation":"<p> Indicates the time reference to indicate the beginning of valid data associated with the sensor that the statistics belong to. </p>"
+ },
+ "DataEndTime":{
+ "shape":"Timestamp",
+ "documentation":"<p> Indicates the time reference to indicate the end of valid data associated with the sensor that the statistics belong to. </p>"
+ }
+ },
+ "documentation":"<p> Summary of ingestion statistics like whether data exists, number of missing values, number of invalid values and so on related to the particular sensor. </p>"
+ },
+ "SensorsWithShortDateRange":{
+ "type":"structure",
+ "required":["AffectedSensorCount"],
+ "members":{
+ "AffectedSensorCount":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the number of sensors that have less than 90 days of data. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises information on sensors that have shorter date range. </p>"
+ },
"ServiceQuotaExceededException":{
"type":"structure",
"required":["Message"],
@@ -1753,6 +2168,13 @@
}
}
},
+ "StatisticalIssueStatus":{
+ "type":"string",
+ "enum":[
+ "POTENTIAL_ISSUE_DETECTED",
+ "NO_ISSUE_DETECTED"
+ ]
+ },
"StopInferenceSchedulerRequest":{
"type":"structure",
"required":["InferenceSchedulerName"],
@@ -1882,6 +2304,17 @@
"pattern":"^(\\+|\\-)[0-9]{2}\\:[0-9]{2}$"
},
"Timestamp":{"type":"timestamp"},
+ "UnsupportedTimestamps":{
+ "type":"structure",
+ "required":["TotalNumberOfUnsupportedTimestamps"],
+ "members":{
+ "TotalNumberOfUnsupportedTimestamps":{
+ "shape":"Integer",
+ "documentation":"<p> Indicates the total number of unsupported timestamps across the ingested data. </p>"
+ }
+ },
+ "documentation":"<p> Entity that comprises information abount unsupported timestamps in the dataset. </p>"
+ },
"UntagResourceRequest":{
"type":"structure",
"required":[
diff --git a/contrib/python/botocore/py3/botocore/data/rekognition/2016-06-27/service-2.json b/contrib/python/botocore/py3/botocore/data/rekognition/2016-06-27/service-2.json
index e97db585be..6bf276dbae 100644
--- a/contrib/python/botocore/py3/botocore/data/rekognition/2016-06-27/service-2.json
+++ b/contrib/python/botocore/py3/botocore/data/rekognition/2016-06-27/service-2.json
@@ -130,7 +130,7 @@
{"shape":"ProvisionedThroughputExceededException"},
{"shape":"ServiceQuotaExceededException"}
],
- "documentation":"<p>Creates an Amazon Rekognition stream processor that you can use to detect and recognize faces in a streaming video.</p> <p>Amazon Rekognition Video is a consumer of live video from Amazon Kinesis Video Streams. Amazon Rekognition Video sends analysis results to Amazon Kinesis Data Streams.</p> <p>You provide as input a Kinesis video stream (<code>Input</code>) and a Kinesis data stream (<code>Output</code>) stream. You also specify the face recognition criteria in <code>Settings</code>. For example, the collection containing faces that you want to recognize. Use <code>Name</code> to assign an identifier for the stream processor. You use <code>Name</code> to manage the stream processor. For example, you can start processing the source video by calling <a>StartStreamProcessor</a> with the <code>Name</code> field. </p> <p>After you have finished analyzing a streaming video, use <a>StopStreamProcessor</a> to stop processing. You can delete the stream processor by calling <a>DeleteStreamProcessor</a>.</p> <p>This operation requires permissions to perform the <code>rekognition:CreateStreamProcessor</code> action. If you want to tag your stream processor, you also require permission to perform the <code>rekognition:TagResource</code> operation.</p>"
+ "documentation":"<p>Creates an Amazon Rekognition stream processor that you can use to detect and recognize faces or to detect labels in a streaming video.</p> <p>Amazon Rekognition Video is a consumer of live video from Amazon Kinesis Video Streams. There are two different settings for stream processors in Amazon Rekognition: detecting faces and detecting labels.</p> <ul> <li> <p>If you are creating a stream processor for detecting faces, you provide as input a Kinesis video stream (<code>Input</code>) and a Kinesis data stream (<code>Output</code>) stream. You also specify the face recognition criteria in <code>Settings</code>. For example, the collection containing faces that you want to recognize. After you have finished analyzing a streaming video, use <a>StopStreamProcessor</a> to stop processing.</p> </li> <li> <p>If you are creating a stream processor to detect labels, you provide as input a Kinesis video stream (<code>Input</code>), Amazon S3 bucket information (<code>Output</code>), and an Amazon SNS topic ARN (<code>NotificationChannel</code>). You can also provide a KMS key ID to encrypt the data sent to your Amazon S3 bucket. You specify what you want to detect in <code>ConnectedHomeSettings</code>, such as people, packages and people, or pets, people, and packages. You can also specify where in the frame you want Amazon Rekognition to monitor with <code>RegionsOfInterest</code>. When you run the <a>StartStreamProcessor</a> operation on a label detection stream processor, you input start and stop information to determine the length of the processing time.</p> </li> </ul> <p> Use <code>Name</code> to assign an identifier for the stream processor. You use <code>Name</code> to manage the stream processor. For example, you can start processing the source video by calling <a>StartStreamProcessor</a> with the <code>Name</code> field. </p> <p>This operation requires permissions to perform the <code>rekognition:CreateStreamProcessor</code> action. If you want to tag your stream processor, you also require permission to perform the <code>rekognition:TagResource</code> operation.</p>"
},
"DeleteCollection":{
"name":"DeleteCollection",
@@ -148,7 +148,7 @@
{"shape":"ProvisionedThroughputExceededException"},
{"shape":"ResourceNotFoundException"}
],
- "documentation":"<p>Deletes the specified collection. Note that this operation removes all faces in the collection. For an example, see <a>delete-collection-procedure</a>.</p> <p>This operation requires permissions to perform the <code>rekognition:DeleteCollection</code> action.</p>"
+ "documentation":"<p>Deletes the specified collection. Note that this operation removes all faces in the collection. For an example, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/delete-collection-procedure.html\">Deleting a collection</a>.</p> <p>This operation requires permissions to perform the <code>rekognition:DeleteCollection</code> action.</p>"
},
"DeleteDataset":{
"name":"DeleteDataset",
@@ -397,7 +397,7 @@
{"shape":"ProvisionedThroughputExceededException"},
{"shape":"InvalidImageFormatException"}
],
- "documentation":"<p>Detects instances of real-world entities within an image (JPEG or PNG) provided as input. This includes objects like flower, tree, and table; events like wedding, graduation, and birthday party; and concepts like landscape, evening, and nature. </p> <p>For an example, see Analyzing Images Stored in an Amazon S3 Bucket in the Amazon Rekognition Developer Guide.</p> <note> <p> <code>DetectLabels</code> does not support the detection of activities. However, activity detection is supported for label detection in videos. For more information, see StartLabelDetection in the Amazon Rekognition Developer Guide.</p> </note> <p>You pass the input image as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file. </p> <p> For each object, scene, and concept the API returns one or more labels. Each label provides the object name, and the level of confidence that the image contains the object. For example, suppose the input image has a lighthouse, the sea, and a rock. The response includes all three labels, one for each object. </p> <p> <code>{Name: lighthouse, Confidence: 98.4629}</code> </p> <p> <code>{Name: rock,Confidence: 79.2097}</code> </p> <p> <code> {Name: sea,Confidence: 75.061}</code> </p> <p>In the preceding example, the operation returns one label for each of the three objects. The operation can also return multiple labels for the same object in the image. For example, if the input image shows a flower (for example, a tulip), the operation might return the following three labels. </p> <p> <code>{Name: flower,Confidence: 99.0562}</code> </p> <p> <code>{Name: plant,Confidence: 99.0562}</code> </p> <p> <code>{Name: tulip,Confidence: 99.0562}</code> </p> <p>In this example, the detection algorithm more precisely identifies the flower as a tulip.</p> <p>In response, the API returns an array of labels. In addition, the response also includes the orientation correction. Optionally, you can specify <code>MinConfidence</code> to control the confidence threshold for the labels returned. The default is 55%. You can also add the <code>MaxLabels</code> parameter to limit the number of labels returned. </p> <note> <p>If the object detected is a person, the operation doesn't provide the same facial details that the <a>DetectFaces</a> operation provides.</p> </note> <p> <code>DetectLabels</code> returns bounding boxes for instances of common object labels in an array of <a>Instance</a> objects. An <code>Instance</code> object contains a <a>BoundingBox</a> object, for the location of the label on the image. It also includes the confidence by which the bounding box was detected.</p> <p> <code>DetectLabels</code> also returns a hierarchical taxonomy of detected labels. For example, a detected car might be assigned the label <i>car</i>. The label <i>car</i> has two parent labels: <i>Vehicle</i> (its parent) and <i>Transportation</i> (its grandparent). The response returns the entire list of ancestors for a label. Each ancestor is a unique label in the response. In the previous example, <i>Car</i>, <i>Vehicle</i>, and <i>Transportation</i> are returned as unique labels in the response. </p> <p>This is a stateless API operation. That is, the operation does not persist any data.</p> <p>This operation requires permissions to perform the <code>rekognition:DetectLabels</code> action. </p>"
+ "documentation":"<p>Detects instances of real-world entities within an image (JPEG or PNG) provided as input. This includes objects like flower, tree, and table; events like wedding, graduation, and birthday party; and concepts like landscape, evening, and nature. </p> <p>For an example, see Analyzing images stored in an Amazon S3 bucket in the Amazon Rekognition Developer Guide.</p> <note> <p> <code>DetectLabels</code> does not support the detection of activities. However, activity detection is supported for label detection in videos. For more information, see StartLabelDetection in the Amazon Rekognition Developer Guide.</p> </note> <p>You pass the input image as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file. </p> <p> For each object, scene, and concept the API returns one or more labels. Each label provides the object name, and the level of confidence that the image contains the object. For example, suppose the input image has a lighthouse, the sea, and a rock. The response includes all three labels, one for each object. </p> <p> <code>{Name: lighthouse, Confidence: 98.4629}</code> </p> <p> <code>{Name: rock,Confidence: 79.2097}</code> </p> <p> <code> {Name: sea,Confidence: 75.061}</code> </p> <p>In the preceding example, the operation returns one label for each of the three objects. The operation can also return multiple labels for the same object in the image. For example, if the input image shows a flower (for example, a tulip), the operation might return the following three labels. </p> <p> <code>{Name: flower,Confidence: 99.0562}</code> </p> <p> <code>{Name: plant,Confidence: 99.0562}</code> </p> <p> <code>{Name: tulip,Confidence: 99.0562}</code> </p> <p>In this example, the detection algorithm more precisely identifies the flower as a tulip.</p> <p>In response, the API returns an array of labels. In addition, the response also includes the orientation correction. Optionally, you can specify <code>MinConfidence</code> to control the confidence threshold for the labels returned. The default is 55%. You can also add the <code>MaxLabels</code> parameter to limit the number of labels returned. </p> <note> <p>If the object detected is a person, the operation doesn't provide the same facial details that the <a>DetectFaces</a> operation provides.</p> </note> <p> <code>DetectLabels</code> returns bounding boxes for instances of common object labels in an array of <a>Instance</a> objects. An <code>Instance</code> object contains a <a>BoundingBox</a> object, for the location of the label on the image. It also includes the confidence by which the bounding box was detected.</p> <p> <code>DetectLabels</code> also returns a hierarchical taxonomy of detected labels. For example, a detected car might be assigned the label <i>car</i>. The label <i>car</i> has two parent labels: <i>Vehicle</i> (its parent) and <i>Transportation</i> (its grandparent). The response returns the entire list of ancestors for a label. Each ancestor is a unique label in the response. In the previous example, <i>Car</i>, <i>Vehicle</i>, and <i>Transportation</i> are returned as unique labels in the response. </p> <p>This is a stateless API operation. That is, the operation does not persist any data.</p> <p>This operation requires permissions to perform the <code>rekognition:DetectLabels</code> action. </p>"
},
"DetectModerationLabels":{
"name":"DetectModerationLabels",
@@ -458,7 +458,7 @@
{"shape":"ProvisionedThroughputExceededException"},
{"shape":"InvalidImageFormatException"}
],
- "documentation":"<p>Detects text in the input image and converts it into machine-readable text.</p> <p>Pass the input image as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, you must pass it as a reference to an image in an Amazon S3 bucket. For the AWS CLI, passing image bytes is not supported. The image must be either a .png or .jpeg formatted file. </p> <p>The <code>DetectText</code> operation returns text in an array of <a>TextDetection</a> elements, <code>TextDetections</code>. Each <code>TextDetection</code> element provides information about a single word or line of text that was detected in the image. </p> <p>A word is one or more script characters that are not separated by spaces. <code>DetectText</code> can detect up to 100 words in an image.</p> <p>A line is a string of equally spaced words. A line isn't necessarily a complete sentence. For example, a driver's license number is detected as a line. A line ends when there is no aligned text after it. Also, a line ends when there is a large gap between words, relative to the length of the words. This means, depending on the gap between words, Amazon Rekognition may detect multiple lines in text aligned in the same direction. Periods don't represent the end of a line. If a sentence spans multiple lines, the <code>DetectText</code> operation returns multiple lines.</p> <p>To determine whether a <code>TextDetection</code> element is a line of text or a word, use the <code>TextDetection</code> object <code>Type</code> field. </p> <p>To be detected, text must be within +/- 90 degrees orientation of the horizontal axis.</p> <p>For more information, see DetectText in the Amazon Rekognition Developer Guide.</p>"
+ "documentation":"<p>Detects text in the input image and converts it into machine-readable text.</p> <p>Pass the input image as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, you must pass it as a reference to an image in an Amazon S3 bucket. For the AWS CLI, passing image bytes is not supported. The image must be either a .png or .jpeg formatted file. </p> <p>The <code>DetectText</code> operation returns text in an array of <a>TextDetection</a> elements, <code>TextDetections</code>. Each <code>TextDetection</code> element provides information about a single word or line of text that was detected in the image. </p> <p>A word is one or more script characters that are not separated by spaces. <code>DetectText</code> can detect up to 100 words in an image.</p> <p>A line is a string of equally spaced words. A line isn't necessarily a complete sentence. For example, a driver's license number is detected as a line. A line ends when there is no aligned text after it. Also, a line ends when there is a large gap between words, relative to the length of the words. This means, depending on the gap between words, Amazon Rekognition may detect multiple lines in text aligned in the same direction. Periods don't represent the end of a line. If a sentence spans multiple lines, the <code>DetectText</code> operation returns multiple lines.</p> <p>To determine whether a <code>TextDetection</code> element is a line of text or a word, use the <code>TextDetection</code> object <code>Type</code> field. </p> <p>To be detected, text must be within +/- 90 degrees orientation of the horizontal axis.</p> <p>For more information, see Detecting text in the Amazon Rekognition Developer Guide.</p>"
},
"DistributeDatasetEntries":{
"name":"DistributeDatasetEntries",
@@ -495,7 +495,7 @@
{"shape":"ProvisionedThroughputExceededException"},
{"shape":"ResourceNotFoundException"}
],
- "documentation":"<p>Gets the name and additional information about a celebrity based on their Amazon Rekognition ID. The additional information is returned as an array of URLs. If there is no additional information about the celebrity, this list is empty.</p> <p>For more information, see Recognizing Celebrities in an Image in the Amazon Rekognition Developer Guide.</p> <p>This operation requires permissions to perform the <code>rekognition:GetCelebrityInfo</code> action. </p>"
+ "documentation":"<p>Gets the name and additional information about a celebrity based on their Amazon Rekognition ID. The additional information is returned as an array of URLs. If there is no additional information about the celebrity, this list is empty.</p> <p>For more information, see Getting information about a celebrity in the Amazon Rekognition Developer Guide.</p> <p>This operation requires permissions to perform the <code>rekognition:GetCelebrityInfo</code> action. </p>"
},
"GetCelebrityRecognition":{
"name":"GetCelebrityRecognition",
@@ -533,7 +533,7 @@
{"shape":"ResourceNotFoundException"},
{"shape":"ThrottlingException"}
],
- "documentation":"<p>Gets the inappropriate, unwanted, or offensive content analysis results for a Amazon Rekognition Video analysis started by <a>StartContentModeration</a>. For a list of moderation labels in Amazon Rekognition, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/moderation.html#moderation-api\">Using the image and video moderation APIs</a>.</p> <p>Amazon Rekognition Video inappropriate or offensive content detection in a stored video is an asynchronous operation. You start analysis by calling <a>StartContentModeration</a> which returns a job identifier (<code>JobId</code>). When analysis finishes, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic registered in the initial call to <code>StartContentModeration</code>. To get the results of the content analysis, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <code>GetContentModeration</code> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartContentModeration</code>. </p> <p>For more information, see Working with Stored Videos in the Amazon Rekognition Devlopers Guide.</p> <p> <code>GetContentModeration</code> returns detected inappropriate, unwanted, or offensive content moderation labels, and the time they are detected, in an array, <code>ModerationLabels</code>, of <a>ContentModerationDetection</a> objects. </p> <p>By default, the moderated labels are returned sorted by time, in milliseconds from the start of the video. You can also sort them by moderated label by specifying <code>NAME</code> for the <code>SortBy</code> input parameter. </p> <p>Since video analysis can return a large number of results, use the <code>MaxResults</code> parameter to limit the number of labels returned in a single call to <code>GetContentModeration</code>. If there are more results than specified in <code>MaxResults</code>, the value of <code>NextToken</code> in the operation response contains a pagination token for getting the next set of results. To get the next page of results, call <code>GetContentModeration</code> and populate the <code>NextToken</code> request parameter with the value of <code>NextToken</code> returned from the previous call to <code>GetContentModeration</code>.</p> <p>For more information, see Content moderation in the Amazon Rekognition Developer Guide.</p>"
+ "documentation":"<p>Gets the inappropriate, unwanted, or offensive content analysis results for a Amazon Rekognition Video analysis started by <a>StartContentModeration</a>. For a list of moderation labels in Amazon Rekognition, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/moderation.html#moderation-api\">Using the image and video moderation APIs</a>.</p> <p>Amazon Rekognition Video inappropriate or offensive content detection in a stored video is an asynchronous operation. You start analysis by calling <a>StartContentModeration</a> which returns a job identifier (<code>JobId</code>). When analysis finishes, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic registered in the initial call to <code>StartContentModeration</code>. To get the results of the content analysis, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <code>GetContentModeration</code> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartContentModeration</code>. </p> <p>For more information, see Working with Stored Videos in the Amazon Rekognition Devlopers Guide.</p> <p> <code>GetContentModeration</code> returns detected inappropriate, unwanted, or offensive content moderation labels, and the time they are detected, in an array, <code>ModerationLabels</code>, of <a>ContentModerationDetection</a> objects. </p> <p>By default, the moderated labels are returned sorted by time, in milliseconds from the start of the video. You can also sort them by moderated label by specifying <code>NAME</code> for the <code>SortBy</code> input parameter. </p> <p>Since video analysis can return a large number of results, use the <code>MaxResults</code> parameter to limit the number of labels returned in a single call to <code>GetContentModeration</code>. If there are more results than specified in <code>MaxResults</code>, the value of <code>NextToken</code> in the operation response contains a pagination token for getting the next set of results. To get the next page of results, call <code>GetContentModeration</code> and populate the <code>NextToken</code> request parameter with the value of <code>NextToken</code> returned from the previous call to <code>GetContentModeration</code>.</p> <p>For more information, see moderating content in the Amazon Rekognition Developer Guide.</p>"
},
"GetFaceDetection":{
"name":"GetFaceDetection",
@@ -628,7 +628,7 @@
{"shape":"ResourceNotFoundException"},
{"shape":"ThrottlingException"}
],
- "documentation":"<p>Gets the segment detection results of a Amazon Rekognition Video analysis started by <a>StartSegmentDetection</a>.</p> <p>Segment detection with Amazon Rekognition Video is an asynchronous operation. You start segment detection by calling <a>StartSegmentDetection</a> which returns a job identifier (<code>JobId</code>). When the segment detection operation finishes, Amazon Rekognition publishes a completion status to the Amazon Simple Notification Service topic registered in the initial call to <code>StartSegmentDetection</code>. To get the results of the segment detection operation, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. if so, call <code>GetSegmentDetection</code> and pass the job identifier (<code>JobId</code>) from the initial call of <code>StartSegmentDetection</code>.</p> <p> <code>GetSegmentDetection</code> returns detected segments in an array (<code>Segments</code>) of <a>SegmentDetection</a> objects. <code>Segments</code> is sorted by the segment types specified in the <code>SegmentTypes</code> input parameter of <code>StartSegmentDetection</code>. Each element of the array includes the detected segment, the precentage confidence in the acuracy of the detected segment, the type of the segment, and the frame in which the segment was detected.</p> <p>Use <code>SelectedSegmentTypes</code> to find out the type of segment detection requested in the call to <code>StartSegmentDetection</code>.</p> <p>Use the <code>MaxResults</code> parameter to limit the number of segment detections returned. If there are more results than specified in <code>MaxResults</code>, the value of <code>NextToken</code> in the operation response contains a pagination token for getting the next set of results. To get the next page of results, call <code>GetSegmentDetection</code> and populate the <code>NextToken</code> request parameter with the token value returned from the previous call to <code>GetSegmentDetection</code>.</p> <p>For more information, see Detecting Video Segments in Stored Video in the Amazon Rekognition Developer Guide.</p>"
+ "documentation":"<p>Gets the segment detection results of a Amazon Rekognition Video analysis started by <a>StartSegmentDetection</a>.</p> <p>Segment detection with Amazon Rekognition Video is an asynchronous operation. You start segment detection by calling <a>StartSegmentDetection</a> which returns a job identifier (<code>JobId</code>). When the segment detection operation finishes, Amazon Rekognition publishes a completion status to the Amazon Simple Notification Service topic registered in the initial call to <code>StartSegmentDetection</code>. To get the results of the segment detection operation, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. if so, call <code>GetSegmentDetection</code> and pass the job identifier (<code>JobId</code>) from the initial call of <code>StartSegmentDetection</code>.</p> <p> <code>GetSegmentDetection</code> returns detected segments in an array (<code>Segments</code>) of <a>SegmentDetection</a> objects. <code>Segments</code> is sorted by the segment types specified in the <code>SegmentTypes</code> input parameter of <code>StartSegmentDetection</code>. Each element of the array includes the detected segment, the precentage confidence in the acuracy of the detected segment, the type of the segment, and the frame in which the segment was detected.</p> <p>Use <code>SelectedSegmentTypes</code> to find out the type of segment detection requested in the call to <code>StartSegmentDetection</code>.</p> <p>Use the <code>MaxResults</code> parameter to limit the number of segment detections returned. If there are more results than specified in <code>MaxResults</code>, the value of <code>NextToken</code> in the operation response contains a pagination token for getting the next set of results. To get the next page of results, call <code>GetSegmentDetection</code> and populate the <code>NextToken</code> request parameter with the token value returned from the previous call to <code>GetSegmentDetection</code>.</p> <p>For more information, see Detecting video segments in stored video in the Amazon Rekognition Developer Guide.</p>"
},
"GetTextDetection":{
"name":"GetTextDetection",
@@ -669,7 +669,7 @@
{"shape":"InvalidImageFormatException"},
{"shape":"ServiceQuotaExceededException"}
],
- "documentation":"<p>Detects faces in the input image and adds them to the specified collection. </p> <p>Amazon Rekognition doesn't save the actual faces that are detected. Instead, the underlying detection algorithm first detects the faces in the input image. For each face, the algorithm extracts facial features into a feature vector, and stores it in the backend database. Amazon Rekognition uses feature vectors when it performs face match and search operations using the <a>SearchFaces</a> and <a>SearchFacesByImage</a> operations.</p> <p>For more information, see Adding Faces to a Collection in the Amazon Rekognition Developer Guide.</p> <p>To get the number of faces in a collection, call <a>DescribeCollection</a>. </p> <p>If you're using version 1.0 of the face detection model, <code>IndexFaces</code> indexes the 15 largest faces in the input image. Later versions of the face detection model index the 100 largest faces in the input image. </p> <p>If you're using version 4 or later of the face model, image orientation information is not returned in the <code>OrientationCorrection</code> field. </p> <p>To determine which version of the model you're using, call <a>DescribeCollection</a> and supply the collection ID. You can also get the model version from the value of <code>FaceModelVersion</code> in the response from <code>IndexFaces</code> </p> <p>For more information, see Model Versioning in the Amazon Rekognition Developer Guide.</p> <p>If you provide the optional <code>ExternalImageId</code> for the input image you provided, Amazon Rekognition associates this ID with all faces that it detects. When you call the <a>ListFaces</a> operation, the response returns the external ID. You can use this external image ID to create a client-side index to associate the faces with each image. You can then use the index to find all faces in an image.</p> <p>You can specify the maximum number of faces to index with the <code>MaxFaces</code> input parameter. This is useful when you want to index the largest faces in an image and don't want to index smaller faces, such as those belonging to people standing in the background.</p> <p>The <code>QualityFilter</code> input parameter allows you to filter out detected faces that don’t meet a required quality bar. The quality bar is based on a variety of common use cases. By default, <code>IndexFaces</code> chooses the quality bar that's used to filter faces. You can also explicitly choose the quality bar. Use <code>QualityFilter</code>, to set the quality bar by specifying <code>LOW</code>, <code>MEDIUM</code>, or <code>HIGH</code>. If you do not want to filter detected faces, specify <code>NONE</code>. </p> <note> <p>To use quality filtering, you need a collection associated with version 3 of the face model or higher. To get the version of the face model associated with a collection, call <a>DescribeCollection</a>. </p> </note> <p>Information about faces detected in an image, but not indexed, is returned in an array of <a>UnindexedFace</a> objects, <code>UnindexedFaces</code>. Faces aren't indexed for reasons such as:</p> <ul> <li> <p>The number of faces detected exceeds the value of the <code>MaxFaces</code> request parameter.</p> </li> <li> <p>The face is too small compared to the image dimensions.</p> </li> <li> <p>The face is too blurry.</p> </li> <li> <p>The image is too dark.</p> </li> <li> <p>The face has an extreme pose.</p> </li> <li> <p>The face doesn’t have enough detail to be suitable for face search.</p> </li> </ul> <p>In response, the <code>IndexFaces</code> operation returns an array of metadata for all detected faces, <code>FaceRecords</code>. This includes: </p> <ul> <li> <p>The bounding box, <code>BoundingBox</code>, of the detected face. </p> </li> <li> <p>A confidence value, <code>Confidence</code>, which indicates the confidence that the bounding box contains a face.</p> </li> <li> <p>A face ID, <code>FaceId</code>, assigned by the service for each face that's detected and stored.</p> </li> <li> <p>An image ID, <code>ImageId</code>, assigned by the service for the input image.</p> </li> </ul> <p>If you request all facial attributes (by using the <code>detectionAttributes</code> parameter), Amazon Rekognition returns detailed facial attributes, such as facial landmarks (for example, location of eye and mouth) and other facial attributes. If you provide the same image, specify the same collection, use the same external ID, and use the same model version in the <code>IndexFaces</code> operation, Amazon Rekognition doesn't save duplicate face metadata.</p> <p/> <p>The input image is passed either as base64-encoded image bytes, or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes isn't supported. The image must be formatted as a PNG or JPEG file. </p> <p>This operation requires permissions to perform the <code>rekognition:IndexFaces</code> action.</p>"
+ "documentation":"<p>Detects faces in the input image and adds them to the specified collection. </p> <p>Amazon Rekognition doesn't save the actual faces that are detected. Instead, the underlying detection algorithm first detects the faces in the input image. For each face, the algorithm extracts facial features into a feature vector, and stores it in the backend database. Amazon Rekognition uses feature vectors when it performs face match and search operations using the <a>SearchFaces</a> and <a>SearchFacesByImage</a> operations.</p> <p>For more information, see Adding faces to a collection in the Amazon Rekognition Developer Guide.</p> <p>To get the number of faces in a collection, call <a>DescribeCollection</a>. </p> <p>If you're using version 1.0 of the face detection model, <code>IndexFaces</code> indexes the 15 largest faces in the input image. Later versions of the face detection model index the 100 largest faces in the input image. </p> <p>If you're using version 4 or later of the face model, image orientation information is not returned in the <code>OrientationCorrection</code> field. </p> <p>To determine which version of the model you're using, call <a>DescribeCollection</a> and supply the collection ID. You can also get the model version from the value of <code>FaceModelVersion</code> in the response from <code>IndexFaces</code> </p> <p>For more information, see Model Versioning in the Amazon Rekognition Developer Guide.</p> <p>If you provide the optional <code>ExternalImageId</code> for the input image you provided, Amazon Rekognition associates this ID with all faces that it detects. When you call the <a>ListFaces</a> operation, the response returns the external ID. You can use this external image ID to create a client-side index to associate the faces with each image. You can then use the index to find all faces in an image.</p> <p>You can specify the maximum number of faces to index with the <code>MaxFaces</code> input parameter. This is useful when you want to index the largest faces in an image and don't want to index smaller faces, such as those belonging to people standing in the background.</p> <p>The <code>QualityFilter</code> input parameter allows you to filter out detected faces that don’t meet a required quality bar. The quality bar is based on a variety of common use cases. By default, <code>IndexFaces</code> chooses the quality bar that's used to filter faces. You can also explicitly choose the quality bar. Use <code>QualityFilter</code>, to set the quality bar by specifying <code>LOW</code>, <code>MEDIUM</code>, or <code>HIGH</code>. If you do not want to filter detected faces, specify <code>NONE</code>. </p> <note> <p>To use quality filtering, you need a collection associated with version 3 of the face model or higher. To get the version of the face model associated with a collection, call <a>DescribeCollection</a>. </p> </note> <p>Information about faces detected in an image, but not indexed, is returned in an array of <a>UnindexedFace</a> objects, <code>UnindexedFaces</code>. Faces aren't indexed for reasons such as:</p> <ul> <li> <p>The number of faces detected exceeds the value of the <code>MaxFaces</code> request parameter.</p> </li> <li> <p>The face is too small compared to the image dimensions.</p> </li> <li> <p>The face is too blurry.</p> </li> <li> <p>The image is too dark.</p> </li> <li> <p>The face has an extreme pose.</p> </li> <li> <p>The face doesn’t have enough detail to be suitable for face search.</p> </li> </ul> <p>In response, the <code>IndexFaces</code> operation returns an array of metadata for all detected faces, <code>FaceRecords</code>. This includes: </p> <ul> <li> <p>The bounding box, <code>BoundingBox</code>, of the detected face. </p> </li> <li> <p>A confidence value, <code>Confidence</code>, which indicates the confidence that the bounding box contains a face.</p> </li> <li> <p>A face ID, <code>FaceId</code>, assigned by the service for each face that's detected and stored.</p> </li> <li> <p>An image ID, <code>ImageId</code>, assigned by the service for the input image.</p> </li> </ul> <p>If you request all facial attributes (by using the <code>detectionAttributes</code> parameter), Amazon Rekognition returns detailed facial attributes, such as facial landmarks (for example, location of eye and mouth) and other facial attributes. If you provide the same image, specify the same collection, and use the same external ID in the <code>IndexFaces</code> operation, Amazon Rekognition doesn't save duplicate face metadata.</p> <p/> <p>The input image is passed either as base64-encoded image bytes, or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes isn't supported. The image must be formatted as a PNG or JPEG file. </p> <p>This operation requires permissions to perform the <code>rekognition:IndexFaces</code> action.</p>"
},
"ListCollections":{
"name":"ListCollections",
@@ -688,7 +688,7 @@
{"shape":"InvalidPaginationTokenException"},
{"shape":"ResourceNotFoundException"}
],
- "documentation":"<p>Returns list of collection IDs in your account. If the result is truncated, the response also provides a <code>NextToken</code> that you can use in the subsequent request to fetch the next set of collection IDs.</p> <p>For an example, see Listing Collections in the Amazon Rekognition Developer Guide.</p> <p>This operation requires permissions to perform the <code>rekognition:ListCollections</code> action.</p>"
+ "documentation":"<p>Returns list of collection IDs in your account. If the result is truncated, the response also provides a <code>NextToken</code> that you can use in the subsequent request to fetch the next set of collection IDs.</p> <p>For an example, see Listing collections in the Amazon Rekognition Developer Guide.</p> <p>This operation requires permissions to perform the <code>rekognition:ListCollections</code> action.</p>"
},
"ListDatasetEntries":{
"name":"ListDatasetEntries",
@@ -806,7 +806,7 @@
{"shape":"ProvisionedThroughputExceededException"},
{"shape":"InvalidImageFormatException"}
],
- "documentation":"<p>Returns an array of celebrities recognized in the input image. For more information, see Recognizing Celebrities in the Amazon Rekognition Developer Guide. </p> <p> <code>RecognizeCelebrities</code> returns the 64 largest faces in the image. It lists the recognized celebrities in the <code>CelebrityFaces</code> array and any unrecognized faces in the <code>UnrecognizedFaces</code> array. <code>RecognizeCelebrities</code> doesn't return celebrities whose faces aren't among the largest 64 faces in the image.</p> <p>For each celebrity recognized, <code>RecognizeCelebrities</code> returns a <code>Celebrity</code> object. The <code>Celebrity</code> object contains the celebrity name, ID, URL links to additional information, match confidence, and a <code>ComparedFace</code> object that you can use to locate the celebrity's face on the image.</p> <p>Amazon Rekognition doesn't retain information about which images a celebrity has been recognized in. Your application must store this information and use the <code>Celebrity</code> ID property as a unique identifier for the celebrity. If you don't store the celebrity name or additional information URLs returned by <code>RecognizeCelebrities</code>, you will need the ID to identify the celebrity in a call to the <a>GetCelebrityInfo</a> operation.</p> <p>You pass the input image either as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file. </p> <p>For an example, see Recognizing Celebrities in an Image in the Amazon Rekognition Developer Guide.</p> <p>This operation requires permissions to perform the <code>rekognition:RecognizeCelebrities</code> operation.</p>"
+ "documentation":"<p>Returns an array of celebrities recognized in the input image. For more information, see Recognizing celebrities in the Amazon Rekognition Developer Guide. </p> <p> <code>RecognizeCelebrities</code> returns the 64 largest faces in the image. It lists the recognized celebrities in the <code>CelebrityFaces</code> array and any unrecognized faces in the <code>UnrecognizedFaces</code> array. <code>RecognizeCelebrities</code> doesn't return celebrities whose faces aren't among the largest 64 faces in the image.</p> <p>For each celebrity recognized, <code>RecognizeCelebrities</code> returns a <code>Celebrity</code> object. The <code>Celebrity</code> object contains the celebrity name, ID, URL links to additional information, match confidence, and a <code>ComparedFace</code> object that you can use to locate the celebrity's face on the image.</p> <p>Amazon Rekognition doesn't retain information about which images a celebrity has been recognized in. Your application must store this information and use the <code>Celebrity</code> ID property as a unique identifier for the celebrity. If you don't store the celebrity name or additional information URLs returned by <code>RecognizeCelebrities</code>, you will need the ID to identify the celebrity in a call to the <a>GetCelebrityInfo</a> operation.</p> <p>You pass the input image either as base64-encoded image bytes or as a reference to an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes is not supported. The image must be either a PNG or JPEG formatted file. </p> <p>For an example, see Recognizing celebrities in an image in the Amazon Rekognition Developer Guide.</p> <p>This operation requires permissions to perform the <code>rekognition:RecognizeCelebrities</code> operation.</p>"
},
"SearchFaces":{
"name":"SearchFaces",
@@ -824,7 +824,7 @@
{"shape":"ProvisionedThroughputExceededException"},
{"shape":"ResourceNotFoundException"}
],
- "documentation":"<p>For a given input face ID, searches for matching faces in the collection the face belongs to. You get a face ID when you add a face to the collection using the <a>IndexFaces</a> operation. The operation compares the features of the input face with faces in the specified collection. </p> <note> <p>You can also search faces without indexing faces by using the <code>SearchFacesByImage</code> operation.</p> </note> <p> The operation response returns an array of faces that match, ordered by similarity score with the highest similarity first. More specifically, it is an array of metadata for each face match that is found. Along with the metadata, the response also includes a <code>confidence</code> value for each face match, indicating the confidence that the specific face matches the input face. </p> <p>For an example, see Searching for a Face Using Its Face ID in the Amazon Rekognition Developer Guide.</p> <p>This operation requires permissions to perform the <code>rekognition:SearchFaces</code> action.</p>"
+ "documentation":"<p>For a given input face ID, searches for matching faces in the collection the face belongs to. You get a face ID when you add a face to the collection using the <a>IndexFaces</a> operation. The operation compares the features of the input face with faces in the specified collection. </p> <note> <p>You can also search faces without indexing faces by using the <code>SearchFacesByImage</code> operation.</p> </note> <p> The operation response returns an array of faces that match, ordered by similarity score with the highest similarity first. More specifically, it is an array of metadata for each face match that is found. Along with the metadata, the response also includes a <code>confidence</code> value for each face match, indicating the confidence that the specific face matches the input face. </p> <p>For an example, see Searching for a face using its face ID in the Amazon Rekognition Developer Guide.</p> <p>This operation requires permissions to perform the <code>rekognition:SearchFaces</code> action.</p>"
},
"SearchFacesByImage":{
"name":"SearchFacesByImage",
@@ -866,7 +866,7 @@
{"shape":"LimitExceededException"},
{"shape":"ThrottlingException"}
],
- "documentation":"<p>Starts asynchronous recognition of celebrities in a stored video.</p> <p>Amazon Rekognition Video can detect celebrities in a video must be stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartCelebrityRecognition</code> returns a job identifier (<code>JobId</code>) which you use to get the results of the analysis. When celebrity recognition analysis is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>. To get the results of the celebrity recognition analysis, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetCelebrityRecognition</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartCelebrityRecognition</code>. </p> <p>For more information, see Recognizing Celebrities in the Amazon Rekognition Developer Guide.</p>",
+ "documentation":"<p>Starts asynchronous recognition of celebrities in a stored video.</p> <p>Amazon Rekognition Video can detect celebrities in a video must be stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartCelebrityRecognition</code> returns a job identifier (<code>JobId</code>) which you use to get the results of the analysis. When celebrity recognition analysis is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>. To get the results of the celebrity recognition analysis, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetCelebrityRecognition</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartCelebrityRecognition</code>. </p> <p>For more information, see Recognizing celebrities in the Amazon Rekognition Developer Guide.</p>",
"idempotent":true
},
"StartContentModeration":{
@@ -888,7 +888,7 @@
{"shape":"LimitExceededException"},
{"shape":"ThrottlingException"}
],
- "documentation":"<p> Starts asynchronous detection of inappropriate, unwanted, or offensive content in a stored video. For a list of moderation labels in Amazon Rekognition, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/moderation.html#moderation-api\">Using the image and video moderation APIs</a>.</p> <p>Amazon Rekognition Video can moderate content in a video stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartContentModeration</code> returns a job identifier (<code>JobId</code>) which you use to get the results of the analysis. When content analysis is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>.</p> <p>To get the results of the content analysis, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetContentModeration</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartContentModeration</code>. </p> <p>For more information, see Content moderation in the Amazon Rekognition Developer Guide.</p>",
+ "documentation":"<p> Starts asynchronous detection of inappropriate, unwanted, or offensive content in a stored video. For a list of moderation labels in Amazon Rekognition, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/moderation.html#moderation-api\">Using the image and video moderation APIs</a>.</p> <p>Amazon Rekognition Video can moderate content in a video stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartContentModeration</code> returns a job identifier (<code>JobId</code>) which you use to get the results of the analysis. When content analysis is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>.</p> <p>To get the results of the content analysis, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetContentModeration</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartContentModeration</code>. </p> <p>For more information, see Moderating content in the Amazon Rekognition Developer Guide.</p>",
"idempotent":true
},
"StartFaceDetection":{
@@ -910,7 +910,7 @@
{"shape":"LimitExceededException"},
{"shape":"ThrottlingException"}
],
- "documentation":"<p>Starts asynchronous detection of faces in a stored video.</p> <p>Amazon Rekognition Video can detect faces in a video stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartFaceDetection</code> returns a job identifier (<code>JobId</code>) that you use to get the results of the operation. When face detection is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>. To get the results of the face detection operation, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetFaceDetection</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartFaceDetection</code>.</p> <p>For more information, see Detecting Faces in a Stored Video in the Amazon Rekognition Developer Guide.</p>",
+ "documentation":"<p>Starts asynchronous detection of faces in a stored video.</p> <p>Amazon Rekognition Video can detect faces in a video stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartFaceDetection</code> returns a job identifier (<code>JobId</code>) that you use to get the results of the operation. When face detection is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>. To get the results of the face detection operation, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetFaceDetection</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartFaceDetection</code>.</p> <p>For more information, see Detecting faces in a stored video in the Amazon Rekognition Developer Guide.</p>",
"idempotent":true
},
"StartFaceSearch":{
@@ -933,7 +933,7 @@
{"shape":"ResourceNotFoundException"},
{"shape":"ThrottlingException"}
],
- "documentation":"<p>Starts the asynchronous search for faces in a collection that match the faces of persons detected in a stored video.</p> <p>The video must be stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartFaceSearch</code> returns a job identifier (<code>JobId</code>) which you use to get the search results once the search has completed. When searching is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>. To get the search results, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetFaceSearch</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartFaceSearch</code>. For more information, see <a>procedure-person-search-videos</a>.</p>",
+ "documentation":"<p>Starts the asynchronous search for faces in a collection that match the faces of persons detected in a stored video.</p> <p>The video must be stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartFaceSearch</code> returns a job identifier (<code>JobId</code>) which you use to get the search results once the search has completed. When searching is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>. To get the search results, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. If so, call <a>GetFaceSearch</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartFaceSearch</code>. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/procedure-person-search-videos.html\">Searching stored videos for faces</a>. </p>",
"idempotent":true
},
"StartLabelDetection":{
@@ -1019,7 +1019,7 @@
{"shape":"LimitExceededException"},
{"shape":"ThrottlingException"}
],
- "documentation":"<p>Starts asynchronous detection of segment detection in a stored video.</p> <p>Amazon Rekognition Video can detect segments in a video stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartSegmentDetection</code> returns a job identifier (<code>JobId</code>) which you use to get the results of the operation. When segment detection is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>.</p> <p>You can use the <code>Filters</code> (<a>StartSegmentDetectionFilters</a>) input parameter to specify the minimum detection confidence returned in the response. Within <code>Filters</code>, use <code>ShotFilter</code> (<a>StartShotDetectionFilter</a>) to filter detected shots. Use <code>TechnicalCueFilter</code> (<a>StartTechnicalCueDetectionFilter</a>) to filter technical cues. </p> <p>To get the results of the segment detection operation, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. if so, call <a>GetSegmentDetection</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartSegmentDetection</code>. </p> <p>For more information, see Detecting Video Segments in Stored Video in the Amazon Rekognition Developer Guide.</p>",
+ "documentation":"<p>Starts asynchronous detection of segment detection in a stored video.</p> <p>Amazon Rekognition Video can detect segments in a video stored in an Amazon S3 bucket. Use <a>Video</a> to specify the bucket name and the filename of the video. <code>StartSegmentDetection</code> returns a job identifier (<code>JobId</code>) which you use to get the results of the operation. When segment detection is finished, Amazon Rekognition Video publishes a completion status to the Amazon Simple Notification Service topic that you specify in <code>NotificationChannel</code>.</p> <p>You can use the <code>Filters</code> (<a>StartSegmentDetectionFilters</a>) input parameter to specify the minimum detection confidence returned in the response. Within <code>Filters</code>, use <code>ShotFilter</code> (<a>StartShotDetectionFilter</a>) to filter detected shots. Use <code>TechnicalCueFilter</code> (<a>StartTechnicalCueDetectionFilter</a>) to filter technical cues. </p> <p>To get the results of the segment detection operation, first check that the status value published to the Amazon SNS topic is <code>SUCCEEDED</code>. if so, call <a>GetSegmentDetection</a> and pass the job identifier (<code>JobId</code>) from the initial call to <code>StartSegmentDetection</code>. </p> <p>For more information, see Detecting video segments in stored video in the Amazon Rekognition Developer Guide.</p>",
"idempotent":true
},
"StartStreamProcessor":{
@@ -1039,7 +1039,7 @@
{"shape":"ResourceInUseException"},
{"shape":"ProvisionedThroughputExceededException"}
],
- "documentation":"<p>Starts processing a stream processor. You create a stream processor by calling <a>CreateStreamProcessor</a>. To tell <code>StartStreamProcessor</code> which stream processor to start, use the value of the <code>Name</code> field specified in the call to <code>CreateStreamProcessor</code>.</p>"
+ "documentation":"<p>Starts processing a stream processor. You create a stream processor by calling <a>CreateStreamProcessor</a>. To tell <code>StartStreamProcessor</code> which stream processor to start, use the value of the <code>Name</code> field specified in the call to <code>CreateStreamProcessor</code>.</p> <p>If you are using a label detection stream processor to detect labels, you need to provide a <code>Start selector</code> and a <code>Stop selector</code> to determine the length of the stream processing time.</p>"
},
"StartTextDetection":{
"name":"StartTextDetection",
@@ -1157,6 +1157,24 @@
{"shape":"ResourceNotFoundException"}
],
"documentation":"<p>Adds or updates one or more entries (images) in a dataset. An entry is a JSON Line which contains the information for a single image, including the image location, assigned labels, and object location bounding boxes. For more information, see Image-Level labels in manifest files and Object localization in manifest files in the <i>Amazon Rekognition Custom Labels Developer Guide</i>. </p> <p>If the <code>source-ref</code> field in the JSON line references an existing image, the existing image in the dataset is updated. If <code>source-ref</code> field doesn't reference an existing image, the image is added as a new image to the dataset. </p> <p>You specify the changes that you want to make in the <code>Changes</code> input parameter. There isn't a limit to the number JSON Lines that you can change, but the size of <code>Changes</code> must be less than 5MB.</p> <p> <code>UpdateDatasetEntries</code> returns immediatly, but the dataset update might take a while to complete. Use <a>DescribeDataset</a> to check the current status. The dataset updated successfully if the value of <code>Status</code> is <code>UPDATE_COMPLETE</code>. </p> <p>To check if any non-terminal errors occured, call <a>ListDatasetEntries</a> and check for the presence of <code>errors</code> lists in the JSON Lines.</p> <p>Dataset update fails if a terminal error occurs (<code>Status</code> = <code>UPDATE_FAILED</code>). Currently, you can't access the terminal error information from the Amazon Rekognition Custom Labels SDK. </p> <p>This operation requires permissions to perform the <code>rekognition:UpdateDatasetEntries</code> action.</p>"
+ },
+ "UpdateStreamProcessor":{
+ "name":"UpdateStreamProcessor",
+ "http":{
+ "method":"POST",
+ "requestUri":"/"
+ },
+ "input":{"shape":"UpdateStreamProcessorRequest"},
+ "output":{"shape":"UpdateStreamProcessorResponse"},
+ "errors":[
+ {"shape":"AccessDeniedException"},
+ {"shape":"InternalServerError"},
+ {"shape":"ThrottlingException"},
+ {"shape":"InvalidParameterException"},
+ {"shape":"ResourceNotFoundException"},
+ {"shape":"ProvisionedThroughputExceededException"}
+ ],
+ "documentation":"<p> Allows you to update a stream processor. You can change some settings and regions of interest and delete certain parameters. </p>"
}
},
"shapes":{
@@ -1291,7 +1309,7 @@
"documentation":"<p>Top coordinate of the bounding box as a ratio of overall image height.</p>"
}
},
- "documentation":"<p>Identifies the bounding box around the label, face, text or personal protective equipment. The <code>left</code> (x-coordinate) and <code>top</code> (y-coordinate) are coordinates representing the top and left sides of the bounding box. Note that the upper-left corner of the image is the origin (0,0). </p> <p>The <code>top</code> and <code>left</code> values returned are ratios of the overall image size. For example, if the input image is 700x200 pixels, and the top-left coordinate of the bounding box is 350x50 pixels, the API returns a <code>left</code> value of 0.5 (350/700) and a <code>top</code> value of 0.25 (50/200).</p> <p>The <code>width</code> and <code>height</code> values represent the dimensions of the bounding box as a ratio of the overall image dimension. For example, if the input image is 700x200 pixels, and the bounding box width is 70 pixels, the width returned is 0.1. </p> <note> <p> The bounding box coordinates can have negative values. For example, if Amazon Rekognition is able to detect a face that is at the image edge and is only partially visible, the service can return coordinates that are outside the image bounds and, depending on the image edge, you might get negative values or values greater than 1 for the <code>left</code> or <code>top</code> values. </p> </note>"
+ "documentation":"<p>Identifies the bounding box around the label, face, text, object of interest, or personal protective equipment. The <code>left</code> (x-coordinate) and <code>top</code> (y-coordinate) are coordinates representing the top and left sides of the bounding box. Note that the upper-left corner of the image is the origin (0,0). </p> <p>The <code>top</code> and <code>left</code> values returned are ratios of the overall image size. For example, if the input image is 700x200 pixels, and the top-left coordinate of the bounding box is 350x50 pixels, the API returns a <code>left</code> value of 0.5 (350/700) and a <code>top</code> value of 0.25 (50/200).</p> <p>The <code>width</code> and <code>height</code> values represent the dimensions of the bounding box as a ratio of the overall image dimension. For example, if the input image is 700x200 pixels, and the bounding box width is 70 pixels, the width returned is 0.1. </p> <note> <p> The bounding box coordinates can have negative values. For example, if Amazon Rekognition is able to detect a face that is at the image edge and is only partially visible, the service can return coordinates that are outside the image bounds and, depending on the image edge, you might get negative values or values greater than 1 for the <code>left</code> or <code>top</code> values. </p> </note>"
},
"BoundingBoxHeight":{
"type":"float",
@@ -1533,6 +1551,42 @@
},
"documentation":"<p>Type that describes the face Amazon Rekognition chose to compare with the faces in the target. This contains a bounding box for the selected face and confidence level that the bounding box contains a face. Note that Amazon Rekognition selects the largest face in the source image for this comparison. </p>"
},
+ "ConnectedHomeLabel":{"type":"string"},
+ "ConnectedHomeLabels":{
+ "type":"list",
+ "member":{"shape":"ConnectedHomeLabel"},
+ "max":128,
+ "min":1
+ },
+ "ConnectedHomeSettings":{
+ "type":"structure",
+ "required":["Labels"],
+ "members":{
+ "Labels":{
+ "shape":"ConnectedHomeLabels",
+ "documentation":"<p> Specifies what you want to detect in the video, such as people, packages, or pets. The current valid labels you can include in this list are: \"PERSON\", \"PET\", \"PACKAGE\", and \"ALL\". </p>"
+ },
+ "MinConfidence":{
+ "shape":"Percent",
+ "documentation":"<p> The minimum confidence required to label an object in the video. </p>"
+ }
+ },
+ "documentation":"<p> Label detection settings to use on a streaming video. Defining the settings is required in the request parameter for <a>CreateStreamProcessor</a>. Including this setting in the <code>CreateStreamProcessor</code> request enables you to use the stream processor for label detection. You can then select what you want the stream processor to detect, such as people or pets. When the stream processor has started, one notification is sent for each object class specified. For example, if packages and pets are selected, one SNS notification is published the first time a package is detected and one SNS notification is published the first time a pet is detected, as well as an end-of-session summary. </p>"
+ },
+ "ConnectedHomeSettingsForUpdate":{
+ "type":"structure",
+ "members":{
+ "Labels":{
+ "shape":"ConnectedHomeLabels",
+ "documentation":"<p> Specifies what you want to detect in the video, such as people, packages, or pets. The current valid labels you can include in this list are: \"PERSON\", \"PET\", \"PACKAGE\", and \"ALL\". </p>"
+ },
+ "MinConfidence":{
+ "shape":"Percent",
+ "documentation":"<p> The minimum confidence required to label an object in the video. </p>"
+ }
+ },
+ "documentation":"<p> The label detection settings you want to use in your stream processor. This includes the labels you want the stream processor to detect and the minimum confidence level allowed to label objects. </p>"
+ },
"ContentClassifier":{
"type":"string",
"enum":[
@@ -1611,7 +1665,7 @@
},
"FaceModelVersion":{
"shape":"String",
- "documentation":"<p>Latest face model being used with the collection. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/face-detection-model.html\">Model versioning</a>.</p>"
+ "documentation":"<p>Version number of the face detection model associated with the collection you are creating.</p>"
}
}
},
@@ -1723,27 +1777,40 @@
"members":{
"Input":{
"shape":"StreamProcessorInput",
- "documentation":"<p>Kinesis video stream stream that provides the source streaming video. If you are using the AWS CLI, the parameter name is <code>StreamProcessorInput</code>.</p>"
+ "documentation":"<p>Kinesis video stream stream that provides the source streaming video. If you are using the AWS CLI, the parameter name is <code>StreamProcessorInput</code>. This is required for both face search and label detection stream processors.</p>"
},
"Output":{
"shape":"StreamProcessorOutput",
- "documentation":"<p>Kinesis data stream stream to which Amazon Rekognition Video puts the analysis results. If you are using the AWS CLI, the parameter name is <code>StreamProcessorOutput</code>.</p>"
+ "documentation":"<p>Kinesis data stream stream or Amazon S3 bucket location to which Amazon Rekognition Video puts the analysis results. If you are using the AWS CLI, the parameter name is <code>StreamProcessorOutput</code>. This must be a <a>S3Destination</a> of an Amazon S3 bucket that you own for a label detection stream processor or a Kinesis data stream ARN for a face search stream processor.</p>"
},
"Name":{
"shape":"StreamProcessorName",
- "documentation":"<p>An identifier you assign to the stream processor. You can use <code>Name</code> to manage the stream processor. For example, you can get the current status of the stream processor by calling <a>DescribeStreamProcessor</a>. <code>Name</code> is idempotent. </p>"
+ "documentation":"<p>An identifier you assign to the stream processor. You can use <code>Name</code> to manage the stream processor. For example, you can get the current status of the stream processor by calling <a>DescribeStreamProcessor</a>. <code>Name</code> is idempotent. This is required for both face search and label detection stream processors. </p>"
},
"Settings":{
"shape":"StreamProcessorSettings",
- "documentation":"<p>Face recognition input parameters to be used by the stream processor. Includes the collection to use for face recognition and the face attributes to detect.</p>"
+ "documentation":"<p>Input parameters used in a streaming video analyzed by a stream processor. You can use <code>FaceSearch</code> to recognize faces in a streaming video, or you can use <code>ConnectedHome</code> to detect labels.</p>"
},
"RoleArn":{
"shape":"RoleArn",
- "documentation":"<p>ARN of the IAM role that allows access to the stream processor.</p>"
+ "documentation":"<p>The Amazon Resource Number (ARN) of the IAM role that allows access to the stream processor. The IAM role provides Rekognition read permissions for a Kinesis stream. It also provides write permissions to an Amazon S3 bucket and Amazon Simple Notification Service topic for a label detection stream processor. This is required for both face search and label detection stream processors.</p>"
},
"Tags":{
"shape":"TagMap",
"documentation":"<p> A set of tags (key-value pairs) that you want to attach to the stream processor. </p>"
+ },
+ "NotificationChannel":{"shape":"StreamProcessorNotificationChannel"},
+ "KmsKeyId":{
+ "shape":"KmsKeyId",
+ "documentation":"<p> The identifier for your AWS Key Management Service key (AWS KMS key). This is an optional parameter for label detection stream processors and should not be used to create a face search stream processor. You can supply the Amazon Resource Name (ARN) of your KMS key, the ID of your KMS key, an alias for your KMS key, or an alias ARN. The key is used to encrypt results and data published to your Amazon S3 bucket, which includes image frames and hero images. Your source images are unaffected. </p> <p> </p>"
+ },
+ "RegionsOfInterest":{
+ "shape":"RegionsOfInterest",
+ "documentation":"<p> Specifies locations in the frames where Amazon Rekognition checks for objects or people. You can specify up to 10 regions of interest. This is an optional parameter for label detection stream processors and should not be used to create a face search stream processor. </p>"
+ },
+ "DataSharingPreference":{
+ "shape":"StreamProcessorDataSharingPreference",
+ "documentation":"<p> Shows whether you are sharing data with Rekognition to improve model performance. You can choose this option at the account level or on a per-stream basis. Note that if you opt out at the account level this setting is ignored on individual streams. </p>"
}
}
},
@@ -1752,7 +1819,7 @@
"members":{
"StreamProcessorArn":{
"shape":"StreamProcessorArn",
- "documentation":"<p>ARN for the newly create stream processor.</p>"
+ "documentation":"<p>Amazon Resource Number for the newly created stream processor.</p>"
}
}
},
@@ -2111,7 +2178,7 @@
},
"FaceModelVersion":{
"shape":"String",
- "documentation":"<p>The version of the face model that's used by the collection for face detection.</p> <p>For more information, see Model Versioning in the Amazon Rekognition Developer Guide.</p>"
+ "documentation":"<p>The version of the face model that's used by the collection for face detection.</p> <p>For more information, see Model versioning in the Amazon Rekognition Developer Guide.</p>"
},
"CollectionARN":{
"shape":"String",
@@ -2258,7 +2325,20 @@
},
"Settings":{
"shape":"StreamProcessorSettings",
- "documentation":"<p>Face recognition input parameters that are being used by the stream processor. Includes the collection to use for face recognition and the face attributes to detect.</p>"
+ "documentation":"<p>Input parameters used in a streaming video analyzed by a stream processor. You can use <code>FaceSearch</code> to recognize faces in a streaming video, or you can use <code>ConnectedHome</code> to detect labels.</p>"
+ },
+ "NotificationChannel":{"shape":"StreamProcessorNotificationChannel"},
+ "KmsKeyId":{
+ "shape":"KmsKeyId",
+ "documentation":"<p> The identifier for your AWS Key Management Service key (AWS KMS key). This is an optional parameter for label detection stream processors. </p>"
+ },
+ "RegionsOfInterest":{
+ "shape":"RegionsOfInterest",
+ "documentation":"<p> Specifies locations in the frames where Amazon Rekognition checks for objects or people. This is an optional parameter for label detection stream processors. </p>"
+ },
+ "DataSharingPreference":{
+ "shape":"StreamProcessorDataSharingPreference",
+ "documentation":"<p> Shows whether you are sharing data with Rekognition to improve model performance. You can choose this option at the account level or on a per-stream basis. Note that if you opt out at the account level this setting is ignored on individual streams. </p>"
}
}
},
@@ -2464,7 +2544,7 @@
"members":{
"MinConfidence":{
"shape":"Percent",
- "documentation":"<p>Sets the confidence of word detection. Words with detection confidence below this will be excluded from the result. Values should be between 50 and 100 as Text in Video will not return any result below 50.</p>"
+ "documentation":"<p>Sets the confidence of word detection. Words with detection confidence below this will be excluded from the result. Values should be between 0 and 100. The default MinConfidence is 80.</p>"
},
"MinBoundingBoxHeight":{
"shape":"BoundingBoxHeight",
@@ -2810,7 +2890,7 @@
"documentation":"<p>Minimum face match confidence score that must be met to return a result for a recognized face. The default is 80. 0 is the lowest confidence. 100 is the highest confidence. Values between 0 and 100 are accepted, and values lower than 80 are set to 80.</p>"
}
},
- "documentation":"<p>Input face recognition parameters for an Amazon Rekognition stream processor. <code>FaceRecognitionSettings</code> is a request parameter for <a>CreateStreamProcessor</a>.</p>"
+ "documentation":"<p>Input face recognition parameters for an Amazon Rekognition stream processor. Includes the collection to use for face recognition and the face attributes to detect. Defining the settings is required in the request parameter for <a>CreateStreamProcessor</a>.</p>"
},
"FaceSearchSortBy":{
"type":"string",
@@ -2836,7 +2916,7 @@
"documentation":"<p>Level of confidence in the prediction.</p>"
}
},
- "documentation":"<p>The predicted gender of a detected face. </p> <p>Amazon Rekognition makes gender binary (male/female) predictions based on the physical appearance of a face in a particular image. This kind of prediction is not designed to categorize a person’s gender identity, and you shouldn't use Amazon Rekognition to make such a determination. For example, a male actor wearing a long-haired wig and earrings for a role might be predicted as female.</p> <p>Using Amazon Rekognition to make gender binary predictions is best suited for use cases where aggregate gender distribution statistics need to be analyzed without identifying specific users. For example, the percentage of female users compared to male users on a social media platform. </p> <p>We don't recommend using gender binary predictions to make decisions that impact&#x2028; an individual's rights, privacy, or access to services.</p>"
+ "documentation":"<p>The predicted gender of a detected face. </p> <p>Amazon Rekognition makes gender binary (male/female) predictions based on the physical appearance of a face in a particular image. This kind of prediction is not designed to categorize a person’s gender identity, and you shouldn't use Amazon Rekognition to make such a determination. For example, a male actor wearing a long-haired wig and earrings for a role might be predicted as female.</p> <p>Using Amazon Rekognition to make gender binary predictions is best suited for use cases where aggregate gender distribution statistics need to be analyzed without identifying specific users. For example, the percentage of female users compared to male users on a social media platform. </p> <p>We don't recommend using gender binary predictions to make decisions that impact an individual's rights, privacy, or access to services.</p>"
},
"GenderType":{
"type":"string",
@@ -3389,7 +3469,7 @@
"documentation":"<p>Identifies an S3 object as the image source.</p>"
}
},
- "documentation":"<p>Provides the input image either as bytes or an S3 object.</p> <p>You pass image bytes to an Amazon Rekognition API operation by using the <code>Bytes</code> property. For example, you would use the <code>Bytes</code> property to pass an image loaded from a local file system. Image bytes passed by using the <code>Bytes</code> property must be base64-encoded. Your code may not need to encode image bytes if you are using an AWS SDK to call Amazon Rekognition API operations. </p> <p>For more information, see Analyzing an Image Loaded from a Local File System in the Amazon Rekognition Developer Guide.</p> <p> You pass images stored in an S3 bucket to an Amazon Rekognition API operation by using the <code>S3Object</code> property. Images stored in an S3 bucket do not need to be base64-encoded.</p> <p>The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.</p> <p>If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes using the Bytes property is not supported. You must first upload the image to an Amazon S3 bucket and then call the operation using the S3Object property.</p> <p>For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource Based Policies in the Amazon Rekognition Developer Guide. </p>"
+ "documentation":"<p>Provides the input image either as bytes or an S3 object.</p> <p>You pass image bytes to an Amazon Rekognition API operation by using the <code>Bytes</code> property. For example, you would use the <code>Bytes</code> property to pass an image loaded from a local file system. Image bytes passed by using the <code>Bytes</code> property must be base64-encoded. Your code may not need to encode image bytes if you are using an AWS SDK to call Amazon Rekognition API operations. </p> <p>For more information, see Analyzing an Image Loaded from a Local File System in the Amazon Rekognition Developer Guide.</p> <p> You pass images stored in an S3 bucket to an Amazon Rekognition API operation by using the <code>S3Object</code> property. Images stored in an S3 bucket do not need to be base64-encoded.</p> <p>The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.</p> <p>If you use the AWS CLI to call Amazon Rekognition operations, passing image bytes using the Bytes property is not supported. You must first upload the image to an Amazon S3 bucket and then call the operation using the S3Object property.</p> <p>For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see How Amazon Rekognition works with IAM in the Amazon Rekognition Developer Guide. </p>"
},
"ImageBlob":{
"type":"blob",
@@ -3418,7 +3498,7 @@
"type":"structure",
"members":{
},
- "documentation":"<p>The input image size exceeds the allowed limit. If you are calling DetectProtectiveEquipment, the image size or resolution exceeds the allowed limit. For more information, see Limits in Amazon Rekognition in the Amazon Rekognition Developer Guide. </p>",
+ "documentation":"<p>The input image size exceeds the allowed limit. If you are calling DetectProtectiveEquipment, the image size or resolution exceeds the allowed limit. For more information, see Guidelines and quotas in Amazon Rekognition in the Amazon Rekognition Developer Guide. </p>",
"exception":true
},
"IndexFacesModelVersion":{
@@ -3471,7 +3551,7 @@
},
"FaceModelVersion":{
"shape":"String",
- "documentation":"<p>Latest face model being used with the collection. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/face-detection-model.html\">Model versioning</a>.</p>"
+ "documentation":"<p>The version number of the face detection model that's associated with the input collection (<code>CollectionId</code>).</p>"
},
"UnindexedFaces":{
"shape":"UnindexedFaces",
@@ -3578,6 +3658,26 @@
},
"documentation":"<p>Kinesis video stream stream that provides the source streaming video for a Amazon Rekognition Video stream processor. For more information, see CreateStreamProcessor in the Amazon Rekognition Developer Guide.</p>"
},
+ "KinesisVideoStreamFragmentNumber":{
+ "type":"string",
+ "max":128,
+ "min":1,
+ "pattern":"^[0-9]+$"
+ },
+ "KinesisVideoStreamStartSelector":{
+ "type":"structure",
+ "members":{
+ "ProducerTimestamp":{
+ "shape":"ULong",
+ "documentation":"<p> The timestamp from the producer corresponding to the fragment. </p>"
+ },
+ "FragmentNumber":{
+ "shape":"KinesisVideoStreamFragmentNumber",
+ "documentation":"<p> The unique identifier of the fragment. This value monotonically increases based on the ingestion order. </p>"
+ }
+ },
+ "documentation":"<p> Specifies the starting point in a Kinesis stream to start processing. You can use the producer timestamp or the fragment number. For more information, see <a href=\"https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_reader_Fragment.html\">Fragment</a>. </p>"
+ },
"KmsKeyId":{
"type":"string",
"max":2048,
@@ -3745,7 +3845,7 @@
},
"FaceModelVersions":{
"shape":"FaceModelVersionList",
- "documentation":"<p>Latest face models being used with the corresponding collections in the array. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/face-detection-model.html\">Model versioning</a>. For example, the value of <code>FaceModelVersions[2]</code> is the version number for the face detection model used by the collection in <code>CollectionId[2]</code>.</p>"
+ "documentation":"<p>Version numbers of the face detection models associated with the collections in the array <code>CollectionIds</code>. For example, the value of <code>FaceModelVersions[2]</code> is the version number for the face detection model used by the collection in <code>CollectionId[2]</code>.</p>"
}
}
},
@@ -3868,7 +3968,7 @@
},
"FaceModelVersion":{
"shape":"String",
- "documentation":"<p>Latest face model being used with the collection. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/face-detection-model.html\">Model versioning</a>.</p>"
+ "documentation":"<p>Version number of the face detection model associated with the input collection (<code>CollectionId</code>).</p>"
}
}
},
@@ -3917,6 +4017,11 @@
}
}
},
+ "MaxDurationInSecondsULong":{
+ "type":"long",
+ "max":120,
+ "min":1
+ },
"MaxFaces":{
"type":"integer",
"max":4096,
@@ -3999,14 +4104,14 @@
"members":{
"SNSTopicArn":{
"shape":"SNSTopicArn",
- "documentation":"<p>The Amazon SNS topic to which Amazon Rekognition to posts the completion status.</p>"
+ "documentation":"<p>The Amazon SNS topic to which Amazon Rekognition posts the completion status.</p>"
},
"RoleArn":{
"shape":"RoleArn",
"documentation":"<p>The ARN of an IAM role that gives Amazon Rekognition publishing permissions to the Amazon SNS topic. </p>"
}
},
- "documentation":"<p>The Amazon Simple Notification Service topic to which Amazon Rekognition publishes the completion status of a video analysis operation. For more information, see <a>api-video</a>. Note that the Amazon SNS topic must have a topic name that begins with <i>AmazonRekognition</i> if you are using the AmazonRekognitionServiceRole permissions policy to access the topic. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/api-video-roles.html#api-video-roles-all-topics\">Giving access to multiple Amazon SNS topics</a>.</p>"
+ "documentation":"<p>The Amazon Simple Notification Service topic to which Amazon Rekognition publishes the completion status of a video analysis operation. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/api-video.html\">Calling Amazon Rekognition Video operations</a>. Note that the Amazon SNS topic must have a topic name that begins with <i>AmazonRekognition</i> if you are using the AmazonRekognitionServiceRole permissions policy to access the topic. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/api-video-roles.html#api-video-roles-all-topics\">Giving access to multiple Amazon SNS topics</a>.</p>"
},
"OrientationCorrection":{
"type":"string",
@@ -4137,7 +4242,7 @@
"documentation":"<p>The value of the Y coordinate for a point on a <code>Polygon</code>.</p>"
}
},
- "documentation":"<p>The X and Y coordinates of a point on an image. The X and Y values returned are ratios of the overall image size. For example, if the input image is 700x200 and the operation returns X=0.5 and Y=0.25, then the point is at the (350,50) pixel coordinate on the image.</p> <p>An array of <code>Point</code> objects, <code>Polygon</code>, is returned by <a>DetectText</a> and by <a>DetectCustomLabels</a>. <code>Polygon</code> represents a fine-grained polygon around a detected item. For more information, see Geometry in the Amazon Rekognition Developer Guide. </p>"
+ "documentation":"<p>The X and Y coordinates of a point on an image or video frame. The X and Y values are ratios of the overall image size or video resolution. For example, if an input image is 700x200 and the values are X=0.5 and Y=0.25, then the point is at the (350,50) pixel coordinate on the image.</p> <p>An array of <code>Point</code> objects makes up a <code>Polygon</code>. A <code>Polygon</code> is returned by <a>DetectText</a> and by <a>DetectCustomLabels</a> <code>Polygon</code> represents a fine-grained polygon around a detected item. For more information, see Geometry in the Amazon Rekognition Developer Guide. </p>"
},
"Polygon":{
"type":"list",
@@ -4473,9 +4578,13 @@
"BoundingBox":{
"shape":"BoundingBox",
"documentation":"<p>The box representing a region of interest on screen.</p>"
+ },
+ "Polygon":{
+ "shape":"Polygon",
+ "documentation":"<p> Specifies a shape made up of up to 10 <code>Point</code> objects to define a region of interest. </p>"
}
},
- "documentation":"<p>Specifies a location within the frame that Rekognition checks for text. Uses a <code>BoundingBox</code> object to set a region of the screen.</p> <p>A word is included in the region if the word is more than half in that region. If there is more than one region, the word will be compared with all regions of the screen. Any word more than half in a region is kept in the results.</p>"
+ "documentation":"<p>Specifies a location within the frame that Rekognition checks for objects of interest such as text, labels, or faces. It uses a <code>BoundingBox</code> or object or <code>Polygon</code> to set a region of the screen.</p> <p>A word, face, or label is included in the region if it is more than half in that region. If there is more than one region, the word, face, or label is compared with all regions of the screen. Any object of interest that is more than half in a region is kept in the results.</p>"
},
"RegionsOfInterest":{
"type":"list",
@@ -4530,6 +4639,20 @@
"min":3,
"pattern":"[0-9A-Za-z\\.\\-_]*"
},
+ "S3Destination":{
+ "type":"structure",
+ "members":{
+ "Bucket":{
+ "shape":"S3Bucket",
+ "documentation":"<p> The name of the Amazon S3 bucket you want to associate with the streaming video project. You must be the owner of the Amazon S3 bucket. </p>"
+ },
+ "KeyPrefix":{
+ "shape":"S3KeyPrefix",
+ "documentation":"<p> The prefix value of the location within the bucket that you want the information to be published to. For more information, see <a href=\"https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-prefixes.html\">Using prefixes</a>. </p>"
+ }
+ },
+ "documentation":"<p> The Amazon S3 bucket location to which Amazon Rekognition publishes the detailed inference results of a video analysis operation. These results include the name of the stream processor resource, the session ID of the stream processing session, and labeled timestamps and bounding boxes for detected labels. </p>"
+ },
"S3KeyPrefix":{
"type":"string",
"max":1024
@@ -4550,7 +4673,7 @@
"documentation":"<p>If the bucket is versioning enabled, you can specify the object version. </p>"
}
},
- "documentation":"<p>Provides the S3 bucket name and object name.</p> <p>The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.</p> <p>For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see Resource-Based Policies in the Amazon Rekognition Developer Guide. </p>"
+ "documentation":"<p>Provides the S3 bucket name and object name.</p> <p>The region for the S3 bucket containing the S3 object must match the region you use for Amazon Rekognition operations.</p> <p>For Amazon Rekognition to process an S3 object, the user must have permission to access the S3 object. For more information, see How Amazon Rekognition works with IAM in the Amazon Rekognition Developer Guide. </p>"
},
"S3ObjectName":{
"type":"string",
@@ -4612,7 +4735,7 @@
},
"FaceModelVersion":{
"shape":"String",
- "documentation":"<p>Latest face model being used with the collection. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/face-detection-model.html\">Model versioning</a>.</p>"
+ "documentation":"<p>Version number of the face detection model associated with the input collection (<code>CollectionId</code>).</p>"
}
}
},
@@ -4654,7 +4777,7 @@
},
"FaceModelVersion":{
"shape":"String",
- "documentation":"<p>Latest face model being used with the collection. For more information, see <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/face-detection-model.html\">Model versioning</a>.</p>"
+ "documentation":"<p>Version number of the face detection model associated with the input collection (<code>CollectionId</code>).</p>"
}
}
},
@@ -4755,7 +4878,7 @@
"type":"structure",
"members":{
},
- "documentation":"<p/> <p>The size of the collection exceeds the allowed limit. For more information, see Limits in Amazon Rekognition in the Amazon Rekognition Developer Guide. </p>",
+ "documentation":"<p/> <p>The size of the collection exceeds the allowed limit. For more information, see Guidelines and quotas in Amazon Rekognition in the Amazon Rekognition Developer Guide. </p>",
"exception":true
},
"ShotSegment":{
@@ -5091,14 +5214,27 @@
"Name":{
"shape":"StreamProcessorName",
"documentation":"<p>The name of the stream processor to start processing.</p>"
+ },
+ "StartSelector":{
+ "shape":"StreamProcessingStartSelector",
+ "documentation":"<p> Specifies the starting point in the Kinesis stream to start processing. You can use the producer timestamp or the fragment number. For more information, see <a href=\"https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_reader_Fragment.html\">Fragment</a>. </p> <p>This is a required parameter for label detection stream processors and should not be used to start a face search stream processor.</p>"
+ },
+ "StopSelector":{
+ "shape":"StreamProcessingStopSelector",
+ "documentation":"<p> Specifies when to stop processing the stream. You can specify a maximum amount of time to process the video. </p> <p>This is a required parameter for label detection stream processors and should not be used to start a face search stream processor.</p>"
}
}
},
"StartStreamProcessorResponse":{
"type":"structure",
"members":{
+ "SessionId":{
+ "shape":"StartStreamProcessorSessionId",
+ "documentation":"<p> A unique identifier for the stream processing session. </p>"
+ }
}
},
+ "StartStreamProcessorSessionId":{"type":"string"},
"StartTechnicalCueDetectionFilter":{
"type":"structure",
"members":{
@@ -5191,6 +5327,26 @@
"members":{
}
},
+ "StreamProcessingStartSelector":{
+ "type":"structure",
+ "members":{
+ "KVSStreamStartSelector":{
+ "shape":"KinesisVideoStreamStartSelector",
+ "documentation":"<p> Specifies the starting point in the stream to start processing. This can be done with a timestamp or a fragment number in a Kinesis stream. </p>"
+ }
+ },
+ "documentation":"<p/>"
+ },
+ "StreamProcessingStopSelector":{
+ "type":"structure",
+ "members":{
+ "MaxDurationInSeconds":{
+ "shape":"MaxDurationInSecondsULong",
+ "documentation":"<p> Specifies the maximum amount of time in seconds that you want the stream to be processed. The largest amount of time is 2 minutes. The default is 10 seconds. </p>"
+ }
+ },
+ "documentation":"<p> Specifies when to stop processing the stream. You can specify a maximum amount of time to process the video. </p>"
+ },
"StreamProcessor":{
"type":"structure",
"members":{
@@ -5203,12 +5359,23 @@
"documentation":"<p>Current status of the Amazon Rekognition stream processor.</p>"
}
},
- "documentation":"<p>An object that recognizes faces in a streaming video. An Amazon Rekognition stream processor is created by a call to <a>CreateStreamProcessor</a>. The request parameters for <code>CreateStreamProcessor</code> describe the Kinesis video stream source for the streaming video, face recognition parameters, and where to stream the analysis resullts. </p>"
+ "documentation":"<p>An object that recognizes faces or labels in a streaming video. An Amazon Rekognition stream processor is created by a call to <a>CreateStreamProcessor</a>. The request parameters for <code>CreateStreamProcessor</code> describe the Kinesis video stream source for the streaming video, face recognition parameters, and where to stream the analysis resullts. </p>"
},
"StreamProcessorArn":{
"type":"string",
"pattern":"(^arn:[a-z\\d-]+:rekognition:[a-z\\d-]+:\\d{12}:streamprocessor\\/.+$)"
},
+ "StreamProcessorDataSharingPreference":{
+ "type":"structure",
+ "required":["OptIn"],
+ "members":{
+ "OptIn":{
+ "shape":"Boolean",
+ "documentation":"<p> If this option is set to true, you choose to share data with Rekognition to improve model performance. </p>"
+ }
+ },
+ "documentation":"<p> Allows you to opt in or opt out to share data with Rekognition to improve model performance. You can choose this option at the account level or on a per-stream basis. Note that if you opt out at the account level this setting is ignored on individual streams. </p>"
+ },
"StreamProcessorInput":{
"type":"structure",
"members":{
@@ -5229,25 +5396,62 @@
"min":1,
"pattern":"[a-zA-Z0-9_.\\-]+"
},
+ "StreamProcessorNotificationChannel":{
+ "type":"structure",
+ "required":["SNSTopicArn"],
+ "members":{
+ "SNSTopicArn":{
+ "shape":"SNSTopicArn",
+ "documentation":"<p> The Amazon Resource Number (ARN) of the Amazon Amazon Simple Notification Service topic to which Amazon Rekognition posts the completion status. </p>"
+ }
+ },
+ "documentation":"<p>The Amazon Simple Notification Service topic to which Amazon Rekognition publishes the object detection results and completion status of a video analysis operation.</p> <p>Amazon Rekognition publishes a notification the first time an object of interest or a person is detected in the video stream. For example, if Amazon Rekognition detects a person at second 2, a pet at second 4, and a person again at second 5, Amazon Rekognition sends 2 object class detected notifications, one for a person at second 2 and one for a pet at second 4.</p> <p>Amazon Rekognition also publishes an an end-of-session notification with a summary when the stream processing session is complete.</p>"
+ },
"StreamProcessorOutput":{
"type":"structure",
"members":{
"KinesisDataStream":{
"shape":"KinesisDataStream",
"documentation":"<p>The Amazon Kinesis Data Streams stream to which the Amazon Rekognition stream processor streams the analysis results.</p>"
+ },
+ "S3Destination":{
+ "shape":"S3Destination",
+ "documentation":"<p> The Amazon S3 bucket location to which Amazon Rekognition publishes the detailed inference results of a video analysis operation. </p>"
}
},
"documentation":"<p>Information about the Amazon Kinesis Data Streams stream to which a Amazon Rekognition Video stream processor streams the results of a video analysis. For more information, see CreateStreamProcessor in the Amazon Rekognition Developer Guide.</p>"
},
+ "StreamProcessorParameterToDelete":{
+ "type":"string",
+ "enum":[
+ "ConnectedHomeMinConfidence",
+ "RegionsOfInterest"
+ ]
+ },
+ "StreamProcessorParametersToDelete":{
+ "type":"list",
+ "member":{"shape":"StreamProcessorParameterToDelete"}
+ },
"StreamProcessorSettings":{
"type":"structure",
"members":{
"FaceSearch":{
"shape":"FaceSearchSettings",
"documentation":"<p>Face search settings to use on a streaming video. </p>"
+ },
+ "ConnectedHome":{"shape":"ConnectedHomeSettings"}
+ },
+ "documentation":"<p>Input parameters used in a streaming video analyzed by a Amazon Rekognition stream processor. You can use <code>FaceSearch</code> to recognize faces in a streaming video, or you can use <code>ConnectedHome</code> to detect labels. </p>"
+ },
+ "StreamProcessorSettingsForUpdate":{
+ "type":"structure",
+ "members":{
+ "ConnectedHomeForUpdate":{
+ "shape":"ConnectedHomeSettingsForUpdate",
+ "documentation":"<p> The label detection settings you want to use for your stream processor. </p>"
}
},
- "documentation":"<p>Input parameters used to recognize faces in a streaming video analyzed by a Amazon Rekognition stream processor.</p>"
+ "documentation":"<p> The stream processor settings that you want to update. <code>ConnectedHome</code> settings can be updated to detect different labels with a different minimum confidence. </p>"
},
"StreamProcessorStatus":{
"type":"string",
@@ -5256,7 +5460,8 @@
"STARTING",
"RUNNING",
"FAILED",
- "STOPPING"
+ "STOPPING",
+ "UPDATING"
]
},
"String":{"type":"string"},
@@ -5414,7 +5619,7 @@
"documentation":"<p>The location of the detected text on the image. Includes an axis aligned coarse bounding box surrounding the text and a finer grain polygon for more accurate spatial information.</p>"
}
},
- "documentation":"<p>Information about a word or line of text detected by <a>DetectText</a>.</p> <p>The <code>DetectedText</code> field contains the text that Amazon Rekognition detected in the image. </p> <p>Every word and line has an identifier (<code>Id</code>). Each word belongs to a line and has a parent identifier (<code>ParentId</code>) that identifies the line of text in which the word appears. The word <code>Id</code> is also an index for the word within a line of words. </p> <p>For more information, see Detecting Text in the Amazon Rekognition Developer Guide.</p>"
+ "documentation":"<p>Information about a word or line of text detected by <a>DetectText</a>.</p> <p>The <code>DetectedText</code> field contains the text that Amazon Rekognition detected in the image. </p> <p>Every word and line has an identifier (<code>Id</code>). Each word belongs to a line and has a parent identifier (<code>ParentId</code>) that identifies the line of text in which the word appears. The word <code>Id</code> is also an index for the word within a line of words. </p> <p>For more information, see Detecting text in the Amazon Rekognition Developer Guide.</p>"
},
"TextDetectionList":{
"type":"list",
@@ -5553,6 +5758,37 @@
"members":{
}
},
+ "UpdateStreamProcessorRequest":{
+ "type":"structure",
+ "required":["Name"],
+ "members":{
+ "Name":{
+ "shape":"StreamProcessorName",
+ "documentation":"<p> Name of the stream processor that you want to update. </p>"
+ },
+ "SettingsForUpdate":{
+ "shape":"StreamProcessorSettingsForUpdate",
+ "documentation":"<p> The stream processor settings that you want to update. Label detection settings can be updated to detect different labels with a different minimum confidence. </p>"
+ },
+ "RegionsOfInterestForUpdate":{
+ "shape":"RegionsOfInterest",
+ "documentation":"<p> Specifies locations in the frames where Amazon Rekognition checks for objects or people. This is an optional parameter for label detection stream processors. </p>"
+ },
+ "DataSharingPreferenceForUpdate":{
+ "shape":"StreamProcessorDataSharingPreference",
+ "documentation":"<p> Shows whether you are sharing data with Rekognition to improve model performance. You can choose this option at the account level or on a per-stream basis. Note that if you opt out at the account level this setting is ignored on individual streams. </p>"
+ },
+ "ParametersToDelete":{
+ "shape":"StreamProcessorParametersToDelete",
+ "documentation":"<p> A list of parameters you want to delete from the stream processor. </p>"
+ }
+ }
+ },
+ "UpdateStreamProcessorResponse":{
+ "type":"structure",
+ "members":{
+ }
+ },
"Url":{"type":"string"},
"Urls":{
"type":"list",
@@ -5653,5 +5889,5 @@
"exception":true
}
},
- "documentation":"<p>This is the Amazon Rekognition API reference.</p>"
+ "documentation":"<p>This is the API Reference for <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/images.html\">Amazon Rekognition Image</a>, <a href=\"https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/what-is.html\">Amazon Rekognition Custom Labels</a>, <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/video.html\">Amazon Rekognition Stored Video</a>, <a href=\"https://docs.aws.amazon.com/rekognition/latest/dg/streaming-video.html\">Amazon Rekognition Streaming Video</a>. It provides descriptions of actions, data types, common parameters, and common errors.</p> <p> <b>Amazon Rekognition Image</b> </p> <ul> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> </ul> <p> <b>Amazon Rekognition Custom Labels</b> </p> <ul> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> </ul> <p> <b>Amazon Rekognition Video Stored Video</b> </p> <ul> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> </ul> <p> <b>Amazon Rekognition Video Streaming Video</b> </p> <ul> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> <li> <p/> </li> </ul>"
}
diff --git a/contrib/python/botocore/py3/botocore/data/sagemaker/2017-07-24/service-2.json b/contrib/python/botocore/py3/botocore/data/sagemaker/2017-07-24/service-2.json
index 9dcbccd6b9..049ccf1e22 100644
--- a/contrib/python/botocore/py3/botocore/data/sagemaker/2017-07-24/service-2.json
+++ b/contrib/python/botocore/py3/botocore/data/sagemaker/2017-07-24/service-2.json
@@ -36,7 +36,7 @@
},
"input":{"shape":"AddTagsInput"},
"output":{"shape":"AddTagsOutput"},
- "documentation":"<p>Adds or overwrites one or more tags for the specified Amazon SageMaker resource. You can add tags to notebook instances, training jobs, hyperparameter tuning jobs, batch transform jobs, models, labeling jobs, work teams, endpoint configurations, and endpoints.</p> <p>Each tag consists of a key and an optional value. Tag keys must be unique per resource. For more information about tags, see For more information, see <a href=\"https://aws.amazon.com/answers/account-management/aws-tagging-strategies/\">Amazon Web Services Tagging Strategies</a>.</p> <note> <p>Tags that you add to a hyperparameter tuning job by calling this API are also added to any training jobs that the hyperparameter tuning job launches after you call this API, but not to training jobs that the hyperparameter tuning job launched before you called this API. To make sure that the tags associated with a hyperparameter tuning job are also added to all training jobs that the hyperparameter tuning job launches, add the tags when you first create the tuning job by specifying them in the <code>Tags</code> parameter of <a>CreateHyperParameterTuningJob</a> </p> </note> <note> <p>Tags that you add to a SageMaker Studio Domain or User Profile by calling this API are also added to any Apps that the Domain or User Profile launches after you call this API, but not to Apps that the Domain or User Profile launched before you called this API. To make sure that the tags associated with a Domain or User Profile are also added to all Apps that the Domain or User Profile launches, add the tags when you first create the Domain or User Profile by specifying them in the <code>Tags</code> parameter of <a>CreateDomain</a> or <a>CreateUserProfile</a>.</p> </note>"
+ "documentation":"<p>Adds or overwrites one or more tags for the specified SageMaker resource. You can add tags to notebook instances, training jobs, hyperparameter tuning jobs, batch transform jobs, models, labeling jobs, work teams, endpoint configurations, and endpoints.</p> <p>Each tag consists of a key and an optional value. Tag keys must be unique per resource. For more information about tags, see For more information, see <a href=\"https://aws.amazon.com/answers/account-management/aws-tagging-strategies/\">Amazon Web Services Tagging Strategies</a>.</p> <note> <p>Tags that you add to a hyperparameter tuning job by calling this API are also added to any training jobs that the hyperparameter tuning job launches after you call this API, but not to training jobs that the hyperparameter tuning job launched before you called this API. To make sure that the tags associated with a hyperparameter tuning job are also added to all training jobs that the hyperparameter tuning job launches, add the tags when you first create the tuning job by specifying them in the <code>Tags</code> parameter of <a>CreateHyperParameterTuningJob</a> </p> </note> <note> <p>Tags that you add to a SageMaker Studio Domain or User Profile by calling this API are also added to any Apps that the Domain or User Profile launches after you call this API, but not to Apps that the Domain or User Profile launched before you called this API. To make sure that the tags associated with a Domain or User Profile are also added to all Apps that the Domain or User Profile launches, add the tags when you first create the Domain or User Profile by specifying them in the <code>Tags</code> parameter of <a>CreateDomain</a> or <a>CreateUserProfile</a>.</p> </note>"
},
"AssociateTrialComponent":{
"name":"AssociateTrialComponent",
@@ -83,7 +83,7 @@
},
"input":{"shape":"CreateAlgorithmInput"},
"output":{"shape":"CreateAlgorithmOutput"},
- "documentation":"<p>Create a machine learning algorithm that you can use in Amazon SageMaker and list in the Amazon Web Services Marketplace.</p>"
+ "documentation":"<p>Create a machine learning algorithm that you can use in SageMaker and list in the Amazon Web Services Marketplace.</p>"
},
"CreateApp":{
"name":"CreateApp",
@@ -147,7 +147,7 @@
},
"input":{"shape":"CreateCodeRepositoryInput"},
"output":{"shape":"CreateCodeRepositoryOutput"},
- "documentation":"<p>Creates a Git repository as a resource in your Amazon SageMaker account. You can associate the repository with notebook instances so that you can use Git source control for the notebooks you create. The Git repository is a resource in your Amazon SageMaker account, so it can be associated with more than one notebook instance, and it persists independently from the lifecycle of any notebook instances it is associated with.</p> <p>The repository can be hosted either in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository.</p>"
+ "documentation":"<p>Creates a Git repository as a resource in your SageMaker account. You can associate the repository with notebook instances so that you can use Git source control for the notebooks you create. The Git repository is a resource in your SageMaker account, so it can be associated with more than one notebook instance, and it persists independently from the lifecycle of any notebook instances it is associated with.</p> <p>The repository can be hosted either in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository.</p>"
},
"CreateCompilationJob":{
"name":"CreateCompilationJob",
@@ -240,7 +240,7 @@
"errors":[
{"shape":"ResourceLimitExceeded"}
],
- "documentation":"<p>Creates an endpoint using the endpoint configuration specified in the request. Amazon SageMaker uses the endpoint to provision resources and deploy models. You create the endpoint configuration with the <a>CreateEndpointConfig</a> API. </p> <p> Use this API to deploy models using Amazon SageMaker hosting services. </p> <p>For an example that calls this method when deploying a model to Amazon SageMaker hosting services, see the <a href=\"https://github.com/aws/amazon-sagemaker-examples/blob/master/sagemaker-fundamentals/create-endpoint/create_endpoint.ipynb\">Create Endpoint example notebook.</a> </p> <note> <p> You must not delete an <code>EndpointConfig</code> that is in use by an endpoint that is live or while the <code>UpdateEndpoint</code> or <code>CreateEndpoint</code> operations are being performed on the endpoint. To update an endpoint, you must create a new <code>EndpointConfig</code>.</p> </note> <p>The endpoint name must be unique within an Amazon Web Services Region in your Amazon Web Services account. </p> <p>When it receives the request, Amazon SageMaker creates the endpoint, launches the resources (ML compute instances), and deploys the model(s) on them. </p> <note> <p>When you call <a>CreateEndpoint</a>, a load call is made to DynamoDB to verify that your endpoint configuration exists. When you read data from a DynamoDB table supporting <a href=\"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html\"> <code>Eventually Consistent Reads</code> </a>, the response might not reflect the results of a recently completed write operation. The response might include some stale data. If the dependent entities are not yet in DynamoDB, this causes a validation error. If you repeat your read request after a short time, the response should return the latest data. So retry logic is recommended to handle these possible issues. We also recommend that customers call <a>DescribeEndpointConfig</a> before calling <a>CreateEndpoint</a> to minimize the potential impact of a DynamoDB eventually consistent read.</p> </note> <p>When Amazon SageMaker receives the request, it sets the endpoint status to <code>Creating</code>. After it creates the endpoint, it sets the status to <code>InService</code>. Amazon SageMaker can then process incoming requests for inferences. To check the status of an endpoint, use the <a>DescribeEndpoint</a> API.</p> <p>If any of the models hosted at this endpoint get model data from an Amazon S3 location, Amazon SageMaker uses Amazon Web Services Security Token Service to download model artifacts from the S3 path you provided. Amazon Web Services STS is activated in your IAM user account by default. If you previously deactivated Amazon Web Services STS for a region, you need to reactivate Amazon Web Services STS for that region. For more information, see <a href=\"https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html\">Activating and Deactivating Amazon Web Services STS in an Amazon Web Services Region</a> in the <i>Amazon Web Services Identity and Access Management User Guide</i>.</p> <note> <p> To add the IAM role policies for using this API operation, go to the <a href=\"https://console.aws.amazon.com/iam/\">IAM console</a>, and choose Roles in the left navigation pane. Search the IAM role that you want to grant access to use the <a>CreateEndpoint</a> and <a>CreateEndpointConfig</a> API operations, add the following policies to the role. </p> <ul> <li> <p>Option 1: For a full SageMaker access, search and attach the <code>AmazonSageMakerFullAccess</code> policy.</p> </li> <li> <p>Option 2: For granting a limited access to an IAM role, paste the following Action elements manually into the JSON file of the IAM role: </p> <p> <code>\"Action\": [\"sagemaker:CreateEndpoint\", \"sagemaker:CreateEndpointConfig\"]</code> </p> <p> <code>\"Resource\": [</code> </p> <p> <code>\"arn:aws:sagemaker:region:account-id:endpoint/endpointName\"</code> </p> <p> <code>\"arn:aws:sagemaker:region:account-id:endpoint-config/endpointConfigName\"</code> </p> <p> <code>]</code> </p> <p>For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/api-permissions-reference.html\">SageMaker API Permissions: Actions, Permissions, and Resources Reference</a>.</p> </li> </ul> </note>"
+ "documentation":"<p>Creates an endpoint using the endpoint configuration specified in the request. SageMaker uses the endpoint to provision resources and deploy models. You create the endpoint configuration with the <a>CreateEndpointConfig</a> API. </p> <p> Use this API to deploy models using SageMaker hosting services. </p> <p>For an example that calls this method when deploying a model to SageMaker hosting services, see the <a href=\"https://github.com/aws/amazon-sagemaker-examples/blob/master/sagemaker-fundamentals/create-endpoint/create_endpoint.ipynb\">Create Endpoint example notebook.</a> </p> <note> <p> You must not delete an <code>EndpointConfig</code> that is in use by an endpoint that is live or while the <code>UpdateEndpoint</code> or <code>CreateEndpoint</code> operations are being performed on the endpoint. To update an endpoint, you must create a new <code>EndpointConfig</code>.</p> </note> <p>The endpoint name must be unique within an Amazon Web Services Region in your Amazon Web Services account. </p> <p>When it receives the request, SageMaker creates the endpoint, launches the resources (ML compute instances), and deploys the model(s) on them. </p> <note> <p>When you call <a>CreateEndpoint</a>, a load call is made to DynamoDB to verify that your endpoint configuration exists. When you read data from a DynamoDB table supporting <a href=\"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html\"> <code>Eventually Consistent Reads</code> </a>, the response might not reflect the results of a recently completed write operation. The response might include some stale data. If the dependent entities are not yet in DynamoDB, this causes a validation error. If you repeat your read request after a short time, the response should return the latest data. So retry logic is recommended to handle these possible issues. We also recommend that customers call <a>DescribeEndpointConfig</a> before calling <a>CreateEndpoint</a> to minimize the potential impact of a DynamoDB eventually consistent read.</p> </note> <p>When SageMaker receives the request, it sets the endpoint status to <code>Creating</code>. After it creates the endpoint, it sets the status to <code>InService</code>. SageMaker can then process incoming requests for inferences. To check the status of an endpoint, use the <a>DescribeEndpoint</a> API.</p> <p>If any of the models hosted at this endpoint get model data from an Amazon S3 location, SageMaker uses Amazon Web Services Security Token Service to download model artifacts from the S3 path you provided. Amazon Web Services STS is activated in your IAM user account by default. If you previously deactivated Amazon Web Services STS for a region, you need to reactivate Amazon Web Services STS for that region. For more information, see <a href=\"https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html\">Activating and Deactivating Amazon Web Services STS in an Amazon Web Services Region</a> in the <i>Amazon Web Services Identity and Access Management User Guide</i>.</p> <note> <p> To add the IAM role policies for using this API operation, go to the <a href=\"https://console.aws.amazon.com/iam/\">IAM console</a>, and choose Roles in the left navigation pane. Search the IAM role that you want to grant access to use the <a>CreateEndpoint</a> and <a>CreateEndpointConfig</a> API operations, add the following policies to the role. </p> <ul> <li> <p>Option 1: For a full SageMaker access, search and attach the <code>AmazonSageMakerFullAccess</code> policy.</p> </li> <li> <p>Option 2: For granting a limited access to an IAM role, paste the following Action elements manually into the JSON file of the IAM role: </p> <p> <code>\"Action\": [\"sagemaker:CreateEndpoint\", \"sagemaker:CreateEndpointConfig\"]</code> </p> <p> <code>\"Resource\": [</code> </p> <p> <code>\"arn:aws:sagemaker:region:account-id:endpoint/endpointName\"</code> </p> <p> <code>\"arn:aws:sagemaker:region:account-id:endpoint-config/endpointConfigName\"</code> </p> <p> <code>]</code> </p> <p>For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/api-permissions-reference.html\">SageMaker API Permissions: Actions, Permissions, and Resources Reference</a>.</p> </li> </ul> </note>"
},
"CreateEndpointConfig":{
"name":"CreateEndpointConfig",
@@ -253,7 +253,7 @@
"errors":[
{"shape":"ResourceLimitExceeded"}
],
- "documentation":"<p>Creates an endpoint configuration that Amazon SageMaker hosting services uses to deploy models. In the configuration, you identify one or more models, created using the <code>CreateModel</code> API, to deploy and the resources that you want Amazon SageMaker to provision. Then you call the <a>CreateEndpoint</a> API.</p> <note> <p> Use this API if you want to use Amazon SageMaker hosting services to deploy models into production. </p> </note> <p>In the request, you define a <code>ProductionVariant</code>, for each model that you want to deploy. Each <code>ProductionVariant</code> parameter also describes the resources that you want Amazon SageMaker to provision. This includes the number and type of ML compute instances to deploy. </p> <p>If you are hosting multiple models, you also assign a <code>VariantWeight</code> to specify how much traffic you want to allocate to each model. For example, suppose that you want to host two models, A and B, and you assign traffic weight 2 for model A and 1 for model B. Amazon SageMaker distributes two-thirds of the traffic to Model A, and one-third to model B. </p> <note> <p>When you call <a>CreateEndpoint</a>, a load call is made to DynamoDB to verify that your endpoint configuration exists. When you read data from a DynamoDB table supporting <a href=\"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html\"> <code>Eventually Consistent Reads</code> </a>, the response might not reflect the results of a recently completed write operation. The response might include some stale data. If the dependent entities are not yet in DynamoDB, this causes a validation error. If you repeat your read request after a short time, the response should return the latest data. So retry logic is recommended to handle these possible issues. We also recommend that customers call <a>DescribeEndpointConfig</a> before calling <a>CreateEndpoint</a> to minimize the potential impact of a DynamoDB eventually consistent read.</p> </note>"
+ "documentation":"<p>Creates an endpoint configuration that SageMaker hosting services uses to deploy models. In the configuration, you identify one or more models, created using the <code>CreateModel</code> API, to deploy and the resources that you want SageMaker to provision. Then you call the <a>CreateEndpoint</a> API.</p> <note> <p> Use this API if you want to use SageMaker hosting services to deploy models into production. </p> </note> <p>In the request, you define a <code>ProductionVariant</code>, for each model that you want to deploy. Each <code>ProductionVariant</code> parameter also describes the resources that you want SageMaker to provision. This includes the number and type of ML compute instances to deploy. </p> <p>If you are hosting multiple models, you also assign a <code>VariantWeight</code> to specify how much traffic you want to allocate to each model. For example, suppose that you want to host two models, A and B, and you assign traffic weight 2 for model A and 1 for model B. SageMaker distributes two-thirds of the traffic to Model A, and one-third to model B. </p> <note> <p>When you call <a>CreateEndpoint</a>, a load call is made to DynamoDB to verify that your endpoint configuration exists. When you read data from a DynamoDB table supporting <a href=\"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html\"> <code>Eventually Consistent Reads</code> </a>, the response might not reflect the results of a recently completed write operation. The response might include some stale data. If the dependent entities are not yet in DynamoDB, this causes a validation error. If you repeat your read request after a short time, the response should return the latest data. So retry logic is recommended to handle these possible issues. We also recommend that customers call <a>DescribeEndpointConfig</a> before calling <a>CreateEndpoint</a> to minimize the potential impact of a DynamoDB eventually consistent read.</p> </note>"
},
"CreateExperiment":{
"name":"CreateExperiment",
@@ -336,7 +336,7 @@
{"shape":"ResourceInUse"},
{"shape":"ResourceLimitExceeded"}
],
- "documentation":"<p>Creates a custom SageMaker image. A SageMaker image is a set of image versions. Each image version represents a container image stored in Amazon Container Registry (ECR). For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/studio-byoi.html\">Bring your own SageMaker image</a>.</p>"
+ "documentation":"<p>Creates a custom SageMaker image. A SageMaker image is a set of image versions. Each image version represents a container image stored in Amazon Elastic Container Registry (ECR). For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/studio-byoi.html\">Bring your own SageMaker image</a>.</p>"
},
"CreateImageVersion":{
"name":"CreateImageVersion",
@@ -351,7 +351,7 @@
{"shape":"ResourceLimitExceeded"},
{"shape":"ResourceNotFound"}
],
- "documentation":"<p>Creates a version of the SageMaker image specified by <code>ImageName</code>. The version represents the Amazon Container Registry (ECR) container image specified by <code>BaseImage</code>.</p>"
+ "documentation":"<p>Creates a version of the SageMaker image specified by <code>ImageName</code>. The version represents the Amazon Elastic Container Registry (ECR) container image specified by <code>BaseImage</code>.</p>"
},
"CreateInferenceRecommendationsJob":{
"name":"CreateInferenceRecommendationsJob",
@@ -392,7 +392,7 @@
"errors":[
{"shape":"ResourceLimitExceeded"}
],
- "documentation":"<p>Creates a model in Amazon SageMaker. In the request, you name the model and describe a primary container. For the primary container, you specify the Docker image that contains inference code, artifacts (from prior training), and a custom environment map that the inference code uses when you deploy the model for predictions.</p> <p>Use this API to create a model if you want to use Amazon SageMaker hosting services or run a batch transform job.</p> <p>To host your model, you create an endpoint configuration with the <code>CreateEndpointConfig</code> API, and then create an endpoint with the <code>CreateEndpoint</code> API. Amazon SageMaker then deploys all of the containers that you defined for the model in the hosting environment. </p> <p>For an example that calls this method when deploying a model to Amazon SageMaker hosting services, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/ex1-deploy-model.html#ex1-deploy-model-boto\">Deploy the Model to Amazon SageMaker Hosting Services (Amazon Web Services SDK for Python (Boto 3)).</a> </p> <p>To run a batch transform using your model, you start a job with the <code>CreateTransformJob</code> API. Amazon SageMaker uses your model and your dataset to get inferences which are then saved to a specified S3 location.</p> <p>In the <code>CreateModel</code> request, you must define a container with the <code>PrimaryContainer</code> parameter.</p> <p>In the request, you also provide an IAM role that Amazon SageMaker can assume to access model artifacts and docker image for deployment on ML compute hosting instances or for batch transform jobs. In addition, you also use the IAM role to manage permissions the inference code needs. For example, if the inference code access any other Amazon Web Services resources, you grant necessary permissions via this role.</p>"
+ "documentation":"<p>Creates a model in SageMaker. In the request, you name the model and describe a primary container. For the primary container, you specify the Docker image that contains inference code, artifacts (from prior training), and a custom environment map that the inference code uses when you deploy the model for predictions.</p> <p>Use this API to create a model if you want to use SageMaker hosting services or run a batch transform job.</p> <p>To host your model, you create an endpoint configuration with the <code>CreateEndpointConfig</code> API, and then create an endpoint with the <code>CreateEndpoint</code> API. SageMaker then deploys all of the containers that you defined for the model in the hosting environment. </p> <p>For an example that calls this method when deploying a model to SageMaker hosting services, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/ex1-deploy-model.html#ex1-deploy-model-boto\">Deploy the Model to Amazon SageMaker Hosting Services (Amazon Web Services SDK for Python (Boto 3)).</a> </p> <p>To run a batch transform using your model, you start a job with the <code>CreateTransformJob</code> API. SageMaker uses your model and your dataset to get inferences which are then saved to a specified S3 location.</p> <p>In the request, you also provide an IAM role that SageMaker can assume to access model artifacts and docker image for deployment on ML compute hosting instances or for batch transform jobs. In addition, you also use the IAM role to manage permissions the inference code needs. For example, if the inference code access any other Amazon Web Services resources, you grant necessary permissions via this role.</p>"
},
"CreateModelBiasJobDefinition":{
"name":"CreateModelBiasJobDefinition",
@@ -434,7 +434,7 @@
{"shape":"ConflictException"},
{"shape":"ResourceLimitExceeded"}
],
- "documentation":"<p>Creates a model package that you can use to create Amazon SageMaker models or list on Amazon Web Services Marketplace, or a versioned model that is part of a model group. Buyers can subscribe to model packages listed on Amazon Web Services Marketplace to create models in Amazon SageMaker.</p> <p>To create a model package by specifying a Docker container that contains your inference code and the Amazon S3 location of your model artifacts, provide values for <code>InferenceSpecification</code>. To create a model from an algorithm resource that you created or subscribed to in Amazon Web Services Marketplace, provide a value for <code>SourceAlgorithmSpecification</code>.</p> <note> <p>There are two types of model packages:</p> <ul> <li> <p>Versioned - a model that is part of a model group in the model registry.</p> </li> <li> <p>Unversioned - a model package that is not part of a model group.</p> </li> </ul> </note>"
+ "documentation":"<p>Creates a model package that you can use to create SageMaker models or list on Amazon Web Services Marketplace, or a versioned model that is part of a model group. Buyers can subscribe to model packages listed on Amazon Web Services Marketplace to create models in SageMaker.</p> <p>To create a model package by specifying a Docker container that contains your inference code and the Amazon S3 location of your model artifacts, provide values for <code>InferenceSpecification</code>. To create a model from an algorithm resource that you created or subscribed to in Amazon Web Services Marketplace, provide a value for <code>SourceAlgorithmSpecification</code>.</p> <note> <p>There are two types of model packages:</p> <ul> <li> <p>Versioned - a model that is part of a model group in the model registry.</p> </li> <li> <p>Unversioned - a model package that is not part of a model group.</p> </li> </ul> </note>"
},
"CreateModelPackageGroup":{
"name":"CreateModelPackageGroup",
@@ -488,7 +488,7 @@
"errors":[
{"shape":"ResourceLimitExceeded"}
],
- "documentation":"<p>Creates an Amazon SageMaker notebook instance. A notebook instance is a machine learning (ML) compute instance running on a Jupyter notebook. </p> <p>In a <code>CreateNotebookInstance</code> request, specify the type of ML compute instance that you want to run. Amazon SageMaker launches the instance, installs common libraries that you can use to explore datasets for model training, and attaches an ML storage volume to the notebook instance. </p> <p>Amazon SageMaker also provides a set of example notebooks. Each notebook demonstrates how to use Amazon SageMaker with a specific algorithm or with a machine learning framework. </p> <p>After receiving the request, Amazon SageMaker does the following:</p> <ol> <li> <p>Creates a network interface in the Amazon SageMaker VPC.</p> </li> <li> <p>(Option) If you specified <code>SubnetId</code>, Amazon SageMaker creates a network interface in your own VPC, which is inferred from the subnet ID that you provide in the input. When creating this network interface, Amazon SageMaker attaches the security group that you specified in the request to the network interface that it creates in your VPC.</p> </li> <li> <p>Launches an EC2 instance of the type specified in the request in the Amazon SageMaker VPC. If you specified <code>SubnetId</code> of your VPC, Amazon SageMaker specifies both network interfaces when launching this instance. This enables inbound traffic from your own VPC to the notebook instance, assuming that the security groups allow it.</p> </li> </ol> <p>After creating the notebook instance, Amazon SageMaker returns its Amazon Resource Name (ARN). You can't change the name of a notebook instance after you create it.</p> <p>After Amazon SageMaker creates the notebook instance, you can connect to the Jupyter server and work in Jupyter notebooks. For example, you can write code to explore a dataset that you can use for model training, train a model, host models by creating Amazon SageMaker endpoints, and validate hosted models. </p> <p>For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html\">How It Works</a>. </p>"
+ "documentation":"<p>Creates an SageMaker notebook instance. A notebook instance is a machine learning (ML) compute instance running on a Jupyter notebook. </p> <p>In a <code>CreateNotebookInstance</code> request, specify the type of ML compute instance that you want to run. SageMaker launches the instance, installs common libraries that you can use to explore datasets for model training, and attaches an ML storage volume to the notebook instance. </p> <p>SageMaker also provides a set of example notebooks. Each notebook demonstrates how to use SageMaker with a specific algorithm or with a machine learning framework. </p> <p>After receiving the request, SageMaker does the following:</p> <ol> <li> <p>Creates a network interface in the SageMaker VPC.</p> </li> <li> <p>(Option) If you specified <code>SubnetId</code>, SageMaker creates a network interface in your own VPC, which is inferred from the subnet ID that you provide in the input. When creating this network interface, SageMaker attaches the security group that you specified in the request to the network interface that it creates in your VPC.</p> </li> <li> <p>Launches an EC2 instance of the type specified in the request in the SageMaker VPC. If you specified <code>SubnetId</code> of your VPC, SageMaker specifies both network interfaces when launching this instance. This enables inbound traffic from your own VPC to the notebook instance, assuming that the security groups allow it.</p> </li> </ol> <p>After creating the notebook instance, SageMaker returns its Amazon Resource Name (ARN). You can't change the name of a notebook instance after you create it.</p> <p>After SageMaker creates the notebook instance, you can connect to the Jupyter server and work in Jupyter notebooks. For example, you can write code to explore a dataset that you can use for model training, train a model, host models by creating SageMaker endpoints, and validate hosted models. </p> <p>For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html\">How It Works</a>. </p>"
},
"CreateNotebookInstanceLifecycleConfig":{
"name":"CreateNotebookInstanceLifecycleConfig",
@@ -538,7 +538,7 @@
},
"input":{"shape":"CreatePresignedNotebookInstanceUrlInput"},
"output":{"shape":"CreatePresignedNotebookInstanceUrlOutput"},
- "documentation":"<p>Returns a URL that you can use to connect to the Jupyter server from a notebook instance. In the Amazon SageMaker console, when you choose <code>Open</code> next to a notebook instance, Amazon SageMaker opens a new tab showing the Jupyter server home page from the notebook instance. The console uses this API to get the URL and show the page.</p> <p> The IAM role or user used to call this API defines the permissions to access the notebook instance. Once the presigned URL is created, no additional permission is required to access this URL. IAM authorization policies for this API are also enforced for every HTTP request and WebSocket frame that attempts to connect to the notebook instance.</p> <p>You can restrict access to this API and to the URL that it returns to a list of IP addresses that you specify. Use the <code>NotIpAddress</code> condition operator and the <code>aws:SourceIP</code> condition context key to specify the list of IP addresses that you want to have access to the notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/security_iam_id-based-policy-examples.html#nbi-ip-filter\">Limit Access to a Notebook Instance by IP Address</a>.</p> <note> <p>The URL that you get from a call to <a>CreatePresignedNotebookInstanceUrl</a> is valid only for 5 minutes. If you try to use the URL after the 5-minute limit expires, you are directed to the Amazon Web Services console sign-in page.</p> </note>"
+ "documentation":"<p>Returns a URL that you can use to connect to the Jupyter server from a notebook instance. In the SageMaker console, when you choose <code>Open</code> next to a notebook instance, SageMaker opens a new tab showing the Jupyter server home page from the notebook instance. The console uses this API to get the URL and show the page.</p> <p> The IAM role or user used to call this API defines the permissions to access the notebook instance. Once the presigned URL is created, no additional permission is required to access this URL. IAM authorization policies for this API are also enforced for every HTTP request and WebSocket frame that attempts to connect to the notebook instance.</p> <p>You can restrict access to this API and to the URL that it returns to a list of IP addresses that you specify. Use the <code>NotIpAddress</code> condition operator and the <code>aws:SourceIP</code> condition context key to specify the list of IP addresses that you want to have access to the notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/security_iam_id-based-policy-examples.html#nbi-ip-filter\">Limit Access to a Notebook Instance by IP Address</a>.</p> <note> <p>The URL that you get from a call to <a>CreatePresignedNotebookInstanceUrl</a> is valid only for 5 minutes. If you try to use the URL after the 5-minute limit expires, you are directed to the Amazon Web Services console sign-in page.</p> </note>"
},
"CreateProcessingJob":{
"name":"CreateProcessingJob",
@@ -594,7 +594,7 @@
{"shape":"ResourceLimitExceeded"},
{"shape":"ResourceNotFound"}
],
- "documentation":"<p>Starts a model training job. After training completes, Amazon SageMaker saves the resulting model artifacts to an Amazon S3 location that you specify. </p> <p>If you choose to host your model using Amazon SageMaker hosting services, you can use the resulting model artifacts as part of the model. You can also use the artifacts in a machine learning service other than Amazon SageMaker, provided that you know how to use them for inference. </p> <p>In the request body, you provide the following: </p> <ul> <li> <p> <code>AlgorithmSpecification</code> - Identifies the training algorithm to use. </p> </li> <li> <p> <code>HyperParameters</code> - Specify these algorithm-specific parameters to enable the estimation of model parameters during training. Hyperparameters can be tuned to optimize this learning process. For a list of hyperparameters for each training algorithm provided by Amazon SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html\">Algorithms</a>. </p> </li> <li> <p> <code>InputDataConfig</code> - Describes the training dataset and the Amazon S3, EFS, or FSx location where it is stored.</p> </li> <li> <p> <code>OutputDataConfig</code> - Identifies the Amazon S3 bucket where you want Amazon SageMaker to save the results of model training. </p> </li> <li> <p> <code>ResourceConfig</code> - Identifies the resources, ML compute instances, and ML storage volumes to deploy for model training. In distributed training, you specify more than one instance. </p> </li> <li> <p> <code>EnableManagedSpotTraining</code> - Optimize the cost of training machine learning models by up to 80% by using Amazon EC2 Spot instances. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html\">Managed Spot Training</a>. </p> </li> <li> <p> <code>RoleArn</code> - The Amazon Resource Name (ARN) that Amazon SageMaker assumes to perform tasks on your behalf during model training. You must grant this role the necessary permissions so that Amazon SageMaker can successfully complete model training. </p> </li> <li> <p> <code>StoppingCondition</code> - To help cap training costs, use <code>MaxRuntimeInSeconds</code> to set a time limit for training. Use <code>MaxWaitTimeInSeconds</code> to specify how long a managed spot training job has to complete. </p> </li> <li> <p> <code>Environment</code> - The environment variables to set in the Docker container.</p> </li> <li> <p> <code>RetryStrategy</code> - The number of times to retry the job when the job fails due to an <code>InternalServerError</code>.</p> </li> </ul> <p> For more information about Amazon SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html\">How It Works</a>. </p>"
+ "documentation":"<p>Starts a model training job. After training completes, SageMaker saves the resulting model artifacts to an Amazon S3 location that you specify. </p> <p>If you choose to host your model using SageMaker hosting services, you can use the resulting model artifacts as part of the model. You can also use the artifacts in a machine learning service other than SageMaker, provided that you know how to use them for inference. </p> <p>In the request body, you provide the following: </p> <ul> <li> <p> <code>AlgorithmSpecification</code> - Identifies the training algorithm to use. </p> </li> <li> <p> <code>HyperParameters</code> - Specify these algorithm-specific parameters to enable the estimation of model parameters during training. Hyperparameters can be tuned to optimize this learning process. For a list of hyperparameters for each training algorithm provided by SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html\">Algorithms</a>. </p> </li> <li> <p> <code>InputDataConfig</code> - Describes the training dataset and the Amazon S3, EFS, or FSx location where it is stored.</p> </li> <li> <p> <code>OutputDataConfig</code> - Identifies the Amazon S3 bucket where you want SageMaker to save the results of model training. </p> </li> <li> <p> <code>ResourceConfig</code> - Identifies the resources, ML compute instances, and ML storage volumes to deploy for model training. In distributed training, you specify more than one instance. </p> </li> <li> <p> <code>EnableManagedSpotTraining</code> - Optimize the cost of training machine learning models by up to 80% by using Amazon EC2 Spot instances. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html\">Managed Spot Training</a>. </p> </li> <li> <p> <code>RoleArn</code> - The Amazon Resource Name (ARN) that SageMaker assumes to perform tasks on your behalf during model training. You must grant this role the necessary permissions so that SageMaker can successfully complete model training. </p> </li> <li> <p> <code>StoppingCondition</code> - To help cap training costs, use <code>MaxRuntimeInSeconds</code> to set a time limit for training. Use <code>MaxWaitTimeInSeconds</code> to specify how long a managed spot training job has to complete. </p> </li> <li> <p> <code>Environment</code> - The environment variables to set in the Docker container.</p> </li> <li> <p> <code>RetryStrategy</code> - The number of times to retry the job when the job fails due to an <code>InternalServerError</code>.</p> </li> </ul> <p> For more information about SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html\">How It Works</a>. </p>"
},
"CreateTransformJob":{
"name":"CreateTransformJob",
@@ -815,7 +815,7 @@
"requestUri":"/"
},
"input":{"shape":"DeleteEndpointInput"},
- "documentation":"<p>Deletes an endpoint. Amazon SageMaker frees up all of the resources that were deployed when the endpoint was created. </p> <p>Amazon SageMaker retires any custom KMS key grants associated with the endpoint, meaning you don't need to use the <a href=\"http://docs.aws.amazon.com/kms/latest/APIReference/API_RevokeGrant.html\">RevokeGrant</a> API call.</p>"
+ "documentation":"<p>Deletes an endpoint. SageMaker frees up all of the resources that were deployed when the endpoint was created. </p> <p>SageMaker retires any custom KMS key grants associated with the endpoint, meaning you don't need to use the <a href=\"http://docs.aws.amazon.com/kms/latest/APIReference/API_RevokeGrant.html\">RevokeGrant</a> API call.</p> <p>When you delete your endpoint, SageMaker asynchronously deletes associated endpoint resources such as KMS key grants. You might still see these resources in your account for a few minutes after deleting your endpoint. Do not delete or revoke the permissions for your <code> <a href=\"https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModel.html#sagemaker-CreateModel-request-ExecutionRoleArn\">ExecutionRoleArn</a> </code>, otherwise SageMaker cannot delete these resources.</p>"
},
"DeleteEndpointConfig":{
"name":"DeleteEndpointConfig",
@@ -913,7 +913,7 @@
"requestUri":"/"
},
"input":{"shape":"DeleteModelInput"},
- "documentation":"<p>Deletes a model. The <code>DeleteModel</code> API deletes only the model entry that was created in Amazon SageMaker when you called the <code>CreateModel</code> API. It does not delete model artifacts, inference code, or the IAM role that you specified when creating the model. </p>"
+ "documentation":"<p>Deletes a model. The <code>DeleteModel</code> API deletes only the model entry that was created in SageMaker when you called the <code>CreateModel</code> API. It does not delete model artifacts, inference code, or the IAM role that you specified when creating the model. </p>"
},
"DeleteModelBiasJobDefinition":{
"name":"DeleteModelBiasJobDefinition",
@@ -949,7 +949,7 @@
"errors":[
{"shape":"ConflictException"}
],
- "documentation":"<p>Deletes a model package.</p> <p>A model package is used to create Amazon SageMaker models or list on Amazon Web Services Marketplace. Buyers can subscribe to model packages listed on Amazon Web Services Marketplace to create models in Amazon SageMaker.</p>"
+ "documentation":"<p>Deletes a model package.</p> <p>A model package is used to create SageMaker models or list on Amazon Web Services Marketplace. Buyers can subscribe to model packages listed on Amazon Web Services Marketplace to create models in SageMaker.</p>"
},
"DeleteModelPackageGroup":{
"name":"DeleteModelPackageGroup",
@@ -1003,7 +1003,7 @@
"requestUri":"/"
},
"input":{"shape":"DeleteNotebookInstanceInput"},
- "documentation":"<p> Deletes an Amazon SageMaker notebook instance. Before you can delete a notebook instance, you must call the <code>StopNotebookInstance</code> API. </p> <important> <p>When you delete a notebook instance, you lose all of your data. Amazon SageMaker removes the ML compute instance, and deletes the ML storage volume and the network interface associated with the notebook instance. </p> </important>"
+ "documentation":"<p> Deletes an SageMaker notebook instance. Before you can delete a notebook instance, you must call the <code>StopNotebookInstance</code> API. </p> <important> <p>When you delete a notebook instance, you lose all of your data. SageMaker removes the ML compute instance, and deletes the ML storage volume and the network interface associated with the notebook instance. </p> </important>"
},
"DeleteNotebookInstanceLifecycleConfig":{
"name":"DeleteNotebookInstanceLifecycleConfig",
@@ -1060,7 +1060,7 @@
},
"input":{"shape":"DeleteTagsInput"},
"output":{"shape":"DeleteTagsOutput"},
- "documentation":"<p>Deletes the specified tags from an Amazon SageMaker resource.</p> <p>To list a resource's tags, use the <code>ListTags</code> API. </p> <note> <p>When you call this API to delete tags from a hyperparameter tuning job, the deleted tags are not removed from training jobs that the hyperparameter tuning job launched before you called this API.</p> </note> <note> <p>When you call this API to delete tags from a SageMaker Studio Domain or User Profile, the deleted tags are not removed from Apps that the SageMaker Studio Domain or User Profile launched before you called this API.</p> </note>"
+ "documentation":"<p>Deletes the specified tags from an SageMaker resource.</p> <p>To list a resource's tags, use the <code>ListTags</code> API. </p> <note> <p>When you call this API to delete tags from a hyperparameter tuning job, the deleted tags are not removed from training jobs that the hyperparameter tuning job launched before you called this API.</p> </note> <note> <p>When you call this API to delete tags from a SageMaker Studio Domain or User Profile, the deleted tags are not removed from Apps that the SageMaker Studio Domain or User Profile launched before you called this API.</p> </note>"
},
"DeleteTrial":{
"name":"DeleteTrial",
@@ -2236,7 +2236,7 @@
},
"input":{"shape":"ListNotebookInstancesInput"},
"output":{"shape":"ListNotebookInstancesOutput"},
- "documentation":"<p>Returns a list of the Amazon SageMaker notebook instances in the requester's account in an Amazon Web Services Region. </p>"
+ "documentation":"<p>Returns a list of the SageMaker notebook instances in the requester's account in an Amazon Web Services Region. </p>"
},
"ListPipelineExecutionSteps":{
"name":"ListPipelineExecutionSteps",
@@ -2338,7 +2338,7 @@
},
"input":{"shape":"ListTagsInput"},
"output":{"shape":"ListTagsOutput"},
- "documentation":"<p>Returns the tags for the specified Amazon SageMaker resource.</p>"
+ "documentation":"<p>Returns the tags for the specified SageMaker resource.</p>"
},
"ListTrainingJobs":{
"name":"ListTrainingJobs",
@@ -2552,7 +2552,7 @@
"errors":[
{"shape":"ResourceLimitExceeded"}
],
- "documentation":"<p>Launches an ML compute instance with the latest version of the libraries and attaches your ML storage volume. After configuring the notebook instance, Amazon SageMaker sets the notebook instance status to <code>InService</code>. A notebook instance's status must be <code>InService</code> before you can connect to your Jupyter notebook. </p>"
+ "documentation":"<p>Launches an ML compute instance with the latest version of the libraries and attaches your ML storage volume. After configuring the notebook instance, SageMaker sets the notebook instance status to <code>InService</code>. A notebook instance's status must be <code>InService</code> before you can connect to your Jupyter notebook. </p>"
},
"StartPipelineExecution":{
"name":"StartPipelineExecution",
@@ -2656,7 +2656,7 @@
"requestUri":"/"
},
"input":{"shape":"StopNotebookInstanceInput"},
- "documentation":"<p>Terminates the ML compute instance. Before terminating the instance, Amazon SageMaker disconnects the ML storage volume from it. Amazon SageMaker preserves the ML storage volume. Amazon SageMaker stops charging you for the ML compute instance when you call <code>StopNotebookInstance</code>.</p> <p>To access data on the ML storage volume for a notebook instance that has been terminated, call the <code>StartNotebookInstance</code> API. <code>StartNotebookInstance</code> launches another ML compute instance, configures it, and attaches the preserved ML storage volume so you can continue your work. </p>"
+ "documentation":"<p>Terminates the ML compute instance. Before terminating the instance, SageMaker disconnects the ML storage volume from it. SageMaker preserves the ML storage volume. SageMaker stops charging you for the ML compute instance when you call <code>StopNotebookInstance</code>.</p> <p>To access data on the ML storage volume for a notebook instance that has been terminated, call the <code>StartNotebookInstance</code> API. <code>StartNotebookInstance</code> launches another ML compute instance, configures it, and attaches the preserved ML storage volume so you can continue your work. </p>"
},
"StopPipelineExecution":{
"name":"StopPipelineExecution",
@@ -2693,7 +2693,7 @@
"errors":[
{"shape":"ResourceNotFound"}
],
- "documentation":"<p>Stops a training job. To stop a job, Amazon SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms might use this 120-second window to save the model artifacts, so the results of the training is not lost. </p> <p>When it receives a <code>StopTrainingJob</code> request, Amazon SageMaker changes the status of the job to <code>Stopping</code>. After Amazon SageMaker stops the job, it sets the status to <code>Stopped</code>.</p>"
+ "documentation":"<p>Stops a training job. To stop a job, SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms might use this 120-second window to save the model artifacts, so the results of the training is not lost. </p> <p>When it receives a <code>StopTrainingJob</code> request, SageMaker changes the status of the job to <code>Stopping</code>. After SageMaker stops the job, it sets the status to <code>Stopped</code>.</p>"
},
"StopTransformJob":{
"name":"StopTransformJob",
@@ -2819,7 +2819,7 @@
"errors":[
{"shape":"ResourceLimitExceeded"}
],
- "documentation":"<p>Deploys the new <code>EndpointConfig</code> specified in the request, switches to using newly created endpoint, and then deletes resources provisioned for the endpoint using the previous <code>EndpointConfig</code> (there is no availability loss). </p> <p>When Amazon SageMaker receives the request, it sets the endpoint status to <code>Updating</code>. After updating the endpoint, it sets the status to <code>InService</code>. To check the status of an endpoint, use the <a>DescribeEndpoint</a> API. </p> <note> <p>You must not delete an <code>EndpointConfig</code> in use by an endpoint that is live or while the <code>UpdateEndpoint</code> or <code>CreateEndpoint</code> operations are being performed on the endpoint. To update an endpoint, you must create a new <code>EndpointConfig</code>.</p> <p>If you delete the <code>EndpointConfig</code> of an endpoint that is active or being created or updated you may lose visibility into the instance type the endpoint is using. The endpoint must be deleted in order to stop incurring charges.</p> </note>"
+ "documentation":"<p>Deploys the new <code>EndpointConfig</code> specified in the request, switches to using newly created endpoint, and then deletes resources provisioned for the endpoint using the previous <code>EndpointConfig</code> (there is no availability loss). </p> <p>When SageMaker receives the request, it sets the endpoint status to <code>Updating</code>. After updating the endpoint, it sets the status to <code>InService</code>. To check the status of an endpoint, use the <a>DescribeEndpoint</a> API. </p> <note> <p>You must not delete an <code>EndpointConfig</code> in use by an endpoint that is live or while the <code>UpdateEndpoint</code> or <code>CreateEndpoint</code> operations are being performed on the endpoint. To update an endpoint, you must create a new <code>EndpointConfig</code>.</p> <p>If you delete the <code>EndpointConfig</code> of an endpoint that is active or being created or updated you may lose visibility into the instance type the endpoint is using. The endpoint must be deleted in order to stop incurring charges.</p> </note>"
},
"UpdateEndpointWeightsAndCapacities":{
"name":"UpdateEndpointWeightsAndCapacities",
@@ -2832,7 +2832,7 @@
"errors":[
{"shape":"ResourceLimitExceeded"}
],
- "documentation":"<p>Updates variant weight of one or more variants associated with an existing endpoint, or capacity of one variant associated with an existing endpoint. When it receives the request, Amazon SageMaker sets the endpoint status to <code>Updating</code>. After updating the endpoint, it sets the status to <code>InService</code>. To check the status of an endpoint, use the <a>DescribeEndpoint</a> API. </p>"
+ "documentation":"<p>Updates variant weight of one or more variants associated with an existing endpoint, or capacity of one variant associated with an existing endpoint. When it receives the request, SageMaker sets the endpoint status to <code>Updating</code>. After updating the endpoint, it sets the status to <code>InService</code>. To check the status of an endpoint, use the <a>DescribeEndpoint</a> API. </p>"
},
"UpdateExperiment":{
"name":"UpdateExperiment",
@@ -3167,7 +3167,7 @@
"members":{
"Tags":{
"shape":"TagList",
- "documentation":"<p>A list of tags associated with the Amazon SageMaker resource.</p>"
+ "documentation":"<p>A list of tags associated with the SageMaker resource.</p>"
}
}
},
@@ -3288,7 +3288,7 @@
"members":{
"TrainingImage":{
"shape":"AlgorithmImage",
- "documentation":"<p>The registry path of the Docker image that contains the training algorithm. For information about docker registry paths for built-in algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html\">Algorithms Provided by Amazon SageMaker: Common Parameters</a>. Amazon SageMaker supports both <code>registry/repository[:tag]</code> and <code>registry/repository[@digest]</code> image path formats. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>.</p>"
+ "documentation":"<p>The registry path of the Docker image that contains the training algorithm. For information about docker registry paths for built-in algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html\">Algorithms Provided by Amazon SageMaker: Common Parameters</a>. SageMaker supports both <code>registry/repository[:tag]</code> and <code>registry/repository[@digest]</code> image path formats. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>.</p>"
},
"AlgorithmName":{
"shape":"ArnOrName",
@@ -3297,14 +3297,14 @@
"TrainingInputMode":{"shape":"TrainingInputMode"},
"MetricDefinitions":{
"shape":"MetricDefinitionList",
- "documentation":"<p>A list of metric definition objects. Each object specifies the metric name and regular expressions used to parse algorithm logs. Amazon SageMaker publishes each metric to Amazon CloudWatch.</p>"
+ "documentation":"<p>A list of metric definition objects. Each object specifies the metric name and regular expressions used to parse algorithm logs. SageMaker publishes each metric to Amazon CloudWatch.</p>"
},
"EnableSageMakerMetricsTimeSeries":{
"shape":"Boolean",
- "documentation":"<p>To generate and save time-series metrics during training, set to <code>true</code>. The default is <code>false</code> and time-series metrics aren't generated except in the following cases:</p> <ul> <li> <p>You use one of the Amazon SageMaker built-in algorithms</p> </li> <li> <p>You use one of the following <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/pre-built-containers-frameworks-deep-learning.html\">Prebuilt Amazon SageMaker Docker Images</a>:</p> <ul> <li> <p>Tensorflow (version &gt;= 1.15)</p> </li> <li> <p>MXNet (version &gt;= 1.6)</p> </li> <li> <p>PyTorch (version &gt;= 1.3)</p> </li> </ul> </li> <li> <p>You specify at least one <a>MetricDefinition</a> </p> </li> </ul>"
+ "documentation":"<p>To generate and save time-series metrics during training, set to <code>true</code>. The default is <code>false</code> and time-series metrics aren't generated except in the following cases:</p> <ul> <li> <p>You use one of the SageMaker built-in algorithms</p> </li> <li> <p>You use one of the following <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/pre-built-containers-frameworks-deep-learning.html\">Prebuilt SageMaker Docker Images</a>:</p> <ul> <li> <p>Tensorflow (version &gt;= 1.15)</p> </li> <li> <p>MXNet (version &gt;= 1.6)</p> </li> <li> <p>PyTorch (version &gt;= 1.3)</p> </li> </ul> </li> <li> <p>You specify at least one <a>MetricDefinition</a> </p> </li> </ul>"
}
},
- "documentation":"<p>Specifies the training algorithm to use in a <a>CreateTrainingJob</a> request.</p> <p>For more information about algorithms provided by Amazon SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html\">Algorithms</a>. For information about using your own algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>. </p>"
+ "documentation":"<p>Specifies the training algorithm to use in a <a>CreateTrainingJob</a> request.</p> <p>For more information about algorithms provided by SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html\">Algorithms</a>. For information about using your own algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>. </p>"
},
"AlgorithmStatus":{
"type":"string",
@@ -3405,14 +3405,14 @@
},
"TrainingJobDefinition":{
"shape":"TrainingJobDefinition",
- "documentation":"<p>The <code>TrainingJobDefinition</code> object that describes the training job that Amazon SageMaker runs to validate your algorithm.</p>"
+ "documentation":"<p>The <code>TrainingJobDefinition</code> object that describes the training job that SageMaker runs to validate your algorithm.</p>"
},
"TransformJobDefinition":{
"shape":"TransformJobDefinition",
- "documentation":"<p>The <code>TransformJobDefinition</code> object that describes the transform job that Amazon SageMaker runs to validate your algorithm.</p>"
+ "documentation":"<p>The <code>TransformJobDefinition</code> object that describes the transform job that SageMaker runs to validate your algorithm.</p>"
}
},
- "documentation":"<p>Defines a training job and a batch transform job that Amazon SageMaker runs to validate your algorithm.</p> <p>The data provided in the validation profile is made available to your buyers on Amazon Web Services Marketplace.</p>"
+ "documentation":"<p>Defines a training job and a batch transform job that SageMaker runs to validate your algorithm.</p> <p>The data provided in the validation profile is made available to your buyers on Amazon Web Services Marketplace.</p>"
},
"AlgorithmValidationProfiles":{
"type":"list",
@@ -3429,14 +3429,14 @@
"members":{
"ValidationRole":{
"shape":"RoleArn",
- "documentation":"<p>The IAM roles that Amazon SageMaker uses to run the training jobs.</p>"
+ "documentation":"<p>The IAM roles that SageMaker uses to run the training jobs.</p>"
},
"ValidationProfiles":{
"shape":"AlgorithmValidationProfiles",
- "documentation":"<p>An array of <code>AlgorithmValidationProfile</code> objects, each of which specifies a training job and batch transform job that Amazon SageMaker runs to validate your algorithm.</p>"
+ "documentation":"<p>An array of <code>AlgorithmValidationProfile</code> objects, each of which specifies a training job and batch transform job that SageMaker runs to validate your algorithm.</p>"
}
},
- "documentation":"<p>Specifies configurations for one or more training jobs that Amazon SageMaker runs to test the algorithm.</p>"
+ "documentation":"<p>Specifies configurations for one or more training jobs that SageMaker runs to test the algorithm.</p>"
},
"AnnotationConsolidationConfig":{
"type":"structure",
@@ -3852,10 +3852,10 @@
"members":{
"MaxConcurrentInvocationsPerInstance":{
"shape":"MaxConcurrentInvocationsPerInstance",
- "documentation":"<p>The maximum number of concurrent requests sent by the SageMaker client to the model container. If no value is provided, Amazon SageMaker will choose an optimal value for you.</p>"
+ "documentation":"<p>The maximum number of concurrent requests sent by the SageMaker client to the model container. If no value is provided, SageMaker chooses an optimal value.</p>"
}
},
- "documentation":"<p>Configures the behavior of the client used by Amazon SageMaker to interact with the model container during asynchronous inference.</p>"
+ "documentation":"<p>Configures the behavior of the client used by SageMaker to interact with the model container during asynchronous inference.</p>"
},
"AsyncInferenceConfig":{
"type":"structure",
@@ -3863,7 +3863,7 @@
"members":{
"ClientConfig":{
"shape":"AsyncInferenceClientConfig",
- "documentation":"<p>Configures the behavior of the client used by Amazon SageMaker to interact with the model container during asynchronous inference.</p>"
+ "documentation":"<p>Configures the behavior of the client used by SageMaker to interact with the model container during asynchronous inference.</p>"
},
"OutputConfig":{
"shape":"AsyncInferenceOutputConfig",
@@ -3892,7 +3892,7 @@
"members":{
"KmsKeyId":{
"shape":"KmsKeyId",
- "documentation":"<p>The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that Amazon SageMaker uses to encrypt the asynchronous inference output in Amazon S3.</p> <p/>"
+ "documentation":"<p>The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that SageMaker uses to encrypt the asynchronous inference output in Amazon S3.</p> <p/>"
},
"S3OutputPath":{
"shape":"DestinationS3Uri",
@@ -4103,9 +4103,20 @@
"ContentType":{
"shape":"ContentType",
"documentation":"<p>The content type of the data from the input source. You can use <code>text/csv;header=present</code> or <code>x-application/vnd.amazon+parquet</code>. The default value is <code>text/csv;header=present</code>.</p>"
+ },
+ "ChannelType":{
+ "shape":"AutoMLChannelType",
+ "documentation":"<p>The channel type (optional) is an enum string. The default value is <code>training</code>. Channels for training and validation must share the same <code>ContentType</code> and <code>TargetAttributeName</code>.</p>"
}
},
- "documentation":"<p>A channel is a named input source that training algorithms can consume. For more information, see .</p>"
+ "documentation":"<p>A channel is a named input source that training algorithms can consume. The validation dataset size is limited to less than 2 GB. The training dataset size must be less than 100 GB. For more information, see .</p> <note> <p>A validation dataset must contain the same headers as the training dataset.</p> </note> <p/>"
+ },
+ "AutoMLChannelType":{
+ "type":"string",
+ "enum":[
+ "training",
+ "validation"
+ ]
},
"AutoMLContainerDefinition":{
"type":"structure",
@@ -4145,6 +4156,16 @@
},
"documentation":"<p>The data source for the Autopilot job.</p>"
},
+ "AutoMLDataSplitConfig":{
+ "type":"structure",
+ "members":{
+ "ValidationFraction":{
+ "shape":"ValidationFraction",
+ "documentation":"<p>The validation fraction (optional) is a float that specifies the portion of the training dataset to be used for validation. The default value is 0.2, and values can range from 0 to 1. We recommend setting this value to be less than 0.5.</p>"
+ }
+ },
+ "documentation":"<p>This structure specifies how to split the data into train and test datasets. The validation and training datasets must contain the same headers. The validation dataset must be less than 2 GB in size.</p>"
+ },
"AutoMLFailureReason":{
"type":"string",
"max":1024
@@ -4203,6 +4224,10 @@
"SecurityConfig":{
"shape":"AutoMLSecurityConfig",
"documentation":"<p>The security configuration for traffic encryption or Amazon VPC settings.</p>"
+ },
+ "DataSplitConfig":{
+ "shape":"AutoMLDataSplitConfig",
+ "documentation":"<p>The configuration for splitting the input training dataset.</p> <p>Type: AutoMLDataSplitConfig</p>"
}
},
"documentation":"<p>A collection of settings used for an AutoML job.</p>"
@@ -4886,11 +4911,11 @@
},
"RecordWrapperType":{
"shape":"RecordWrapper",
- "documentation":"<p/> <p>Specify RecordIO as the value when input data is in raw format but the training algorithm requires the RecordIO format. In this case, Amazon SageMaker wraps each individual S3 object in a RecordIO record. If the input data is already in RecordIO format, you don't need to set this attribute. For more information, see <a href=\"https://mxnet.apache.org/api/architecture/note_data_loading#data-format\">Create a Dataset Using RecordIO</a>. </p> <p>In File mode, leave this field unset or set it to None.</p>"
+ "documentation":"<p/> <p>Specify RecordIO as the value when input data is in raw format but the training algorithm requires the RecordIO format. In this case, SageMaker wraps each individual S3 object in a RecordIO record. If the input data is already in RecordIO format, you don't need to set this attribute. For more information, see <a href=\"https://mxnet.apache.org/api/architecture/note_data_loading#data-format\">Create a Dataset Using RecordIO</a>. </p> <p>In File mode, leave this field unset or set it to None.</p>"
},
"InputMode":{
"shape":"TrainingInputMode",
- "documentation":"<p>(Optional) The input mode to use for the data channel in a training job. If you don't set a value for <code>InputMode</code>, Amazon SageMaker uses the value set for <code>TrainingInputMode</code>. Use this parameter to override the <code>TrainingInputMode</code> setting in a <a>AlgorithmSpecification</a> request when you have a channel that needs a different input mode from the training job's general setting. To download the data from Amazon Simple Storage Service (Amazon S3) to the provisioned ML storage volume, and mount the directory to a Docker volume, use <code>File</code> input mode. To stream data directly from Amazon S3 to the container, choose <code>Pipe</code> input mode.</p> <p>To use a model for incremental training, choose <code>File</code> input model.</p>"
+ "documentation":"<p>(Optional) The input mode to use for the data channel in a training job. If you don't set a value for <code>InputMode</code>, SageMaker uses the value set for <code>TrainingInputMode</code>. Use this parameter to override the <code>TrainingInputMode</code> setting in a <a>AlgorithmSpecification</a> request when you have a channel that needs a different input mode from the training job's general setting. To download the data from Amazon Simple Storage Service (Amazon S3) to the provisioned ML storage volume, and mount the directory to a Docker volume, use <code>File</code> input mode. To stream data directly from Amazon S3 to the container, choose <code>Pipe</code> input mode.</p> <p>To use a model for incremental training, choose <code>File</code> input model.</p>"
},
"ShuffleConfig":{
"shape":"ShuffleConfig",
@@ -4952,7 +4977,7 @@
"members":{
"S3Uri":{
"shape":"S3Uri",
- "documentation":"<p>Identifies the S3 path where you want Amazon SageMaker to store checkpoints. For example, <code>s3://bucket-name/key-name-prefix</code>.</p>"
+ "documentation":"<p>Identifies the S3 path where you want SageMaker to store checkpoints. For example, <code>s3://bucket-name/key-name-prefix</code>.</p>"
},
"LocalPath":{
"shape":"DirectoryPath",
@@ -5336,7 +5361,7 @@
},
"Image":{
"shape":"ContainerImage",
- "documentation":"<p>The path where inference code is stored. This can be either in Amazon EC2 Container Registry or in a Docker registry that is accessible from the same VPC that you configure for your endpoint. If you are using your own custom algorithm instead of an algorithm provided by Amazon SageMaker, the inference code must meet Amazon SageMaker requirements. Amazon SageMaker supports both <code>registry/repository[:tag]</code> and <code>registry/repository[@digest]</code> image path formats. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a> </p>"
+ "documentation":"<p>The path where inference code is stored. This can be either in Amazon EC2 Container Registry or in a Docker registry that is accessible from the same VPC that you configure for your endpoint. If you are using your own custom algorithm instead of an algorithm provided by SageMaker, the inference code must meet SageMaker requirements. SageMaker supports both <code>registry/repository[:tag]</code> and <code>registry/repository[@digest]</code> image path formats. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a> </p>"
},
"ImageConfig":{
"shape":"ImageConfig",
@@ -5348,7 +5373,7 @@
},
"ModelDataUrl":{
"shape":"Url",
- "documentation":"<p>The S3 path where the model artifacts, which result from model training, are stored. This path must point to a single gzip compressed tar archive (.tar.gz suffix). The S3 path is required for Amazon SageMaker built-in algorithms, but not if you use your own algorithms. For more information on built-in algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html\">Common Parameters</a>. </p> <note> <p>The model artifacts must be in an S3 bucket that is in the same region as the model or endpoint you are creating.</p> </note> <p>If you provide a value for this parameter, Amazon SageMaker uses Amazon Web Services Security Token Service to download model artifacts from the S3 path you provide. Amazon Web Services STS is activated in your IAM user account by default. If you previously deactivated Amazon Web Services STS for a region, you need to reactivate Amazon Web Services STS for that region. For more information, see <a href=\"https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html\">Activating and Deactivating Amazon Web Services STS in an Amazon Web Services Region</a> in the <i>Amazon Web Services Identity and Access Management User Guide</i>.</p> <important> <p>If you use a built-in algorithm to create a model, Amazon SageMaker requires that you provide a S3 path to the model artifacts in <code>ModelDataUrl</code>.</p> </important>"
+ "documentation":"<p>The S3 path where the model artifacts, which result from model training, are stored. This path must point to a single gzip compressed tar archive (.tar.gz suffix). The S3 path is required for SageMaker built-in algorithms, but not if you use your own algorithms. For more information on built-in algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html\">Common Parameters</a>. </p> <note> <p>The model artifacts must be in an S3 bucket that is in the same region as the model or endpoint you are creating.</p> </note> <p>If you provide a value for this parameter, SageMaker uses Amazon Web Services Security Token Service to download model artifacts from the S3 path you provide. Amazon Web Services STS is activated in your IAM user account by default. If you previously deactivated Amazon Web Services STS for a region, you need to reactivate Amazon Web Services STS for that region. For more information, see <a href=\"https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html\">Activating and Deactivating Amazon Web Services STS in an Amazon Web Services Region</a> in the <i>Amazon Web Services Identity and Access Management User Guide</i>.</p> <important> <p>If you use a built-in algorithm to create a model, SageMaker requires that you provide a S3 path to the model artifacts in <code>ModelDataUrl</code>.</p> </important>"
},
"Environment":{
"shape":"EnvironmentMap",
@@ -5508,7 +5533,7 @@
},
"ScalingType":{
"shape":"HyperParameterScalingType",
- "documentation":"<p>The scale that hyperparameter tuning uses to search the hyperparameter range. For information about choosing a hyperparameter scale, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type\">Hyperparameter Scaling</a>. One of the following values:</p> <dl> <dt>Auto</dt> <dd> <p>Amazon SageMaker hyperparameter tuning chooses the best scale for the hyperparameter.</p> </dd> <dt>Linear</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a linear scale.</p> </dd> <dt>Logarithmic</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a logarithmic scale.</p> <p>Logarithmic scaling works only for ranges that have only values greater than 0.</p> </dd> <dt>ReverseLogarithmic</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a reverse logarithmic scale.</p> <p>Reverse logarithmic scaling works only for ranges that are entirely within the range 0&lt;=x&lt;1.0.</p> </dd> </dl>"
+ "documentation":"<p>The scale that hyperparameter tuning uses to search the hyperparameter range. For information about choosing a hyperparameter scale, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type\">Hyperparameter Scaling</a>. One of the following values:</p> <dl> <dt>Auto</dt> <dd> <p>SageMaker hyperparameter tuning chooses the best scale for the hyperparameter.</p> </dd> <dt>Linear</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a linear scale.</p> </dd> <dt>Logarithmic</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a logarithmic scale.</p> <p>Logarithmic scaling works only for ranges that have only values greater than 0.</p> </dd> <dt>ReverseLogarithmic</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a reverse logarithmic scale.</p> <p>Reverse logarithmic scaling works only for ranges that are entirely within the range 0&lt;=x&lt;1.0.</p> </dd> </dl>"
}
},
"documentation":"<p>A list of continuous hyperparameters to tune.</p>"
@@ -5610,7 +5635,7 @@
},
"ValidationSpecification":{
"shape":"AlgorithmValidationSpecification",
- "documentation":"<p>Specifies configurations for one or more training jobs and that Amazon SageMaker runs to test the algorithm's training code and, optionally, one or more batch transform jobs that Amazon SageMaker runs to test the algorithm's inference code.</p>"
+ "documentation":"<p>Specifies configurations for one or more training jobs and that SageMaker runs to test the algorithm's training code and, optionally, one or more batch transform jobs that SageMaker runs to test the algorithm's inference code.</p>"
},
"CertifyForMarketplace":{
"shape":"CertifyForMarketplace",
@@ -6155,7 +6180,7 @@
},
"KmsKeyId":{
"shape":"KmsKeyId",
- "documentation":"<p>The Amazon Resource Name (ARN) of a Amazon Web Services Key Management Service key that Amazon SageMaker uses to encrypt data on the storage volume attached to the ML compute instance that hosts the endpoint.</p> <p>The KmsKeyId can be any of the following formats: </p> <ul> <li> <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> <li> <p>Key ARN: <code>arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> <li> <p>Alias name: <code>alias/ExampleAlias</code> </p> </li> <li> <p>Alias name ARN: <code>arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias</code> </p> </li> </ul> <p>The KMS key policy must grant permission to the IAM role that you specify in your <code>CreateEndpoint</code>, <code>UpdateEndpoint</code> requests. For more information, refer to the Amazon Web Services Key Management Service section<a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html\"> Using Key Policies in Amazon Web Services KMS </a> </p> <note> <p>Certain Nitro-based instances include local storage, dependent on the instance type. Local storage volumes are encrypted using a hardware module on the instance. You can't request a <code>KmsKeyId</code> when using an instance type with local storage. If any of the models that you specify in the <code>ProductionVariants</code> parameter use nitro-based instances with local storage, do not specify a value for the <code>KmsKeyId</code> parameter. If you specify a value for <code>KmsKeyId</code> when using any nitro-based instances with local storage, the call to <code>CreateEndpointConfig</code> fails.</p> <p>For a list of instance types that support local instance storage, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes\">Instance Store Volumes</a>.</p> <p>For more information about local instance storage encryption, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html\">SSD Instance Store Volumes</a>.</p> </note>"
+ "documentation":"<p>The Amazon Resource Name (ARN) of a Amazon Web Services Key Management Service key that SageMaker uses to encrypt data on the storage volume attached to the ML compute instance that hosts the endpoint.</p> <p>The KmsKeyId can be any of the following formats: </p> <ul> <li> <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> <li> <p>Key ARN: <code>arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> <li> <p>Alias name: <code>alias/ExampleAlias</code> </p> </li> <li> <p>Alias name ARN: <code>arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias</code> </p> </li> </ul> <p>The KMS key policy must grant permission to the IAM role that you specify in your <code>CreateEndpoint</code>, <code>UpdateEndpoint</code> requests. For more information, refer to the Amazon Web Services Key Management Service section<a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html\"> Using Key Policies in Amazon Web Services KMS </a> </p> <note> <p>Certain Nitro-based instances include local storage, dependent on the instance type. Local storage volumes are encrypted using a hardware module on the instance. You can't request a <code>KmsKeyId</code> when using an instance type with local storage. If any of the models that you specify in the <code>ProductionVariants</code> parameter use nitro-based instances with local storage, do not specify a value for the <code>KmsKeyId</code> parameter. If you specify a value for <code>KmsKeyId</code> when using any nitro-based instances with local storage, the call to <code>CreateEndpointConfig</code> fails.</p> <p>For a list of instance types that support local instance storage, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes\">Instance Store Volumes</a>.</p> <p>For more information about local instance storage encryption, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html\">SSD Instance Store Volumes</a>.</p> </note>"
},
"AsyncInferenceConfig":{
"shape":"AsyncInferenceConfig",
@@ -6409,7 +6434,7 @@
"members":{
"HyperParameterTuningJobArn":{
"shape":"HyperParameterTuningJobArn",
- "documentation":"<p>The Amazon Resource Name (ARN) of the tuning job. Amazon SageMaker assigns an ARN to a hyperparameter tuning job when you create it.</p>"
+ "documentation":"<p>The Amazon Resource Name (ARN) of the tuning job. SageMaker assigns an ARN to a hyperparameter tuning job when you create it.</p>"
}
}
},
@@ -6461,7 +6486,7 @@
"members":{
"BaseImage":{
"shape":"ImageBaseImage",
- "documentation":"<p>The registry path of the container image to use as the starting point for this version. The path is an Amazon Container Registry (ECR) URI in the following format:</p> <p> <code>&lt;acct-id&gt;.dkr.ecr.&lt;region&gt;.amazonaws.com/&lt;repo-name[:tag] or [@digest]&gt;</code> </p>"
+ "documentation":"<p>The registry path of the container image to use as the starting point for this version. The path is an Amazon Elastic Container Registry (ECR) URI in the following format:</p> <p> <code>&lt;acct-id&gt;.dkr.ecr.&lt;region&gt;.amazonaws.com/&lt;repo-name[:tag] or [@digest]&gt;</code> </p>"
},
"ClientToken":{
"shape":"ClientToken",
@@ -6732,7 +6757,7 @@
},
"ExecutionRoleArn":{
"shape":"RoleArn",
- "documentation":"<p>The Amazon Resource Name (ARN) of the IAM role that Amazon SageMaker can assume to access model artifacts and docker image for deployment on ML compute instances or for batch transform jobs. Deploying on ML compute instances is part of model hosting. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html\">Amazon SageMaker Roles</a>. </p> <note> <p>To be able to pass this role to Amazon SageMaker, the caller of this API must have the <code>iam:PassRole</code> permission.</p> </note>"
+ "documentation":"<p>The Amazon Resource Name (ARN) of the IAM role that SageMaker can assume to access model artifacts and docker image for deployment on ML compute instances or for batch transform jobs. Deploying on ML compute instances is part of model hosting. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html\">SageMaker Roles</a>. </p> <note> <p>To be able to pass this role to SageMaker, the caller of this API must have the <code>iam:PassRole</code> permission.</p> </note>"
},
"Tags":{
"shape":"TagList",
@@ -6754,7 +6779,7 @@
"members":{
"ModelArn":{
"shape":"ModelArn",
- "documentation":"<p>The ARN of the model created in Amazon SageMaker.</p>"
+ "documentation":"<p>The ARN of the model created in SageMaker.</p>"
}
}
},
@@ -6807,7 +6832,7 @@
},
"ValidationSpecification":{
"shape":"ModelPackageValidationSpecification",
- "documentation":"<p>Specifies configurations for one or more transform jobs that Amazon SageMaker runs to test the model package.</p>"
+ "documentation":"<p>Specifies configurations for one or more transform jobs that SageMaker runs to test the model package.</p>"
},
"SourceAlgorithmSpecification":{
"shape":"SourceAlgorithmSpecification",
@@ -6982,11 +7007,11 @@
},
"RoleArn":{
"shape":"RoleArn",
- "documentation":"<p> When you send any requests to Amazon Web Services resources from the notebook instance, Amazon SageMaker assumes this role to perform tasks on your behalf. You must grant this role necessary permissions so Amazon SageMaker can perform these tasks. The policy must allow the Amazon SageMaker service principal (sagemaker.amazonaws.com) permissions to assume this role. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html\">Amazon SageMaker Roles</a>. </p> <note> <p>To be able to pass this role to Amazon SageMaker, the caller of this API must have the <code>iam:PassRole</code> permission.</p> </note>"
+ "documentation":"<p> When you send any requests to Amazon Web Services resources from the notebook instance, SageMaker assumes this role to perform tasks on your behalf. You must grant this role necessary permissions so SageMaker can perform these tasks. The policy must allow the SageMaker service principal (sagemaker.amazonaws.com) permissions to assume this role. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html\">SageMaker Roles</a>. </p> <note> <p>To be able to pass this role to SageMaker, the caller of this API must have the <code>iam:PassRole</code> permission.</p> </note>"
},
"KmsKeyId":{
"shape":"KmsKeyId",
- "documentation":"<p>The Amazon Resource Name (ARN) of a Amazon Web Services Key Management Service key that Amazon SageMaker uses to encrypt data on the storage volume attached to your notebook instance. The KMS key you provide must be enabled. For information, see <a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/enabling-keys.html\">Enabling and Disabling Keys</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>"
+ "documentation":"<p>The Amazon Resource Name (ARN) of a Amazon Web Services Key Management Service key that SageMaker uses to encrypt data on the storage volume attached to your notebook instance. The KMS key you provide must be enabled. For information, see <a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/enabling-keys.html\">Enabling and Disabling Keys</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>"
},
"Tags":{
"shape":"TagList",
@@ -6998,7 +7023,7 @@
},
"DirectInternetAccess":{
"shape":"DirectInternetAccess",
- "documentation":"<p>Sets whether Amazon SageMaker provides internet access to the notebook instance. If you set this to <code>Disabled</code> this notebook instance is able to access resources only in your VPC, and is not be able to connect to Amazon SageMaker training and endpoint services unless you configure a NAT Gateway in your VPC.</p> <p>For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/appendix-additional-considerations.html#appendix-notebook-and-internet-access\">Notebook Instances Are Internet-Enabled by Default</a>. You can set the value of this parameter to <code>Disabled</code> only if you set a value for the <code>SubnetId</code> parameter.</p>"
+ "documentation":"<p>Sets whether SageMaker provides internet access to the notebook instance. If you set this to <code>Disabled</code> this notebook instance is able to access resources only in your VPC, and is not be able to connect to SageMaker training and endpoint services unless you configure a NAT Gateway in your VPC.</p> <p>For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/appendix-additional-considerations.html#appendix-notebook-and-internet-access\">Notebook Instances Are Internet-Enabled by Default</a>. You can set the value of this parameter to <code>Disabled</code> only if you set a value for the <code>SubnetId</code> parameter.</p>"
},
"VolumeSizeInGB":{
"shape":"NotebookInstanceVolumeSizeInGB",
@@ -7010,11 +7035,11 @@
},
"DefaultCodeRepository":{
"shape":"CodeRepositoryNameOrUrl",
- "documentation":"<p>A Git repository to associate with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with Amazon SageMaker Notebook Instances</a>.</p>"
+ "documentation":"<p>A Git repository to associate with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with SageMaker Notebook Instances</a>.</p>"
},
"AdditionalCodeRepositories":{
"shape":"AdditionalCodeRepositoryNamesOrUrls",
- "documentation":"<p>An array of up to three Git repositories to associate with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with Amazon SageMaker Notebook Instances</a>.</p>"
+ "documentation":"<p>An array of up to three Git repositories to associate with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with SageMaker Notebook Instances</a>.</p>"
},
"RootAccess":{
"shape":"RootAccess",
@@ -7331,27 +7356,27 @@
},
"HyperParameters":{
"shape":"HyperParameters",
- "documentation":"<p>Algorithm-specific parameters that influence the quality of the model. You set hyperparameters before you start the learning process. For a list of hyperparameters for each training algorithm provided by Amazon SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html\">Algorithms</a>. </p> <p>You can specify a maximum of 100 hyperparameters. Each hyperparameter is a key-value pair. Each key and value is limited to 256 characters, as specified by the <code>Length Constraint</code>. </p>"
+ "documentation":"<p>Algorithm-specific parameters that influence the quality of the model. You set hyperparameters before you start the learning process. For a list of hyperparameters for each training algorithm provided by SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html\">Algorithms</a>. </p> <p>You can specify a maximum of 100 hyperparameters. Each hyperparameter is a key-value pair. Each key and value is limited to 256 characters, as specified by the <code>Length Constraint</code>. </p>"
},
"AlgorithmSpecification":{
"shape":"AlgorithmSpecification",
- "documentation":"<p>The registry path of the Docker image that contains the training algorithm and algorithm-specific metadata, including the input mode. For more information about algorithms provided by Amazon SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html\">Algorithms</a>. For information about providing your own algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>. </p>"
+ "documentation":"<p>The registry path of the Docker image that contains the training algorithm and algorithm-specific metadata, including the input mode. For more information about algorithms provided by SageMaker, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html\">Algorithms</a>. For information about providing your own algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>. </p>"
},
"RoleArn":{
"shape":"RoleArn",
- "documentation":"<p>The Amazon Resource Name (ARN) of an IAM role that Amazon SageMaker can assume to perform tasks on your behalf. </p> <p>During model training, Amazon SageMaker needs your permission to read input data from an S3 bucket, download a Docker image that contains training code, write model artifacts to an S3 bucket, write logs to Amazon CloudWatch Logs, and publish metrics to Amazon CloudWatch. You grant permissions for all of these tasks to an IAM role. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html\">Amazon SageMaker Roles</a>. </p> <note> <p>To be able to pass this role to Amazon SageMaker, the caller of this API must have the <code>iam:PassRole</code> permission.</p> </note>"
+ "documentation":"<p>The Amazon Resource Name (ARN) of an IAM role that SageMaker can assume to perform tasks on your behalf. </p> <p>During model training, SageMaker needs your permission to read input data from an S3 bucket, download a Docker image that contains training code, write model artifacts to an S3 bucket, write logs to Amazon CloudWatch Logs, and publish metrics to Amazon CloudWatch. You grant permissions for all of these tasks to an IAM role. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html\">SageMaker Roles</a>. </p> <note> <p>To be able to pass this role to SageMaker, the caller of this API must have the <code>iam:PassRole</code> permission.</p> </note>"
},
"InputDataConfig":{
"shape":"InputDataConfig",
- "documentation":"<p>An array of <code>Channel</code> objects. Each channel is a named input source. <code>InputDataConfig</code> describes the input data and its location. </p> <p>Algorithms can accept input data from one or more channels. For example, an algorithm might have two channels of input data, <code>training_data</code> and <code>validation_data</code>. The configuration for each channel provides the S3, EFS, or FSx location where the input data is stored. It also provides information about the stored data: the MIME type, compression method, and whether the data is wrapped in RecordIO format. </p> <p>Depending on the input mode that the algorithm supports, Amazon SageMaker either copies input data files from an S3 bucket to a local directory in the Docker container, or makes it available as input streams. For example, if you specify an EFS location, input data files will be made available as input streams. They do not need to be downloaded.</p>"
+ "documentation":"<p>An array of <code>Channel</code> objects. Each channel is a named input source. <code>InputDataConfig</code> describes the input data and its location. </p> <p>Algorithms can accept input data from one or more channels. For example, an algorithm might have two channels of input data, <code>training_data</code> and <code>validation_data</code>. The configuration for each channel provides the S3, EFS, or FSx location where the input data is stored. It also provides information about the stored data: the MIME type, compression method, and whether the data is wrapped in RecordIO format. </p> <p>Depending on the input mode that the algorithm supports, SageMaker either copies input data files from an S3 bucket to a local directory in the Docker container, or makes it available as input streams. For example, if you specify an EFS location, input data files are available as input streams. They do not need to be downloaded.</p>"
},
"OutputDataConfig":{
"shape":"OutputDataConfig",
- "documentation":"<p>Specifies the path to the S3 location where you want to store model artifacts. Amazon SageMaker creates subfolders for the artifacts. </p>"
+ "documentation":"<p>Specifies the path to the S3 location where you want to store model artifacts. SageMaker creates subfolders for the artifacts. </p>"
},
"ResourceConfig":{
"shape":"ResourceConfig",
- "documentation":"<p>The resources, including the ML compute instances and ML storage volumes, to use for model training. </p> <p>ML storage volumes store model artifacts and incremental states. Training algorithms might also use ML storage volumes for scratch space. If you want Amazon SageMaker to use the ML storage volume to store the training data, choose <code>File</code> as the <code>TrainingInputMode</code> in the algorithm specification. For distributed training algorithms, specify an instance count greater than 1.</p>"
+ "documentation":"<p>The resources, including the ML compute instances and ML storage volumes, to use for model training. </p> <p>ML storage volumes store model artifacts and incremental states. Training algorithms might also use ML storage volumes for scratch space. If you want SageMaker to use the ML storage volume to store the training data, choose <code>File</code> as the <code>TrainingInputMode</code> in the algorithm specification. For distributed training algorithms, specify an instance count greater than 1.</p>"
},
"VpcConfig":{
"shape":"VpcConfig",
@@ -7359,7 +7384,7 @@
},
"StoppingCondition":{
"shape":"StoppingCondition",
- "documentation":"<p>Specifies a limit to how long a model training job can run. It also specifies how long a managed Spot training job has to complete. When the job reaches the time limit, Amazon SageMaker ends the training job. Use this API to cap model training costs.</p> <p>To stop a job, Amazon SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. </p>"
+ "documentation":"<p>Specifies a limit to how long a model training job can run. It also specifies how long a managed Spot training job has to complete. When the job reaches the time limit, SageMaker ends the training job. Use this API to cap model training costs.</p> <p>To stop a job, SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. </p>"
},
"Tags":{
"shape":"TagList",
@@ -7367,7 +7392,7 @@
},
"EnableNetworkIsolation":{
"shape":"Boolean",
- "documentation":"<p>Isolates the training container. No inbound or outbound network calls can be made, except for calls between peers within a training cluster for distributed training. If you enable network isolation for training jobs that are configured to use a VPC, Amazon SageMaker downloads and uploads customer data and model artifacts through the specified VPC, but the training container does not have network access.</p>"
+ "documentation":"<p>Isolates the training container. No inbound or outbound network calls can be made, except for calls between peers within a training cluster for distributed training. If you enable network isolation for training jobs that are configured to use a VPC, SageMaker downloads and uploads customer data and model artifacts through the specified VPC, but the training container does not have network access.</p>"
},
"EnableInterContainerTrafficEncryption":{
"shape":"Boolean",
@@ -7441,7 +7466,7 @@
},
"MaxPayloadInMB":{
"shape":"MaxPayloadInMB",
- "documentation":"<p>The maximum allowed size of the payload, in MB. A <i>payload</i> is the data portion of a record (without metadata). The value in <code>MaxPayloadInMB</code> must be greater than, or equal to, the size of a single record. To estimate the size of a record in MB, divide the size of your dataset by the number of records. To ensure that the records fit within the maximum payload size, we recommend using a slightly larger value. The default value is <code>6</code> MB. </p> <p>For cases where the payload might be arbitrarily large and is transmitted using HTTP chunked encoding, set the value to <code>0</code>. This feature works only in supported algorithms. Currently, Amazon SageMaker built-in algorithms do not support HTTP chunked encoding.</p>"
+ "documentation":"<p>The maximum allowed size of the payload, in MB. A <i>payload</i> is the data portion of a record (without metadata). The value in <code>MaxPayloadInMB</code> must be greater than, or equal to, the size of a single record. To estimate the size of a record in MB, divide the size of your dataset by the number of records. To ensure that the records fit within the maximum payload size, we recommend using a slightly larger value. The default value is <code>6</code> MB. </p> <p>The value of <code>MaxPayloadInMB</code> cannot be greater than 100 MB. If you specify the <code>MaxConcurrentTransforms</code> parameter, the value of <code>(MaxConcurrentTransforms * MaxPayloadInMB)</code> also cannot exceed 100 MB.</p> <p>For cases where the payload might be arbitrarily large and is transmitted using HTTP chunked encoding, set the value to <code>0</code>. This feature works only in supported algorithms. Currently, Amazon SageMaker built-in algorithms do not support HTTP chunked encoding.</p>"
},
"BatchStrategy":{
"shape":"BatchStrategy",
@@ -7866,11 +7891,11 @@
"members":{
"InputFilter":{
"shape":"JsonPath",
- "documentation":"<p>A <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/batch-transform-data-processing.html#data-processing-operators\">JSONPath</a> expression used to select a portion of the input data to pass to the algorithm. Use the <code>InputFilter</code> parameter to exclude fields, such as an ID column, from the input. If you want Amazon SageMaker to pass the entire input dataset to the algorithm, accept the default value <code>$</code>.</p> <p>Examples: <code>\"$\"</code>, <code>\"$[1:]\"</code>, <code>\"$.features\"</code> </p>"
+ "documentation":"<p>A <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/batch-transform-data-processing.html#data-processing-operators\">JSONPath</a> expression used to select a portion of the input data to pass to the algorithm. Use the <code>InputFilter</code> parameter to exclude fields, such as an ID column, from the input. If you want SageMaker to pass the entire input dataset to the algorithm, accept the default value <code>$</code>.</p> <p>Examples: <code>\"$\"</code>, <code>\"$[1:]\"</code>, <code>\"$.features\"</code> </p>"
},
"OutputFilter":{
"shape":"JsonPath",
- "documentation":"<p>A <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/batch-transform-data-processing.html#data-processing-operators\">JSONPath</a> expression used to select a portion of the joined dataset to save in the output file for a batch transform job. If you want Amazon SageMaker to store the entire input dataset in the output file, leave the default value, <code>$</code>. If you specify indexes that aren't within the dimension size of the joined dataset, you get an error.</p> <p>Examples: <code>\"$\"</code>, <code>\"$[0,5:]\"</code>, <code>\"$['id','SageMakerOutput']\"</code> </p>"
+ "documentation":"<p>A <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/batch-transform-data-processing.html#data-processing-operators\">JSONPath</a> expression used to select a portion of the joined dataset to save in the output file for a batch transform job. If you want SageMaker to store the entire input dataset in the output file, leave the default value, <code>$</code>. If you specify indexes that aren't within the dimension size of the joined dataset, you get an error.</p> <p>Examples: <code>\"$\"</code>, <code>\"$[0,5:]\"</code>, <code>\"$['id','SageMakerOutput']\"</code> </p>"
},
"JoinSource":{
"shape":"JoinSource",
@@ -8462,7 +8487,7 @@
"members":{
"NotebookInstanceName":{
"shape":"NotebookInstanceName",
- "documentation":"<p>The name of the Amazon SageMaker notebook instance to delete.</p>"
+ "documentation":"<p>The name of the SageMaker notebook instance to delete.</p>"
}
}
},
@@ -8794,7 +8819,7 @@
},
"ValidationSpecification":{
"shape":"AlgorithmValidationSpecification",
- "documentation":"<p>Details about configurations for one or more training jobs that Amazon SageMaker runs to test the algorithm.</p>"
+ "documentation":"<p>Details about configurations for one or more training jobs that SageMaker runs to test the algorithm.</p>"
},
"AlgorithmStatus":{
"shape":"AlgorithmStatus",
@@ -9662,7 +9687,7 @@
"members":{
"EndpointConfigName":{
"shape":"EndpointConfigName",
- "documentation":"<p>Name of the Amazon SageMaker endpoint configuration.</p>"
+ "documentation":"<p>Name of the SageMaker endpoint configuration.</p>"
},
"EndpointConfigArn":{
"shape":"EndpointConfigArn",
@@ -10331,7 +10356,7 @@
},
"RoleArn":{
"shape":"RoleArn",
- "documentation":"<p>The Amazon Resource Name (ARN) that Amazon SageMaker assumes to perform tasks on your behalf during data labeling.</p>"
+ "documentation":"<p>The Amazon Resource Name (ARN) that SageMaker assumes to perform tasks on your behalf during data labeling.</p>"
},
"LabelCategoryConfigS3Uri":{
"shape":"S3Uri",
@@ -10541,7 +10566,7 @@
"members":{
"ModelName":{
"shape":"ModelName",
- "documentation":"<p>Name of the Amazon SageMaker model.</p>"
+ "documentation":"<p>Name of the SageMaker model.</p>"
},
"PrimaryContainer":{
"shape":"ContainerDefinition",
@@ -10583,7 +10608,7 @@
"members":{
"ModelPackageGroupName":{
"shape":"ArnOrName",
- "documentation":"<p>The name of the model group to describe.</p>"
+ "documentation":"<p>The name of gthe model group to describe.</p>"
}
}
},
@@ -10700,7 +10725,7 @@
},
"LastModifiedTime":{
"shape":"Timestamp",
- "documentation":"<p>The last time the model package was modified.</p>"
+ "documentation":"<p>The last time that the model package was modified.</p>"
},
"LastModifiedBy":{"shape":"UserContext"},
"ApprovalDescription":{
@@ -10914,7 +10939,7 @@
},
"NotebookInstanceName":{
"shape":"NotebookInstanceName",
- "documentation":"<p>The name of the Amazon SageMaker notebook instance. </p>"
+ "documentation":"<p>The name of the SageMaker notebook instance. </p>"
},
"NotebookInstanceStatus":{
"shape":"NotebookInstanceStatus",
@@ -10946,11 +10971,11 @@
},
"KmsKeyId":{
"shape":"KmsKeyId",
- "documentation":"<p>The Amazon Web Services KMS key ID Amazon SageMaker uses to encrypt data when storing it on the ML storage volume attached to the instance. </p>"
+ "documentation":"<p>The Amazon Web Services KMS key ID SageMaker uses to encrypt data when storing it on the ML storage volume attached to the instance. </p>"
},
"NetworkInterfaceId":{
"shape":"NetworkInterfaceId",
- "documentation":"<p>The network interface IDs that Amazon SageMaker created at the time of creating the instance. </p>"
+ "documentation":"<p>The network interface IDs that SageMaker created at the time of creating the instance. </p>"
},
"LastModifiedTime":{
"shape":"LastModifiedTime",
@@ -10966,7 +10991,7 @@
},
"DirectInternetAccess":{
"shape":"DirectInternetAccess",
- "documentation":"<p>Describes whether Amazon SageMaker provides internet access to the notebook instance. If this value is set to <i>Disabled</i>, the notebook instance does not have internet access, and cannot connect to Amazon SageMaker training and endpoint services.</p> <p>For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/appendix-additional-considerations.html#appendix-notebook-and-internet-access\">Notebook Instances Are Internet-Enabled by Default</a>.</p>"
+ "documentation":"<p>Describes whether SageMaker provides internet access to the notebook instance. If this value is set to <i>Disabled</i>, the notebook instance does not have internet access, and cannot connect to SageMaker training and endpoint services.</p> <p>For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/appendix-additional-considerations.html#appendix-notebook-and-internet-access\">Notebook Instances Are Internet-Enabled by Default</a>.</p>"
},
"VolumeSizeInGB":{
"shape":"NotebookInstanceVolumeSizeInGB",
@@ -10978,11 +11003,11 @@
},
"DefaultCodeRepository":{
"shape":"CodeRepositoryNameOrUrl",
- "documentation":"<p>The Git repository associated with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with Amazon SageMaker Notebook Instances</a>.</p>"
+ "documentation":"<p>The Git repository associated with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with SageMaker Notebook Instances</a>.</p>"
},
"AdditionalCodeRepositories":{
"shape":"AdditionalCodeRepositoryNamesOrUrls",
- "documentation":"<p>An array of up to three Git repositories associated with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with Amazon SageMaker Notebook Instances</a>.</p>"
+ "documentation":"<p>An array of up to three Git repositories associated with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with SageMaker Notebook Instances</a>.</p>"
},
"RootAccess":{
"shape":"RootAccess",
@@ -11397,7 +11422,7 @@
},
"LabelingJobArn":{
"shape":"LabelingJobArn",
- "documentation":"<p>The Amazon Resource Name (ARN) of the Amazon SageMaker Ground Truth labeling job that created the transform or training job.</p>"
+ "documentation":"<p>The Amazon Resource Name (ARN) of the SageMaker Ground Truth labeling job that created the transform or training job.</p>"
},
"AutoMLJobArn":{
"shape":"AutoMLJobArn",
@@ -11409,11 +11434,11 @@
},
"TrainingJobStatus":{
"shape":"TrainingJobStatus",
- "documentation":"<p>The status of the training job.</p> <p>Amazon SageMaker provides the following training job statuses:</p> <ul> <li> <p> <code>InProgress</code> - The training is in progress.</p> </li> <li> <p> <code>Completed</code> - The training job has completed.</p> </li> <li> <p> <code>Failed</code> - The training job has failed. To see the reason for the failure, see the <code>FailureReason</code> field in the response to a <code>DescribeTrainingJobResponse</code> call.</p> </li> <li> <p> <code>Stopping</code> - The training job is stopping.</p> </li> <li> <p> <code>Stopped</code> - The training job has stopped.</p> </li> </ul> <p>For more detailed information, see <code>SecondaryStatus</code>. </p>"
+ "documentation":"<p>The status of the training job.</p> <p>SageMaker provides the following training job statuses:</p> <ul> <li> <p> <code>InProgress</code> - The training is in progress.</p> </li> <li> <p> <code>Completed</code> - The training job has completed.</p> </li> <li> <p> <code>Failed</code> - The training job has failed. To see the reason for the failure, see the <code>FailureReason</code> field in the response to a <code>DescribeTrainingJobResponse</code> call.</p> </li> <li> <p> <code>Stopping</code> - The training job is stopping.</p> </li> <li> <p> <code>Stopped</code> - The training job has stopped.</p> </li> </ul> <p>For more detailed information, see <code>SecondaryStatus</code>. </p>"
},
"SecondaryStatus":{
"shape":"SecondaryStatus",
- "documentation":"<p> Provides detailed information about the state of the training job. For detailed information on the secondary status of the training job, see <code>StatusMessage</code> under <a>SecondaryStatusTransition</a>.</p> <p>Amazon SageMaker provides primary statuses and secondary statuses that apply to each of them:</p> <dl> <dt>InProgress</dt> <dd> <ul> <li> <p> <code>Starting</code> - Starting the training job.</p> </li> <li> <p> <code>Downloading</code> - An optional stage for algorithms that support <code>File</code> training input mode. It indicates that data is being downloaded to the ML storage volumes.</p> </li> <li> <p> <code>Training</code> - Training is in progress.</p> </li> <li> <p> <code>Interrupted</code> - The job stopped because the managed spot training instances were interrupted. </p> </li> <li> <p> <code>Uploading</code> - Training is complete and the model artifacts are being uploaded to the S3 location.</p> </li> </ul> </dd> <dt>Completed</dt> <dd> <ul> <li> <p> <code>Completed</code> - The training job has completed.</p> </li> </ul> </dd> <dt>Failed</dt> <dd> <ul> <li> <p> <code>Failed</code> - The training job has failed. The reason for the failure is returned in the <code>FailureReason</code> field of <code>DescribeTrainingJobResponse</code>.</p> </li> </ul> </dd> <dt>Stopped</dt> <dd> <ul> <li> <p> <code>MaxRuntimeExceeded</code> - The job stopped because it exceeded the maximum allowed runtime.</p> </li> <li> <p> <code>MaxWaitTimeExceeded</code> - The job stopped because it exceeded the maximum allowed wait time.</p> </li> <li> <p> <code>Stopped</code> - The training job has stopped.</p> </li> </ul> </dd> <dt>Stopping</dt> <dd> <ul> <li> <p> <code>Stopping</code> - Stopping the training job.</p> </li> </ul> </dd> </dl> <important> <p>Valid values for <code>SecondaryStatus</code> are subject to change. </p> </important> <p>We no longer support the following secondary statuses:</p> <ul> <li> <p> <code>LaunchingMLInstances</code> </p> </li> <li> <p> <code>PreparingTraining</code> </p> </li> <li> <p> <code>DownloadingTrainingImage</code> </p> </li> </ul>"
+ "documentation":"<p> Provides detailed information about the state of the training job. For detailed information on the secondary status of the training job, see <code>StatusMessage</code> under <a>SecondaryStatusTransition</a>.</p> <p>SageMaker provides primary statuses and secondary statuses that apply to each of them:</p> <dl> <dt>InProgress</dt> <dd> <ul> <li> <p> <code>Starting</code> - Starting the training job.</p> </li> <li> <p> <code>Downloading</code> - An optional stage for algorithms that support <code>File</code> training input mode. It indicates that data is being downloaded to the ML storage volumes.</p> </li> <li> <p> <code>Training</code> - Training is in progress.</p> </li> <li> <p> <code>Interrupted</code> - The job stopped because the managed spot training instances were interrupted. </p> </li> <li> <p> <code>Uploading</code> - Training is complete and the model artifacts are being uploaded to the S3 location.</p> </li> </ul> </dd> <dt>Completed</dt> <dd> <ul> <li> <p> <code>Completed</code> - The training job has completed.</p> </li> </ul> </dd> <dt>Failed</dt> <dd> <ul> <li> <p> <code>Failed</code> - The training job has failed. The reason for the failure is returned in the <code>FailureReason</code> field of <code>DescribeTrainingJobResponse</code>.</p> </li> </ul> </dd> <dt>Stopped</dt> <dd> <ul> <li> <p> <code>MaxRuntimeExceeded</code> - The job stopped because it exceeded the maximum allowed runtime.</p> </li> <li> <p> <code>MaxWaitTimeExceeded</code> - The job stopped because it exceeded the maximum allowed wait time.</p> </li> <li> <p> <code>Stopped</code> - The training job has stopped.</p> </li> </ul> </dd> <dt>Stopping</dt> <dd> <ul> <li> <p> <code>Stopping</code> - Stopping the training job.</p> </li> </ul> </dd> </dl> <important> <p>Valid values for <code>SecondaryStatus</code> are subject to change. </p> </important> <p>We no longer support the following secondary statuses:</p> <ul> <li> <p> <code>LaunchingMLInstances</code> </p> </li> <li> <p> <code>PreparingTraining</code> </p> </li> <li> <p> <code>DownloadingTrainingImage</code> </p> </li> </ul>"
},
"FailureReason":{
"shape":"FailureReason",
@@ -11437,7 +11462,7 @@
},
"OutputDataConfig":{
"shape":"OutputDataConfig",
- "documentation":"<p>The S3 path where model artifacts that you configured when creating the job are stored. Amazon SageMaker creates subfolders for model artifacts. </p>"
+ "documentation":"<p>The S3 path where model artifacts that you configured when creating the job are stored. SageMaker creates subfolders for model artifacts. </p>"
},
"ResourceConfig":{
"shape":"ResourceConfig",
@@ -11449,7 +11474,7 @@
},
"StoppingCondition":{
"shape":"StoppingCondition",
- "documentation":"<p>Specifies a limit to how long a model training job can run. It also specifies how long a managed Spot training job has to complete. When the job reaches the time limit, Amazon SageMaker ends the training job. Use this API to cap model training costs.</p> <p>To stop a job, Amazon SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. </p>"
+ "documentation":"<p>Specifies a limit to how long a model training job can run. It also specifies how long a managed Spot training job has to complete. When the job reaches the time limit, SageMaker ends the training job. Use this API to cap model training costs.</p> <p>To stop a job, SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. </p>"
},
"CreationTime":{
"shape":"Timestamp",
@@ -11461,7 +11486,7 @@
},
"TrainingEndTime":{
"shape":"Timestamp",
- "documentation":"<p>Indicates the time when the training job ends on training instances. You are billed for the time interval between the value of <code>TrainingStartTime</code> and this time. For successful jobs and stopped jobs, this is the time after model artifacts are uploaded. For failed jobs, this is the time when Amazon SageMaker detects a job failure.</p>"
+ "documentation":"<p>Indicates the time when the training job ends on training instances. You are billed for the time interval between the value of <code>TrainingStartTime</code> and this time. For successful jobs and stopped jobs, this is the time after model artifacts are uploaded. For failed jobs, this is the time when SageMaker detects a job failure.</p>"
},
"LastModifiedTime":{
"shape":"Timestamp",
@@ -11477,7 +11502,7 @@
},
"EnableNetworkIsolation":{
"shape":"Boolean",
- "documentation":"<p>If you want to allow inbound or outbound network calls, except for calls between peers within a training cluster for distributed training, choose <code>True</code>. If you enable network isolation for training jobs that are configured to use a VPC, Amazon SageMaker downloads and uploads customer data and model artifacts through the specified VPC, but the training container does not have network access.</p>"
+ "documentation":"<p>If you want to allow inbound or outbound network calls, except for calls between peers within a training cluster for distributed training, choose <code>True</code>. If you enable network isolation for training jobs that are configured to use a VPC, SageMaker downloads and uploads customer data and model artifacts through the specified VPC, but the training container does not have network access.</p>"
},
"EnableInterContainerTrafficEncryption":{
"shape":"Boolean",
@@ -11494,7 +11519,7 @@
},
"BillableTimeInSeconds":{
"shape":"BillableTimeInSeconds",
- "documentation":"<p>The billable time in seconds. Billable time refers to the absolute wall-clock time.</p> <p>Multiply <code>BillableTimeInSeconds</code> by the number of instances (<code>InstanceCount</code>) in your training cluster to get the total compute time SageMaker will bill you if you run distributed training. The formula is as follows: <code>BillableTimeInSeconds * InstanceCount</code> .</p> <p>You can calculate the savings from using managed spot training using the formula <code>(1 - BillableTimeInSeconds / TrainingTimeInSeconds) * 100</code>. For example, if <code>BillableTimeInSeconds</code> is 100 and <code>TrainingTimeInSeconds</code> is 500, the savings is 80%.</p>"
+ "documentation":"<p>The billable time in seconds. Billable time refers to the absolute wall-clock time.</p> <p>Multiply <code>BillableTimeInSeconds</code> by the number of instances (<code>InstanceCount</code>) in your training cluster to get the total compute time SageMaker bills you if you run distributed training. The formula is as follows: <code>BillableTimeInSeconds * InstanceCount</code> .</p> <p>You can calculate the savings from using managed spot training using the formula <code>(1 - BillableTimeInSeconds / TrainingTimeInSeconds) * 100</code>. For example, if <code>BillableTimeInSeconds</code> is 100 and <code>TrainingTimeInSeconds</code> is 500, the savings is 80%.</p>"
},
"DebugHookConfig":{"shape":"DebugHookConfig"},
"ExperimentConfig":{"shape":"ExperimentConfig"},
@@ -13961,7 +13986,7 @@
"members":{
"TrainingImage":{
"shape":"AlgorithmImage",
- "documentation":"<p> The registry path of the Docker image that contains the training algorithm. For information about Docker registry paths for built-in algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html\">Algorithms Provided by Amazon SageMaker: Common Parameters</a>. Amazon SageMaker supports both <code>registry/repository[:tag]</code> and <code>registry/repository[@digest]</code> image path formats. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>.</p>"
+ "documentation":"<p> The registry path of the Docker image that contains the training algorithm. For information about Docker registry paths for built-in algorithms, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html\">Algorithms Provided by Amazon SageMaker: Common Parameters</a>. SageMaker supports both <code>registry/repository[:tag]</code> and <code>registry/repository[@digest]</code> image path formats. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>.</p>"
},
"TrainingInputMode":{"shape":"TrainingInputMode"},
"AlgorithmName":{
@@ -14075,15 +14100,15 @@
},
"ResourceConfig":{
"shape":"ResourceConfig",
- "documentation":"<p>The resources, including the compute instances and storage volumes, to use for the training jobs that the tuning job launches.</p> <p>Storage volumes store model artifacts and incremental states. Training algorithms might also use storage volumes for scratch space. If you want Amazon SageMaker to use the storage volume to store the training data, choose <code>File</code> as the <code>TrainingInputMode</code> in the algorithm specification. For distributed training algorithms, specify an instance count greater than 1.</p>"
+ "documentation":"<p>The resources, including the compute instances and storage volumes, to use for the training jobs that the tuning job launches.</p> <p>Storage volumes store model artifacts and incremental states. Training algorithms might also use storage volumes for scratch space. If you want SageMaker to use the storage volume to store the training data, choose <code>File</code> as the <code>TrainingInputMode</code> in the algorithm specification. For distributed training algorithms, specify an instance count greater than 1.</p>"
},
"StoppingCondition":{
"shape":"StoppingCondition",
- "documentation":"<p>Specifies a limit to how long a model hyperparameter training job can run. It also specifies how long a managed spot training job has to complete. When the job reaches the time limit, Amazon SageMaker ends the training job. Use this API to cap model training costs.</p>"
+ "documentation":"<p>Specifies a limit to how long a model hyperparameter training job can run. It also specifies how long a managed spot training job has to complete. When the job reaches the time limit, SageMaker ends the training job. Use this API to cap model training costs.</p>"
},
"EnableNetworkIsolation":{
"shape":"Boolean",
- "documentation":"<p>Isolates the training container. No inbound or outbound network calls can be made, except for calls between peers within a training cluster for distributed training. If network isolation is used for training jobs that are configured to use a VPC, Amazon SageMaker downloads and uploads customer data and model artifacts through the specified VPC, but the training container does not have network access.</p>"
+ "documentation":"<p>Isolates the training container. No inbound or outbound network calls can be made, except for calls between peers within a training cluster for distributed training. If network isolation is used for training jobs that are configured to use a VPC, SageMaker downloads and uploads customer data and model artifacts through the specified VPC, but the training container does not have network access.</p>"
},
"EnableInterContainerTrafficEncryption":{
"shape":"Boolean",
@@ -14153,7 +14178,7 @@
},
"TrainingEndTime":{
"shape":"Timestamp",
- "documentation":"<p>Specifies the time when the training job ends on training instances. You are billed for the time interval between the value of <code>TrainingStartTime</code> and this time. For successful jobs and stopped jobs, this is the time after model artifacts are uploaded. For failed jobs, this is the time when Amazon SageMaker detects a job failure.</p>"
+ "documentation":"<p>Specifies the time when the training job ends on training instances. You are billed for the time interval between the value of <code>TrainingStartTime</code> and this time. For successful jobs and stopped jobs, this is the time after model artifacts are uploaded. For failed jobs, this is the time when SageMaker detects a job failure.</p>"
},
"TrainingJobStatus":{
"shape":"TrainingJobStatus",
@@ -14176,7 +14201,7 @@
"documentation":"<p>The status of the objective metric for the training job:</p> <ul> <li> <p>Succeeded: The final objective metric for the training job was evaluated by the hyperparameter tuning job and used in the hyperparameter tuning process.</p> </li> </ul> <ul> <li> <p>Pending: The training job is in progress and evaluation of its final objective metric is pending.</p> </li> </ul> <ul> <li> <p>Failed: The final objective metric for the training job was not evaluated, and was not used in the hyperparameter tuning process. This typically occurs when the training job failed or did not emit an objective metric.</p> </li> </ul>"
}
},
- "documentation":"<p>Specifies summary information about a training job.</p>"
+ "documentation":"<p>The container for the summary information about a training job.</p>"
},
"HyperParameterTuningJobArn":{
"type":"string",
@@ -14208,7 +14233,7 @@
},
"TrainingJobEarlyStoppingType":{
"shape":"TrainingJobEarlyStoppingType",
- "documentation":"<p>Specifies whether to use early stopping for training jobs launched by the hyperparameter tuning job. This can be one of the following values (the default value is <code>OFF</code>):</p> <dl> <dt>OFF</dt> <dd> <p>Training jobs launched by the hyperparameter tuning job do not use early stopping.</p> </dd> <dt>AUTO</dt> <dd> <p>Amazon SageMaker stops training jobs launched by the hyperparameter tuning job when they are unlikely to perform better than previously completed training jobs. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-early-stopping.html\">Stop Training Jobs Early</a>.</p> </dd> </dl>"
+ "documentation":"<p>Specifies whether to use early stopping for training jobs launched by the hyperparameter tuning job. This can be one of the following values (the default value is <code>OFF</code>):</p> <dl> <dt>OFF</dt> <dd> <p>Training jobs launched by the hyperparameter tuning job do not use early stopping.</p> </dd> <dt>AUTO</dt> <dd> <p>SageMaker stops training jobs launched by the hyperparameter tuning job when they are unlikely to perform better than previously completed training jobs. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-early-stopping.html\">Stop Training Jobs Early</a>.</p> </dd> </dl>"
},
"TuningJobCompletionCriteria":{
"shape":"TuningJobCompletionCriteria",
@@ -14908,7 +14933,7 @@
},
"ScalingType":{
"shape":"HyperParameterScalingType",
- "documentation":"<p>The scale that hyperparameter tuning uses to search the hyperparameter range. For information about choosing a hyperparameter scale, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type\">Hyperparameter Scaling</a>. One of the following values:</p> <dl> <dt>Auto</dt> <dd> <p>Amazon SageMaker hyperparameter tuning chooses the best scale for the hyperparameter.</p> </dd> <dt>Linear</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a linear scale.</p> </dd> <dt>Logarithmic</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a logarithmic scale.</p> <p>Logarithmic scaling works only for ranges that have only values greater than 0.</p> </dd> </dl>"
+ "documentation":"<p>The scale that hyperparameter tuning uses to search the hyperparameter range. For information about choosing a hyperparameter scale, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-ranges.html#scaling-type\">Hyperparameter Scaling</a>. One of the following values:</p> <dl> <dt>Auto</dt> <dd> <p>SageMaker hyperparameter tuning chooses the best scale for the hyperparameter.</p> </dd> <dt>Linear</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a linear scale.</p> </dd> <dt>Logarithmic</dt> <dd> <p>Hyperparameter tuning searches the values in the hyperparameter range by using a logarithmic scale.</p> <p>Logarithmic scaling works only for ranges that have only values greater than 0.</p> </dd> </dl>"
}
},
"documentation":"<p>For a hyperparameter of the integer type, specifies the range that a hyperparameter tuning job searches.</p>"
@@ -14996,11 +15021,11 @@
"members":{
"DefaultResourceSpec":{
"shape":"ResourceSpec",
- "documentation":"<p>The default instance type and the Amazon Resource Name (ARN) of the default SageMaker image used by the JupyterServer app.</p>"
+ "documentation":"<p>The default instance type and the Amazon Resource Name (ARN) of the default SageMaker image used by the JupyterServer app. If you use the <code>LifecycleConfigArns</code> parameter, then this parameter is also required.</p>"
},
"LifecycleConfigArns":{
"shape":"LifecycleConfigArns",
- "documentation":"<p> The Amazon Resource Name (ARN) of the Lifecycle Configurations attached to the JupyterServerApp.</p>"
+ "documentation":"<p> The Amazon Resource Name (ARN) of the Lifecycle Configurations attached to the JupyterServerApp. If you use this parameter, the <code>DefaultResourceSpec</code> parameter is also required.</p> <note> <p>To remove a Lifecycle Config, you must set <code>LifecycleConfigArns</code> to an empty list.</p> </note>"
}
},
"documentation":"<p>The JupyterServer app settings.</p>"
@@ -15014,7 +15039,7 @@
"members":{
"DefaultResourceSpec":{
"shape":"ResourceSpec",
- "documentation":"<p>The default instance type and the Amazon Resource Name (ARN) of the default SageMaker image used by the KernelGateway app.</p>"
+ "documentation":"<p>The default instance type and the Amazon Resource Name (ARN) of the default SageMaker image used by the KernelGateway app.</p> <note> <p>The Amazon SageMaker Studio UI does not use the default instance type value set here. The default instance type set here is used when Apps are created using the Amazon Web Services Command Line Interface or Amazon Web Services CloudFormation and the instance type parameter value is not passed.</p> </note>"
},
"CustomImages":{
"shape":"CustomImages",
@@ -15022,7 +15047,7 @@
},
"LifecycleConfigArns":{
"shape":"LifecycleConfigArns",
- "documentation":"<p> The Amazon Resource Name (ARN) of the Lifecycle Configurations attached to the the user profile or domain.</p>"
+ "documentation":"<p> The Amazon Resource Name (ARN) of the Lifecycle Configurations attached to the the user profile or domain.</p> <note> <p>To remove a Lifecycle Config, you must set <code>LifecycleConfigArns</code> to an empty list.</p> </note>"
}
},
"documentation":"<p>The KernelGateway app settings.</p>"
@@ -15166,7 +15191,7 @@
"members":{
"ContentClassifiers":{
"shape":"ContentClassifiers",
- "documentation":"<p>Declares that your content is free of personally identifiable information or adult content. Amazon SageMaker may restrict the Amazon Mechanical Turk workers that can view your task based on this information.</p>"
+ "documentation":"<p>Declares that your content is free of personally identifiable information or adult content. SageMaker may restrict the Amazon Mechanical Turk workers that can view your task based on this information.</p>"
}
},
"documentation":"<p>Attributes of the data specified by the customer. Use these to describe the data to be labeled.</p>"
@@ -15255,7 +15280,7 @@
},
"FinalActiveLearningModelArn":{
"shape":"ModelArn",
- "documentation":"<p>The Amazon Resource Name (ARN) for the most recent Amazon SageMaker model trained as part of automated data labeling. </p>"
+ "documentation":"<p>The Amazon Resource Name (ARN) for the most recent SageMaker model trained as part of automated data labeling. </p>"
}
},
"documentation":"<p>Specifies the location of the output produced by the labeling job. </p>"
@@ -15577,7 +15602,7 @@
},
"NextToken":{
"shape":"NextToken",
- "documentation":"<p>If the response is truncated, Amazon SageMaker returns this token. To retrieve the next set of algorithms, use it in the subsequent request.</p>"
+ "documentation":"<p>If the response is truncated, SageMaker returns this token. To retrieve the next set of algorithms, use it in the subsequent request.</p>"
}
}
},
@@ -16369,7 +16394,7 @@
},
"NextToken":{
"shape":"PaginationToken",
- "documentation":"<p> If the response is truncated, Amazon SageMaker returns this token. To retrieve the next set of endpoint configurations, use it in the subsequent request </p>"
+ "documentation":"<p> If the response is truncated, SageMaker returns this token. To retrieve the next set of endpoint configurations, use it in the subsequent request </p>"
}
}
},
@@ -16428,7 +16453,7 @@
},
"NextToken":{
"shape":"PaginationToken",
- "documentation":"<p> If the response is truncated, Amazon SageMaker returns this token. To retrieve the next set of training jobs, use it in the subsequent request. </p>"
+ "documentation":"<p> If the response is truncated, SageMaker returns this token. To retrieve the next set of training jobs, use it in the subsequent request. </p>"
}
}
},
@@ -16896,7 +16921,7 @@
},
"NextToken":{
"shape":"NextToken",
- "documentation":"<p>If the response is truncated, Amazon SageMaker returns this token. To retrieve the next set of labeling jobs, use it in the subsequent request.</p>"
+ "documentation":"<p>If the response is truncated, SageMaker returns this token. To retrieve the next set of labeling jobs, use it in the subsequent request.</p>"
}
}
},
@@ -16958,7 +16983,7 @@
},
"NextToken":{
"shape":"NextToken",
- "documentation":"<p>If the response is truncated, Amazon SageMaker returns this token. To retrieve the next set of labeling jobs, use it in the subsequent request.</p>"
+ "documentation":"<p>If the response is truncated, SageMaker returns this token. To retrieve the next set of labeling jobs, use it in the subsequent request.</p>"
}
}
},
@@ -17247,7 +17272,7 @@
},
"NextToken":{
"shape":"NextToken",
- "documentation":"<p>If the response is truncated, Amazon SageMaker returns this token. To retrieve the next set of model packages, use it in the subsequent request.</p>"
+ "documentation":"<p>If the response is truncated, SageMaker returns this token. To retrieve the next set of model packages, use it in the subsequent request.</p>"
}
}
},
@@ -17345,7 +17370,7 @@
},
"NextToken":{
"shape":"PaginationToken",
- "documentation":"<p> If the response is truncated, Amazon SageMaker returns this token. To retrieve the next set of models, use it in the subsequent request. </p>"
+ "documentation":"<p> If the response is truncated, SageMaker returns this token. To retrieve the next set of models, use it in the subsequent request. </p>"
}
}
},
@@ -17545,7 +17570,7 @@
"members":{
"NextToken":{
"shape":"NextToken",
- "documentation":"<p>If the response is truncated, Amazon SageMaker returns this token. To get the next set of lifecycle configurations, use it in the next request. </p>"
+ "documentation":"<p>If the response is truncated, SageMaker returns this token. To get the next set of lifecycle configurations, use it in the next request. </p>"
},
"NotebookInstanceLifecycleConfigs":{
"shape":"NotebookInstanceLifecycleConfigSummaryList",
@@ -17615,7 +17640,7 @@
"members":{
"NextToken":{
"shape":"NextToken",
- "documentation":"<p>If the response to the previous <code>ListNotebookInstances</code> request was truncated, Amazon SageMaker returns this token. To retrieve the next set of notebook instances, use the token in the next request.</p>"
+ "documentation":"<p>If the response to the previous <code>ListNotebookInstances</code> request was truncated, SageMaker returns this token. To retrieve the next set of notebook instances, use the token in the next request.</p>"
},
"NotebookInstances":{
"shape":"NotebookInstanceSummaryList",
@@ -17988,7 +18013,7 @@
},
"NextToken":{
"shape":"NextToken",
- "documentation":"<p> If the response to the previous <code>ListTags</code> request is truncated, Amazon SageMaker returns this token. To retrieve the next set of tags, use it in the subsequent request. </p>"
+ "documentation":"<p> If the response to the previous <code>ListTags</code> request is truncated, SageMaker returns this token. To retrieve the next set of tags, use it in the subsequent request. </p>"
},
"MaxResults":{
"shape":"ListTagsMaxResults",
@@ -18009,7 +18034,7 @@
},
"NextToken":{
"shape":"NextToken",
- "documentation":"<p> If response is truncated, Amazon SageMaker includes a token in the response. You can use this token in your subsequent request to fetch next set of tokens. </p>"
+ "documentation":"<p> If response is truncated, SageMaker includes a token in the response. You can use this token in your subsequent request to fetch next set of tokens. </p>"
}
}
},
@@ -18113,7 +18138,7 @@
},
"NextToken":{
"shape":"NextToken",
- "documentation":"<p>If the response is truncated, Amazon SageMaker returns this token. To retrieve the next set of training jobs, use it in the subsequent request.</p>"
+ "documentation":"<p>If the response is truncated, SageMaker returns this token. To retrieve the next set of training jobs, use it in the subsequent request.</p>"
}
}
},
@@ -18614,7 +18639,7 @@
"documentation":"<p>A regular expression that searches the output of a training job and gets the value of the metric. For more information about using regular expressions to define metrics, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-define-metrics.html\">Defining Objective Metrics</a>.</p>"
}
},
- "documentation":"<p>Specifies a metric that the training algorithm writes to <code>stderr</code> or <code>stdout</code>. Amazon SageMakerhyperparameter tuning captures all defined metrics. You specify one metric that a hyperparameter tuning job uses as its objective metric to choose the best training job.</p>"
+ "documentation":"<p>Specifies a metric that the training algorithm writes to <code>stderr</code> or <code>stdout</code>. SageMakerhyperparameter tuning captures all defined metrics. You specify one metric that a hyperparameter tuning job uses as its objective metric to choose the best training job.</p>"
},
"MetricDefinitionList":{
"type":"list",
@@ -18750,11 +18775,11 @@
"members":{
"InvocationsTimeoutInSeconds":{
"shape":"InvocationsTimeoutInSeconds",
- "documentation":"<p>The timeout value in seconds for an invocation request.</p>"
+ "documentation":"<p>The timeout value in seconds for an invocation request. The default value is 600.</p>"
},
"InvocationsMaxRetries":{
"shape":"InvocationsMaxRetries",
- "documentation":"<p>The maximum number of retries when invocation requests are failing.</p>"
+ "documentation":"<p>The maximum number of retries when invocation requests are failing. The default value is 3.</p>"
}
},
"documentation":"<p>Configures the timeout and maximum number of retries for processing a transform job invocation.</p>"
@@ -19120,7 +19145,7 @@
},
"Image":{
"shape":"ContainerImage",
- "documentation":"<p>The Amazon EC2 Container Registry (Amazon ECR) path where inference code is stored.</p> <p>If you are using your own custom algorithm instead of an algorithm provided by Amazon SageMaker, the inference code must meet Amazon SageMaker requirements. Amazon SageMaker supports both <code>registry/repository[:tag]</code> and <code>registry/repository[@digest]</code> image path formats. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>.</p>"
+ "documentation":"<p>The Amazon EC2 Container Registry (Amazon ECR) path where inference code is stored.</p> <p>If you are using your own custom algorithm instead of an algorithm provided by SageMaker, the inference code must meet SageMaker requirements. SageMaker supports both <code>registry/repository[:tag]</code> and <code>registry/repository[@digest]</code> image path formats. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html\">Using Your Own Algorithms with Amazon SageMaker</a>.</p>"
},
"ImageDigest":{
"shape":"ImageDigest",
@@ -19410,10 +19435,10 @@
},
"ValidationProfiles":{
"shape":"ModelPackageValidationProfiles",
- "documentation":"<p>An array of <code>ModelPackageValidationProfile</code> objects, each of which specifies a batch transform job that Amazon SageMaker runs to validate your model package.</p>"
+ "documentation":"<p>An array of <code>ModelPackageValidationProfile</code> objects, each of which specifies a batch transform job that SageMaker runs to validate your model package.</p>"
}
},
- "documentation":"<p>Specifies batch transform jobs that Amazon SageMaker runs to validate your model package.</p>"
+ "documentation":"<p>Specifies batch transform jobs that SageMaker runs to validate your model package.</p>"
},
"ModelPackageVersion":{
"type":"integer",
@@ -20357,7 +20382,7 @@
},
"Url":{
"shape":"NotebookInstanceUrl",
- "documentation":"<p>The URL that you use to connect to the Jupyter instance running in your notebook instance. </p>"
+ "documentation":"<p>The URL that you use to connect to the Jupyter notebook running in your notebook instance. </p>"
},
"InstanceType":{
"shape":"InstanceType",
@@ -20377,14 +20402,14 @@
},
"DefaultCodeRepository":{
"shape":"CodeRepositoryNameOrUrl",
- "documentation":"<p>The Git repository associated with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with Amazon SageMaker Notebook Instances</a>.</p>"
+ "documentation":"<p>The Git repository associated with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with SageMaker Notebook Instances</a>.</p>"
},
"AdditionalCodeRepositories":{
"shape":"AdditionalCodeRepositoryNamesOrUrls",
- "documentation":"<p>An array of up to three Git repositories associated with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with Amazon SageMaker Notebook Instances</a>.</p>"
+ "documentation":"<p>An array of up to three Git repositories associated with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with SageMaker Notebook Instances</a>.</p>"
}
},
- "documentation":"<p>Provides summary information for an Amazon SageMaker notebook instance.</p>"
+ "documentation":"<p>Provides summary information for an SageMaker notebook instance.</p>"
},
"NotebookInstanceSummaryList":{
"type":"list",
@@ -20677,11 +20702,11 @@
"members":{
"KmsKeyId":{
"shape":"KmsKeyId",
- "documentation":"<p>The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that Amazon SageMaker uses to encrypt the model artifacts at rest using Amazon S3 server-side encryption. The <code>KmsKeyId</code> can be any of the following formats: </p> <ul> <li> <p>// KMS Key ID</p> <p> <code>\"1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// KMS Key Alias</p> <p> <code>\"alias/ExampleAlias\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key Alias</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias\"</code> </p> </li> </ul> <p>If you use a KMS key ID or an alias of your KMS key, the Amazon SageMaker execution role must include permissions to call <code>kms:Encrypt</code>. If you don't provide a KMS key ID, Amazon SageMaker uses the default KMS key for Amazon S3 for your role's account. Amazon SageMaker uses server-side encryption with KMS-managed keys for <code>OutputDataConfig</code>. If you use a bucket policy with an <code>s3:PutObject</code> permission that only allows objects with server-side encryption, set the condition key of <code>s3:x-amz-server-side-encryption</code> to <code>\"aws:kms\"</code>. For more information, see <a href=\"https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html\">KMS-Managed Encryption Keys</a> in the <i>Amazon Simple Storage Service Developer Guide.</i> </p> <p>The KMS key policy must grant permission to the IAM role that you specify in your <code>CreateTrainingJob</code>, <code>CreateTransformJob</code>, or <code>CreateHyperParameterTuningJob</code> requests. For more information, see <a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html\">Using Key Policies in Amazon Web Services KMS</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>"
+ "documentation":"<p>The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that SageMaker uses to encrypt the model artifacts at rest using Amazon S3 server-side encryption. The <code>KmsKeyId</code> can be any of the following formats: </p> <ul> <li> <p>// KMS Key ID</p> <p> <code>\"1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// KMS Key Alias</p> <p> <code>\"alias/ExampleAlias\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key Alias</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias\"</code> </p> </li> </ul> <p>If you use a KMS key ID or an alias of your KMS key, the SageMaker execution role must include permissions to call <code>kms:Encrypt</code>. If you don't provide a KMS key ID, SageMaker uses the default KMS key for Amazon S3 for your role's account. SageMaker uses server-side encryption with KMS-managed keys for <code>OutputDataConfig</code>. If you use a bucket policy with an <code>s3:PutObject</code> permission that only allows objects with server-side encryption, set the condition key of <code>s3:x-amz-server-side-encryption</code> to <code>\"aws:kms\"</code>. For more information, see <a href=\"https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html\">KMS-Managed Encryption Keys</a> in the <i>Amazon Simple Storage Service Developer Guide.</i> </p> <p>The KMS key policy must grant permission to the IAM role that you specify in your <code>CreateTrainingJob</code>, <code>CreateTransformJob</code>, or <code>CreateHyperParameterTuningJob</code> requests. For more information, see <a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html\">Using Key Policies in Amazon Web Services KMS</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>"
},
"S3OutputPath":{
"shape":"S3Uri",
- "documentation":"<p>Identifies the S3 path where you want Amazon SageMaker to store the model artifacts. For example, <code>s3://bucket-name/key-name-prefix</code>. </p>"
+ "documentation":"<p>Identifies the S3 path where you want SageMaker to store the model artifacts. For example, <code>s3://bucket-name/key-name-prefix</code>. </p>"
}
},
"documentation":"<p>Provides information about how to store model training results (model artifacts).</p>"
@@ -20911,11 +20936,11 @@
},
"CurrentServerlessConfig":{
"shape":"ProductionVariantServerlessConfig",
- "documentation":"<p>The serverless configuration for the endpoint.</p> <note> <p>Serverless Inference is in preview release for Amazon SageMaker and is subject to change. We do not recommend using this feature in production environments.</p> </note>"
+ "documentation":"<p>The serverless configuration for the endpoint.</p>"
},
"DesiredServerlessConfig":{
"shape":"ProductionVariantServerlessConfig",
- "documentation":"<p>The serverless configuration requested for this deployment, as specified in the endpoint configuration for the endpoint.</p> <note> <p>Serverless Inference is in preview release for Amazon SageMaker and is subject to change. We do not recommend using this feature in production environments.</p> </note>"
+ "documentation":"<p>The serverless configuration requested for this deployment, as specified in the endpoint configuration for the endpoint.</p>"
}
},
"documentation":"<p>The production variant summary for a deployment when an endpoint is creating or updating with the <code> <a>CreateEndpoint</a> </code> or <code> <a>UpdateEndpoint</a> </code> operations. Describes the <code>VariantStatus </code>, weight and capacity for a production variant associated with an endpoint. </p>"
@@ -21872,10 +21897,10 @@
},
"ServerlessConfig":{
"shape":"ProductionVariantServerlessConfig",
- "documentation":"<p>The serverless configuration for an endpoint. Specifies a serverless endpoint configuration instead of an instance-based endpoint configuration.</p> <note> <p>Serverless Inference is in preview release for Amazon SageMaker and is subject to change. We do not recommend using this feature in production environments.</p> </note>"
+ "documentation":"<p>The serverless configuration for an endpoint. Specifies a serverless endpoint configuration instead of an instance-based endpoint configuration.</p>"
}
},
- "documentation":"<p>Identifies a model that you want to host and the resources chosen to deploy for hosting it. If you are deploying multiple models, tell Amazon SageMaker how to distribute traffic among the models by specifying variant weights. </p>"
+ "documentation":"<p>Identifies a model that you want to host and the resources chosen to deploy for hosting it. If you are deploying multiple models, tell SageMaker how to distribute traffic among the models by specifying variant weights. </p>"
},
"ProductionVariantAcceleratorType":{
"type":"string",
@@ -21898,7 +21923,7 @@
},
"KmsKeyId":{
"shape":"KmsKeyId",
- "documentation":"<p>The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that Amazon SageMaker uses to encrypt the core dump data at rest using Amazon S3 server-side encryption. The <code>KmsKeyId</code> can be any of the following formats: </p> <ul> <li> <p>// KMS Key ID</p> <p> <code>\"1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// KMS Key Alias</p> <p> <code>\"alias/ExampleAlias\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key Alias</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias\"</code> </p> </li> </ul> <p>If you use a KMS key ID or an alias of your KMS key, the Amazon SageMaker execution role must include permissions to call <code>kms:Encrypt</code>. If you don't provide a KMS key ID, Amazon SageMaker uses the default KMS key for Amazon S3 for your role's account. Amazon SageMaker uses server-side encryption with KMS-managed keys for <code>OutputDataConfig</code>. If you use a bucket policy with an <code>s3:PutObject</code> permission that only allows objects with server-side encryption, set the condition key of <code>s3:x-amz-server-side-encryption</code> to <code>\"aws:kms\"</code>. For more information, see <a href=\"https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html\">KMS-Managed Encryption Keys</a> in the <i>Amazon Simple Storage Service Developer Guide.</i> </p> <p>The KMS key policy must grant permission to the IAM role that you specify in your <code>CreateEndpoint</code> and <code>UpdateEndpoint</code> requests. For more information, see <a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html\">Using Key Policies in Amazon Web Services KMS</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>"
+ "documentation":"<p>The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that SageMaker uses to encrypt the core dump data at rest using Amazon S3 server-side encryption. The <code>KmsKeyId</code> can be any of the following formats: </p> <ul> <li> <p>// KMS Key ID</p> <p> <code>\"1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// KMS Key Alias</p> <p> <code>\"alias/ExampleAlias\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key Alias</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:alias/ExampleAlias\"</code> </p> </li> </ul> <p>If you use a KMS key ID or an alias of your KMS key, the SageMaker execution role must include permissions to call <code>kms:Encrypt</code>. If you don't provide a KMS key ID, SageMaker uses the default KMS key for Amazon S3 for your role's account. SageMaker uses server-side encryption with KMS-managed keys for <code>OutputDataConfig</code>. If you use a bucket policy with an <code>s3:PutObject</code> permission that only allows objects with server-side encryption, set the condition key of <code>s3:x-amz-server-side-encryption</code> to <code>\"aws:kms\"</code>. For more information, see <a href=\"https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html\">KMS-Managed Encryption Keys</a> in the <i>Amazon Simple Storage Service Developer Guide.</i> </p> <p>The KMS key policy must grant permission to the IAM role that you specify in your <code>CreateEndpoint</code> and <code>UpdateEndpoint</code> requests. For more information, see <a href=\"https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html\">Using Key Policies in Amazon Web Services KMS</a> in the <i>Amazon Web Services Key Management Service Developer Guide</i>.</p>"
}
},
"documentation":"<p>Specifies configuration for a core dump from the model container when the process crashes.</p>"
@@ -21996,7 +22021,7 @@
"documentation":"<p>The maximum number of concurrent invocations your serverless endpoint can process.</p>"
}
},
- "documentation":"<important> <p>Serverless Inference is in preview release for Amazon SageMaker and is subject to change. We do not recommend using this feature in production environments.</p> </important> <p>Specifies the serverless configuration for an endpoint variant.</p>"
+ "documentation":"<p>Specifies the serverless configuration for an endpoint variant.</p>"
},
"ProductionVariantStatus":{
"type":"structure",
@@ -22057,11 +22082,11 @@
},
"CurrentServerlessConfig":{
"shape":"ProductionVariantServerlessConfig",
- "documentation":"<p>The serverless configuration for the endpoint.</p> <note> <p>Serverless Inference is in preview release for Amazon SageMaker and is subject to change. We do not recommend using this feature in production environments.</p> </note>"
+ "documentation":"<p>The serverless configuration for the endpoint.</p>"
},
"DesiredServerlessConfig":{
"shape":"ProductionVariantServerlessConfig",
- "documentation":"<p>The serverless configuration requested for the endpoint update.</p> <note> <p>Serverless Inference is in preview release for Amazon SageMaker and is subject to change. We do not recommend using this feature in production environments.</p> </note>"
+ "documentation":"<p>The serverless configuration requested for the endpoint update.</p>"
}
},
"documentation":"<p>Describes weight and capacities for a production variant associated with an endpoint. If you sent a request to the <code>UpdateEndpointWeightsAndCapacities</code> API and the endpoint status is <code>Updating</code>, you get different desired and current values. </p>"
@@ -22512,7 +22537,7 @@
},
"Properties":{
"shape":"QueryProperties",
- "documentation":"<p>Filter the lineage entities connected to the <code>StartArn</code>(s) by a set if property key value pairs. If multiple pairs are provided, an entity will be included in the results if it matches any of the provided pairs.</p>"
+ "documentation":"<p>Filter the lineage entities connected to the <code>StartArn</code>(s) by a set if property key value pairs. If multiple pairs are provided, an entity is included in the results if it matches any of the provided pairs.</p>"
}
},
"documentation":"<p>A set of filters to narrow the set of lineage entities connected to the <code>StartArn</code>(s) returned by the <code>QueryLineage</code> API action.</p>"
@@ -22535,11 +22560,11 @@
},
"Direction":{
"shape":"Direction",
- "documentation":"<p>Associations between lineage entities are directed. This parameter determines the direction from the StartArn(s) the query will look.</p>"
+ "documentation":"<p>Associations between lineage entities have a direction. This parameter determines the direction from the StartArn(s) that the query traverses.</p>"
},
"IncludeEdges":{
"shape":"Boolean",
- "documentation":"<p> Setting this value to <code>True</code> will retrieve not only the entities of interest but also the <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/lineage-tracking-entities.html\">Associations</a> and lineage entities on the path. Set to <code>False</code> to only return lineage entities that match your query.</p>"
+ "documentation":"<p> Setting this value to <code>True</code> retrieves not only the entities of interest but also the <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/lineage-tracking-entities.html\">Associations</a> and lineage entities on the path. Set to <code>False</code> to only return lineage entities that match your query.</p>"
},
"Filters":{
"shape":"QueryFilters",
@@ -22547,7 +22572,7 @@
},
"MaxDepth":{
"shape":"QueryLineageMaxDepth",
- "documentation":"<p>The maximum depth in lineage relationships from the <code>StartArns</code> that will be traversed. Depth is a measure of the number of <code>Associations</code> from the <code>StartArn</code> entity to the matched results.</p>"
+ "documentation":"<p>The maximum depth in lineage relationships from the <code>StartArns</code> that are traversed. Depth is a measure of the number of <code>Associations</code> from the <code>StartArn</code> entity to the matched results.</p>"
},
"MaxResults":{
"shape":"QueryLineageMaxResults",
@@ -23064,11 +23089,11 @@
},
"VolumeSizeInGB":{
"shape":"VolumeSizeInGB",
- "documentation":"<p>The size of the ML storage volume that you want to provision. </p> <p>ML storage volumes store model artifacts and incremental states. Training algorithms might also use the ML storage volume for scratch space. If you want to store the training data in the ML storage volume, choose <code>File</code> as the <code>TrainingInputMode</code> in the algorithm specification. </p> <p>You must specify sufficient ML storage for your scenario. </p> <note> <p> Amazon SageMaker supports only the General Purpose SSD (gp2) ML storage volume type. </p> </note> <note> <p>Certain Nitro-based instances include local storage with a fixed total size, dependent on the instance type. When using these instances for training, Amazon SageMaker mounts the local instance storage instead of Amazon EBS gp2 storage. You can't request a <code>VolumeSizeInGB</code> greater than the total size of the local instance storage.</p> <p>For a list of instance types that support local instance storage, including the total size per instance type, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes\">Instance Store Volumes</a>.</p> </note>"
+ "documentation":"<p>The size of the ML storage volume that you want to provision. </p> <p>ML storage volumes store model artifacts and incremental states. Training algorithms might also use the ML storage volume for scratch space. If you want to store the training data in the ML storage volume, choose <code>File</code> as the <code>TrainingInputMode</code> in the algorithm specification. </p> <p>You must specify sufficient ML storage for your scenario. </p> <note> <p> SageMaker supports only the General Purpose SSD (gp2) ML storage volume type. </p> </note> <note> <p>Certain Nitro-based instances include local storage with a fixed total size, dependent on the instance type. When using these instances for training, SageMaker mounts the local instance storage instead of Amazon EBS gp2 storage. You can't request a <code>VolumeSizeInGB</code> greater than the total size of the local instance storage.</p> <p>For a list of instance types that support local instance storage, including the total size per instance type, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes\">Instance Store Volumes</a>.</p> </note>"
},
"VolumeKmsKeyId":{
"shape":"KmsKeyId",
- "documentation":"<p>The Amazon Web Services KMS key that Amazon SageMaker uses to encrypt data on the storage volume attached to the ML compute instance(s) that run the training job.</p> <note> <p>Certain Nitro-based instances include local storage, dependent on the instance type. Local storage volumes are encrypted using a hardware module on the instance. You can't request a <code>VolumeKmsKeyId</code> when using an instance type with local storage.</p> <p>For a list of instance types that support local instance storage, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes\">Instance Store Volumes</a>.</p> <p>For more information about local instance storage encryption, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html\">SSD Instance Store Volumes</a>.</p> </note> <p>The <code>VolumeKmsKeyId</code> can be in any of the following formats:</p> <ul> <li> <p>// KMS Key ID</p> <p> <code>\"1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> </ul>"
+ "documentation":"<p>The Amazon Web Services KMS key that SageMaker uses to encrypt data on the storage volume attached to the ML compute instance(s) that run the training job.</p> <note> <p>Certain Nitro-based instances include local storage, dependent on the instance type. Local storage volumes are encrypted using a hardware module on the instance. You can't request a <code>VolumeKmsKeyId</code> when using an instance type with local storage.</p> <p>For a list of instance types that support local instance storage, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes\">Instance Store Volumes</a>.</p> <p>For more information about local instance storage encryption, see <a href=\"https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html\">SSD Instance Store Volumes</a>.</p> </note> <p>The <code>VolumeKmsKeyId</code> can be in any of the following formats:</p> <ul> <li> <p>// KMS Key ID</p> <p> <code>\"1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> <li> <p>// Amazon Resource Name (ARN) of a KMS Key</p> <p> <code>\"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab\"</code> </p> </li> </ul>"
}
},
"documentation":"<p>Describes the resources, including ML compute instances and ML storage volumes, to use for model training. </p>"
@@ -23090,7 +23115,7 @@
"members":{
"Message":{"shape":"FailureReason"}
},
- "documentation":"<p> You have exceeded an Amazon SageMaker resource limit. For example, you might have too many training jobs created. </p>",
+ "documentation":"<p> You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created. </p>",
"exception":true
},
"ResourceLimits":{
@@ -23143,7 +23168,7 @@
},
"InstanceType":{
"shape":"AppInstanceType",
- "documentation":"<p>The instance type that the image version runs on.</p>"
+ "documentation":"<p>The instance type that the image version runs on.</p> <note> <p>JupyterServer Apps only support the <code>system</code> value. KernelGateway Apps do not support the <code>system</code> value, but support all other values for available instance types.</p> </note>"
},
"LifecycleConfigArn":{
"shape":"StudioLifecycleConfigArn",
@@ -23289,15 +23314,15 @@
"members":{
"S3DataType":{
"shape":"S3DataType",
- "documentation":"<p>If you choose <code>S3Prefix</code>, <code>S3Uri</code> identifies a key name prefix. Amazon SageMaker uses all objects that match the specified key name prefix for model training. </p> <p>If you choose <code>ManifestFile</code>, <code>S3Uri</code> identifies an object that is a manifest file containing a list of object keys that you want Amazon SageMaker to use for model training. </p> <p>If you choose <code>AugmentedManifestFile</code>, S3Uri identifies an object that is an augmented manifest file in JSON lines format. This file contains the data you want to use for model training. <code>AugmentedManifestFile</code> can only be used if the Channel's input mode is <code>Pipe</code>.</p>"
+ "documentation":"<p>If you choose <code>S3Prefix</code>, <code>S3Uri</code> identifies a key name prefix. SageMaker uses all objects that match the specified key name prefix for model training. </p> <p>If you choose <code>ManifestFile</code>, <code>S3Uri</code> identifies an object that is a manifest file containing a list of object keys that you want SageMaker to use for model training. </p> <p>If you choose <code>AugmentedManifestFile</code>, S3Uri identifies an object that is an augmented manifest file in JSON lines format. This file contains the data you want to use for model training. <code>AugmentedManifestFile</code> can only be used if the Channel's input mode is <code>Pipe</code>.</p>"
},
"S3Uri":{
"shape":"S3Uri",
- "documentation":"<p>Depending on the value specified for the <code>S3DataType</code>, identifies either a key name prefix or a manifest. For example: </p> <ul> <li> <p> A key name prefix might look like this: <code>s3://bucketname/exampleprefix</code> </p> </li> <li> <p> A manifest might look like this: <code>s3://bucketname/example.manifest</code> </p> <p> A manifest is an S3 object which is a JSON file consisting of an array of elements. The first element is a prefix which is followed by one or more suffixes. SageMaker appends the suffix elements to the prefix to get a full set of <code>S3Uri</code>. Note that the prefix must be a valid non-empty <code>S3Uri</code> that precludes users from specifying a manifest whose individual <code>S3Uri</code> is sourced from different S3 buckets.</p> <p> The following code example shows a valid manifest format: </p> <p> <code>[ {\"prefix\": \"s3://customer_bucket/some/prefix/\"},</code> </p> <p> <code> \"relative/path/to/custdata-1\",</code> </p> <p> <code> \"relative/path/custdata-2\",</code> </p> <p> <code> ...</code> </p> <p> <code> \"relative/path/custdata-N\"</code> </p> <p> <code>]</code> </p> <p> This JSON is equivalent to the following <code>S3Uri</code> list:</p> <p> <code>s3://customer_bucket/some/prefix/relative/path/to/custdata-1</code> </p> <p> <code>s3://customer_bucket/some/prefix/relative/path/custdata-2</code> </p> <p> <code>...</code> </p> <p> <code>s3://customer_bucket/some/prefix/relative/path/custdata-N</code> </p> <p>The complete set of <code>S3Uri</code> in this manifest is the input data for the channel for this data source. The object that each <code>S3Uri</code> points to must be readable by the IAM role that Amazon SageMaker uses to perform tasks on your behalf. </p> </li> </ul>"
+ "documentation":"<p>Depending on the value specified for the <code>S3DataType</code>, identifies either a key name prefix or a manifest. For example: </p> <ul> <li> <p> A key name prefix might look like this: <code>s3://bucketname/exampleprefix</code> </p> </li> <li> <p> A manifest might look like this: <code>s3://bucketname/example.manifest</code> </p> <p> A manifest is an S3 object which is a JSON file consisting of an array of elements. The first element is a prefix which is followed by one or more suffixes. SageMaker appends the suffix elements to the prefix to get a full set of <code>S3Uri</code>. Note that the prefix must be a valid non-empty <code>S3Uri</code> that precludes users from specifying a manifest whose individual <code>S3Uri</code> is sourced from different S3 buckets.</p> <p> The following code example shows a valid manifest format: </p> <p> <code>[ {\"prefix\": \"s3://customer_bucket/some/prefix/\"},</code> </p> <p> <code> \"relative/path/to/custdata-1\",</code> </p> <p> <code> \"relative/path/custdata-2\",</code> </p> <p> <code> ...</code> </p> <p> <code> \"relative/path/custdata-N\"</code> </p> <p> <code>]</code> </p> <p> This JSON is equivalent to the following <code>S3Uri</code> list:</p> <p> <code>s3://customer_bucket/some/prefix/relative/path/to/custdata-1</code> </p> <p> <code>s3://customer_bucket/some/prefix/relative/path/custdata-2</code> </p> <p> <code>...</code> </p> <p> <code>s3://customer_bucket/some/prefix/relative/path/custdata-N</code> </p> <p>The complete set of <code>S3Uri</code> in this manifest is the input data for the channel for this data source. The object that each <code>S3Uri</code> points to must be readable by the IAM role that SageMaker uses to perform tasks on your behalf. </p> </li> </ul>"
},
"S3DataDistributionType":{
"shape":"S3DataDistribution",
- "documentation":"<p>If you want Amazon SageMaker to replicate the entire dataset on each ML compute instance that is launched for model training, specify <code>FullyReplicated</code>. </p> <p>If you want Amazon SageMaker to replicate a subset of data on each ML compute instance that is launched for model training, specify <code>ShardedByS3Key</code>. If there are <i>n</i> ML compute instances launched for a training job, each instance gets approximately 1/<i>n</i> of the number of S3 objects. In this case, model training on each machine uses only the subset of training data. </p> <p>Don't choose more ML compute instances for training than available S3 objects. If you do, some nodes won't get any data and you will pay for nodes that aren't getting any training data. This applies in both File and Pipe modes. Keep this in mind when developing algorithms. </p> <p>In distributed training, where you use multiple ML compute EC2 instances, you might choose <code>ShardedByS3Key</code>. If the algorithm requires copying training data to the ML storage volume (when <code>TrainingInputMode</code> is set to <code>File</code>), this copies 1/<i>n</i> of the number of objects. </p>"
+ "documentation":"<p>If you want SageMaker to replicate the entire dataset on each ML compute instance that is launched for model training, specify <code>FullyReplicated</code>. </p> <p>If you want SageMaker to replicate a subset of data on each ML compute instance that is launched for model training, specify <code>ShardedByS3Key</code>. If there are <i>n</i> ML compute instances launched for a training job, each instance gets approximately 1/<i>n</i> of the number of S3 objects. In this case, model training on each machine uses only the subset of training data. </p> <p>Don't choose more ML compute instances for training than available S3 objects. If you do, some nodes won't get any data and you will pay for nodes that aren't getting any training data. This applies in both File and Pipe modes. Keep this in mind when developing algorithms. </p> <p>In distributed training, where you use multiple ML compute EC2 instances, you might choose <code>ShardedByS3Key</code>. If the algorithm requires copying training data to the ML storage volume (when <code>TrainingInputMode</code> is set to <code>File</code>), this copies 1/<i>n</i> of the number of objects. </p>"
},
"AttributeNames":{
"shape":"AttributeNames",
@@ -23532,10 +23557,10 @@
},
"StatusMessage":{
"shape":"StatusMessage",
- "documentation":"<p>A detailed description of the progress within a secondary status. </p> <p>Amazon SageMaker provides secondary statuses and status messages that apply to each of them:</p> <dl> <dt>Starting</dt> <dd> <ul> <li> <p>Starting the training job.</p> </li> <li> <p>Launching requested ML instances.</p> </li> <li> <p>Insufficient capacity error from EC2 while launching instances, retrying!</p> </li> <li> <p>Launched instance was unhealthy, replacing it!</p> </li> <li> <p>Preparing the instances for training.</p> </li> </ul> </dd> <dt>Training</dt> <dd> <ul> <li> <p>Downloading the training image.</p> </li> <li> <p>Training image download completed. Training in progress.</p> </li> </ul> </dd> </dl> <important> <p>Status messages are subject to change. Therefore, we recommend not including them in code that programmatically initiates actions. For examples, don't use status messages in if statements.</p> </important> <p>To have an overview of your training job's progress, view <code>TrainingJobStatus</code> and <code>SecondaryStatus</code> in <a>DescribeTrainingJob</a>, and <code>StatusMessage</code> together. For example, at the start of a training job, you might see the following:</p> <ul> <li> <p> <code>TrainingJobStatus</code> - InProgress</p> </li> <li> <p> <code>SecondaryStatus</code> - Training</p> </li> <li> <p> <code>StatusMessage</code> - Downloading the training image</p> </li> </ul>"
+ "documentation":"<p>A detailed description of the progress within a secondary status. </p> <p>SageMaker provides secondary statuses and status messages that apply to each of them:</p> <dl> <dt>Starting</dt> <dd> <ul> <li> <p>Starting the training job.</p> </li> <li> <p>Launching requested ML instances.</p> </li> <li> <p>Insufficient capacity error from EC2 while launching instances, retrying!</p> </li> <li> <p>Launched instance was unhealthy, replacing it!</p> </li> <li> <p>Preparing the instances for training.</p> </li> </ul> </dd> <dt>Training</dt> <dd> <ul> <li> <p>Downloading the training image.</p> </li> <li> <p>Training image download completed. Training in progress.</p> </li> </ul> </dd> </dl> <important> <p>Status messages are subject to change. Therefore, we recommend not including them in code that programmatically initiates actions. For examples, don't use status messages in if statements.</p> </important> <p>To have an overview of your training job's progress, view <code>TrainingJobStatus</code> and <code>SecondaryStatus</code> in <a>DescribeTrainingJob</a>, and <code>StatusMessage</code> together. For example, at the start of a training job, you might see the following:</p> <ul> <li> <p> <code>TrainingJobStatus</code> - InProgress</p> </li> <li> <p> <code>SecondaryStatus</code> - Training</p> </li> <li> <p> <code>StatusMessage</code> - Downloading the training image</p> </li> </ul>"
}
},
- "documentation":"<p>An array element of <a>DescribeTrainingJobResponse$SecondaryStatusTransitions</a>. It provides additional details about a status that the training job has transitioned through. A training job can be in one of several states, for example, starting, downloading, training, or uploading. Within each state, there are a number of intermediate states. For example, within the starting state, Amazon SageMaker could be starting the training job or launching the ML instances. These transitional states are referred to as the job's secondary status. </p> <p/>"
+ "documentation":"<p>An array element of <a>DescribeTrainingJobResponse$SecondaryStatusTransitions</a>. It provides additional details about a status that the training job has transitioned through. A training job can be in one of several states, for example, starting, downloading, training, or uploading. Within each state, there are a number of intermediate states. For example, within the starting state, SageMaker could be starting the training job or launching the ML instances. These transitional states are referred to as the job's secondary status. </p> <p/>"
},
"SecondaryStatusTransitions":{
"type":"list",
@@ -23819,10 +23844,10 @@
},
"AlgorithmName":{
"shape":"ArnOrName",
- "documentation":"<p>The name of an algorithm that was used to create the model package. The algorithm must be either an algorithm resource in your Amazon SageMaker account or an algorithm in Amazon Web Services Marketplace that you are subscribed to.</p>"
+ "documentation":"<p>The name of an algorithm that was used to create the model package. The algorithm must be either an algorithm resource in your SageMaker account or an algorithm in Amazon Web Services Marketplace that you are subscribed to.</p>"
}
},
- "documentation":"<p>Specifies an algorithm that was used to create the model package. The algorithm must be either an algorithm resource in your Amazon SageMaker account or an algorithm in Amazon Web Services Marketplace that you are subscribed to.</p>"
+ "documentation":"<p>Specifies an algorithm that was used to create the model package. The algorithm must be either an algorithm resource in your SageMaker account or an algorithm in Amazon Web Services Marketplace that you are subscribed to.</p>"
},
"SourceAlgorithmList":{
"type":"list",
@@ -24113,14 +24138,14 @@
"members":{
"MaxRuntimeInSeconds":{
"shape":"MaxRuntimeInSeconds",
- "documentation":"<p>The maximum length of time, in seconds, that a training or compilation job can run.</p> <p>For compilation jobs, if the job does not complete during this time, you will receive a <code>TimeOut</code> error. We recommend starting with 900 seconds and increase as necessary based on your model.</p> <p>For all other jobs, if the job does not complete during this time, Amazon SageMaker ends the job. When <code>RetryStrategy</code> is specified in the job request, <code>MaxRuntimeInSeconds</code> specifies the maximum time for all of the attempts in total, not each individual attempt. The default value is 1 day. The maximum value is 28 days.</p>"
+ "documentation":"<p>The maximum length of time, in seconds, that a training or compilation job can run.</p> <p>For compilation jobs, if the job does not complete during this time, a <code>TimeOut</code> error is generated. We recommend starting with 900 seconds and increasing as necessary based on your model.</p> <p>For all other jobs, if the job does not complete during this time, SageMaker ends the job. When <code>RetryStrategy</code> is specified in the job request, <code>MaxRuntimeInSeconds</code> specifies the maximum time for all of the attempts in total, not each individual attempt. The default value is 1 day. The maximum value is 28 days.</p>"
},
"MaxWaitTimeInSeconds":{
"shape":"MaxWaitTimeInSeconds",
- "documentation":"<p>The maximum length of time, in seconds, that a managed Spot training job has to complete. It is the amount of time spent waiting for Spot capacity plus the amount of time the job can run. It must be equal to or greater than <code>MaxRuntimeInSeconds</code>. If the job does not complete during this time, Amazon SageMaker ends the job.</p> <p>When <code>RetryStrategy</code> is specified in the job request, <code>MaxWaitTimeInSeconds</code> specifies the maximum time for all of the attempts in total, not each individual attempt.</p>"
+ "documentation":"<p>The maximum length of time, in seconds, that a managed Spot training job has to complete. It is the amount of time spent waiting for Spot capacity plus the amount of time the job can run. It must be equal to or greater than <code>MaxRuntimeInSeconds</code>. If the job does not complete during this time, SageMaker ends the job.</p> <p>When <code>RetryStrategy</code> is specified in the job request, <code>MaxWaitTimeInSeconds</code> specifies the maximum time for all of the attempts in total, not each individual attempt.</p>"
}
},
- "documentation":"<p>Specifies a limit to how long a model training job or model compilation job can run. It also specifies how long a managed spot training job has to complete. When the job reaches the time limit, Amazon SageMaker ends the training or compilation job. Use this API to cap model training costs.</p> <p>To stop a training job, Amazon SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. </p> <p>The training algorithms provided by Amazon SageMaker automatically save the intermediate results of a model training job when possible. This attempt to save artifacts is only a best effort case as model might not be in a state from which it can be saved. For example, if training has just started, the model might not be ready to save. When saved, this intermediate data is a valid model artifact. You can use it to create a model with <code>CreateModel</code>.</p> <note> <p>The Neural Topic Model (NTM) currently does not support saving intermediate model artifacts. When training NTMs, make sure that the maximum runtime is sufficient for the training job to complete.</p> </note>"
+ "documentation":"<p>Specifies a limit to how long a model training job or model compilation job can run. It also specifies how long a managed spot training job has to complete. When the job reaches the time limit, SageMaker ends the training or compilation job. Use this API to cap model training costs.</p> <p>To stop a training job, SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. </p> <p>The training algorithms provided by SageMaker automatically save the intermediate results of a model training job when possible. This attempt to save artifacts is only a best effort case as model might not be in a state from which it can be saved. For example, if training has just started, the model might not be ready to save. When saved, this intermediate data is a valid model artifact. You can use it to create a model with <code>CreateModel</code>.</p> <note> <p>The Neural Topic Model (NTM) currently does not support saving intermediate model artifacts. When training NTMs, make sure that the maximum runtime is sufficient for the training job to complete.</p> </note>"
},
"String":{"type":"string"},
"String1024":{
@@ -24691,7 +24716,7 @@
},
"SecondaryStatus":{
"shape":"SecondaryStatus",
- "documentation":"<p> Provides detailed information about the state of the training job. For detailed information about the secondary status of the training job, see <code>StatusMessage</code> under <a>SecondaryStatusTransition</a>.</p> <p>Amazon SageMaker provides primary statuses and secondary statuses that apply to each of them:</p> <dl> <dt>InProgress</dt> <dd> <ul> <li> <p> <code>Starting</code> - Starting the training job.</p> </li> <li> <p> <code>Downloading</code> - An optional stage for algorithms that support <code>File</code> training input mode. It indicates that data is being downloaded to the ML storage volumes.</p> </li> <li> <p> <code>Training</code> - Training is in progress.</p> </li> <li> <p> <code>Uploading</code> - Training is complete and the model artifacts are being uploaded to the S3 location.</p> </li> </ul> </dd> <dt>Completed</dt> <dd> <ul> <li> <p> <code>Completed</code> - The training job has completed.</p> </li> </ul> </dd> <dt>Failed</dt> <dd> <ul> <li> <p> <code>Failed</code> - The training job has failed. The reason for the failure is returned in the <code>FailureReason</code> field of <code>DescribeTrainingJobResponse</code>.</p> </li> </ul> </dd> <dt>Stopped</dt> <dd> <ul> <li> <p> <code>MaxRuntimeExceeded</code> - The job stopped because it exceeded the maximum allowed runtime.</p> </li> <li> <p> <code>Stopped</code> - The training job has stopped.</p> </li> </ul> </dd> <dt>Stopping</dt> <dd> <ul> <li> <p> <code>Stopping</code> - Stopping the training job.</p> </li> </ul> </dd> </dl> <important> <p>Valid values for <code>SecondaryStatus</code> are subject to change. </p> </important> <p>We no longer support the following secondary statuses:</p> <ul> <li> <p> <code>LaunchingMLInstances</code> </p> </li> <li> <p> <code>PreparingTrainingStack</code> </p> </li> <li> <p> <code>DownloadingTrainingImage</code> </p> </li> </ul>"
+ "documentation":"<p> Provides detailed information about the state of the training job. For detailed information about the secondary status of the training job, see <code>StatusMessage</code> under <a>SecondaryStatusTransition</a>.</p> <p>SageMaker provides primary statuses and secondary statuses that apply to each of them:</p> <dl> <dt>InProgress</dt> <dd> <ul> <li> <p> <code>Starting</code> - Starting the training job.</p> </li> <li> <p> <code>Downloading</code> - An optional stage for algorithms that support <code>File</code> training input mode. It indicates that data is being downloaded to the ML storage volumes.</p> </li> <li> <p> <code>Training</code> - Training is in progress.</p> </li> <li> <p> <code>Uploading</code> - Training is complete and the model artifacts are being uploaded to the S3 location.</p> </li> </ul> </dd> <dt>Completed</dt> <dd> <ul> <li> <p> <code>Completed</code> - The training job has completed.</p> </li> </ul> </dd> <dt>Failed</dt> <dd> <ul> <li> <p> <code>Failed</code> - The training job has failed. The reason for the failure is returned in the <code>FailureReason</code> field of <code>DescribeTrainingJobResponse</code>.</p> </li> </ul> </dd> <dt>Stopped</dt> <dd> <ul> <li> <p> <code>MaxRuntimeExceeded</code> - The job stopped because it exceeded the maximum allowed runtime.</p> </li> <li> <p> <code>Stopped</code> - The training job has stopped.</p> </li> </ul> </dd> <dt>Stopping</dt> <dd> <ul> <li> <p> <code>Stopping</code> - Stopping the training job.</p> </li> </ul> </dd> </dl> <important> <p>Valid values for <code>SecondaryStatus</code> are subject to change. </p> </important> <p>We no longer support the following secondary statuses:</p> <ul> <li> <p> <code>LaunchingMLInstances</code> </p> </li> <li> <p> <code>PreparingTrainingStack</code> </p> </li> <li> <p> <code>DownloadingTrainingImage</code> </p> </li> </ul>"
},
"FailureReason":{
"shape":"FailureReason",
@@ -24715,7 +24740,7 @@
},
"OutputDataConfig":{
"shape":"OutputDataConfig",
- "documentation":"<p>The S3 path where model artifacts that you configured when creating the job are stored. Amazon SageMaker creates subfolders for model artifacts.</p>"
+ "documentation":"<p>The S3 path where model artifacts that you configured when creating the job are stored. SageMaker creates subfolders for model artifacts.</p>"
},
"ResourceConfig":{
"shape":"ResourceConfig",
@@ -24727,7 +24752,7 @@
},
"StoppingCondition":{
"shape":"StoppingCondition",
- "documentation":"<p>Specifies a limit to how long a model training job can run. It also specifies how long a managed Spot training job has to complete. When the job reaches the time limit, Amazon SageMaker ends the training job. Use this API to cap model training costs.</p> <p>To stop a job, Amazon SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. </p>"
+ "documentation":"<p>Specifies a limit to how long a model training job can run. It also specifies how long a managed Spot training job has to complete. When the job reaches the time limit, SageMaker ends the training job. Use this API to cap model training costs.</p> <p>To stop a job, SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. </p>"
},
"CreationTime":{
"shape":"Timestamp",
@@ -24739,7 +24764,7 @@
},
"TrainingEndTime":{
"shape":"Timestamp",
- "documentation":"<p>Indicates the time when the training job ends on training instances. You are billed for the time interval between the value of <code>TrainingStartTime</code> and this time. For successful jobs and stopped jobs, this is the time after model artifacts are uploaded. For failed jobs, this is the time when Amazon SageMaker detects a job failure.</p>"
+ "documentation":"<p>Indicates the time when the training job ends on training instances. You are billed for the time interval between the value of <code>TrainingStartTime</code> and this time. For successful jobs and stopped jobs, this is the time after model artifacts are uploaded. For failed jobs, this is the time when SageMaker detects a job failure.</p>"
},
"LastModifiedTime":{
"shape":"Timestamp",
@@ -24826,7 +24851,7 @@
},
"OutputDataConfig":{
"shape":"OutputDataConfig",
- "documentation":"<p>the path to the S3 bucket where you want to store model artifacts. Amazon SageMaker creates subfolders for the artifacts.</p>"
+ "documentation":"<p>the path to the S3 bucket where you want to store model artifacts. SageMaker creates subfolders for the artifacts.</p>"
},
"ResourceConfig":{
"shape":"ResourceConfig",
@@ -24834,7 +24859,7 @@
},
"StoppingCondition":{
"shape":"StoppingCondition",
- "documentation":"<p>Specifies a limit to how long a model training job can run. It also specifies how long a managed Spot training job has to complete. When the job reaches the time limit, Amazon SageMaker ends the training job. Use this API to cap model training costs.</p> <p>To stop a job, Amazon SageMaker sends the algorithm the SIGTERM signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts.</p>"
+ "documentation":"<p>Specifies a limit to how long a model training job can run. It also specifies how long a managed Spot training job has to complete. When the job reaches the time limit, SageMaker ends the training job. Use this API to cap model training costs.</p> <p>To stop a job, SageMaker sends the algorithm the SIGTERM signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts.</p>"
}
},
"documentation":"<p>Defines the input needed to run a training job using the algorithm.</p>"
@@ -26121,7 +26146,7 @@
"members":{
"EndpointName":{
"shape":"EndpointName",
- "documentation":"<p>The name of an existing Amazon SageMaker endpoint.</p>"
+ "documentation":"<p>The name of an existing SageMaker endpoint.</p>"
},
"DesiredWeightsAndCapacities":{
"shape":"DesiredWeightAndCapacityList",
@@ -26282,7 +26307,7 @@
},
"RoleArn":{
"shape":"RoleArn",
- "documentation":"<p>The Amazon Resource Name (ARN) of the IAM role that Amazon SageMaker can assume to access the notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html\">Amazon SageMaker Roles</a>. </p> <note> <p>To be able to pass this role to Amazon SageMaker, the caller of this API must have the <code>iam:PassRole</code> permission.</p> </note>"
+ "documentation":"<p>The Amazon Resource Name (ARN) of the IAM role that SageMaker can assume to access the notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html\">SageMaker Roles</a>. </p> <note> <p>To be able to pass this role to SageMaker, the caller of this API must have the <code>iam:PassRole</code> permission.</p> </note>"
},
"LifecycleConfigName":{
"shape":"NotebookInstanceLifecycleConfigName",
@@ -26294,15 +26319,15 @@
},
"VolumeSizeInGB":{
"shape":"NotebookInstanceVolumeSizeInGB",
- "documentation":"<p>The size, in GB, of the ML storage volume to attach to the notebook instance. The default value is 5 GB. ML storage volumes are encrypted, so Amazon SageMaker can't determine the amount of available free space on the volume. Because of this, you can increase the volume size when you update a notebook instance, but you can't decrease the volume size. If you want to decrease the size of the ML storage volume in use, create a new notebook instance with the desired size.</p>"
+ "documentation":"<p>The size, in GB, of the ML storage volume to attach to the notebook instance. The default value is 5 GB. ML storage volumes are encrypted, so SageMaker can't determine the amount of available free space on the volume. Because of this, you can increase the volume size when you update a notebook instance, but you can't decrease the volume size. If you want to decrease the size of the ML storage volume in use, create a new notebook instance with the desired size.</p>"
},
"DefaultCodeRepository":{
"shape":"CodeRepositoryNameOrUrl",
- "documentation":"<p>The Git repository to associate with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with Amazon SageMaker Notebook Instances</a>.</p>"
+ "documentation":"<p>The Git repository to associate with the notebook instance as its default code repository. This can be either the name of a Git repository stored as a resource in your account, or the URL of a Git repository in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. When you open a notebook instance, it opens in the directory that contains this repository. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with SageMaker Notebook Instances</a>.</p>"
},
"AdditionalCodeRepositories":{
"shape":"AdditionalCodeRepositoryNamesOrUrls",
- "documentation":"<p>An array of up to three Git repositories to associate with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with Amazon SageMaker Notebook Instances</a>.</p>"
+ "documentation":"<p>An array of up to three Git repositories to associate with the notebook instance. These can be either the names of Git repositories stored as resources in your account, or the URL of Git repositories in <a href=\"https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html\">Amazon Web Services CodeCommit</a> or in any other Git repository. These repositories are cloned at the same level as the default repository of your notebook instance. For more information, see <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/nbi-git-repo.html\">Associating Git Repositories with SageMaker Notebook Instances</a>.</p>"
},
"AcceleratorTypes":{
"shape":"NotebookInstanceAcceleratorTypes",
@@ -26780,6 +26805,11 @@
},
"documentation":"<p>A collection of settings that apply to users of Amazon SageMaker Studio. These settings are specified when the <code>CreateUserProfile</code> API is called, and as <code>DefaultUserSettings</code> when the <code>CreateDomain</code> API is called.</p> <p> <code>SecurityGroups</code> is aggregated when specified in both calls. For all other settings in <code>UserSettings</code>, the values specified in <code>CreateUserProfile</code> take precedence over those specified in <code>CreateDomain</code>.</p>"
},
+ "ValidationFraction":{
+ "type":"float",
+ "max":1,
+ "min":0
+ },
"VariantName":{
"type":"string",
"max":63,
@@ -27025,5 +27055,5 @@
"member":{"shape":"Workteam"}
}
},
- "documentation":"<p>Provides APIs for creating and managing Amazon SageMaker resources. </p> <p>Other Resources:</p> <ul> <li> <p> <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/whatis.html#first-time-user\">Amazon SageMaker Developer Guide</a> </p> </li> <li> <p> <a href=\"https://docs.aws.amazon.com/augmented-ai/2019-11-07/APIReference/Welcome.html\">Amazon Augmented AI Runtime API Reference</a> </p> </li> </ul>"
+ "documentation":"<p>Provides APIs for creating and managing SageMaker resources. </p> <p>Other Resources:</p> <ul> <li> <p> <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/whatis.html#first-time-user\">SageMaker Developer Guide</a> </p> </li> <li> <p> <a href=\"https://docs.aws.amazon.com/augmented-ai/2019-11-07/APIReference/Welcome.html\">Amazon Augmented AI Runtime API Reference</a> </p> </li> </ul>"
}
diff --git a/contrib/python/botocore/py3/patches/01-unvendor-six.patch b/contrib/python/botocore/py3/patches/01-unvendor-six.patch
index 44753b669d..b7eadde22c 100644
--- a/contrib/python/botocore/py3/patches/01-unvendor-six.patch
+++ b/contrib/python/botocore/py3/patches/01-unvendor-six.patch
@@ -1,53 +1,23 @@
--- contrib/python/botocore/py3/botocore/compat.py (index)
+++ contrib/python/botocore/py3/botocore/compat.py (working tree)
-@@ -22,7 +22,7 @@ import shlex
- import os
- from math import floor
-
+@@ -28,1 +28,1 @@ import shlex
-from botocore.vendored import six
+import six
- from botocore.exceptions import MD5UnavailableError
- from dateutil.tz import tzlocal
- from urllib3 import exceptions
-@@ -31,7 +31,7 @@ logger = logging.getLogger(__name__)
-
-
- if six.PY3:
-- from botocore.vendored.six.moves import http_client
-+ from six.moves import http_client
-
- class HTTPHeaders(http_client.HTTPMessage):
- pass
+@@ -36,1 +36,1 @@ logger = logging.getLogger(__name__)
+-from botocore.vendored.six.moves import http_client
++from six.moves import http_client
--- contrib/python/botocore/py3/botocore/endpoint.py (index)
+++ contrib/python/botocore/py3/botocore/endpoint.py (working tree)
-@@ -32,7 +32,7 @@ import logging
- is_valid_endpoint_url,
- is_valid_ipv6_endpoint_url,
- )
+@@ -35,1 +35,1 @@ import logging
-from botocore.vendored import six
+from botocore.compat import six
-
- logger = logging.getLogger(__name__)
- history_recorder = get_global_history_recorder()
--- contrib/python/botocore/py3/botocore/httpsession.py (index)
+++ contrib/python/botocore/py3/botocore/httpsession.py (working tree)
-@@ -47,7 +47,7 @@ except ImportError:
- ReadTimeoutError,
- SSLError,
- )
+@@ -62,1 +62,1 @@ except ImportError:
-from botocore.vendored.six.moves.urllib_parse import unquote
+from six.moves.urllib_parse import unquote
-
- filter_ssl_warnings()
- logger = logging.getLogger(__name__)
--- contrib/python/botocore/py3/botocore/utils.py (index)
+++ contrib/python/botocore/py3/botocore/utils.py (working tree)
-@@ -70,7 +70,7 @@ from botocore.compat import (
- UnsupportedS3ControlArnError,
- UnsupportedS3ControlConfigurationError,
- )
+@@ -85,1 +85,1 @@ from botocore.compat import (
-from botocore.vendored.six.moves.urllib.request import getproxies, proxy_bypass
+from six.moves.urllib.request import getproxies, proxy_bypass
-
- logger = logging.getLogger(__name__)
- DEFAULT_METADATA_SERVICE_TIMEOUT = 1
diff --git a/contrib/python/botocore/py3/patches/02-fix-for-arcadia.patch b/contrib/python/botocore/py3/patches/02-fix-for-arcadia.patch
index efc83bdb96..276cacb398 100644
--- a/contrib/python/botocore/py3/patches/02-fix-for-arcadia.patch
+++ b/contrib/python/botocore/py3/patches/02-fix-for-arcadia.patch
@@ -1,6 +1,6 @@
--- contrib/python/botocore/py3/botocore/data/endpoints.json (index)
+++ contrib/python/botocore/py3/botocore/data/endpoints.json (working tree)
-@@ -18343,6 +18343,46 @@
+@@ -18584,6 +18584,46 @@
}
}
}
diff --git a/contrib/python/pyparsing/py3/.dist-info/METADATA b/contrib/python/pyparsing/py3/.dist-info/METADATA
index d6c8e9beba..33e5194172 100644
--- a/contrib/python/pyparsing/py3/.dist-info/METADATA
+++ b/contrib/python/pyparsing/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pyparsing
-Version: 3.0.8
+Version: 3.0.9
Summary: pyparsing module - Classes and methods to define and execute parsing grammars
Author-email: Paul McGuire <ptmcg.gm+pyparsing@gmail.com>
Requires-Python: >=3.6.8
diff --git a/contrib/python/pyparsing/py3/pyparsing/__init__.py b/contrib/python/pyparsing/py3/pyparsing/__init__.py
index 45f334d043..7802ff158d 100644
--- a/contrib/python/pyparsing/py3/pyparsing/__init__.py
+++ b/contrib/python/pyparsing/py3/pyparsing/__init__.py
@@ -128,8 +128,8 @@ class version_info(NamedTuple):
)
-__version_info__ = version_info(3, 0, 8, "final", 0)
-__version_time__ = "09 Apr 2022 23:29 UTC"
+__version_info__ = version_info(3, 0, 9, "final", 0)
+__version_time__ = "05 May 2022 07:02 UTC"
__version__ = __version_info__.__version__
__versionTime__ = __version_time__
__author__ = "Paul McGuire <ptmcg.gm+pyparsing@gmail.com>"
diff --git a/contrib/python/pyparsing/py3/pyparsing/actions.py b/contrib/python/pyparsing/py3/pyparsing/actions.py
index 2bcc5502b0..f72c66e743 100644
--- a/contrib/python/pyparsing/py3/pyparsing/actions.py
+++ b/contrib/python/pyparsing/py3/pyparsing/actions.py
@@ -55,7 +55,7 @@ def replace_with(repl_str):
na = one_of("N/A NA").set_parse_action(replace_with(math.nan))
term = na | num
- OneOrMore(term).parse_string("324 234 N/A 234") # -> [324, 234, nan, 234]
+ term[1, ...].parse_string("324 234 N/A 234") # -> [324, 234, nan, 234]
"""
return lambda s, l, t: [repl_str]
diff --git a/contrib/python/pyparsing/py3/pyparsing/core.py b/contrib/python/pyparsing/py3/pyparsing/core.py
index 454bd57d04..9acba3f3e9 100644
--- a/contrib/python/pyparsing/py3/pyparsing/core.py
+++ b/contrib/python/pyparsing/py3/pyparsing/core.py
@@ -2,9 +2,8 @@
# core.py
#
import os
+import typing
from typing import (
- Optional as OptionalType,
- Iterable as IterableType,
NamedTuple,
Union,
Callable,
@@ -14,7 +13,6 @@ from typing import (
List,
TextIO,
Set,
- Dict as DictType,
Sequence,
)
from abc import ABC, abstractmethod
@@ -192,7 +190,7 @@ del __config_flags
def _should_enable_warnings(
- cmd_line_warn_options: IterableType[str], warn_env_var: OptionalType[str]
+ cmd_line_warn_options: typing.Iterable[str], warn_env_var: typing.Optional[str]
) -> bool:
enable = bool(warn_env_var)
for warn_opt in cmd_line_warn_options:
@@ -404,7 +402,7 @@ class ParserElement(ABC):
DEFAULT_WHITE_CHARS: str = " \n\t\r"
verbose_stacktrace: bool = False
- _literalStringClass: OptionalType[type] = None
+ _literalStringClass: typing.Optional[type] = None
@staticmethod
def set_default_whitespace_chars(chars: str) -> None:
@@ -414,11 +412,11 @@ class ParserElement(ABC):
Example::
# default whitespace chars are space, <TAB> and newline
- OneOrMore(Word(alphas)).parse_string("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl']
+ Word(alphas)[1, ...].parse_string("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl']
# change to just treat newline as significant
ParserElement.set_default_whitespace_chars(" \t")
- OneOrMore(Word(alphas)).parse_string("abc def\nghi jkl") # -> ['abc', 'def']
+ Word(alphas)[1, ...].parse_string("abc def\nghi jkl") # -> ['abc', 'def']
"""
ParserElement.DEFAULT_WHITE_CHARS = chars
@@ -450,13 +448,13 @@ class ParserElement(ABC):
ParserElement._literalStringClass = cls
class DebugActions(NamedTuple):
- debug_try: OptionalType[DebugStartAction]
- debug_match: OptionalType[DebugSuccessAction]
- debug_fail: OptionalType[DebugExceptionAction]
+ debug_try: typing.Optional[DebugStartAction]
+ debug_match: typing.Optional[DebugSuccessAction]
+ debug_fail: typing.Optional[DebugExceptionAction]
def __init__(self, savelist: bool = False):
self.parseAction: List[ParseAction] = list()
- self.failAction: OptionalType[ParseFailAction] = None
+ self.failAction: typing.Optional[ParseFailAction] = None
self.customName = None
self._defaultName = None
self.resultsName = None
@@ -510,7 +508,7 @@ class ParserElement(ABC):
integerK = integer.copy().add_parse_action(lambda toks: toks[0] * 1024) + Suppress("K")
integerM = integer.copy().add_parse_action(lambda toks: toks[0] * 1024 * 1024) + Suppress("M")
- print(OneOrMore(integerK | integerM | integer).parse_string("5K 100 640K 256M"))
+ print((integerK | integerM | integer)[1, ...].parse_string("5K 100 640K 256M"))
prints::
@@ -895,7 +893,7 @@ class ParserElement(ABC):
# cache for left-recursion in Forward references
recursion_lock = RLock()
- recursion_memos: DictType[
+ recursion_memos: typing.Dict[
Tuple[int, "Forward", bool], Tuple[int, Union[ParseResults, Exception]]
] = {}
@@ -985,7 +983,7 @@ class ParserElement(ABC):
@staticmethod
def enable_left_recursion(
- cache_size_limit: OptionalType[int] = None, *, force=False
+ cache_size_limit: typing.Optional[int] = None, *, force=False
) -> None:
"""
Enables "bounded recursion" parsing, which allows for both direct and indirect
@@ -1738,7 +1736,7 @@ class ParserElement(ABC):
Example::
- patt = OneOrMore(Word(alphas))
+ patt = Word(alphas)[1, ...]
patt.parse_string('ablaj /* comment */ lskjd')
# -> ['ablaj']
@@ -1798,7 +1796,7 @@ class ParserElement(ABC):
# turn on debugging for wd
wd.set_debug()
- OneOrMore(term).parse_string("abc 123 xyz 890")
+ term[1, ...].parse_string("abc 123 xyz 890")
prints::
@@ -1953,12 +1951,12 @@ class ParserElement(ABC):
self,
tests: Union[str, List[str]],
parse_all: bool = True,
- comment: OptionalType[Union["ParserElement", str]] = "#",
+ comment: typing.Optional[Union["ParserElement", str]] = "#",
full_dump: bool = True,
print_results: bool = True,
failure_tests: bool = False,
post_parse: Callable[[str, ParseResults], str] = None,
- file: OptionalType[TextIO] = None,
+ file: typing.Optional[TextIO] = None,
with_line_numbers: bool = False,
*,
parseAll: bool = True,
@@ -2385,11 +2383,11 @@ class Keyword(Token):
def __init__(
self,
match_string: str = "",
- ident_chars: OptionalType[str] = None,
+ ident_chars: typing.Optional[str] = None,
caseless: bool = False,
*,
matchString: str = "",
- identChars: OptionalType[str] = None,
+ identChars: typing.Optional[str] = None,
):
super().__init__()
identChars = identChars or ident_chars
@@ -2479,7 +2477,7 @@ class CaselessLiteral(Literal):
Example::
- OneOrMore(CaselessLiteral("CMD")).parse_string("cmd CMD Cmd10")
+ CaselessLiteral("CMD")[1, ...].parse_string("cmd CMD Cmd10")
# -> ['CMD', 'CMD', 'CMD']
(Contrast with example for :class:`CaselessKeyword`.)
@@ -2504,7 +2502,7 @@ class CaselessKeyword(Keyword):
Example::
- OneOrMore(CaselessKeyword("CMD")).parse_string("cmd CMD Cmd10")
+ CaselessKeyword("CMD")[1, ...].parse_string("cmd CMD Cmd10")
# -> ['CMD', 'CMD']
(Contrast with example for :class:`CaselessLiteral`.)
@@ -2513,10 +2511,10 @@ class CaselessKeyword(Keyword):
def __init__(
self,
match_string: str = "",
- ident_chars: OptionalType[str] = None,
+ ident_chars: typing.Optional[str] = None,
*,
matchString: str = "",
- identChars: OptionalType[str] = None,
+ identChars: typing.Optional[str] = None,
):
identChars = identChars or ident_chars
match_string = matchString or match_string
@@ -2680,17 +2678,17 @@ class Word(Token):
def __init__(
self,
init_chars: str = "",
- body_chars: OptionalType[str] = None,
+ body_chars: typing.Optional[str] = None,
min: int = 1,
max: int = 0,
exact: int = 0,
as_keyword: bool = False,
- exclude_chars: OptionalType[str] = None,
+ exclude_chars: typing.Optional[str] = None,
*,
- initChars: OptionalType[str] = None,
- bodyChars: OptionalType[str] = None,
+ initChars: typing.Optional[str] = None,
+ bodyChars: typing.Optional[str] = None,
asKeyword: bool = False,
- excludeChars: OptionalType[str] = None,
+ excludeChars: typing.Optional[str] = None,
):
initChars = initChars or init_chars
bodyChars = bodyChars or body_chars
@@ -2872,10 +2870,10 @@ class Char(_WordRegex):
self,
charset: str,
as_keyword: bool = False,
- exclude_chars: OptionalType[str] = None,
+ exclude_chars: typing.Optional[str] = None,
*,
asKeyword: bool = False,
- excludeChars: OptionalType[str] = None,
+ excludeChars: typing.Optional[str] = None,
):
asKeyword = asKeyword or as_keyword
excludeChars = excludeChars or exclude_chars
@@ -3088,18 +3086,18 @@ class QuotedString(Token):
def __init__(
self,
quote_char: str = "",
- esc_char: OptionalType[str] = None,
- esc_quote: OptionalType[str] = None,
+ esc_char: typing.Optional[str] = None,
+ esc_quote: typing.Optional[str] = None,
multiline: bool = False,
unquote_results: bool = True,
- end_quote_char: OptionalType[str] = None,
+ end_quote_char: typing.Optional[str] = None,
convert_whitespace_escapes: bool = True,
*,
quoteChar: str = "",
- escChar: OptionalType[str] = None,
- escQuote: OptionalType[str] = None,
+ escChar: typing.Optional[str] = None,
+ escQuote: typing.Optional[str] = None,
unquoteResults: bool = True,
- endQuoteChar: OptionalType[str] = None,
+ endQuoteChar: typing.Optional[str] = None,
convertWhitespaceEscapes: bool = True,
):
super().__init__()
@@ -3600,7 +3598,7 @@ class ParseExpression(ParserElement):
post-processing parsed tokens.
"""
- def __init__(self, exprs: IterableType[ParserElement], savelist: bool = False):
+ def __init__(self, exprs: typing.Iterable[ParserElement], savelist: bool = False):
super().__init__(savelist)
self.exprs: List[ParserElement]
if isinstance(exprs, _generatorType):
@@ -3767,7 +3765,7 @@ class And(ParseExpression):
Example::
integer = Word(nums)
- name_expr = OneOrMore(Word(alphas))
+ name_expr = Word(alphas)[1, ...]
expr = And([integer("id"), name_expr("name"), integer("age")])
# more easily written as:
@@ -3782,7 +3780,9 @@ class And(ParseExpression):
def _generateDefaultName(self):
return "-"
- def __init__(self, exprs_arg: IterableType[ParserElement], savelist: bool = True):
+ def __init__(
+ self, exprs_arg: typing.Iterable[ParserElement], savelist: bool = True
+ ):
exprs: List[ParserElement] = list(exprs_arg)
if exprs and Ellipsis in exprs:
tmp = []
@@ -3926,7 +3926,7 @@ class Or(ParseExpression):
[['123'], ['3.1416'], ['789']]
"""
- def __init__(self, exprs: IterableType[ParserElement], savelist: bool = False):
+ def __init__(self, exprs: typing.Iterable[ParserElement], savelist: bool = False):
super().__init__(exprs, savelist)
if self.exprs:
self.mayReturnEmpty = any(e.mayReturnEmpty for e in self.exprs)
@@ -4081,7 +4081,7 @@ class MatchFirst(ParseExpression):
print(number.search_string("123 3.1416 789")) # Better -> [['123'], ['3.1416'], ['789']]
"""
- def __init__(self, exprs: IterableType[ParserElement], savelist: bool = False):
+ def __init__(self, exprs: typing.Iterable[ParserElement], savelist: bool = False):
super().__init__(exprs, savelist)
if self.exprs:
self.mayReturnEmpty = any(e.mayReturnEmpty for e in self.exprs)
@@ -4232,7 +4232,7 @@ class Each(ParseExpression):
- size: 20
"""
- def __init__(self, exprs: IterableType[ParserElement], savelist: bool = True):
+ def __init__(self, exprs: typing.Iterable[ParserElement], savelist: bool = True):
super().__init__(exprs, savelist)
if self.exprs:
self.mayReturnEmpty = all(e.mayReturnEmpty for e in self.exprs)
@@ -4568,7 +4568,7 @@ class FollowedBy(ParseElementEnhance):
label = data_word + FollowedBy(':')
attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))
- OneOrMore(attr_expr).parse_string("shape: SQUARE color: BLACK posn: upper left").pprint()
+ attr_expr[1, ...].parse_string("shape: SQUARE color: BLACK posn: upper left").pprint()
prints::
@@ -4619,7 +4619,7 @@ class PrecededBy(ParseElementEnhance):
"""
def __init__(
- self, expr: Union[ParserElement, str], retreat: OptionalType[int] = None
+ self, expr: Union[ParserElement, str], retreat: typing.Optional[int] = None
):
super().__init__(expr)
self.expr = self.expr().leave_whitespace()
@@ -4730,7 +4730,7 @@ class NotAny(ParseElementEnhance):
# very crude boolean expression - to support parenthesis groups and
# operation hierarchy, use infix_notation
- boolean_expr = boolean_term + ZeroOrMore((AND | OR) + boolean_term)
+ boolean_expr = boolean_term + ((AND | OR) + boolean_term)[...]
# integers that are followed by "." are actually floats
integer = Word(nums) + ~Char(".")
@@ -4758,9 +4758,9 @@ class _MultipleMatch(ParseElementEnhance):
def __init__(
self,
expr: ParserElement,
- stop_on: OptionalType[Union[ParserElement, str]] = None,
+ stop_on: typing.Optional[Union[ParserElement, str]] = None,
*,
- stopOn: OptionalType[Union[ParserElement, str]] = None,
+ stopOn: typing.Optional[Union[ParserElement, str]] = None,
):
super().__init__(expr)
stopOn = stopOn or stop_on
@@ -4849,7 +4849,7 @@ class OneOrMore(_MultipleMatch):
attr_expr = Group(label + Suppress(':') + OneOrMore(data_word).set_parse_action(' '.join))
text = "shape: SQUARE posn: upper left color: BLACK"
- OneOrMore(attr_expr).parse_string(text).pprint() # Fail! read 'color' as data instead of next label -> [['shape', 'SQUARE color']]
+ attr_expr[1, ...].parse_string(text).pprint() # Fail! read 'color' as data instead of next label -> [['shape', 'SQUARE color']]
# use stop_on attribute for OneOrMore to avoid reading label string as part of the data
attr_expr = Group(label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))
@@ -4879,9 +4879,9 @@ class ZeroOrMore(_MultipleMatch):
def __init__(
self,
expr: ParserElement,
- stop_on: OptionalType[Union[ParserElement, str]] = None,
+ stop_on: typing.Optional[Union[ParserElement, str]] = None,
*,
- stopOn: OptionalType[Union[ParserElement, str]] = None,
+ stopOn: typing.Optional[Union[ParserElement, str]] = None,
):
super().__init__(expr, stopOn=stopOn or stop_on)
self.mayReturnEmpty = True
@@ -5046,7 +5046,7 @@ class SkipTo(ParseElementEnhance):
other: Union[ParserElement, str],
include: bool = False,
ignore: bool = None,
- fail_on: OptionalType[Union[ParserElement, str]] = None,
+ fail_on: typing.Optional[Union[ParserElement, str]] = None,
*,
failOn: Union[ParserElement, str] = None,
):
@@ -5143,7 +5143,7 @@ class Forward(ParseElementEnhance):
parser created using ``Forward``.
"""
- def __init__(self, other: OptionalType[Union[ParserElement, str]] = None):
+ def __init__(self, other: typing.Optional[Union[ParserElement, str]] = None):
self.caller_frame = traceback.extract_stack(limit=2)[0]
super().__init__(other, savelist=False)
self.lshift_line = None
@@ -5395,7 +5395,7 @@ class Combine(TokenConverter):
join_string: str = "",
adjacent: bool = True,
*,
- joinString: OptionalType[str] = None,
+ joinString: typing.Optional[str] = None,
):
super().__init__(expr)
joinString = joinString if joinString is not None else join_string
@@ -5482,10 +5482,10 @@ class Dict(TokenConverter):
attr_expr = (label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))
# print attributes as plain groups
- print(OneOrMore(attr_expr).parse_string(text).dump())
+ print(attr_expr[1, ...].parse_string(text).dump())
- # instead of OneOrMore(expr), parse using Dict(OneOrMore(Group(expr))) - Dict will auto-assign names
- result = Dict(OneOrMore(Group(attr_expr))).parse_string(text)
+ # instead of OneOrMore(expr), parse using Dict(Group(expr)[1, ...]) - Dict will auto-assign names
+ result = Dict(Group(attr_expr)[1, ...]).parse_string(text)
print(result.dump())
# access named fields as dict entries, or output as dict
@@ -5558,12 +5558,12 @@ class Suppress(TokenConverter):
source = "a, b, c,d"
wd = Word(alphas)
- wd_list1 = wd + ZeroOrMore(',' + wd)
+ wd_list1 = wd + (',' + wd)[...]
print(wd_list1.parse_string(source))
# often, delimiters that are useful during parsing are just in the
# way afterward - use Suppress to keep them out of the parsed output
- wd_list2 = wd + ZeroOrMore(Suppress(',') + wd)
+ wd_list2 = wd + (Suppress(',') + wd)[...]
print(wd_list2.parse_string(source))
# Skipped text (using '...') can be suppressed as well
@@ -5622,7 +5622,7 @@ def trace_parse_action(f: ParseAction) -> ParseAction:
def remove_duplicate_chars(tokens):
return ''.join(sorted(set(''.join(tokens))))
- wds = OneOrMore(wd).set_parse_action(remove_duplicate_chars)
+ wds = wd[1, ...].set_parse_action(remove_duplicate_chars)
print(wds.parse_string("slkdjs sld sldd sdlf sdljf"))
prints::
@@ -5728,18 +5728,18 @@ def token_map(func, *args) -> ParseAction:
Example (compare the last to example in :class:`ParserElement.transform_string`::
- hex_ints = OneOrMore(Word(hexnums)).set_parse_action(token_map(int, 16))
+ hex_ints = Word(hexnums)[1, ...].set_parse_action(token_map(int, 16))
hex_ints.run_tests('''
00 11 22 aa FF 0a 0d 1a
''')
upperword = Word(alphas).set_parse_action(token_map(str.upper))
- OneOrMore(upperword).run_tests('''
+ upperword[1, ...].run_tests('''
my kingdom for a horse
''')
wd = Word(alphas).set_parse_action(token_map(str.title))
- OneOrMore(wd).set_parse_action(' '.join).run_tests('''
+ wd[1, ...].set_parse_action(' '.join).run_tests('''
now is the winter of our discontent made glorious summer by this sun of york
''')
@@ -5795,7 +5795,9 @@ punc8bit = srange(r"[\0xa1-\0xbf\0xd7\0xf7]")
# build list of built-in expressions, for future reference if a global default value
# gets updated
-_builtin_exprs = [v for v in vars().values() if isinstance(v, ParserElement)]
+_builtin_exprs: List[ParserElement] = [
+ v for v in vars().values() if isinstance(v, ParserElement)
+]
# backward compatibility names
tokenMap = token_map
diff --git a/contrib/python/pyparsing/py3/pyparsing/diagram/__init__.py b/contrib/python/pyparsing/py3/pyparsing/diagram/__init__.py
index 2d0c587cbf..898644755c 100644
--- a/contrib/python/pyparsing/py3/pyparsing/diagram/__init__.py
+++ b/contrib/python/pyparsing/py3/pyparsing/diagram/__init__.py
@@ -1,9 +1,8 @@
import railroad
import pyparsing
-from pkg_resources import resource_filename
+import typing
from typing import (
List,
- Optional,
NamedTuple,
Generic,
TypeVar,
@@ -17,13 +16,41 @@ from io import StringIO
import inspect
-with open(resource_filename(__name__, "template.jinja2"), encoding="utf-8") as fp:
- template = Template(fp.read())
+jinja2_template_source = """\
+<!DOCTYPE html>
+<html>
+<head>
+ {% if not head %}
+ <style type="text/css">
+ .railroad-heading {
+ font-family: monospace;
+ }
+ </style>
+ {% else %}
+ {{ head | safe }}
+ {% endif %}
+</head>
+<body>
+{{ body | safe }}
+{% for diagram in diagrams %}
+ <div class="railroad-group">
+ <h1 class="railroad-heading">{{ diagram.title }}</h1>
+ <div class="railroad-description">{{ diagram.text }}</div>
+ <div class="railroad-svg">
+ {{ diagram.svg }}
+ </div>
+ </div>
+{% endfor %}
+</body>
+</html>
+"""
+
+template = Template(jinja2_template_source)
# Note: ideally this would be a dataclass, but we're supporting Python 3.5+ so we can't do this yet
NamedDiagram = NamedTuple(
"NamedDiagram",
- [("name", str), ("diagram", Optional[railroad.DiagramItem]), ("index", int)],
+ [("name", str), ("diagram", typing.Optional[railroad.DiagramItem]), ("index", int)],
)
"""
A simple structure for associating a name with a railroad diagram
@@ -107,6 +134,8 @@ def railroad_to_html(diagrams: List[NamedDiagram], **kwargs) -> str:
"""
data = []
for diagram in diagrams:
+ if diagram.diagram is None:
+ continue
io = StringIO()
diagram.diagram.writeSvg(io.write)
title = diagram.name
@@ -135,7 +164,7 @@ def resolve_partial(partial: "EditablePartial[T]") -> T:
def to_railroad(
element: pyparsing.ParserElement,
- diagram_kwargs: Optional[dict] = None,
+ diagram_kwargs: typing.Optional[dict] = None,
vertical: int = 3,
show_results_names: bool = False,
show_groups: bool = False,
@@ -216,12 +245,12 @@ class ElementState:
parent: EditablePartial,
number: int,
name: str = None,
- parent_index: Optional[int] = None,
+ parent_index: typing.Optional[int] = None,
):
#: The pyparsing element that this represents
self.element: pyparsing.ParserElement = element
#: The name of the element
- self.name: str = name
+ self.name: typing.Optional[str] = name
#: The output Railroad element in an unconverted state
self.converted: EditablePartial = converted
#: The parent Railroad element, which we store so that we can extract this if it's duplicated
@@ -229,7 +258,7 @@ class ElementState:
#: The order in which we found this element, used for sorting diagrams if this is extracted into a diagram
self.number: int = number
#: The index of this inside its parent
- self.parent_index: Optional[int] = parent_index
+ self.parent_index: typing.Optional[int] = parent_index
#: If true, we should extract this out into a subdiagram
self.extract: bool = False
#: If true, all of this element's children have been filled out
@@ -270,7 +299,7 @@ class ConverterState:
Stores some state that persists between recursions into the element tree
"""
- def __init__(self, diagram_kwargs: Optional[dict] = None):
+ def __init__(self, diagram_kwargs: typing.Optional[dict] = None):
#: A dictionary mapping ParserElements to state relating to them
self._element_diagram_states: Dict[int, ElementState] = {}
#: A dictionary mapping ParserElement IDs to subdiagrams generated from them
@@ -361,14 +390,14 @@ def _apply_diagram_item_enhancements(fn):
def _inner(
element: pyparsing.ParserElement,
- parent: Optional[EditablePartial],
+ parent: typing.Optional[EditablePartial],
lookup: ConverterState = None,
vertical: int = None,
index: int = 0,
name_hint: str = None,
show_results_names: bool = False,
show_groups: bool = False,
- ) -> Optional[EditablePartial]:
+ ) -> typing.Optional[EditablePartial]:
ret = fn(
element,
@@ -412,14 +441,14 @@ def _visible_exprs(exprs: Iterable[pyparsing.ParserElement]):
@_apply_diagram_item_enhancements
def _to_diagram_element(
element: pyparsing.ParserElement,
- parent: Optional[EditablePartial],
+ parent: typing.Optional[EditablePartial],
lookup: ConverterState = None,
vertical: int = None,
index: int = 0,
name_hint: str = None,
show_results_names: bool = False,
show_groups: bool = False,
-) -> Optional[EditablePartial]:
+) -> typing.Optional[EditablePartial]:
"""
Recursively converts a PyParsing Element to a railroad Element
:param lookup: The shared converter state that keeps track of useful things
@@ -526,7 +555,9 @@ def _to_diagram_element(
else:
ret = EditablePartial.from_call(railroad.Group, label="", item="")
elif isinstance(element, pyparsing.TokenConverter):
- ret = EditablePartial.from_call(AnnotatedItem, label=type(element).__name__.lower(), item="")
+ ret = EditablePartial.from_call(
+ AnnotatedItem, label=type(element).__name__.lower(), item=""
+ )
elif isinstance(element, pyparsing.Opt):
ret = EditablePartial.from_call(railroad.Optional, item="")
elif isinstance(element, pyparsing.OneOrMore):
diff --git a/contrib/python/pyparsing/py3/pyparsing/diagram/template.jinja2 b/contrib/python/pyparsing/py3/pyparsing/diagram/template.jinja2
deleted file mode 100644
index d2219fb011..0000000000
--- a/contrib/python/pyparsing/py3/pyparsing/diagram/template.jinja2
+++ /dev/null
@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- {% if not head %}
- <style type="text/css">
- .railroad-heading {
- font-family: monospace;
- }
- </style>
- {% else %}
- {{ hear | safe }}
- {% endif %}
-</head>
-<body>
-{{ body | safe }}
-{% for diagram in diagrams %}
- <div class="railroad-group">
- <h1 class="railroad-heading">{{ diagram.title }}</h1>
- <div class="railroad-description">{{ diagram.text }}</div>
- <div class="railroad-svg">
- {{ diagram.svg }}
- </div>
- </div>
-{% endfor %}
-</body>
-</html>
diff --git a/contrib/python/pyparsing/py3/pyparsing/exceptions.py b/contrib/python/pyparsing/py3/pyparsing/exceptions.py
index e06513eb00..a38447bb05 100644
--- a/contrib/python/pyparsing/py3/pyparsing/exceptions.py
+++ b/contrib/python/pyparsing/py3/pyparsing/exceptions.py
@@ -2,7 +2,7 @@
import re
import sys
-from typing import Optional
+import typing
from .util import col, line, lineno, _collapse_string_to_ranges
from .unicode import pyparsing_unicode as ppu
@@ -25,7 +25,7 @@ class ParseBaseException(Exception):
self,
pstr: str,
loc: int = 0,
- msg: Optional[str] = None,
+ msg: typing.Optional[str] = None,
elem=None,
):
self.loc = loc
diff --git a/contrib/python/pyparsing/py3/pyparsing/helpers.py b/contrib/python/pyparsing/py3/pyparsing/helpers.py
index be8a365788..9588b3b780 100644
--- a/contrib/python/pyparsing/py3/pyparsing/helpers.py
+++ b/contrib/python/pyparsing/py3/pyparsing/helpers.py
@@ -1,6 +1,7 @@
# helpers.py
import html.entities
import re
+import typing
from . import __diag__
from .core import *
@@ -14,8 +15,8 @@ def delimited_list(
expr: Union[str, ParserElement],
delim: Union[str, ParserElement] = ",",
combine: bool = False,
- min: OptionalType[int] = None,
- max: OptionalType[int] = None,
+ min: typing.Optional[int] = None,
+ max: typing.Optional[int] = None,
*,
allow_trailing_delim: bool = False,
) -> ParserElement:
@@ -69,9 +70,9 @@ def delimited_list(
def counted_array(
expr: ParserElement,
- int_expr: OptionalType[ParserElement] = None,
+ int_expr: typing.Optional[ParserElement] = None,
*,
- intExpr: OptionalType[ParserElement] = None,
+ intExpr: typing.Optional[ParserElement] = None,
) -> ParserElement:
"""Helper to define a counted list of expressions.
@@ -197,7 +198,7 @@ def match_previous_expr(expr: ParserElement) -> ParserElement:
def one_of(
- strs: Union[IterableType[str], str],
+ strs: Union[typing.Iterable[str], str],
caseless: bool = False,
use_regex: bool = True,
as_keyword: bool = False,
@@ -337,7 +338,7 @@ def dict_of(key: ParserElement, value: ParserElement) -> ParserElement:
text = "shape: SQUARE posn: upper left color: light blue texture: burlap"
attr_expr = (label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))
- print(OneOrMore(attr_expr).parse_string(text).dump())
+ print(attr_expr[1, ...].parse_string(text).dump())
attr_label = label
attr_value = Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join)
@@ -461,7 +462,7 @@ def locatedExpr(expr: ParserElement) -> ParserElement:
def nested_expr(
opener: Union[str, ParserElement] = "(",
closer: Union[str, ParserElement] = ")",
- content: OptionalType[ParserElement] = None,
+ content: typing.Optional[ParserElement] = None,
ignore_expr: ParserElement = quoted_string(),
*,
ignoreExpr: ParserElement = quoted_string(),
@@ -682,6 +683,8 @@ def make_xml_tags(
return _makeTags(tag_str, True)
+any_open_tag: ParserElement
+any_close_tag: ParserElement
any_open_tag, any_close_tag = make_html_tags(
Word(alphas, alphanums + "_:").set_name("any tag")
)
@@ -710,7 +713,7 @@ InfixNotationOperatorSpec = Union[
InfixNotationOperatorArgType,
int,
OpAssoc,
- OptionalType[ParseAction],
+ typing.Optional[ParseAction],
],
Tuple[
InfixNotationOperatorArgType,
@@ -840,7 +843,7 @@ def infix_notation(
if rightLeftAssoc not in (OpAssoc.LEFT, OpAssoc.RIGHT):
raise ValueError("operator must indicate right or left associativity")
- thisExpr = Forward().set_name(term_name)
+ thisExpr: Forward = Forward().set_name(term_name)
if rightLeftAssoc is OpAssoc.LEFT:
if arity == 1:
matchExpr = _FB(lastExpr + opExpr) + Group(lastExpr + opExpr[1, ...])
@@ -945,7 +948,7 @@ def indentedBlock(blockStatementExpr, indentStack, indent=True, backup_stacks=[]
assignment = Group(identifier + "=" + rvalue)
stmt << (funcDef | assignment | identifier)
- module_body = OneOrMore(stmt)
+ module_body = stmt[1, ...]
parseTree = module_body.parseString(data)
parseTree.pprint()
@@ -1055,7 +1058,9 @@ python_style_comment = Regex(r"#.*").set_name("Python style comment")
# build list of built-in expressions, for future reference if a global default value
# gets updated
-_builtin_exprs = [v for v in vars().values() if isinstance(v, ParserElement)]
+_builtin_exprs: List[ParserElement] = [
+ v for v in vars().values() if isinstance(v, ParserElement)
+]
# pre-PEP8 compatible names
diff --git a/contrib/python/pyparsing/py3/pyparsing/results.py b/contrib/python/pyparsing/py3/pyparsing/results.py
index bb444df4e5..00c9421d3b 100644
--- a/contrib/python/pyparsing/py3/pyparsing/results.py
+++ b/contrib/python/pyparsing/py3/pyparsing/results.py
@@ -287,7 +287,7 @@ class ParseResults:
print(numlist.parse_string("0 123 321")) # -> ['123', '321']
label = Word(alphas)
- patt = label("LABEL") + OneOrMore(Word(nums))
+ patt = label("LABEL") + Word(nums)[1, ...]
print(patt.parse_string("AAB 123 321").dump())
# Use pop() in a parse action to remove named result (note that corresponding value is not
@@ -394,7 +394,7 @@ class ParseResults:
Example::
- patt = OneOrMore(Word(alphas))
+ patt = Word(alphas)[1, ...]
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrome(tokens):
@@ -487,7 +487,7 @@ class ParseResults:
Example::
- patt = OneOrMore(Word(alphas))
+ patt = Word(alphas)[1, ...]
result = patt.parse_string("sldkj lsdkj sldkj")
# even though the result prints in string-like form, it is actually a pyparsing ParseResults
print(type(result), result) # -> <class 'pyparsing.ParseResults'> ['sldkj', 'lsdkj', 'sldkj']
@@ -554,7 +554,7 @@ class ParseResults:
user_data = (Group(house_number_expr)("house_number")
| Group(ssn_expr)("ssn")
| Group(integer)("age"))
- user_info = OneOrMore(user_data)
+ user_info = user_data[1, ...]
result = user_info.parse_string("22 111-22-3333 #221B")
for item in result:
diff --git a/contrib/python/pyparsing/py3/pyparsing/testing.py b/contrib/python/pyparsing/py3/pyparsing/testing.py
index 991972f3fb..84a0ef1707 100644
--- a/contrib/python/pyparsing/py3/pyparsing/testing.py
+++ b/contrib/python/pyparsing/py3/pyparsing/testing.py
@@ -1,7 +1,7 @@
# testing.py
from contextlib import contextmanager
-from typing import Optional
+import typing
from .core import (
ParserElement,
@@ -237,12 +237,12 @@ class pyparsing_test:
@staticmethod
def with_line_numbers(
s: str,
- start_line: Optional[int] = None,
- end_line: Optional[int] = None,
+ start_line: typing.Optional[int] = None,
+ end_line: typing.Optional[int] = None,
expand_tabs: bool = True,
eol_mark: str = "|",
- mark_spaces: Optional[str] = None,
- mark_control: Optional[str] = None,
+ mark_spaces: typing.Optional[str] = None,
+ mark_control: typing.Optional[str] = None,
) -> str:
"""
Helpful method for debugging a parser - prints a string with line and column numbers.
diff --git a/contrib/python/pyparsing/py3/pyparsing/unicode.py b/contrib/python/pyparsing/py3/pyparsing/unicode.py
index 92261487c7..0652620391 100644
--- a/contrib/python/pyparsing/py3/pyparsing/unicode.py
+++ b/contrib/python/pyparsing/py3/pyparsing/unicode.py
@@ -120,7 +120,18 @@ class pyparsing_unicode(unicode_set):
A namespace class for defining common language unicode_sets.
"""
- _ranges: UnicodeRangeList = [(32, sys.maxunicode)]
+ # fmt: off
+
+ # define ranges in language character sets
+ _ranges: UnicodeRangeList = [
+ (0x0020, sys.maxunicode),
+ ]
+
+ class BasicMultilingualPlane(unicode_set):
+ "Unicode set for the Basic Multilingual Plane"
+ _ranges: UnicodeRangeList = [
+ (0x0020, 0xFFFF),
+ ]
class Latin1(unicode_set):
"Unicode set for Latin-1 Unicode Character Range"
@@ -278,11 +289,13 @@ class pyparsing_unicode(unicode_set):
class CJK(Chinese, Japanese, Hangul):
"Unicode set for combined Chinese, Japanese, and Korean (CJK) Unicode Character Range"
- pass
class Thai(unicode_set):
"Unicode set for Thai Unicode Character Range"
- _ranges: UnicodeRangeList = [(0x0E01, 0x0E3A), (0x0E3F, 0x0E5B)]
+ _ranges: UnicodeRangeList = [
+ (0x0E01, 0x0E3A),
+ (0x0E3F, 0x0E5B)
+ ]
class Arabic(unicode_set):
"Unicode set for Arabic Unicode Character Range"
@@ -308,7 +321,12 @@ class pyparsing_unicode(unicode_set):
class Devanagari(unicode_set):
"Unicode set for Devanagari Unicode Character Range"
- _ranges: UnicodeRangeList = [(0x0900, 0x097F), (0xA8E0, 0xA8FF)]
+ _ranges: UnicodeRangeList = [
+ (0x0900, 0x097F),
+ (0xA8E0, 0xA8FF)
+ ]
+
+ # fmt: on
pyparsing_unicode.Japanese._ranges = (
@@ -317,7 +335,9 @@ pyparsing_unicode.Japanese._ranges = (
+ pyparsing_unicode.Japanese.Katakana._ranges
)
-# define ranges in language character sets
+pyparsing_unicode.BMP = pyparsing_unicode.BasicMultilingualPlane
+
+# add language identifiers using language Unicode
pyparsing_unicode.العربية = pyparsing_unicode.Arabic
pyparsing_unicode.中文 = pyparsing_unicode.Chinese
pyparsing_unicode.кириллица = pyparsing_unicode.Cyrillic
diff --git a/contrib/python/traitlets/py3/.dist-info/METADATA b/contrib/python/traitlets/py3/.dist-info/METADATA
index 7387396b72..eb35757fe1 100644
--- a/contrib/python/traitlets/py3/.dist-info/METADATA
+++ b/contrib/python/traitlets/py3/.dist-info/METADATA
@@ -1,30 +1,21 @@
Metadata-Version: 2.1
Name: traitlets
-Version: 5.1.1
+Version: 5.2.0
Summary: Traitlets Python configuration system
-Home-page: https://github.com/ipython/traitlets
-Author: IPython Development Team
-Author-email: ipython-dev@python.org
-License: BSD
-Project-URL: Documentation, https://traitlets.readthedocs.io/
-Project-URL: Funding, https://numfocus.org/
-Project-URL: Source, https://github.com/ipython/traitlets
-Project-URL: Tracker, https://github.com/ipython/traitlets/issues
Keywords: Interactive,Interpreter,Shell,Web
-Platform: Linux
-Platform: Mac OS X
-Platform: Windows
+Author-email: IPython Development Team <ipython-dev@python.org>
+Requires-Python: >=3.7
+Description-Content-Type: text/markdown
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
-Requires-Python: >=3.7
-Description-Content-Type: text/markdown
-License-File: COPYING.md
+Requires-Dist: pytest ; extra == "test"
+Requires-Dist: pre-commit ; extra == "test"
+Project-URL: Homepage, https://github.com/ipython/traitlets
Provides-Extra: test
-Requires-Dist: pytest ; extra == 'test'
# Traitlets
@@ -32,17 +23,17 @@ Requires-Dist: pytest ; extra == 'test'
[![Test downstream projects](https://github.com/ipython/traitlets/actions/workflows/downstream.yml/badge.svg)](https://github.com/ipython/traitlets/actions/workflows/downstream.yml)
[![Documentation Status](https://readthedocs.org/projects/traitlets/badge/?version=latest)](https://traitlets.readthedocs.io/en/latest/?badge=latest)
-| | |
-|---------------|----------------------------------------|
-| **home** | https://github.com/ipython/traitlets |
-| **pypi-repo** | https://pypi.org/project/traitlets/ |
-| **docs** | https://traitlets.readthedocs.io/ |
-| **license** | Modified BSD License |
+| | |
+| ------------- | ------------------------------------ |
+| **home** | https://github.com/ipython/traitlets |
+| **pypi-repo** | https://pypi.org/project/traitlets/ |
+| **docs** | https://traitlets.readthedocs.io/ |
+| **license** | Modified BSD License |
Traitlets is a pure Python library enabling:
- the enforcement of strong typing for attributes of Python objects
- (typed attributes are called *"traits"*);
+ (typed attributes are called _"traits"_);
- dynamically calculated default values;
- automatic validation and coercion of trait attributes when attempting a
change;
@@ -53,7 +44,7 @@ Traitlets is a pure Python library enabling:
Its implementation relies on the [descriptor](https://docs.python.org/howto/descriptor.html)
pattern, and it is a lightweight pure-python alternative of the
-[*traits* library](https://docs.enthought.com/traits/).
+[_traits_ library](https://docs.enthought.com/traits/).
Traitlets powers the configuration system of IPython and Jupyter
and the declarative API of IPython interactive widgets.
@@ -83,6 +74,35 @@ pip install "traitlets[test]"
py.test traitlets
```
+## Code Styling
+
+`traitlets` has adopted automatic code formatting so you shouldn't
+need to worry too much about your code style.
+As long as your code is valid,
+the pre-commit hook should take care of how it should look.
+
+To install `pre-commit` locally, run the following::
+
+ pip install pre-commit
+ pre-commit install
+
+You can invoke the pre-commit hook by hand at any time with::
+
+ pre-commit run
+
+which should run any autoformatting on your code
+and tell you about any errors it couldn't fix automatically.
+You may also install [black integration](https://github.com/psf/black#editor-integration)
+into your text editor to format code automatically.
+
+If you have already committed files before setting up the pre-commit
+hook with `pre-commit install`, you can fix everything up using
+`pre-commit run --all-files`. You need to make the fixing commit
+yourself after that.
+
+Some of the hooks only run on CI by default, but you can invoke them by
+running with the `--hook-stage manual` argument.
+
## Usage
Any class with trait attributes must inherit from `HasTraits`.
@@ -119,7 +139,7 @@ To do something when a trait attribute is changed, decorate a method with
The method will be called with a single argument, a dictionary which contains
an owner, new value, old value, name of the changed trait, and the event type.
-In this example, the `_num_changed` method is decorated with ``@observe(`num`)``:
+In this example, the `_num_changed` method is decorated with `` @observe(`num`) ``:
```Python
from traitlets import HasTraits, Integer, observe
@@ -192,4 +212,3 @@ $ pip install build
$ python -m build .
```
-
diff --git a/contrib/python/traitlets/py3/COPYING.md b/contrib/python/traitlets/py3/COPYING.md
index 39ca730a63..861df38586 100644
--- a/contrib/python/traitlets/py3/COPYING.md
+++ b/contrib/python/traitlets/py3/COPYING.md
@@ -27,7 +27,7 @@ software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
@@ -49,8 +49,8 @@ IPython uses a shared copyright model. Each contributor maintains copyright
over their contributions to IPython. But, it is important to note that these
contributions are typically only changes to the repositories. Thus, the IPython
source code, in its entirety is not the copyright of any single person or
-institution. Instead, it is the collective copyright of the entire IPython
-Development Team. If individual contributors want to maintain a record of what
+institution. Instead, it is the collective copyright of the entire IPython
+Development Team. If individual contributors want to maintain a record of what
changes/contributions they have specific copyright on, they should indicate
their copyright in the commit message of the change, when they commit the
change to one of the IPython repositories.
diff --git a/contrib/python/traitlets/py3/README.md b/contrib/python/traitlets/py3/README.md
index b0c1b2e67c..98fa570aa1 100644
--- a/contrib/python/traitlets/py3/README.md
+++ b/contrib/python/traitlets/py3/README.md
@@ -4,17 +4,17 @@
[![Test downstream projects](https://github.com/ipython/traitlets/actions/workflows/downstream.yml/badge.svg)](https://github.com/ipython/traitlets/actions/workflows/downstream.yml)
[![Documentation Status](https://readthedocs.org/projects/traitlets/badge/?version=latest)](https://traitlets.readthedocs.io/en/latest/?badge=latest)
-| | |
-|---------------|----------------------------------------|
-| **home** | https://github.com/ipython/traitlets |
-| **pypi-repo** | https://pypi.org/project/traitlets/ |
-| **docs** | https://traitlets.readthedocs.io/ |
-| **license** | Modified BSD License |
+| | |
+| ------------- | ------------------------------------ |
+| **home** | https://github.com/ipython/traitlets |
+| **pypi-repo** | https://pypi.org/project/traitlets/ |
+| **docs** | https://traitlets.readthedocs.io/ |
+| **license** | Modified BSD License |
Traitlets is a pure Python library enabling:
- the enforcement of strong typing for attributes of Python objects
- (typed attributes are called *"traits"*);
+ (typed attributes are called _"traits"_);
- dynamically calculated default values;
- automatic validation and coercion of trait attributes when attempting a
change;
@@ -25,7 +25,7 @@ Traitlets is a pure Python library enabling:
Its implementation relies on the [descriptor](https://docs.python.org/howto/descriptor.html)
pattern, and it is a lightweight pure-python alternative of the
-[*traits* library](https://docs.enthought.com/traits/).
+[_traits_ library](https://docs.enthought.com/traits/).
Traitlets powers the configuration system of IPython and Jupyter
and the declarative API of IPython interactive widgets.
@@ -55,6 +55,35 @@ pip install "traitlets[test]"
py.test traitlets
```
+## Code Styling
+
+`traitlets` has adopted automatic code formatting so you shouldn't
+need to worry too much about your code style.
+As long as your code is valid,
+the pre-commit hook should take care of how it should look.
+
+To install `pre-commit` locally, run the following::
+
+ pip install pre-commit
+ pre-commit install
+
+You can invoke the pre-commit hook by hand at any time with::
+
+ pre-commit run
+
+which should run any autoformatting on your code
+and tell you about any errors it couldn't fix automatically.
+You may also install [black integration](https://github.com/psf/black#editor-integration)
+into your text editor to format code automatically.
+
+If you have already committed files before setting up the pre-commit
+hook with `pre-commit install`, you can fix everything up using
+`pre-commit run --all-files`. You need to make the fixing commit
+yourself after that.
+
+Some of the hooks only run on CI by default, but you can invoke them by
+running with the `--hook-stage manual` argument.
+
## Usage
Any class with trait attributes must inherit from `HasTraits`.
@@ -91,7 +120,7 @@ To do something when a trait attribute is changed, decorate a method with
The method will be called with a single argument, a dictionary which contains
an owner, new value, old value, name of the changed trait, and the event type.
-In this example, the `_num_changed` method is decorated with ``@observe(`num`)``:
+In this example, the `_num_changed` method is decorated with `` @observe(`num`) ``:
```Python
from traitlets import HasTraits, Integer, observe
diff --git a/contrib/python/traitlets/py3/patches/01-fix-tests.patch b/contrib/python/traitlets/py3/patches/01-fix-tests.patch
index a4b6de274d..3b23932a03 100644
--- a/contrib/python/traitlets/py3/patches/01-fix-tests.patch
+++ b/contrib/python/traitlets/py3/patches/01-fix-tests.patch
@@ -1,83 +1,44 @@
--- contrib/python/traitlets/py3/traitlets/config/tests/test_configurable.py (index)
+++ contrib/python/traitlets/py3/traitlets/config/tests/test_configurable.py (working tree)
-@@ -22,7 +22,7 @@ from traitlets.traitlets import (
-
- from traitlets.config.loader import Config
-
+@@ -33,1 +33,1 @@ from traitlets.traitlets import (
-from ...tests._warnings import expected_warnings
+from traitlets.tests._warnings import expected_warnings
-
- class MyConfigurable(Configurable):
- a = Integer(1, help="The integer a.").tag(config=True)
--- contrib/python/traitlets/py3/traitlets/config/tests/test_application.py (index)
+++ contrib/python/traitlets/py3/traitlets/config/tests/test_application.py (working tree)
-@@ -629,6 +629,8 @@ class TestApplication(TestCase):
- self.assertEqual(app.running, False)
+@@ -635,2 +635,3 @@ class TestApplication(TestCase):
-
-+
+@mark.skip
def test_cli_multi_scalar(caplog):
- class App(Application):
- aliases = {"opt": "App.opt"}
-@@ -648,7 +650,7 @@ def test_cli_multi_scalar(caplog):
-
- class Root(Application):
- subcommands = {
-- 'sub1': ('traitlets.config.tests.test_application.Sub1', 'import string'),
-+ 'sub1': ('__tests__.config.tests.test_application.Sub1', 'import string'),
- }
-
-
+@@ -655,1 +656,1 @@ def test_cli_multi_scalar(caplog):
+- "sub1": ("traitlets.config.tests.test_application.Sub1", "import string"),
++ "sub1": ("__tests__.config.tests.test_application.Sub1", "import string"),
--- contrib/python/traitlets/py3/traitlets/tests/test_traitlets.py (index)
+++ contrib/python/traitlets/py3/traitlets/tests/test_traitlets.py (working tree)
-@@ -13,7 +13,7 @@ from unittest import TestCase
-
- import pytest
-
+@@ -63,1 +63,1 @@ from unittest import TestCase
-from ._warnings import expected_warnings
+from traitlets.tests._warnings import expected_warnings
- from traitlets import (
- HasTraits,
- MetaHasTraits,
--- contrib/python/traitlets/py3/traitlets/utils/tests/test_bunch.py (index)
+++ contrib/python/traitlets/py3/traitlets/utils/tests/test_bunch.py (working tree)
-@@ -1,4 +1,4 @@
+@@ -1,1 +1,1 @@
-from ..bunch import Bunch
+from traitlets.utils.bunch import Bunch
-
- def test_bunch():
- b = Bunch(x=5, y=10)
--- contrib/python/traitlets/py3/traitlets/utils/tests/test_decorators.py (index)
+++ contrib/python/traitlets/py3/traitlets/utils/tests/test_decorators.py (working tree)
-@@ -2,9 +2,9 @@ from unittest import TestCase
-
- from inspect import Signature, Parameter, signature
-
+@@ -4,2 +4,2 @@ from unittest import TestCase
-from ...traitlets import HasTraits, Int, Unicode
+from traitlets.traitlets import HasTraits, Int, Unicode
-
-from ..decorators import signature_has_traits
+from traitlets.utils.decorators import signature_has_traits
-
-
- class TestExpandSignature(TestCase):
--- contrib/python/traitlets/py3/traitlets/utils/tests/test_importstring.py (index)
+++ contrib/python/traitlets/py3/traitlets/utils/tests/test_importstring.py (working tree)
-@@ -8,7 +8,7 @@
- import os
- from unittest import TestCase
-
+@@ -11,1 +11,1 @@
-from ..importstring import import_item
+from traitlets.utils.importstring import import_item
-
-
- class TestImportItem(TestCase):
--- contrib/python/traitlets/py3/traitlets/tests/utils.py (index)
+++ contrib/python/traitlets/py3/traitlets/tests/utils.py (working tree)
@@ -1,10 +1,13 @@
- from subprocess import Popen, PIPE
import sys
+ from subprocess import PIPE, Popen
+import os
@@ -85,8 +46,8 @@
"""Get stdout, stderr, and exit code from running a command"""
- p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+ env = os.environ.copy()
-+ env['Y_PYTHON_ENTRY_POINT'] = ':main'
++ env["Y_PYTHON_ENTRY_POINT"] = ":main"
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env)
out, err = p.communicate()
- out = out.decode('utf8', 'replace')
- err = err.decode('utf8', 'replace')
+ out = out.decode("utf8", "replace")
+ err = err.decode("utf8", "replace")
diff --git a/contrib/python/traitlets/py3/traitlets/__init__.py b/contrib/python/traitlets/py3/traitlets/__init__.py
index ad5ba73c86..a3ea9f0d54 100644
--- a/contrib/python/traitlets/py3/traitlets/__init__.py
+++ b/contrib/python/traitlets/py3/traitlets/__init__.py
@@ -1,16 +1,17 @@
+"""Traitlets Python configuration system"""
from warnings import warn
from . import traitlets
+from ._version import __version__, version_info
from .traitlets import *
-from .utils.importstring import import_item
-from .utils.decorators import signature_has_traits
from .utils.bunch import Bunch
-from ._version import version_info, __version__
+from .utils.decorators import signature_has_traits
+from .utils.importstring import import_item
-class Sentinel(traitlets.Sentinel):
+class Sentinel(traitlets.Sentinel): # type:ignore[name-defined]
def __init__(self, *args, **kwargs):
- super(Sentinel, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
warn(
"""
Sentinel is not a public part of the traitlets API.
diff --git a/contrib/python/traitlets/py3/traitlets/_version.py b/contrib/python/traitlets/py3/traitlets/_version.py
index 5f05912b66..c416b77b84 100644
--- a/contrib/python/traitlets/py3/traitlets/_version.py
+++ b/contrib/python/traitlets/py3/traitlets/_version.py
@@ -1,13 +1,10 @@
-version_info = (5, 1, 1)
+version_info = (5, 2, 0)
# unlike `.dev`, alpha, beta and rc _must not_ have dots,
# or the wheel and tgz won't look to pip like the same version.
__version__ = (
- ".".join(map(str, version_info))
- .replace(".b", "b")
- .replace(".a", "a")
- .replace(".rc", "rc")
+ ".".join(map(str, version_info)).replace(".b", "b").replace(".a", "a").replace(".rc", "rc")
)
assert ".b" not in __version__
assert ".a" not in __version__
diff --git a/contrib/python/traitlets/py3/traitlets/config/__init__.py b/contrib/python/traitlets/py3/traitlets/config/__init__.py
index 0ae7d63171..c5feccc73b 100644
--- a/contrib/python/traitlets/py3/traitlets/config/__init__.py
+++ b/contrib/python/traitlets/py3/traitlets/config/__init__.py
@@ -1,5 +1,3 @@
-# encoding: utf-8
-
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
diff --git a/contrib/python/traitlets/py3/traitlets/config/application.py b/contrib/python/traitlets/py3/traitlets/config/application.py
index 99a6ef7ee0..02dc72eb56 100644
--- a/contrib/python/traitlets/py3/traitlets/config/application.py
+++ b/contrib/python/traitlets/py3/traitlets/config/application.py
@@ -4,8 +4,6 @@
# Distributed under the terms of the Modified BSD License.
-from collections import defaultdict, OrderedDict
-from copy import deepcopy
import functools
import json
import logging
@@ -13,25 +11,43 @@ import os
import pprint
import re
import sys
-import warnings
+import typing as t
+from collections import OrderedDict, defaultdict
+from contextlib import suppress
+from copy import deepcopy
+from logging.config import dictConfig
+from textwrap import dedent
from traitlets.config.configurable import Configurable, SingletonConfigurable
from traitlets.config.loader import (
- KVArgParseConfigLoader, PyFileConfigLoader, Config, ArgumentError, ConfigFileNotFound, JSONFileConfigLoader
+ ArgumentError,
+ Config,
+ ConfigFileNotFound,
+ JSONFileConfigLoader,
+ KVArgParseConfigLoader,
+ PyFileConfigLoader,
)
from traitlets.traitlets import (
- Bool, Unicode, List, Enum, Dict, Instance, TraitError, observe, observe_compat, default,
+ Bool,
+ Dict,
+ Enum,
+ Instance,
+ List,
+ TraitError,
+ Unicode,
+ default,
+ observe,
+ observe_compat,
)
-
-from ..utils.importstring import import_item
-from ..utils import cast_unicode
+from traitlets.utils.nested_update import nested_update
from traitlets.utils.text import indent, wrap_paragraphs
-from textwrap import dedent
+from ..utils import cast_unicode
+from ..utils.importstring import import_item
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Descriptions for the various sections
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# merge flags&aliases into options
option_description = """
The options below are convenience aliases to configurable class-options,
@@ -46,7 +62,7 @@ The command-line option below sets the respective configurable class-parameter:
This line is evaluated in Python, so simple expressions are allowed.
For instance, to set `C.a=[0,1,2]`, you may type this:
--C.a='range(3)'
-""".strip() # trim newlines of front and back
+""".strip() # trim newlines of front and back
# sys.argv can be missing, for example when python is embedded. See the docs
# for details: http://docs.python.org/2/c-api/intro.html#embedding-python
@@ -59,19 +75,21 @@ subcommand 'cmd', do: `{app} cmd -h`.
"""
# get running program name
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Application class
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
-
-_envvar = os.environ.get('TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR','')
-if _envvar.lower() in {'1','true'}:
+_envvar = os.environ.get("TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR", "")
+if _envvar.lower() in {"1", "true"}:
TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR = True
-elif _envvar.lower() in {'0','false',''} :
+elif _envvar.lower() in {"0", "false", ""}:
TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR = False
else:
- raise ValueError("Unsupported value for environment variable: 'TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR' is set to '%s' which is none of {'0', '1', 'false', 'true', ''}."% _envvar )
+ raise ValueError(
+ "Unsupported value for environment variable: 'TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR' is set to '%s' which is none of {'0', '1', 'false', 'true', ''}."
+ % _envvar
+ )
def catch_config_error(method):
@@ -82,6 +100,7 @@ def catch_config_error(method):
For use on init methods, to prevent invoking excepthook on invalid input.
"""
+
@functools.wraps(method)
def inner(app, *args, **kwargs):
try:
@@ -93,6 +112,7 @@ def catch_config_error(method):
return inner
+
class ApplicationError(Exception):
pass
@@ -106,6 +126,7 @@ class LevelFormatter(logging.Formatter):
Useful for adding 'WARNING' to warning messages,
without adding 'INFO' to info, etc.
"""
+
highlevel_limit = logging.WARN
highlevel_format = " %(levelname)s |"
@@ -114,7 +135,7 @@ class LevelFormatter(logging.Formatter):
record.highlevel = self.highlevel_format % record.__dict__
else:
record.highlevel = ""
- return super(LevelFormatter, self).format(record)
+ return super().format(record)
class Application(SingletonConfigurable):
@@ -122,11 +143,11 @@ class Application(SingletonConfigurable):
# The name of the application, will usually match the name of the command
# line application
- name = Unicode('application')
+ name = Unicode("application")
# The description of the application that is printed at the beginning
# of the help.
- description = Unicode('This is an application.')
+ description = Unicode("This is an application.")
# default section descriptions
option_description = Unicode(option_description)
keyvalue_description = Unicode(keyvalue_description)
@@ -140,7 +161,7 @@ class Application(SingletonConfigurable):
# A sequence of Configurable subclasses whose config=True attributes will
# be exposed at the command line.
- classes = []
+ classes: t.List[t.Type[t.Any]] = []
def _classes_inc_parents(self, classes=None):
"""Iterate through configurable classes, including configurable parents
@@ -163,7 +184,7 @@ class Application(SingletonConfigurable):
yield parent
# The version string of this application.
- version = Unicode('0.0')
+ version = Unicode("0.0")
# the argv used to initialize the application
argv = List()
@@ -172,99 +193,189 @@ class Application(SingletonConfigurable):
raise_config_file_errors = Bool(TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR)
# The log level for the application
- log_level = Enum((0,10,20,30,40,50,'DEBUG','INFO','WARN','ERROR','CRITICAL'),
- default_value=logging.WARN,
- help="Set the log level by value or name.").tag(config=True)
-
- @observe('log_level')
- @observe_compat
- def _log_level_changed(self, change):
- """Adjust the log level when log_level is set."""
- new = change.new
- if isinstance(new, str):
- new = getattr(logging, new)
- self.log_level = new
- self.log.setLevel(new)
+ log_level = Enum(
+ (0, 10, 20, 30, 40, 50, "DEBUG", "INFO", "WARN", "ERROR", "CRITICAL"),
+ default_value=logging.WARN,
+ help="Set the log level by value or name.",
+ ).tag(config=True)
_log_formatter_cls = LevelFormatter
- log_datefmt = Unicode("%Y-%m-%d %H:%M:%S",
- help="The date format used by logging formatters for %(asctime)s"
+ log_datefmt = Unicode(
+ "%Y-%m-%d %H:%M:%S", help="The date format used by logging formatters for %(asctime)s"
).tag(config=True)
- log_format = Unicode("[%(name)s]%(highlevel)s %(message)s",
+ log_format = Unicode(
+ "[%(name)s]%(highlevel)s %(message)s",
help="The Logging format template",
).tag(config=True)
- @observe('log_datefmt', 'log_format')
- @observe_compat
- def _log_format_changed(self, change):
- """Change the log formatter when log_format is set."""
- _log_handler = self._get_log_handler()
- if not _log_handler:
- warnings.warn(
- f"No Handler found on {self.log}, setting log_format will have no effect",
- RuntimeWarning,
- )
- return
- _log_formatter = self._log_formatter_cls(fmt=self.log_format, datefmt=self.log_datefmt)
- _log_handler.setFormatter(_log_formatter)
-
- @default('log')
- def _log_default(self):
- """Start logging for this application.
+ def get_default_logging_config(self):
+ """Return the base logging configuration.
The default is to log to stderr using a StreamHandler, if no default
- handler already exists. The log level starts at logging.WARN, but this
- can be adjusted by setting the ``log_level`` attribute.
+ handler already exists.
+
+ The log handler level starts at logging.WARN, but this can be adjusted
+ by setting the ``log_level`` attribute.
+
+ The ``logging_config`` trait is merged into this allowing for finer
+ control of logging.
+
"""
+ config: t.Dict[str, t.Any] = {
+ "version": 1,
+ "handlers": {
+ "console": {
+ "class": "logging.StreamHandler",
+ "formatter": "console",
+ "level": logging.getLevelName(self.log_level),
+ "stream": "ext://sys.stderr",
+ },
+ },
+ "formatters": {
+ "console": {
+ "class": (
+ f"{self._log_formatter_cls.__module__}"
+ f".{self._log_formatter_cls.__name__}"
+ ),
+ "format": self.log_format,
+ "datefmt": self.log_datefmt,
+ },
+ },
+ "loggers": {
+ self.__class__.__name__: {
+ "level": "DEBUG",
+ "handlers": ["console"],
+ }
+ },
+ "disable_existing_loggers": False,
+ }
+
+ if sys.executable and sys.executable.endswith("pythonw.exe"):
+ # disable logging
+ # (this should really go to a file, but file-logging is only
+ # hooked up in parallel applications)
+ del config["handlers"]["loggers"]
+
+ return config
+
+ @observe("log_datefmt", "log_format", "log_level", "logging_config")
+ def _observe_logging_change(self, change):
+ # convert log level strings to ints
+ log_level = self.log_level
+ if isinstance(log_level, str):
+ self.log_level = getattr(logging, log_level)
+ self._configure_logging()
+
+ @observe("log", type="default")
+ def _observe_logging_default(self, change):
+ self._configure_logging()
+
+ def _configure_logging(self):
+ config = self.get_default_logging_config()
+ nested_update(config, self.logging_config or {})
+ dictConfig(config)
+
+ @default("log")
+ def _log_default(self):
+ """Start logging for this application."""
log = logging.getLogger(self.__class__.__name__)
- log.setLevel(self.log_level)
log.propagate = False
- _log = log # copied from Logger.hasHandlers() (new in Python 3.2)
+ _log = log # copied from Logger.hasHandlers() (new in Python 3.2)
while _log:
if _log.handlers:
return log
if not _log.propagate:
break
else:
- _log = _log.parent
- if sys.executable and sys.executable.endswith('pythonw.exe'):
- # this should really go to a file, but file-logging is only
- # hooked up in parallel applications
- _log_handler = logging.StreamHandler(open(os.devnull, 'w'))
- else:
- _log_handler = logging.StreamHandler()
- _log_formatter = self._log_formatter_cls(fmt=self.log_format, datefmt=self.log_datefmt)
- _log_handler.setFormatter(_log_formatter)
- log.addHandler(_log_handler)
+ _log = _log.parent # type:ignore[assignment]
return log
+ logging_config = Dict(
+ help="""
+ Configure additional log handlers.
+
+ The default stderr logs handler is configured by the
+ log_level, log_datefmt and log_format settings.
+
+ This configuration can be used to configure additional handlers
+ (e.g. to output the log to a file) or for finer control over the
+ default handlers.
+
+ If provided this should be a logging configuration dictionary, for
+ more information see:
+ https://docs.python.org/3/library/logging.config.html#logging-config-dictschema
+
+ This dictionary is merged with the base logging configuration which
+ defines the following:
+
+ * A logging formatter intended for interactive use called
+ ``console``.
+ * A logging handler that writes to stderr called
+ ``console`` which uses the formatter ``console``.
+ * A logger with the name of this application set to ``DEBUG``
+ level.
+
+ This example adds a new handler that writes to a file:
+
+ .. code-block:: python
+
+ c.Application.logging_configuration = {
+ 'handlers': {
+ 'file': {
+ 'class': 'logging.FileHandler',
+ 'level': 'DEBUG',
+ 'filename': '<path/to/file>',
+ }
+ },
+ 'loggers': {
+ '<application-name>': {
+ 'level': 'DEBUG',
+ # NOTE: if you don't list the default "console"
+ # handler here then it will be disabled
+ 'handlers': ['console', 'file'],
+ },
+ }
+ }
+
+ """,
+ ).tag(config=True)
+
#: the alias map for configurables
#: Keys might strings or tuples for additional options; single-letter alias accessed like `-v`.
#: Values might be like "Class.trait" strings of two-tuples: (Class.trait, help-text).
- aliases = {'log-level' : 'Application.log_level'}
+ aliases: t.Dict[str, str] = {"log-level": "Application.log_level"}
# flags for loading Configurables or store_const style flags
# flags are loaded from this dict by '--key' flags
# this must be a dict of two-tuples, the first element being the Config/dict
# and the second being the help string for the flag
- flags = {
- 'debug': ({
- 'Application': {
- 'log_level': logging.DEBUG,
+ flags: t.Dict[str, t.Any] = {
+ "debug": (
+ {
+ "Application": {
+ "log_level": logging.DEBUG,
+ },
},
- }, "Set log-level to debug, for the most verbose logging."),
- 'show-config': ({
- 'Application': {
- 'show_config': True,
+ "Set log-level to debug, for the most verbose logging.",
+ ),
+ "show-config": (
+ {
+ "Application": {
+ "show_config": True,
+ },
},
- }, "Show the application's configuration (human-readable format)"),
- 'show-config-json': ({
- 'Application': {
- 'show_config_json': True,
+ "Show the application's configuration (human-readable format)",
+ ),
+ "show-config-json": (
+ {
+ "Application": {
+ "show_config_json": True,
+ },
},
- }, "Show the application's configuration (json format)"),
+ "Show the application's configuration (json format)",
+ ),
}
# subcommands for launching other applications
@@ -274,17 +385,20 @@ class Application(SingletonConfigurable):
# and the second being the help string for the subcommand
subcommands = Dict()
# parse_command_line will initialize a subapp, if requested
- subapp = Instance('traitlets.config.application.Application', allow_none=True)
+ subapp = Instance("traitlets.config.application.Application", allow_none=True)
# extra command-line arguments that don't set config values
extra_args = List(Unicode())
- cli_config = Instance(Config, (), {},
+ cli_config = Instance(
+ Config,
+ (),
+ {},
help="""The subset of our configuration that came from the command-line
We re-load this configuration after loading config files,
to ensure that it maintains highest priority.
- """
+ """,
)
_loaded_config_files = List()
@@ -297,15 +411,15 @@ class Application(SingletonConfigurable):
help="Instead of starting the Application, dump configuration to stdout (as JSON)"
).tag(config=True)
- @observe('show_config_json')
+ @observe("show_config_json")
def _show_config_json_changed(self, change):
self.show_config = change.new
- @observe('show_config')
+ @observe("show_config")
def _show_config_changed(self, change):
if change.new:
self._save_start = self.start
- self.start = self.start_show_config
+ self.start = self.start_show_config # type:ignore[assignment]
def __init__(self, **kwargs):
SingletonConfigurable.__init__(self, **kwargs)
@@ -319,11 +433,11 @@ class Application(SingletonConfigurable):
else:
self.classes.insert(0, self.__class__)
- @observe('config')
+ @observe("config")
@observe_compat
def _config_changed(self, change):
- super(Application, self)._config_changed(change)
- self.log.debug('Config changed: %r', change.new)
+ super()._config_changed(change)
+ self.log.debug("Config changed: %r", change.new)
@catch_config_error
def initialize(self, argv=None):
@@ -333,7 +447,6 @@ class Application(SingletonConfigurable):
"""
self.parse_command_line(argv)
-
def start(self):
"""Start the app mainloop.
@@ -349,20 +462,19 @@ class Application(SingletonConfigurable):
for cls in self.__class__.mro():
if cls.__name__ in config:
cls_config = config[cls.__name__]
- cls_config.pop('show_config', None)
- cls_config.pop('show_config_json', None)
+ cls_config.pop("show_config", None)
+ cls_config.pop("show_config_json", None)
if self.show_config_json:
- json.dump(config, sys.stdout,
- indent=1, sort_keys=True, default=repr)
+ json.dump(config, sys.stdout, indent=1, sort_keys=True, default=repr)
# add trailing newline
- sys.stdout.write('\n')
+ sys.stdout.write("\n")
return
if self._loaded_config_files:
print("Loaded config files:")
for f in self._loaded_config_files:
- print(' ' + f)
+ print(" " + f)
print()
for classname in sorted(config):
@@ -370,18 +482,20 @@ class Application(SingletonConfigurable):
if not class_config:
continue
print(classname)
- pformat_kwargs = dict(indent=4, compact=True)
+ pformat_kwargs: t.Dict[str, t.Any] = dict(indent=4, compact=True)
for traitname in sorted(class_config):
value = class_config[traitname]
- print(' .{} = {}'.format(
- traitname,
- pprint.pformat(value, **pformat_kwargs),
- ))
+ print(
+ " .{} = {}".format(
+ traitname,
+ pprint.pformat(value, **pformat_kwargs),
+ )
+ )
def print_alias_help(self):
"""Print the alias parts of the help."""
- print('\n'.join(self.emit_alias_help()))
+ print("\n".join(self.emit_alias_help()))
def emit_alias_help(self):
"""Yield the lines for alias part of the help."""
@@ -400,32 +514,29 @@ class Application(SingletonConfigurable):
longname, fhelp = longname
else:
fhelp = None
- classname, traitname = longname.split('.')[-2:]
- longname = classname + '.' + traitname
+ classname, traitname = longname.split(".")[-2:]
+ longname = classname + "." + traitname
cls = classdict[classname]
trait = cls.class_traits(config=True)[traitname]
fhelp = cls.class_get_trait_help(trait, helptext=fhelp).splitlines()
if not isinstance(alias, tuple):
- alias = (alias, )
- alias = sorted(alias, key=len)
- alias = ', '.join(('--%s' if len(m) > 1 else '-%s') % m
- for m in alias)
+ alias = (alias,) # type:ignore[assignment]
+ alias = sorted(alias, key=len) # type:ignore[assignment]
+ alias = ", ".join(("--%s" if len(m) > 1 else "-%s") % m for m in alias)
# reformat first line
- fhelp[0] = fhelp[0].replace('--' + longname, alias)
- for l in fhelp:
- yield l
+ fhelp[0] = fhelp[0].replace("--" + longname, alias)
+ yield from fhelp
yield indent("Equivalent to: [--%s]" % longname)
except Exception as ex:
- self.log.error('Failed collecting help-message for alias %r, due to: %s',
- alias, ex)
+ self.log.error("Failed collecting help-message for alias %r, due to: %s", alias, ex)
raise
def print_flag_help(self):
"""Print the flag part of the help."""
- print('\n'.join(self.emit_flag_help()))
+ print("\n".join(self.emit_flag_help()))
def emit_flag_help(self):
"""Yield the lines for the flag part of the help."""
@@ -435,47 +546,44 @@ class Application(SingletonConfigurable):
for flags, (cfg, fhelp) in self.flags.items():
try:
if not isinstance(flags, tuple):
- flags = (flags, )
- flags = sorted(flags, key=len)
- flags = ', '.join(('--%s' if len(m) > 1 else '-%s') % m
- for m in flags)
+ flags = (flags,) # type:ignore[assignment]
+ flags = sorted(flags, key=len) # type:ignore[assignment]
+ flags = ", ".join(("--%s" if len(m) > 1 else "-%s") % m for m in flags)
yield flags
yield indent(dedent(fhelp.strip()))
- cfg_list = ' '.join('--%s.%s=%s' %(clname, prop, val)
- for clname, props_dict
- in cfg.items()
- for prop, val in props_dict.items())
+ cfg_list = " ".join(
+ f"--{clname}.{prop}={val}"
+ for clname, props_dict in cfg.items()
+ for prop, val in props_dict.items()
+ )
cfg_txt = "Equivalent to: [%s]" % cfg_list
yield indent(dedent(cfg_txt))
except Exception as ex:
- self.log.error('Failed collecting help-message for flag %r, due to: %s',
- flags, ex)
+ self.log.error("Failed collecting help-message for flag %r, due to: %s", flags, ex)
raise
def print_options(self):
"""Print the options part of the help."""
- print('\n'.join(self.emit_options_help()))
+ print("\n".join(self.emit_options_help()))
def emit_options_help(self):
"""Yield the lines for the options part of the help."""
if not self.flags and not self.aliases:
return
- header = 'Options'
+ header = "Options"
yield header
- yield '=' * len(header)
+ yield "=" * len(header)
for p in wrap_paragraphs(self.option_description):
yield p
- yield ''
+ yield ""
- for l in self.emit_flag_help():
- yield l
- for l in self.emit_alias_help():
- yield l
- yield ''
+ yield from self.emit_flag_help()
+ yield from self.emit_alias_help()
+ yield ""
def print_subcommands(self):
"""Print the subcommand part of the help."""
- print('\n'.join(self.emit_subcommands_help()))
+ print("\n".join(self.emit_subcommands_help()))
def emit_subcommands_help(self):
"""Yield the lines for the subcommand part of the help."""
@@ -484,16 +592,15 @@ class Application(SingletonConfigurable):
header = "Subcommands"
yield header
- yield '=' * len(header)
- for p in wrap_paragraphs(self.subcommand_description.format(
- app=self.name)):
+ yield "=" * len(header)
+ for p in wrap_paragraphs(self.subcommand_description.format(app=self.name)):
yield p
- yield ''
- for subc, (cls, help) in self.subcommands.items():
+ yield ""
+ for subc, (_, help) in self.subcommands.items():
yield subc
if help:
yield indent(dedent(help.strip()))
- yield ''
+ yield ""
def emit_help_epilogue(self, classes):
"""Yield the very bottom lines of the help message.
@@ -502,26 +609,23 @@ class Application(SingletonConfigurable):
"""
if not classes:
yield "To see all available configurables, use `--help-all`."
- yield ''
+ yield ""
def print_help(self, classes=False):
"""Print the help for each Configurable class in self.classes.
If classes=False (the default), only flags and aliases are printed.
"""
- print('\n'.join(self.emit_help(classes=classes)))
+ print("\n".join(self.emit_help(classes=classes)))
def emit_help(self, classes=False):
"""Yield the help-lines for each Configurable class in self.classes.
If classes=False (the default), only flags and aliases are printed.
"""
- for l in self.emit_description():
- yield l
- for l in self.emit_subcommands_help():
- yield l
- for l in self.emit_options_help():
- yield l
+ yield from self.emit_description()
+ yield from self.emit_subcommands_help()
+ yield from self.emit_options_help()
if classes:
help_classes = self._classes_with_config_traits()
@@ -530,38 +634,35 @@ class Application(SingletonConfigurable):
yield "============="
for p in wrap_paragraphs(self.keyvalue_description):
yield p
- yield ''
+ yield ""
for cls in help_classes:
yield cls.class_get_help()
- yield ''
- for l in self.emit_examples():
- yield l
+ yield ""
+ yield from self.emit_examples()
- for l in self.emit_help_epilogue(classes):
- yield l
+ yield from self.emit_help_epilogue(classes)
def document_config_options(self):
"""Generate rST format documentation for the config options this application
Returns a multiline string.
"""
- return '\n'.join(c.class_config_rst_doc()
- for c in self._classes_inc_parents())
+ return "\n".join(c.class_config_rst_doc() for c in self._classes_inc_parents())
def print_description(self):
"""Print the application description."""
- print('\n'.join(self.emit_description()))
+ print("\n".join(self.emit_description()))
def emit_description(self):
"""Yield lines with the application description."""
- for p in wrap_paragraphs(self.description or self.__doc__):
+ for p in wrap_paragraphs(self.description or self.__doc__ or ""):
yield p
- yield ''
+ yield ""
def print_examples(self):
- """Print usage and examples (see `emit_examples()`). """
- print('\n'.join(self.emit_examples()))
+ """Print usage and examples (see `emit_examples()`)."""
+ print("\n".join(self.emit_examples()))
def emit_examples(self):
"""Yield lines with the usage and examples.
@@ -572,9 +673,9 @@ class Application(SingletonConfigurable):
if self.examples:
yield "Examples"
yield "--------"
- yield ''
+ yield ""
yield indent(dedent(self.examples.strip()))
- yield ''
+ yield ""
def print_version(self):
"""Print the version string."""
@@ -588,7 +689,7 @@ class Application(SingletonConfigurable):
if isinstance(subapp, str):
subapp = import_item(subapp)
- ## Cannot issubclass() on a non-type (SOhttp://stackoverflow.com/questions/8692430)
+ # Cannot issubclass() on a non-type (SOhttp://stackoverflow.com/questions/8692430)
if isinstance(subapp, type) and issubclass(subapp, Application):
# Clear existing instances before...
self.__class__.clear_instance()
@@ -596,7 +697,7 @@ class Application(SingletonConfigurable):
self.subapp = subapp.instance(parent=self)
elif callable(subapp):
# or ask factory to create it...
- self.subapp = subapp(self)
+ self.subapp = subapp(self) # type:ignore[call-arg]
else:
raise AssertionError("Invalid mappings for subcommand '%s'!" % subc)
@@ -626,30 +727,30 @@ class Application(SingletonConfigurable):
mro_tree[parent.__name__].append(clsname)
# flatten aliases, which have the form:
# { 'alias' : 'Class.trait' }
- aliases = {}
+ aliases: t.Dict[str, str] = {}
for alias, longname in self.aliases.items():
if isinstance(longname, tuple):
longname, _ = longname
- cls, trait = longname.split('.', 1)
- children = mro_tree[cls]
+ cls, trait = longname.split(".", 1) # type:ignore[assignment]
+ children = mro_tree[cls] # type:ignore[index]
if len(children) == 1:
# exactly one descendent, promote alias
- cls = children[0]
+ cls = children[0] # type:ignore[assignment]
if not isinstance(aliases, tuple):
- alias = (alias, )
+ alias = (alias,) # type:ignore[assignment]
for al in alias:
- aliases[al] = '.'.join([cls,trait])
+ aliases[al] = ".".join([cls, trait]) # type:ignore[list-item]
# flatten flags, which are of the form:
# { 'key' : ({'Cls' : {'trait' : value}}, 'help')}
flags = {}
for key, (flagdict, help) in self.flags.items():
- newflag = {}
+ newflag: t.Dict[t.Any, t.Any] = {}
for cls, subdict in flagdict.items():
- children = mro_tree[cls]
+ children = mro_tree[cls] # type:ignore[index]
# exactly one descendent, promote flag section
if len(children) == 1:
- cls = children[0]
+ cls = children[0] # type:ignore[assignment]
if cls in newflag:
newflag[cls].update(subdict)
@@ -657,30 +758,29 @@ class Application(SingletonConfigurable):
newflag[cls] = subdict
if not isinstance(key, tuple):
- key = (key, )
+ key = (key,) # type:ignore[assignment]
for k in key:
flags[k] = (newflag, help)
return flags, aliases
def _create_loader(self, argv, aliases, flags, classes):
- return KVArgParseConfigLoader(argv, aliases, flags, classes=classes,
- log=self.log)
+ return KVArgParseConfigLoader(argv, aliases, flags, classes=classes, log=self.log)
@catch_config_error
def parse_command_line(self, argv=None):
"""Parse the command line arguments."""
assert not isinstance(argv, str)
argv = sys.argv[1:] if argv is None else argv
- self.argv = [cast_unicode(arg) for arg in argv ]
+ self.argv = [cast_unicode(arg) for arg in argv]
- if argv and argv[0] == 'help':
+ if argv and argv[0] == "help":
# turn `ipython help notebook` into `ipython notebook -h`
- argv = argv[1:] + ['-h']
+ argv = argv[1:] + ["-h"]
if self.subcommands and len(argv) > 0:
# we have subcommands, and one may have been specified
subc, subargv = argv[0], argv[1:]
- if re.match(r'^\w(\-?\w)*$', subc) and subc in self.subcommands:
+ if re.match(r"^\w(\-?\w)*$", subc) and subc in self.subcommands:
# it's a subcommand, and *not* a flag or class parameter
return self.initialize_subcommand(subc, subargv)
@@ -689,15 +789,15 @@ class Application(SingletonConfigurable):
# version), we want to only search the arguments up to the first
# occurrence of '--', which we're calling interpreted_argv.
try:
- interpreted_argv = argv[:argv.index('--')]
+ interpreted_argv = argv[: argv.index("--")]
except ValueError:
interpreted_argv = argv
- if any(x in interpreted_argv for x in ('-h', '--help-all', '--help')):
- self.print_help('--help-all' in interpreted_argv)
+ if any(x in interpreted_argv for x in ("-h", "--help-all", "--help")):
+ self.print_help("--help-all" in interpreted_argv)
self.exit(0)
- if '--version' in interpreted_argv or '-V' in interpreted_argv:
+ if "--version" in interpreted_argv or "-V" in interpreted_argv:
self.print_version()
self.exit(0)
@@ -726,12 +826,12 @@ class Application(SingletonConfigurable):
path = [path]
for path in path[::-1]:
# path list is in descending priority order, so load files backwards:
- pyloader = cls.python_config_loader_class(basefilename+'.py', path=path, log=log)
+ pyloader = cls.python_config_loader_class(basefilename + ".py", path=path, log=log)
if log:
log.debug("Looking for %s in %s", basefilename, path or os.getcwd())
- jsonloader = cls.json_config_loader_class(basefilename+'.json', path=path, log=log)
- loaded = []
- filenames = []
+ jsonloader = cls.json_config_loader_class(basefilename + ".json", path=path, log=log)
+ loaded: t.List[t.Any] = []
+ filenames: t.List[str] = []
for loader in [pyloader, jsonloader]:
config = None
try:
@@ -746,8 +846,7 @@ class Application(SingletonConfigurable):
if raise_config_file_errors:
raise
if log:
- log.error("Exception while loading config file %s",
- filename, exc_info=True)
+ log.error("Exception while loading config file %s", filename, exc_info=True)
else:
if log:
log.debug("Loaded config file: %s", loader.full_filename)
@@ -755,10 +854,14 @@ class Application(SingletonConfigurable):
for filename, earlier_config in zip(filenames, loaded):
collisions = earlier_config.collisions(config)
if collisions and log:
- log.warning("Collisions detected in {0} and {1} config files."
+ log.warning(
+ "Collisions detected in {0} and {1} config files."
" {1} has higher priority: {2}".format(
- filename, loader.full_filename, json.dumps(collisions, indent=2),
- ))
+ filename,
+ loader.full_filename,
+ json.dumps(collisions, indent=2),
+ )
+ )
yield (config, loader.full_filename)
loaded.append(config)
filenames.append(loader.full_filename)
@@ -773,11 +876,16 @@ class Application(SingletonConfigurable):
"""Load config files by filename and path."""
filename, ext = os.path.splitext(filename)
new_config = Config()
- for (config, filename) in self._load_config_files(filename, path=path, log=self.log,
+ for (config, filename) in self._load_config_files(
+ filename,
+ path=path,
+ log=self.log,
raise_config_file_errors=self.raise_config_file_errors,
):
new_config.merge(config)
- if filename not in self._loaded_config_files: # only add to list of loaded files if not previously loaded
+ if (
+ filename not in self._loaded_config_files
+ ): # only add to list of loaded files if not previously loaded
self._loaded_config_files.append(filename)
# add self.cli_config to preserve CLI config priority
new_config.merge(self.cli_config)
@@ -800,21 +908,23 @@ class Application(SingletonConfigurable):
if classes is None:
classes = self.classes
- cls_to_config = OrderedDict( (cls, bool(cls.class_own_traits(config=True)))
- for cls
- in self._classes_inc_parents(classes))
+ cls_to_config = OrderedDict(
+ (cls, bool(cls.class_own_traits(config=True)))
+ for cls in self._classes_inc_parents(classes)
+ )
def is_any_parent_included(cls):
return any(b in cls_to_config and cls_to_config[b] for b in cls.__bases__)
- ## Mark "empty" classes for inclusion if their parents own-traits,
+ # Mark "empty" classes for inclusion if their parents own-traits,
# and loop until no more classes gets marked.
#
while True:
to_incl_orig = cls_to_config.copy()
- cls_to_config = OrderedDict( (cls, inc_yes or is_any_parent_included(cls))
- for cls, inc_yes
- in cls_to_config.items())
+ cls_to_config = OrderedDict(
+ (cls, inc_yes or is_any_parent_included(cls))
+ for cls, inc_yes in cls_to_config.items()
+ )
if cls_to_config == to_incl_orig:
break
for cl, inc_yes in cls_to_config.items():
@@ -824,17 +934,26 @@ class Application(SingletonConfigurable):
def generate_config_file(self, classes=None):
"""generate default config file from Configurables"""
lines = ["# Configuration file for %s." % self.name]
- lines.append('')
+ lines.append("")
classes = self.classes if classes is None else classes
config_classes = list(self._classes_with_config_traits(classes))
for cls in config_classes:
lines.append(cls.class_config_section(config_classes))
- return '\n'.join(lines)
+ return "\n".join(lines)
+
+ def close_handlers(self):
+ for handler in self.log.handlers:
+ with suppress(Exception):
+ handler.close()
def exit(self, exit_status=0):
self.log.debug("Exiting application: %s" % self.name)
+ self.close_handlers()
sys.exit(exit_status)
+ def __del__(self):
+ self.close_handlers()
+
@classmethod
def launch_instance(cls, argv=None, **kwargs):
"""Launch a global instance of this Application
@@ -845,14 +964,16 @@ class Application(SingletonConfigurable):
app.initialize(argv)
app.start()
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# utility functions, for convenience
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
default_aliases = Application.aliases
default_flags = Application.flags
-def boolean_flag(name, configurable, set_help='', unset_help=''):
+
+def boolean_flag(name, configurable, set_help="", unset_help=""):
"""Helper for building basic --trait, --no-trait flags.
Parameters
@@ -873,14 +994,14 @@ def boolean_flag(name, configurable, set_help='', unset_help=''):
the trait, respectively.
"""
# default helpstrings
- set_help = set_help or "set %s=True"%configurable
- unset_help = unset_help or "set %s=False"%configurable
+ set_help = set_help or "set %s=True" % configurable
+ unset_help = unset_help or "set %s=False" % configurable
- cls,trait = configurable.split('.')
+ cls, trait = configurable.split(".")
- setter = {cls : {trait : True}}
- unsetter = {cls : {trait : False}}
- return {name : (setter, set_help), 'no-'+name : (unsetter, unset_help)}
+ setter = {cls: {trait: True}}
+ unsetter = {cls: {trait: False}}
+ return {name: (setter, set_help), "no-" + name: (unsetter, unset_help)}
def get_config():
@@ -894,5 +1015,5 @@ def get_config():
return Config()
-if __name__ == '__main__':
+if __name__ == "__main__":
Application.launch_instance()
diff --git a/contrib/python/traitlets/py3/traitlets/config/configurable.py b/contrib/python/traitlets/py3/traitlets/config/configurable.py
index 3b2044a01b..5edb489201 100644
--- a/contrib/python/traitlets/py3/traitlets/config/configurable.py
+++ b/contrib/python/traitlets/py3/traitlets/config/configurable.py
@@ -4,31 +4,29 @@
# Distributed under the terms of the Modified BSD License.
-from copy import deepcopy
import logging
import warnings
+from copy import deepcopy
+from textwrap import dedent
-from .loader import Config, LazyConfigValue, DeferredConfig, _is_section_key
from traitlets.traitlets import (
Any,
- HasTraits,
- Instance,
Container,
Dict,
+ HasTraits,
+ Instance,
+ default,
observe,
observe_compat,
- default,
validate,
)
from traitlets.utils.text import indent, wrap_paragraphs
-from textwrap import dedent
-
+from .loader import Config, DeferredConfig, LazyConfigValue, _is_section_key
-
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Helper classes for Configurables
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
class ConfigurableError(Exception):
@@ -38,14 +36,16 @@ class ConfigurableError(Exception):
class MultipleInstanceError(ConfigurableError):
pass
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# Configurable implementation
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
+
class Configurable(HasTraits):
config = Instance(Config, (), {})
- parent = Instance('traitlets.config.configurable.Configurable', allow_none=True)
+ parent = Instance("traitlets.config.configurable.Configurable", allow_none=True)
def __init__(self, **kwargs):
"""Create a configurable given a config config.
@@ -72,20 +72,21 @@ class Configurable(HasTraits):
This ensures that instances will be configured properly.
"""
- parent = kwargs.pop('parent', None)
+ parent = kwargs.pop("parent", None)
if parent is not None:
# config is implied from parent
- if kwargs.get('config', None) is None:
- kwargs['config'] = parent.config
+ if kwargs.get("config", None) is None:
+ kwargs["config"] = parent.config
self.parent = parent
- config = kwargs.pop('config', None)
+ config = kwargs.pop("config", None)
# load kwarg traits, other than config
- super(Configurable, self).__init__(**kwargs)
+ super().__init__(**kwargs)
# record traits set by config
config_override_names = set()
+
def notice_config_override(change):
"""Record traits set by both config and kwargs.
@@ -93,6 +94,7 @@ class Configurable(HasTraits):
"""
if change.name in kwargs:
config_override_names.add(change.name)
+
self.observe(notice_config_override)
# load config
@@ -113,16 +115,17 @@ class Configurable(HasTraits):
for name in config_override_names:
setattr(self, name, kwargs[name])
-
- #-------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
# Static trait notifiations
- #-------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
@classmethod
def section_names(cls):
"""return section names as a list"""
- return [c.__name__ for c in reversed(cls.__mro__) if
- issubclass(c, Configurable) and issubclass(cls, c)
+ return [
+ c.__name__
+ for c in reversed(cls.__mro__)
+ if issubclass(c, Configurable) and issubclass(cls, c)
]
def _find_my_config(self, cfg):
@@ -178,21 +181,25 @@ class Configurable(HasTraits):
setattr(self, name, deepcopy(config_value))
elif not _is_section_key(name) and not isinstance(config_value, Config):
from difflib import get_close_matches
+
if isinstance(self, LoggingConfigurable):
warn = self.log.warning
else:
- warn = lambda msg: warnings.warn(msg, stacklevel=9)
+ warn = lambda msg: warnings.warn(msg, stacklevel=9) # noqa[E371]
matches = get_close_matches(name, traits)
msg = "Config option `{option}` not recognized by `{klass}`.".format(
- option=name, klass=self.__class__.__name__)
+ option=name, klass=self.__class__.__name__
+ )
if len(matches) == 1:
- msg += " Did you mean `{matches}`?".format(matches=matches[0])
+ msg += f" Did you mean `{matches[0]}`?"
elif len(matches) >= 1:
- msg +=" Did you mean one of: `{matches}`?".format(matches=', '.join(sorted(matches)))
+ msg += " Did you mean one of: `{matches}`?".format(
+ matches=", ".join(sorted(matches))
+ )
warn(msg)
- @observe('config')
+ @observe("config")
@observe_compat
def _config_changed(self, change):
"""Update all the class traits having ``config=True`` in metadata.
@@ -235,13 +242,13 @@ class Configurable(HasTraits):
"""
assert inst is None or isinstance(inst, cls)
final_help = []
- base_classes = ', '.join(p.__name__ for p in cls.__bases__)
- final_help.append('%s(%s) options' % (cls.__name__, base_classes))
- final_help.append(len(final_help[0])*'-')
- for k, v in sorted(cls.class_traits(config=True).items()):
+ base_classes = ", ".join(p.__name__ for p in cls.__bases__)
+ final_help.append(f"{cls.__name__}({base_classes}) options")
+ final_help.append(len(final_help[0]) * "-")
+ for _, v in sorted(cls.class_traits(config=True).items()):
help = cls.class_get_trait_help(v, inst)
final_help.append(help)
- return '\n'.join(final_help)
+ return "\n".join(final_help)
@classmethod
def class_get_trait_help(cls, trait, inst=None, helptext=None):
@@ -255,45 +262,45 @@ class Configurable(HasTraits):
"""
assert inst is None or isinstance(inst, cls)
lines = []
- header = "--%s.%s" % (cls.__name__, trait.name)
+ header = f"--{cls.__name__}.{trait.name}"
if isinstance(trait, (Container, Dict)):
- multiplicity = trait.metadata.get('multiplicity', 'append')
+ multiplicity = trait.metadata.get("multiplicity", "append")
if isinstance(trait, Dict):
- sample_value = '<key-1>=<value-1>'
+ sample_value = "<key-1>=<value-1>"
else:
- sample_value = '<%s-item-1>' % trait.__class__.__name__.lower()
- if multiplicity == 'append':
- header = "%s=%s..." % (header, sample_value)
+ sample_value = "<%s-item-1>" % trait.__class__.__name__.lower()
+ if multiplicity == "append":
+ header = f"{header}={sample_value}..."
else:
- header = "%s %s..." % (header, sample_value)
+ header = f"{header} {sample_value}..."
else:
- header = '%s=<%s>' % (header, trait.__class__.__name__)
- #header = "--%s.%s=<%s>" % (cls.__name__, trait.name, trait.__class__.__name__)
+ header = f"{header}=<{trait.__class__.__name__}>"
+ # header = "--%s.%s=<%s>" % (cls.__name__, trait.name, trait.__class__.__name__)
lines.append(header)
if helptext is None:
helptext = trait.help
- if helptext != '':
- helptext = '\n'.join(wrap_paragraphs(helptext, 76))
+ if helptext != "":
+ helptext = "\n".join(wrap_paragraphs(helptext, 76))
lines.append(indent(helptext))
- if 'Enum' in trait.__class__.__name__:
+ if "Enum" in trait.__class__.__name__:
# include Enum choices
- lines.append(indent('Choices: %s' % trait.info()))
+ lines.append(indent("Choices: %s" % trait.info()))
if inst is not None:
- lines.append(indent("Current: %r" % (getattr(inst, trait.name),)))
+ lines.append(indent(f"Current: {getattr(inst, trait.name)!r}"))
else:
try:
dvr = trait.default_value_repr()
except Exception:
- dvr = None # ignore defaults we can't construct
+ dvr = None # ignore defaults we can't construct
if dvr is not None:
if len(dvr) > 64:
dvr = dvr[:61] + "..."
lines.append(indent("Default: %s" % dvr))
- return '\n'.join(lines)
+ return "\n".join(lines)
@classmethod
def class_print_help(cls, inst=None):
@@ -320,9 +327,11 @@ class Configurable(HasTraits):
"""
defining_cls = cls
for parent in cls.mro():
- if issubclass(parent, Configurable) and \
- parent in classes and \
- parent.class_own_traits(config=True).get(trait.name, None) is trait:
+ if (
+ issubclass(parent, Configurable)
+ and parent in classes
+ and parent.class_own_traits(config=True).get(trait.name, None) is trait
+ ):
defining_cls = parent
return defining_cls
@@ -336,31 +345,29 @@ class Configurable(HasTraits):
The list of other classes in the config file.
Used to reduce redundant information.
"""
+
def c(s):
"""return a commented, wrapped block."""
- s = '\n\n'.join(wrap_paragraphs(s, 78))
+ s = "\n\n".join(wrap_paragraphs(s, 78))
- return '## ' + s.replace('\n', '\n# ')
+ return "## " + s.replace("\n", "\n# ")
# section header
- breaker = '#' + '-' * 78
- parent_classes = ', '.join(
- p.__name__ for p in cls.__bases__
- if issubclass(p, Configurable)
- )
+ breaker = "#" + "-" * 78
+ parent_classes = ", ".join(p.__name__ for p in cls.__bases__ if issubclass(p, Configurable))
- s = "# %s(%s) configuration" % (cls.__name__, parent_classes)
+ s = f"# {cls.__name__}({parent_classes}) configuration"
lines = [breaker, s, breaker]
# get the description trait
- desc = cls.class_traits().get('description')
+ desc = cls.class_traits().get("description")
if desc:
desc = desc.default_value
if not desc:
# no description from trait, use __doc__
- desc = getattr(cls, '__doc__', '')
+ desc = getattr(cls, "__doc__", "")
if desc:
lines.append(c(desc))
- lines.append('')
+ lines.append("")
for name, trait in sorted(cls.class_traits(config=True).items()):
default_repr = trait.default_value_repr()
@@ -373,20 +380,20 @@ class Configurable(HasTraits):
# cls owns the trait, show full help
if trait.help:
lines.append(c(trait.help))
- if 'Enum' in type(trait).__name__:
+ if "Enum" in type(trait).__name__:
# include Enum choices
- lines.append('# Choices: %s' % trait.info())
- lines.append('# Default: %s' % default_repr)
+ lines.append("# Choices: %s" % trait.info())
+ lines.append("# Default: %s" % default_repr)
else:
# Trait appears multiple times and isn't defined here.
# Truncate help to first line + "See also Original.trait"
if trait.help:
- lines.append(c(trait.help.split('\n', 1)[0]))
- lines.append('# See also: %s.%s' % (defining_class.__name__, name))
+ lines.append(c(trait.help.split("\n", 1)[0]))
+ lines.append(f"# See also: {defining_class.__name__}.{name}")
- lines.append('# c.%s.%s = %s' % (cls.__name__, name, default_repr))
- lines.append('')
- return '\n'.join(lines)
+ lines.append(f"# c.{cls.__name__}.{name} = {default_repr}")
+ lines.append("")
+ return "\n".join(lines)
@classmethod
def class_config_rst_doc(cls):
@@ -396,40 +403,39 @@ class Configurable(HasTraits):
"""
lines = []
classname = cls.__name__
- for k, trait in sorted(cls.class_traits(config=True).items()):
+ for _, trait in sorted(cls.class_traits(config=True).items()):
ttype = trait.__class__.__name__
- termline = classname + '.' + trait.name
+ termline = classname + "." + trait.name
# Choices or type
- if 'Enum' in ttype:
+ if "Enum" in ttype:
# include Enum choices
- termline += ' : ' + trait.info_rst()
+ termline += " : " + trait.info_rst()
else:
- termline += ' : ' + ttype
+ termline += " : " + ttype
lines.append(termline)
# Default value
try:
dvr = trait.default_value_repr()
except Exception:
- dvr = None # ignore defaults we can't construct
+ dvr = None # ignore defaults we can't construct
if dvr is not None:
if len(dvr) > 64:
- dvr = dvr[:61]+'...'
+ dvr = dvr[:61] + "..."
# Double up backslashes, so they get to the rendered docs
dvr = dvr.replace("\\n", "\\\\n")
lines.append(indent("Default: ``%s``" % dvr))
lines.append("")
- help = trait.help or 'No description'
+ help = trait.help or "No description"
lines.append(indent(dedent(help)))
# Blank line
- lines.append('')
-
- return '\n'.join(lines)
+ lines.append("")
+ return "\n".join(lines)
class LoggingConfigurable(Configurable):
@@ -456,12 +462,16 @@ class LoggingConfigurable(Configurable):
if isinstance(self.parent, LoggingConfigurable):
return self.parent.log
from traitlets import log
+
return log.get_logger()
def _get_log_handler(self):
"""Return the default Handler
Returns None if none can be found
+
+ Deprecated, this now returns the first log handler which may or may
+ not be the default one.
"""
logger = self.log
if isinstance(logger, logging.LoggerAdapter):
@@ -490,15 +500,16 @@ class SingletonConfigurable(LoggingConfigurable):
"""
for subclass in cls.mro():
- if issubclass(cls, subclass) and \
- issubclass(subclass, SingletonConfigurable) and \
- subclass != SingletonConfigurable:
+ if (
+ issubclass(cls, subclass)
+ and issubclass(subclass, SingletonConfigurable)
+ and subclass != SingletonConfigurable
+ ):
yield subclass
@classmethod
def clear_instance(cls):
- """unset _instance for this class and singleton parents.
- """
+ """unset _instance for this class and singleton parents."""
if not cls.initialized():
return
for subclass in cls._walk_mro():
@@ -555,6 +566,3 @@ class SingletonConfigurable(LoggingConfigurable):
def initialized(cls):
"""Has an instance been created?"""
return hasattr(cls, "_instance") and cls._instance is not None
-
-
-
diff --git a/contrib/python/traitlets/py3/traitlets/config/loader.py b/contrib/python/traitlets/py3/traitlets/config/loader.py
index 5360f889ab..14a6863589 100644
--- a/contrib/python/traitlets/py3/traitlets/config/loader.py
+++ b/contrib/python/traitlets/py3/traitlets/config/loader.py
@@ -5,38 +5,41 @@
import argparse
import copy
+import json
import os
import re
import sys
-import json
+import typing as t
import warnings
-from ..utils import cast_unicode, filefind
+from traitlets.traitlets import Any, Container, Dict, HasTraits, List, Undefined
-from traitlets.traitlets import (
- HasTraits, Container, List, Dict, Any, Undefined,
-)
+from ..utils import cast_unicode, filefind
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Exceptions
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
class ConfigError(Exception):
pass
+
class ConfigLoaderError(ConfigError):
pass
+
class ConfigFileNotFound(ConfigError):
pass
+
class ArgumentError(ConfigLoaderError):
pass
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# Argparse fix
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Unfortunately argparse by default prints help messages to stderr instead of
# stdout. This makes it annoying to capture long help screens at the command
@@ -62,17 +65,20 @@ class ArgumentParser(argparse.ArgumentParser):
def print_help(self, file=None):
if file is None:
file = sys.stdout
- return super(ArgumentParser, self).print_help(file)
+ return super().print_help(file)
print_help.__doc__ = argparse.ArgumentParser.print_help.__doc__
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# Config class for holding config information
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
+
def execfile(fname, glob):
- with open(fname, 'rb') as f:
- exec(compile(f.read(), fname, 'exec'), glob, glob)
+ with open(fname, "rb") as f:
+ exec(compile(f.read(), fname, "exec"), glob, glob)
+
class LazyConfigValue(HasTraits):
"""Proxy object for exposing methods on configurable containers
@@ -106,7 +112,6 @@ class LazyConfigValue(HasTraits):
"""like list.extend, but for the front"""
self._prepend[:0] = other
-
def merge_into(self, other):
"""
Merge with another earlier LazyConfigValue or an earlier container.
@@ -193,31 +198,31 @@ class LazyConfigValue(HasTraits):
"""
d = {}
if self._update:
- d['update'] = self._update
+ d["update"] = self._update
if self._extend:
- d['extend'] = self._extend
+ d["extend"] = self._extend
if self._prepend:
- d['prepend'] = self._prepend
+ d["prepend"] = self._prepend
elif self._inserts:
- d['inserts'] = self._inserts
+ d["inserts"] = self._inserts
return d
def __repr__(self):
if self._value is not None:
- return "<%s value=%r>" % (self.__class__.__name__, self._value)
+ return f"<{self.__class__.__name__} value={self._value!r}>"
else:
- return "<%s %r>" % (self.__class__.__name__, self.to_dict())
+ return f"<{self.__class__.__name__} {self.to_dict()!r}>"
def _is_section_key(key):
"""Is a Config key a section name (does it start with a capital)?"""
- if key and key[0].upper()==key[0] and not key.startswith('_'):
+ if key and key[0].upper() == key[0] and not key.startswith("_"):
return True
else:
return False
-class Config(dict):
+class Config(dict): # type:ignore[type-arg]
"""An attribute-based dict that can do smart merges.
Accessing a field on a config object for the first time populates the key
@@ -243,9 +248,7 @@ class Config(dict):
"""
for key in self:
obj = self[key]
- if _is_section_key(key) \
- and isinstance(obj, dict) \
- and not isinstance(obj, Config):
+ if _is_section_key(key) and isinstance(obj, dict) and not isinstance(obj, Config):
setattr(self, key, Config(obj))
def _merge(self, other):
@@ -258,7 +261,7 @@ class Config(dict):
for k, v in other.items():
if k not in self:
to_update[k] = v
- else: # I have this key
+ else: # I have this key
if isinstance(v, Config) and isinstance(self[k], Config):
# Recursively merge common sub Configs
self[k].merge(v)
@@ -270,7 +273,7 @@ class Config(dict):
self.update(to_update)
- def collisions(self, other):
+ def collisions(self, other: "Config") -> t.Dict[str, t.Any]:
"""Check for collisions between two config objects.
Returns a dict of the form {"Class": {"trait": "collision message"}}`,
@@ -278,7 +281,7 @@ class Config(dict):
An empty dict indicates no collisions.
"""
- collisions = {}
+ collisions: t.Dict[str, t.Any] = {}
for section in self:
if section not in other:
continue
@@ -287,18 +290,18 @@ class Config(dict):
for key in mine:
if key in theirs and mine[key] != theirs[key]:
collisions.setdefault(section, {})
- collisions[section][key] = "%r ignored, using %r" % (mine[key], theirs[key])
+ collisions[section][key] = f"{mine[key]!r} ignored, using {theirs[key]!r}"
return collisions
def __contains__(self, key):
# allow nested contains of the form `"Section.key" in config`
- if '.' in key:
- first, remainder = key.split('.', 1)
+ if "." in key:
+ first, remainder = key.split(".", 1)
if first not in self:
return False
return remainder in self[first]
- return super(Config, self).__contains__(key)
+ return super().__contains__(key)
# .has_key is deprecated for dictionaries.
has_key = __contains__
@@ -332,7 +335,7 @@ class Config(dict):
c = Config()
dict.__setitem__(self, key, c)
return c
- elif not key.startswith('_'):
+ elif not key.startswith("_"):
# undefined, create lazy value, used for container methods
v = LazyConfigValue()
dict.__setitem__(self, key, v)
@@ -343,20 +346,22 @@ class Config(dict):
def __setitem__(self, key, value):
if _is_section_key(key):
if not isinstance(value, Config):
- raise ValueError('values whose keys begin with an uppercase '
- 'char must be Config instances: %r, %r' % (key, value))
+ raise ValueError(
+ "values whose keys begin with an uppercase "
+ "char must be Config instances: %r, %r" % (key, value)
+ )
dict.__setitem__(self, key, value)
def __getattr__(self, key):
- if key.startswith('__'):
- return dict.__getattr__(self, key)
+ if key.startswith("__"):
+ return dict.__getattr__(self, key) # type:ignore[attr-defined]
try:
return self.__getitem__(key)
except KeyError as e:
raise AttributeError(e)
def __setattr__(self, key, value):
- if key.startswith('__'):
+ if key.startswith("__"):
return dict.__setattr__(self, key, value)
try:
self.__setitem__(key, value)
@@ -364,7 +369,7 @@ class Config(dict):
raise AttributeError(e)
def __delattr__(self, key):
- if key.startswith('__'):
+ if key.startswith("__"):
return dict.__delattr__(self, key)
try:
dict.__delitem__(self, key)
@@ -374,6 +379,7 @@ class Config(dict):
class DeferredConfig:
"""Class for deferred-evaluation of config from CLI"""
+
pass
def get_value(self, trait):
@@ -401,6 +407,7 @@ class DeferredConfigString(str, DeferredConfig):
.. versionadded:: 5.0
"""
+
def get_value(self, trait):
"""Get the value stored in this string"""
s = str(self)
@@ -413,10 +420,10 @@ class DeferredConfigString(str, DeferredConfig):
return s
def __repr__(self):
- return '%s(%s)' % (self.__class__.__name__, self._super_repr())
+ return f"{self.__class__.__name__}({self._super_repr()})"
-class DeferredConfigList(list, DeferredConfig):
+class DeferredConfigList(list, DeferredConfig): # type:ignore[type-arg]
"""Config value for loading config from a list of strings
Interpretation is deferred until it is loaded into the trait.
@@ -431,6 +438,7 @@ class DeferredConfigList(list, DeferredConfig):
.. versionadded:: 5.0
"""
+
def get_value(self, trait):
"""Get the value stored in this string"""
if hasattr(trait, "from_string_list"):
@@ -439,7 +447,9 @@ class DeferredConfigList(list, DeferredConfig):
else:
# only allow one item
if len(self) > 1:
- raise ValueError(f"{trait.name} only accepts one value, got {len(self)}: {list(self)}")
+ raise ValueError(
+ f"{trait.name} only accepts one value, got {len(self)}: {list(self)}"
+ )
src = self[0]
cast = trait.from_string
@@ -452,15 +462,15 @@ class DeferredConfigList(list, DeferredConfig):
return src
def __repr__(self):
- return '%s(%s)' % (self.__class__.__name__, self._super_repr())
+ return f"{self.__class__.__name__}({self._super_repr()})"
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Config loading classes
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
-class ConfigLoader(object):
+class ConfigLoader:
"""A object for loading configurations from just about anywhere.
The resulting configuration is packaged as a :class:`Config`.
@@ -477,6 +487,7 @@ class ConfigLoader(object):
def _log_default(self):
from traitlets.log import get_logger
+
return get_logger()
def __init__(self, log=None):
@@ -496,7 +507,7 @@ class ConfigLoader(object):
self.clear()
if log is None:
self.log = self._log_default()
- self.log.debug('Using default logger')
+ self.log.debug("Using default logger")
else:
self.log = log
@@ -532,15 +543,16 @@ class FileConfigLoader(ConfigLoader):
The path to search for the config file on, or a sequence of
paths to try in order.
"""
- super(FileConfigLoader, self).__init__(**kw)
+ super().__init__(**kw)
self.filename = filename
self.path = path
- self.full_filename = ''
+ self.full_filename = ""
def _find_file(self):
"""Try to find the file by searching the paths."""
self.full_filename = filefind(self.filename, self.path)
+
class JSONFileConfigLoader(FileConfigLoader):
"""A JSON file loader for config
@@ -558,7 +570,7 @@ class JSONFileConfigLoader(FileConfigLoader):
self.clear()
try:
self._find_file()
- except IOError as e:
+ except OSError as e:
raise ConfigFileNotFound(str(e))
dct = self._read_file_as_dict()
self.config = self._convert_to_config(dct)
@@ -569,15 +581,15 @@ class JSONFileConfigLoader(FileConfigLoader):
return json.load(f)
def _convert_to_config(self, dictionary):
- if 'version' in dictionary:
- version = dictionary.pop('version')
+ if "version" in dictionary:
+ version = dictionary.pop("version")
else:
version = 1
if version == 1:
return Config(dictionary)
else:
- raise ValueError('Unknown version of JSON config file: {version}'.format(version=version))
+ raise ValueError(f"Unknown version of JSON config file: {version}")
def __enter__(self):
self.load_config()
@@ -592,11 +604,10 @@ class JSONFileConfigLoader(FileConfigLoader):
"""
self.config.version = 1
json_config = json.dumps(self.config, indent=2)
- with open(self.full_filename, 'w') as f:
+ with open(self.full_filename, "w") as f:
f.write(json_config)
-
class PyFileConfigLoader(FileConfigLoader):
"""A config loader for pure python files.
@@ -609,7 +620,7 @@ class PyFileConfigLoader(FileConfigLoader):
self.clear()
try:
self._find_file()
- except IOError as e:
+ except OSError as e:
raise ConfigFileNotFound(str(e))
self._read_file_as_dict()
return self.config
@@ -631,6 +642,7 @@ class PyFileConfigLoader(FileConfigLoader):
def _read_file_as_dict(self):
"""Load the config file into self.config, with recursive loading."""
+
def get_config():
"""Unnecessary now, but a deprecation warning is more trouble than it's worth."""
return self.config
@@ -642,8 +654,8 @@ class PyFileConfigLoader(FileConfigLoader):
__file__=self.full_filename,
)
conf_filename = self.full_filename
- with open(conf_filename, 'rb') as f:
- exec(compile(f.read(), conf_filename, 'exec'), namespace, namespace)
+ with open(conf_filename, "rb") as f:
+ exec(compile(f.read(), conf_filename, "exec"), namespace, namespace)
class CommandLineConfigLoader(ConfigLoader):
@@ -690,13 +702,14 @@ class CommandLineConfigLoader(ConfigLoader):
else:
raise TypeError("Invalid flag: %r" % cfg)
+
# match --Class.trait keys for argparse
# matches:
# --Class.trait
# --x
# -x
-class_trait_opt_pattern = re.compile(r'^\-?\-[A-Za-z][\w]*(\.[\w]+)*$')
+class_trait_opt_pattern = re.compile(r"^\-?\-[A-Za-z][\w]*(\.[\w]+)*$")
_DOT_REPLACEMENT = "__DOT__"
_DASH_REPLACEMENT = "__DASH__"
@@ -707,6 +720,7 @@ class _KVAction(argparse.Action):
Always
"""
+
def __call__(self, parser, namespace, values, option_string=None):
if isinstance(values, str):
values = [values]
@@ -720,11 +734,12 @@ class _KVAction(argparse.Action):
setattr(namespace, self.dest, items)
-class _DefaultOptionDict(dict):
+class _DefaultOptionDict(dict): # type:ignore[type-arg]
"""Like the default options dict
but acts as if all --Class.trait options are predefined
"""
+
def _add_kv_action(self, key):
self[key] = _KVAction(
option_strings=[key],
@@ -734,7 +749,7 @@ class _DefaultOptionDict(dict):
)
def __contains__(self, key):
- if '=' in key:
+ if "=" in key:
return False
if super().__contains__(key):
return True
@@ -759,12 +774,12 @@ class _DefaultOptionDict(dict):
class _KVArgParser(argparse.ArgumentParser):
"""subclass of ArgumentParser where any --Class.trait option is implicitly defined"""
+
def parse_known_args(self, args=None, namespace=None):
# must be done immediately prior to parsing because if we do it in init,
# registration of explicit actions via parser.add_option will fail during setup
for container in (self, self._optionals):
- container._option_string_actions = _DefaultOptionDict(
- container._option_string_actions)
+ container._option_string_actions = _DefaultOptionDict(container._option_string_actions)
return super().parse_known_args(args, namespace)
@@ -773,8 +788,16 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
parser_class = ArgumentParser
- def __init__(self, argv=None, aliases=None, flags=None, log=None, classes=(),
- *parser_args, **parser_kw):
+ def __init__(
+ self,
+ argv: t.Optional[t.List[str]] = None,
+ aliases: t.Optional[t.Dict[str, str]] = None,
+ flags: t.Optional[t.Dict[str, str]] = None,
+ log: t.Any = None,
+ classes: t.Optional[t.List[t.Type[t.Any]]] = None,
+ *parser_args: t.Any,
+ **parser_kw: t.Any,
+ ) -> None:
"""Create a config loader for use with argparse.
Parameters
@@ -803,6 +826,7 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
config : Config
The resulting Config object.
"""
+ classes = classes or []
super(CommandLineConfigLoader, self).__init__(log=log)
self.clear()
if argv is None:
@@ -853,13 +877,15 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
return self.config
def get_extra_args(self):
- if hasattr(self, 'extra_args'):
+ if hasattr(self, "extra_args"):
return self.extra_args
else:
return []
def _create_parser(self):
- self.parser = self.parser_class(*self.parser_args, **self.parser_kw)
+ self.parser = self.parser_class(
+ *self.parser_args, **self.parser_kw # type:ignore[arg-type]
+ )
self._add_arguments(self.aliases, self.flags, self.classes)
def _add_arguments(self, aliases, flags, classes):
@@ -869,14 +895,14 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
"""self.parser->self.parsed_data"""
uargs = [cast_unicode(a) for a in args]
- unpacked_aliases = {}
+ unpacked_aliases: t.Dict[str, str] = {}
if self.aliases:
unpacked_aliases = {}
for alias, alias_target in self.aliases.items():
if alias in self.flags:
continue
if not isinstance(alias, tuple):
- short_alias, alias = alias, None
+ short_alias, alias = alias, None # type:ignore[assignment]
else:
short_alias, alias = alias
for al in (short_alias, alias):
@@ -893,12 +919,12 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
if arg == k:
return v
if arg.startswith(k + "="):
- return v + "=" + arg[len(k) + 1:]
+ return v + "=" + arg[len(k) + 1 :]
return arg
- if '--' in uargs:
- idx = uargs.index('--')
- extra_args = uargs[idx+1:]
+ if "--" in uargs:
+ idx = uargs.index("--")
+ extra_args = uargs[idx + 1 :]
to_parse = uargs[:idx]
else:
extra_args = []
@@ -920,17 +946,18 @@ class ArgParseConfigLoader(CommandLineConfigLoader):
class _FlagAction(argparse.Action):
"""ArgParse action to handle a flag"""
+
def __init__(self, *args, **kwargs):
- self.flag = kwargs.pop('flag')
- self.alias = kwargs.pop('alias', None)
- kwargs['const'] = Undefined
+ self.flag = kwargs.pop("flag")
+ self.alias = kwargs.pop("alias", None)
+ kwargs["const"] = Undefined
if not self.alias:
- kwargs['nargs'] = 0
- super(_FlagAction, self).__init__(*args, **kwargs)
+ kwargs["nargs"] = 0
+ super().__init__(*args, **kwargs)
def __call__(self, parser, namespace, values, option_string=None):
if self.nargs == 0 or values is Undefined:
- if not hasattr(namespace, '_flags'):
+ if not hasattr(namespace, "_flags"):
namespace._flags = []
namespace._flags.append(self.flag)
else:
@@ -943,15 +970,16 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
as well as arbitrary --Class.trait value
"""
- parser_class = _KVArgParser
+ parser_class = _KVArgParser # type:ignore[assignment]
def _add_arguments(self, aliases, flags, classes):
- alias_flags = {}
+ alias_flags: t.Dict[str, t.Any] = {}
+ argparse_kwds: t.Dict[str, t.Any]
paa = self.parser.add_argument
self.parser.set_defaults(_flags=[])
paa("extra_args", nargs="*")
- ## An index of all container traits collected::
+ # An index of all container traits collected::
#
# { <traitname>: (<trait>, <argparse-kwds>) }
#
@@ -960,14 +988,14 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
self.argparse_traits = argparse_traits = {}
for cls in classes:
for traitname, trait in cls.class_traits(config=True).items():
- argname = '%s.%s' % (cls.__name__, traitname)
- argparse_kwds = {'type': str}
+ argname = f"{cls.__name__}.{traitname}"
+ argparse_kwds = {"type": str}
if isinstance(trait, (Container, Dict)):
- multiplicity = trait.metadata.get('multiplicity', 'append')
- if multiplicity == 'append':
- argparse_kwds['action'] = multiplicity
+ multiplicity = trait.metadata.get("multiplicity", "append")
+ if multiplicity == "append":
+ argparse_kwds["action"] = multiplicity
else:
- argparse_kwds['nargs'] = multiplicity
+ argparse_kwds["nargs"] = multiplicity
argparse_traits[argname] = (trait, argparse_kwds)
for keys, (value, _) in flags.items():
@@ -977,7 +1005,7 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
if key in aliases:
alias_flags[aliases[key]] = value
continue
- keys = ('-' + key, '--' + key) if len(key) == 1 else ('--' + key,)
+ keys = ("-" + key, "--" + key) if len(key) == 1 else ("--" + key,)
paa(*keys, action=_FlagAction, flag=value)
for keys, traitname in aliases.items():
@@ -986,28 +1014,28 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
for key in keys:
argparse_kwds = {
- 'type': str,
- 'dest': traitname.replace(".", _DOT_REPLACEMENT),
- 'metavar': traitname,
+ "type": str,
+ "dest": traitname.replace(".", _DOT_REPLACEMENT),
+ "metavar": traitname,
}
if traitname in argparse_traits:
argparse_kwds.update(argparse_traits[traitname][1])
- if 'action' in argparse_kwds and traitname in alias_flags:
+ if "action" in argparse_kwds and traitname in alias_flags:
# flag sets 'action', so can't have flag & alias with custom action
# on the same name
raise ArgumentError(
"The alias `%s` for the 'append' sequence "
- "config-trait `%s` cannot be also a flag!'"
- % (key, traitname))
+ "config-trait `%s` cannot be also a flag!'" % (key, traitname)
+ )
if traitname in alias_flags:
# alias and flag.
# when called with 0 args: flag
# when called with >= 1: alias
- argparse_kwds.setdefault('nargs', '?')
- argparse_kwds['action'] = _FlagAction
- argparse_kwds['flag'] = alias_flags[traitname]
- argparse_kwds['alias'] = traitname
- keys = ('-' + key, '--' + key) if len(key) == 1 else ('--'+ key,)
+ argparse_kwds.setdefault("nargs", "?")
+ argparse_kwds["action"] = _FlagAction
+ argparse_kwds["flag"] = alias_flags[traitname]
+ argparse_kwds["alias"] = traitname
+ keys = ("-" + key, "--" + key) if len(key) == 1 else ("--" + key,)
paa(*keys, **argparse_kwds)
def _convert_to_config(self):
@@ -1018,12 +1046,12 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
if lhs == "extra_args":
self.extra_args = ["-" if a == _DASH_REPLACEMENT else a for a in rhs] + extra_args
continue
- elif lhs == '_flags':
+ elif lhs == "_flags":
# _flags will be handled later
continue
lhs = lhs.replace(_DOT_REPLACEMENT, ".")
- if '.' not in lhs:
+ if "." not in lhs:
# probably a mistyped alias, but not technically illegal
self.log.warning("Unrecognized alias: '%s', it will have no effect.", lhs)
trait = None
@@ -1056,6 +1084,7 @@ class KeyValueConfigLoader(KVArgParseConfigLoader):
Use KVArgParseConfigLoader
"""
+
def __init__(self, *args, **kwargs):
warnings.warn(
"KeyValueConfigLoader is deprecated since Traitlets 5.0."
@@ -1083,7 +1112,7 @@ def load_pyconfig_files(config_files, path):
next_config = loader.load_config()
except ConfigFileNotFound:
pass
- except:
+ except Exception:
raise
else:
config.merge(next_config)
diff --git a/contrib/python/traitlets/py3/traitlets/config/manager.py b/contrib/python/traitlets/py3/traitlets/config/manager.py
index 164053261e..728cd2f22c 100644
--- a/contrib/python/traitlets/py3/traitlets/config/manager.py
+++ b/contrib/python/traitlets/py3/traitlets/config/manager.py
@@ -3,7 +3,6 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import errno
-import io
import json
import os
@@ -38,7 +37,7 @@ class BaseJSONConfigManager(LoggingConfigurable):
Deals with persisting/storing config in a json file
"""
- config_dir = Unicode('.')
+ config_dir = Unicode(".")
def ensure_config_dir_exists(self):
try:
@@ -48,7 +47,7 @@ class BaseJSONConfigManager(LoggingConfigurable):
raise
def file_name(self, section_name):
- return os.path.join(self.config_dir, section_name+'.json')
+ return os.path.join(self.config_dir, section_name + ".json")
def get(self, section_name):
"""Retrieve the config data for the specified section.
@@ -58,18 +57,17 @@ class BaseJSONConfigManager(LoggingConfigurable):
"""
filename = self.file_name(section_name)
if os.path.isfile(filename):
- with io.open(filename, encoding='utf-8') as f:
+ with open(filename, encoding="utf-8") as f:
return json.load(f)
else:
return {}
def set(self, section_name, data):
- """Store the given config data.
- """
+ """Store the given config data."""
filename = self.file_name(section_name)
self.ensure_config_dir_exists()
- f = open(filename, 'w', encoding='utf-8')
+ f = open(filename, "w", encoding="utf-8")
with f:
json.dump(data, f, indent=2)
diff --git a/contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py b/contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py
index ce22e4a674..92c2d64d67 100644
--- a/contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py
+++ b/contrib/python/traitlets/py3/traitlets/config/sphinxdoc.py
@@ -32,11 +32,11 @@ The generated rST syntax looks like this::
Cross reference like this: :configtrait:`Application.log_datefmt`.
"""
-from traitlets import Undefined
-from traitlets.utils.text import indent
from collections import defaultdict
+from textwrap import dedent
-from textwrap import indent as _indent, dedent
+from traitlets import Undefined
+from traitlets.utils.text import indent
def setup(app):
@@ -45,10 +45,11 @@ def setup(app):
You shouldn't need to call this directly; configure Sphinx to use this
module instead.
"""
- app.add_object_type('configtrait', 'configtrait', objname='Config option')
- metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
+ app.add_object_type("configtrait", "configtrait", objname="Config option")
+ metadata = {"parallel_read_safe": True, "parallel_write_safe": True}
return metadata
+
def interesting_default_value(dv):
if (dv is None) or (dv is Undefined):
return False
@@ -56,12 +57,14 @@ def interesting_default_value(dv):
return bool(dv)
return True
+
def format_aliases(aliases):
fmted = []
for a in aliases:
- dashes = '-' if len(a) == 1 else '--'
- fmted.append('``%s%s``' % (dashes, a))
- return ', '.join(fmted)
+ dashes = "-" if len(a) == 1 else "--"
+ fmted.append(f"``{dashes}{a}``")
+ return ", ".join(fmted)
+
def class_config_rst_doc(cls, trait_aliases):
"""Generate rST documentation for this class' config options.
@@ -70,23 +73,19 @@ def class_config_rst_doc(cls, trait_aliases):
"""
lines = []
classname = cls.__name__
- for k, trait in sorted(cls.class_traits(config=True).items()):
+ for _, trait in sorted(cls.class_traits(config=True).items()):
ttype = trait.__class__.__name__
- fullname = classname + '.' + trait.name
- lines += ['.. configtrait:: ' + fullname,
- ''
- ]
+ fullname = classname + "." + trait.name
+ lines += [".. configtrait:: " + fullname, ""]
help = trait.help.rstrip() or "No description"
lines.append(indent(dedent(help)) + "\n")
# Choices or type
- if 'Enum' in ttype:
+ if "Enum" in ttype:
# include Enum choices
- lines.append(
- indent(":options: " + ", ".join("``%r``" % x for x in trait.values))
- )
+ lines.append(indent(":options: " + ", ".join("``%r``" % x for x in trait.values)))
else:
lines.append(indent(":trait type: " + ttype))
@@ -99,7 +98,7 @@ def class_config_rst_doc(cls, trait_aliases):
dvr = None # ignore defaults we can't construct
if dvr is not None:
if len(dvr) > 64:
- dvr = dvr[:61] + '...'
+ dvr = dvr[:61] + "..."
# Double up backslashes, so they get to the rendered docs
dvr = dvr.replace("\\n", "\\\\n")
lines.append(indent(":default: ``%s``" % dvr))
@@ -110,13 +109,13 @@ def class_config_rst_doc(cls, trait_aliases):
lines.append(indent(":CLI option: " + fmt_aliases))
# Blank line
- lines.append('')
+ lines.append("")
+
+ return "\n".join(lines)
- return '\n'.join(lines)
def reverse_aliases(app):
- """Produce a mapping of trait names to lists of command line aliases.
- """
+ """Produce a mapping of trait names to lists of command line aliases."""
res = defaultdict(list)
for alias, trait in app.aliases.items():
res[trait].append(alias)
@@ -130,10 +129,11 @@ def reverse_aliases(app):
if len(cls_cfg) == 1:
traitname = list(cls_cfg)[0]
if cls_cfg[traitname] is True:
- res[classname+'.'+traitname].append(flag)
+ res[classname + "." + traitname].append(flag)
return res
+
def write_doc(path, title, app, preamble=None):
"""Write a rst file documenting config options for a traitlets application.
@@ -149,13 +149,13 @@ def write_doc(path, title, app, preamble=None):
Extra text to add just after the title (optional)
"""
trait_aliases = reverse_aliases(app)
- with open(path, 'w') as f:
- f.write(title + '\n')
- f.write(('=' * len(title)) + '\n')
- f.write('\n')
+ with open(path, "w") as f:
+ f.write(title + "\n")
+ f.write(("=" * len(title)) + "\n")
+ f.write("\n")
if preamble is not None:
- f.write(preamble + '\n\n')
+ f.write(preamble + "\n\n")
for c in app._classes_inc_parents():
f.write(class_config_rst_doc(c, trait_aliases))
- f.write('\n')
+ f.write("\n")
diff --git a/contrib/python/traitlets/py3/traitlets/config/tests/test_application.py b/contrib/python/traitlets/py3/traitlets/config/tests/test_application.py
index b3188bd7d1..860d1be2c9 100644
--- a/contrib/python/traitlets/py3/traitlets/config/tests/test_application.py
+++ b/contrib/python/traitlets/py3/traitlets/config/tests/test_application.py
@@ -1,4 +1,3 @@
-# coding: utf-8
"""
Tests for traitlets.config.application.Application
"""
@@ -19,17 +18,7 @@ from unittest import TestCase
import pytest
from pytest import mark
-from traitlets import (
- Bool,
- Bytes,
- Dict,
- HasTraits,
- Integer,
- List,
- Set,
- Tuple,
- Unicode,
-)
+from traitlets import Bool, Bytes, Dict, HasTraits, Integer, List, Set, Tuple, Unicode
from traitlets.config.application import Application
from traitlets.config.configurable import Configurable
from traitlets.config.loader import Config
@@ -42,73 +31,78 @@ from traitlets.tests.utils import (
try:
from unittest import mock
except ImportError:
- import mock
+ from unittest import mock
pjoin = os.path.join
class Foo(Configurable):
- i = Integer(0, help="""
+ i = Integer(
+ 0,
+ help="""
The integer i.
Details about i.
- """).tag(config=True)
+ """,
+ ).tag(config=True)
j = Integer(1, help="The integer j.").tag(config=True)
- name = Unicode('Brian', help="First name.").tag(config=True)
+ name = Unicode("Brian", help="First name.").tag(config=True)
la = List([]).tag(config=True)
li = List(Integer()).tag(config=True)
- fdict = Dict().tag(config=True, multiplicity='+')
+ fdict = Dict().tag(config=True, multiplicity="+")
class Bar(Configurable):
b = Integer(0, help="The integer b.").tag(config=True)
enabled = Bool(True, help="Enable bar.").tag(config=True)
- tb = Tuple(()).tag(config=True, multiplicity='*')
- aset = Set().tag(config=True, multiplicity='+')
+ tb = Tuple(()).tag(config=True, multiplicity="*")
+ aset = Set().tag(config=True, multiplicity="+")
bdict = Dict().tag(config=True)
idict = Dict(value_trait=Integer()).tag(config=True)
- key_dict = Dict(per_key_traits={'i': Integer(), 'b': Bytes()}).tag(config=True)
+ key_dict = Dict(per_key_traits={"i": Integer(), "b": Bytes()}).tag(config=True)
class MyApp(Application):
- name = Unicode('myapp')
+ name = Unicode("myapp")
running = Bool(False, help="Is the app running?").tag(config=True)
classes = List([Bar, Foo])
- config_file = Unicode('', help="Load this config file").tag(config=True)
+ config_file = Unicode("", help="Load this config file").tag(config=True)
- warn_tpyo = Unicode("yes the name is wrong on purpose", config=True,
- help="Should print a warning if `MyApp.warn-typo=...` command is passed")
+ warn_tpyo = Unicode(
+ "yes the name is wrong on purpose",
+ config=True,
+ help="Should print a warning if `MyApp.warn-typo=...` command is passed",
+ )
aliases = {}
aliases.update(Application.aliases)
- aliases.update({
- ('fooi', 'i') : 'Foo.i',
- ('j', 'fooj') : ('Foo.j', "`j` terse help msg"),
- 'name' : 'Foo.name',
- 'la': 'Foo.la',
- 'li': 'Foo.li',
- 'tb': 'Bar.tb',
- 'D': 'Bar.bdict',
- 'enabled' : 'Bar.enabled',
- 'enable' : 'Bar.enabled',
- 'log-level' : 'Application.log_level',
- })
+ aliases.update(
+ {
+ ("fooi", "i"): "Foo.i",
+ ("j", "fooj"): ("Foo.j", "`j` terse help msg"),
+ "name": "Foo.name",
+ "la": "Foo.la",
+ "li": "Foo.li",
+ "tb": "Bar.tb",
+ "D": "Bar.bdict",
+ "enabled": "Bar.enabled",
+ "enable": "Bar.enabled",
+ "log-level": "Application.log_level",
+ }
+ )
flags = {}
flags.update(Application.flags)
- flags.update({('enable', 'e'):
- ({'Bar': {'enabled' : True}},
- "Set Bar.enabled to True"),
- ('d', 'disable'):
- ({'Bar': {'enabled' : False}},
- "Set Bar.enabled to False"),
- 'crit':
- ({'Application' : {'log_level' : logging.CRITICAL}},
- "set level=CRITICAL"),
- })
+ flags.update(
+ {
+ ("enable", "e"): ({"Bar": {"enabled": True}}, "Set Bar.enabled to True"),
+ ("d", "disable"): ({"Bar": {"enabled": False}}, "Set Bar.enabled to False"),
+ "crit": ({"Application": {"log_level": logging.CRITICAL}}, "set level=CRITICAL"),
+ }
+ )
def init_foo(self):
self.foo = Foo(parent=self)
@@ -127,62 +121,76 @@ class TestApplication(TestCase):
app = MyApp(log_level=logging.INFO)
handler = logging.StreamHandler(stream)
# trigger reconstruction of the log formatter
- app.log.handlers = [handler]
app.log_format = "%(message)s"
app.log_datefmt = "%Y-%m-%d %H:%M"
+ app.log.handlers = [handler]
app.log.info("hello")
assert "hello" in stream.getvalue()
def test_no_eval_cli_text(self):
app = MyApp()
- app.initialize(['--Foo.name=1'])
+ app.initialize(["--Foo.name=1"])
app.init_foo()
- assert app.foo.name == '1'
+ assert app.foo.name == "1"
def test_basic(self):
app = MyApp()
- self.assertEqual(app.name, 'myapp')
+ self.assertEqual(app.name, "myapp")
self.assertEqual(app.running, False)
self.assertEqual(app.classes, [MyApp, Bar, Foo])
- self.assertEqual(app.config_file, '')
+ self.assertEqual(app.config_file, "")
def test_mro_discovery(self):
app = MyApp()
- self.assertSequenceEqual(class_to_names(app._classes_with_config_traits()),
- ['Application', 'MyApp', 'Bar', 'Foo'])
- self.assertSequenceEqual(class_to_names(app._classes_inc_parents()),
- ['Configurable', 'LoggingConfigurable', 'SingletonConfigurable',
- 'Application', 'MyApp', 'Bar', 'Foo'])
+ self.assertSequenceEqual(
+ class_to_names(app._classes_with_config_traits()),
+ ["Application", "MyApp", "Bar", "Foo"],
+ )
+ self.assertSequenceEqual(
+ class_to_names(app._classes_inc_parents()),
+ [
+ "Configurable",
+ "LoggingConfigurable",
+ "SingletonConfigurable",
+ "Application",
+ "MyApp",
+ "Bar",
+ "Foo",
+ ],
+ )
- self.assertSequenceEqual(class_to_names(app._classes_with_config_traits([Application])),
- ['Application'])
- self.assertSequenceEqual(class_to_names(app._classes_inc_parents([Application])),
- ['Configurable', 'LoggingConfigurable', 'SingletonConfigurable',
- 'Application'])
+ self.assertSequenceEqual(
+ class_to_names(app._classes_with_config_traits([Application])), ["Application"]
+ )
+ self.assertSequenceEqual(
+ class_to_names(app._classes_inc_parents([Application])),
+ ["Configurable", "LoggingConfigurable", "SingletonConfigurable", "Application"],
+ )
- self.assertSequenceEqual(class_to_names(app._classes_with_config_traits([Foo])),
- ['Foo'])
- self.assertSequenceEqual(class_to_names(app._classes_inc_parents([Bar])),
- ['Configurable', 'Bar'])
+ self.assertSequenceEqual(class_to_names(app._classes_with_config_traits([Foo])), ["Foo"])
+ self.assertSequenceEqual(
+ class_to_names(app._classes_inc_parents([Bar])), ["Configurable", "Bar"]
+ )
class MyApp2(Application): # no defined `classes` attr
pass
- self.assertSequenceEqual(class_to_names(app._classes_with_config_traits([Foo])),
- ['Foo'])
- self.assertSequenceEqual(class_to_names(app._classes_inc_parents([Bar])),
- ['Configurable', 'Bar'])
-
+ self.assertSequenceEqual(class_to_names(app._classes_with_config_traits([Foo])), ["Foo"])
+ self.assertSequenceEqual(
+ class_to_names(app._classes_inc_parents([Bar])), ["Configurable", "Bar"]
+ )
def test_config(self):
app = MyApp()
- app.parse_command_line([
- "--i=10",
- "--Foo.j=10",
- "--enable=False",
- "--log-level=50",
- ])
+ app.parse_command_line(
+ [
+ "--i=10",
+ "--Foo.j=10",
+ "--enable=False",
+ "--log-level=50",
+ ]
+ )
config = app.config
print(config)
self.assertEqual(config.Foo.i, 10)
@@ -192,7 +200,9 @@ class TestApplication(TestCase):
def test_config_seq_args(self):
app = MyApp()
- app.parse_command_line("--li 1 --li 3 --la 1 --tb AB 2 --Foo.la=ab --Bar.aset S1 --Bar.aset S2 --Bar.aset S1".split())
+ app.parse_command_line(
+ "--li 1 --li 3 --la 1 --tb AB 2 --Foo.la=ab --Bar.aset S1 --Bar.aset S2 --Bar.aset S1".split()
+ )
assert app.extra_args == ["2"]
config = app.config
assert config.Foo.li == [1, 3]
@@ -201,21 +211,21 @@ class TestApplication(TestCase):
self.assertEqual(config.Bar.aset, {"S1", "S2"})
app.init_foo()
assert app.foo.li == [1, 3]
- assert app.foo.la == ['1', 'ab']
+ assert app.foo.la == ["1", "ab"]
app.init_bar()
- self.assertEqual(app.bar.aset, {'S1', 'S2'})
- assert app.bar.tb == ('AB',)
+ self.assertEqual(app.bar.aset, {"S1", "S2"})
+ assert app.bar.tb == ("AB",)
def test_config_dict_args(self):
app = MyApp()
app.parse_command_line(
"--Foo.fdict a=1 --Foo.fdict b=b --Foo.fdict c=3 "
"--Bar.bdict k=1 -D=a=b -D 22=33 "
- "--Bar.idict k=1 --Bar.idict b=2 --Bar.idict c=3 "
- .split())
- fdict = {'a': '1', 'b': 'b', 'c': '3'}
- bdict = {'k': '1', 'a': 'b', '22': '33'}
- idict = {'k': 1, 'b': 2, 'c': 3}
+ "--Bar.idict k=1 --Bar.idict b=2 --Bar.idict c=3 ".split()
+ )
+ fdict = {"a": "1", "b": "b", "c": "3"}
+ bdict = {"k": "1", "a": "b", "22": "33"}
+ idict = {"k": 1, "b": 2, "c": 3}
config = app.config
assert config.Bar.idict == idict
self.assertDictEqual(config.Foo.fdict, fdict)
@@ -228,7 +238,7 @@ class TestApplication(TestCase):
def test_config_propagation(self):
app = MyApp()
- app.parse_command_line(["--i=10","--Foo.j=10","--enable=False","--log-level=50"])
+ app.parse_command_line(["--i=10", "--Foo.j=10", "--enable=False", "--log-level=50"])
app.init_foo()
app.init_bar()
self.assertEqual(app.foo.i, 10)
@@ -237,64 +247,66 @@ class TestApplication(TestCase):
def test_cli_priority(self):
"""Test that loading config files does not override CLI options"""
- name = 'config.py'
+ name = "config.py"
+
class TestApp(Application):
value = Unicode().tag(config=True)
config_file_loaded = Bool().tag(config=True)
- aliases = {'v': 'TestApp.value'}
+ aliases = {"v": "TestApp.value"}
+
app = TestApp()
with TemporaryDirectory() as td:
config_file = pjoin(td, name)
- with open(config_file, 'w') as f:
- f.writelines([
- "c.TestApp.value = 'config file'\n",
- "c.TestApp.config_file_loaded = True\n"
- ])
+ with open(config_file, "w") as f:
+ f.writelines(
+ ["c.TestApp.value = 'config file'\n", "c.TestApp.config_file_loaded = True\n"]
+ )
- app.parse_command_line(['--v=cli'])
- assert 'value' in app.config.TestApp
- assert app.config.TestApp.value == 'cli'
- assert app.value == 'cli'
+ app.parse_command_line(["--v=cli"])
+ assert "value" in app.config.TestApp
+ assert app.config.TestApp.value == "cli"
+ assert app.value == "cli"
app.load_config_file(name, path=[td])
assert app.config_file_loaded
- assert app.config.TestApp.value == 'cli'
- assert app.value == 'cli'
+ assert app.config.TestApp.value == "cli"
+ assert app.value == "cli"
def test_ipython_cli_priority(self):
# this test is almost entirely redundant with above,
# but we can keep it around in case of subtle issues creeping into
# the exact sequence IPython follows.
- name = 'config.py'
+ name = "config.py"
+
class TestApp(Application):
value = Unicode().tag(config=True)
config_file_loaded = Bool().tag(config=True)
- aliases = {'v': ('TestApp.value', 'some help')}
+ aliases = {"v": ("TestApp.value", "some help")}
+
app = TestApp()
with TemporaryDirectory() as td:
config_file = pjoin(td, name)
- with open(config_file, 'w') as f:
- f.writelines([
- "c.TestApp.value = 'config file'\n",
- "c.TestApp.config_file_loaded = True\n"
- ])
+ with open(config_file, "w") as f:
+ f.writelines(
+ ["c.TestApp.value = 'config file'\n", "c.TestApp.config_file_loaded = True\n"]
+ )
# follow IPython's config-loading sequence to ensure CLI priority is preserved
- app.parse_command_line(['--v=cli'])
+ app.parse_command_line(["--v=cli"])
# this is where IPython makes a mistake:
# it assumes app.config will not be modified,
# and storing a reference is storing a copy
cli_config = app.config
- assert 'value' in app.config.TestApp
- assert app.config.TestApp.value == 'cli'
- assert app.value == 'cli'
+ assert "value" in app.config.TestApp
+ assert app.config.TestApp.value == "cli"
+ assert app.value == "cli"
app.load_config_file(name, path=[td])
assert app.config_file_loaded
# enforce cl-opts override config file opts:
# this is where IPython makes a mistake: it assumes
# that cl_config is a different object, but it isn't.
app.update_config(cli_config)
- assert app.config.TestApp.value == 'cli'
- assert app.value == 'cli'
+ assert app.config.TestApp.value == "cli"
+ assert app.value == "cli"
def test_cli_allow_none(self):
class App(Application):
@@ -395,7 +407,6 @@ class TestApplication(TestCase):
self.assertIn("warn_typo", stream.getvalue())
self.assertIn("warn_tpyo", stream.getvalue())
-
def test_flatten_flags(self):
cfg = Config()
cfg.MyApp.log_level = logging.WARN
@@ -423,28 +434,26 @@ class TestApplication(TestCase):
def test_extra_args(self):
app = MyApp()
- app.parse_command_line(["--Bar.b=5", 'extra', 'args', "--disable"])
+ app.parse_command_line(["--Bar.b=5", "extra", "args", "--disable"])
app.init_bar()
self.assertEqual(app.bar.enabled, False)
self.assertEqual(app.bar.b, 5)
- self.assertEqual(app.extra_args, ['extra', 'args'])
+ self.assertEqual(app.extra_args, ["extra", "args"])
app = MyApp()
- app.parse_command_line(["--Bar.b=5", '--', 'extra', "--disable", 'args'])
+ app.parse_command_line(["--Bar.b=5", "--", "extra", "--disable", "args"])
app.init_bar()
self.assertEqual(app.bar.enabled, True)
self.assertEqual(app.bar.b, 5)
- self.assertEqual(app.extra_args, ['extra', '--disable', 'args'])
+ self.assertEqual(app.extra_args, ["extra", "--disable", "args"])
app = MyApp()
- app.parse_command_line(
- ["--disable", "--la", "-", "-", "--Bar.b=1", "--", "-", "extra"]
- )
+ app.parse_command_line(["--disable", "--la", "-", "-", "--Bar.b=1", "--", "-", "extra"])
self.assertEqual(app.extra_args, ["-", "-", "extra"])
def test_unicode_argv(self):
app = MyApp()
- app.parse_command_line(['ünîcødé'])
+ app.parse_command_line(["ünîcødé"])
def test_document_config_option(self):
app = MyApp()
@@ -452,14 +461,17 @@ class TestApplication(TestCase):
def test_generate_config_file(self):
app = MyApp()
- assert 'The integer b.' in app.generate_config_file()
+ assert "The integer b." in app.generate_config_file()
def test_generate_config_file_classes_to_include(self):
class NotInConfig(HasTraits):
- from_hidden = Unicode('x', help="""From hidden class
-
+ from_hidden = Unicode(
+ "x",
+ help="""From hidden class
+
Details about from_hidden.
- """).tag(config=True)
+ """,
+ ).tag(config=True)
class NoTraits(Foo, Bar, NotInConfig):
pass
@@ -469,34 +481,34 @@ class TestApplication(TestCase):
conf_txt = app.generate_config_file()
print(conf_txt)
- self.assertIn('The integer b.', conf_txt)
- self.assertIn('# Foo(Configurable)', conf_txt)
- self.assertNotIn('# Configurable', conf_txt)
- self.assertIn('# NoTraits(Foo, Bar)', conf_txt)
+ self.assertIn("The integer b.", conf_txt)
+ self.assertIn("# Foo(Configurable)", conf_txt)
+ self.assertNotIn("# Configurable", conf_txt)
+ self.assertIn("# NoTraits(Foo, Bar)", conf_txt)
# inherited traits, parent in class list:
- self.assertIn('# c.NoTraits.i', conf_txt)
- self.assertIn('# c.NoTraits.j', conf_txt)
- self.assertIn('# c.NoTraits.n', conf_txt)
- self.assertIn('# See also: Foo.j', conf_txt)
- self.assertIn('# See also: Bar.b', conf_txt)
- self.assertEqual(conf_txt.count('Details about i.'), 1)
+ self.assertIn("# c.NoTraits.i", conf_txt)
+ self.assertIn("# c.NoTraits.j", conf_txt)
+ self.assertIn("# c.NoTraits.n", conf_txt)
+ self.assertIn("# See also: Foo.j", conf_txt)
+ self.assertIn("# See also: Bar.b", conf_txt)
+ self.assertEqual(conf_txt.count("Details about i."), 1)
# inherited traits, parent not in class list:
self.assertIn("# c.NoTraits.from_hidden", conf_txt)
- self.assertNotIn('# See also: NotInConfig.', conf_txt)
- self.assertEqual(conf_txt.count('Details about from_hidden.'), 1)
+ self.assertNotIn("# See also: NotInConfig.", conf_txt)
+ self.assertEqual(conf_txt.count("Details about from_hidden."), 1)
self.assertNotIn("NotInConfig", conf_txt)
def test_multi_file(self):
app = MyApp()
app.log = logging.getLogger()
- name = 'config.py'
- with TemporaryDirectory('_1') as td1:
- with open(pjoin(td1, name), 'w') as f1:
+ name = "config.py"
+ with TemporaryDirectory("_1") as td1:
+ with open(pjoin(td1, name), "w") as f1:
f1.write("get_config().MyApp.Bar.b = 1")
- with TemporaryDirectory('_2') as td2:
- with open(pjoin(td2, name), 'w') as f2:
+ with TemporaryDirectory("_2") as td2:
+ with open(pjoin(td2, name), "w") as f2:
f2.write("get_config().MyApp.Bar.b = 2")
app.load_config_file(name, path=[td2, td1])
app.init_bar()
@@ -505,51 +517,47 @@ class TestApplication(TestCase):
app.init_bar()
self.assertEqual(app.bar.b, 1)
- @mark.skipif(not hasattr(TestCase, 'assertLogs'), reason='requires TestCase.assertLogs')
+ @mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs")
def test_log_collisions(self):
app = MyApp()
app.log = logging.getLogger()
app.log.setLevel(logging.INFO)
- name = 'config'
- with TemporaryDirectory('_1') as td:
- with open(pjoin(td, name + '.py'), 'w') as f:
+ name = "config"
+ with TemporaryDirectory("_1") as td:
+ with open(pjoin(td, name + ".py"), "w") as f:
f.write("get_config().Bar.b = 1")
- with open(pjoin(td, name + '.json'), 'w') as f:
- json.dump({
- 'Bar': {
- 'b': 2
- }
- }, f)
+ with open(pjoin(td, name + ".json"), "w") as f:
+ json.dump({"Bar": {"b": 2}}, f)
with self.assertLogs(app.log, logging.WARNING) as captured:
app.load_config_file(name, path=[td])
app.init_bar()
assert app.bar.b == 2
- output = '\n'.join(captured.output)
- assert 'Collision' in output
- assert '1 ignored, using 2' in output
- assert pjoin(td, name + '.py') in output
- assert pjoin(td, name + '.json') in output
+ output = "\n".join(captured.output)
+ assert "Collision" in output
+ assert "1 ignored, using 2" in output
+ assert pjoin(td, name + ".py") in output
+ assert pjoin(td, name + ".json") in output
- @mark.skipif(not hasattr(TestCase, 'assertLogs'), reason='requires TestCase.assertLogs')
+ @mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs")
def test_log_bad_config(self):
app = MyApp()
app.log = logging.getLogger()
- name = 'config.py'
+ name = "config.py"
with TemporaryDirectory() as td:
- with open(pjoin(td, name), 'w') as f:
+ with open(pjoin(td, name), "w") as f:
f.write("syntax error()")
with self.assertLogs(app.log, logging.ERROR) as captured:
app.load_config_file(name, path=[td])
- output = '\n'.join(captured.output)
- self.assertIn('SyntaxError', output)
+ output = "\n".join(captured.output)
+ self.assertIn("SyntaxError", output)
def test_raise_on_bad_config(self):
app = MyApp()
app.raise_config_file_errors = True
app.log = logging.getLogger()
- name = 'config.py'
+ name = "config.py"
with TemporaryDirectory() as td:
- with open(pjoin(td, name), 'w') as f:
+ with open(pjoin(td, name), "w") as f:
f.write("syntax error()")
with self.assertRaises(SyntaxError):
app.load_config_file(name, path=[td])
@@ -557,20 +565,20 @@ class TestApplication(TestCase):
def test_subcommands_instanciation(self):
"""Try all ways to specify how to create sub-apps."""
app = Root.instance()
- app.parse_command_line(['sub1'])
+ app.parse_command_line(["sub1"])
self.assertIsInstance(app.subapp, Sub1)
- ## Check parent hierarchy.
+ # Check parent hierarchy.
self.assertIs(app.subapp.parent, app)
Root.clear_instance()
Sub1.clear_instance() # Otherwise, replaced spuriously and hierarchy check fails.
app = Root.instance()
- app.parse_command_line(['sub1', 'sub2'])
+ app.parse_command_line(["sub1", "sub2"])
self.assertIsInstance(app.subapp, Sub1)
self.assertIsInstance(app.subapp.subapp, Sub2)
- ## Check parent hierarchy.
+ # Check parent hierarchy.
self.assertIs(app.subapp.parent, app)
self.assertIs(app.subapp.subapp.parent, app.subapp)
@@ -578,24 +586,22 @@ class TestApplication(TestCase):
Sub1.clear_instance() # Otherwise, replaced spuriously and hierarchy check fails.
app = Root.instance()
- app.parse_command_line(['sub1', 'sub3'])
+ app.parse_command_line(["sub1", "sub3"])
self.assertIsInstance(app.subapp, Sub1)
self.assertIsInstance(app.subapp.subapp, Sub3)
- self.assertTrue(app.subapp.subapp.flag) # Set by factory.
- ## Check parent hierarchy.
+ self.assertTrue(app.subapp.subapp.flag) # Set by factory.
+ # Check parent hierarchy.
self.assertIs(app.subapp.parent, app)
- self.assertIs(app.subapp.subapp.parent, app.subapp) # Set by factory.
+ self.assertIs(app.subapp.subapp.parent, app.subapp) # Set by factory.
def test_loaded_config_files(self):
app = MyApp()
app.log = logging.getLogger()
- name = 'config.py'
- with TemporaryDirectory('_1') as td1:
+ name = "config.py"
+ with TemporaryDirectory("_1") as td1:
config_file = pjoin(td1, name)
- with open(config_file, 'w') as f:
- f.writelines([
- "c.MyApp.running = True\n"
- ])
+ with open(config_file, "w") as f:
+ f.writelines(["c.MyApp.running = True\n"])
app.load_config_file(name, path=[td1])
self.assertEqual(len(app.loaded_config_files), 1)
@@ -605,10 +611,8 @@ class TestApplication(TestCase):
self.assertEqual(app.running, True)
# emulate an app that allows dynamic updates and update config file
- with open(config_file, 'w') as f:
- f.writelines([
- "c.MyApp.running = False\n"
- ])
+ with open(config_file, "w") as f:
+ f.writelines(["c.MyApp.running = False\n"])
# reload and verify update, and that loaded_configs was not increased
app.load_config_file(name, path=[td1])
@@ -629,7 +633,6 @@ class TestApplication(TestCase):
self.assertEqual(app.running, False)
-
@mark.skip
def test_cli_multi_scalar(caplog):
class App(Application):
@@ -650,7 +653,7 @@ def test_cli_multi_scalar(caplog):
class Root(Application):
subcommands = {
- 'sub1': ('__tests__.config.tests.test_application.Sub1', 'import string'),
+ "sub1": ("__tests__.config.tests.test_application.Sub1", "import string"),
}
@@ -664,27 +667,30 @@ class Sub2(Application):
class Sub1(Application):
subcommands = {
- 'sub2': (Sub2, 'Application class'),
- 'sub3': (lambda root: Sub3(parent=root, flag=True), 'factory'),
+ "sub2": (Sub2, "Application class"),
+ "sub3": (lambda root: Sub3(parent=root, flag=True), "factory"),
}
class DeprecatedApp(Application):
override_called = False
parent_called = False
+
def _config_changed(self, name, old, new):
self.override_called = True
+
def _capture(*args):
self.parent_called = True
- with mock.patch.object(self.log, 'debug', _capture):
- super(DeprecatedApp, self)._config_changed(name, old, new)
+
+ with mock.patch.object(self.log, "debug", _capture):
+ super()._config_changed(name, old, new)
def test_deprecated_notifier():
app = DeprecatedApp()
assert not app.override_called
assert not app.parent_called
- app.config = Config({'A': {'b': 'c'}})
+ app.config = Config({"A": {"b": "c"}})
assert app.override_called
assert app.parent_called
@@ -698,15 +704,15 @@ def test_help_all_output():
def test_show_config_cli():
- out, err, ec = get_output_error_code([sys.executable, '-m', __name__, '--show-config'])
+ out, err, ec = get_output_error_code([sys.executable, "-m", __name__, "--show-config"])
assert ec == 0
- assert 'show_config' not in out
+ assert "show_config" not in out
def test_show_config_json_cli():
- out, err, ec = get_output_error_code([sys.executable, '-m', __name__, '--show-config-json'])
+ out, err, ec = get_output_error_code([sys.executable, "-m", __name__, "--show-config-json"])
assert ec == 0
- assert 'show_config' not in out
+ assert "show_config" not in out
def test_show_config(capsys):
@@ -718,9 +724,9 @@ def test_show_config(capsys):
app = MyApp(config=cfg, show_config=True)
app.start()
out, err = capsys.readouterr()
- assert 'MyApp' in out
- assert 'i = 5' in out
- assert 'OtherApp' not in out
+ assert "MyApp" in out
+ assert "i = 5" in out
+ assert "OtherApp" not in out
def test_show_config_json(capsys):
@@ -736,22 +742,21 @@ def test_show_config_json(capsys):
def test_deep_alias():
- from traitlets.config import Application, Configurable
from traitlets import Int
+ from traitlets.config import Application, Configurable
class Foo(Configurable):
val = Int(default_value=5).tag(config=True)
class Bar(Configurable):
-
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.foo = Foo(parent=self)
class TestApp(Application):
- name = 'test'
+ name = "test"
- aliases = {'val': 'Bar.Foo.val'}
+ aliases = {"val": "Bar.Foo.val"}
classes = [Foo, Bar]
def initialize(self, *args, **kwargs):
@@ -759,11 +764,47 @@ def test_deep_alias():
self.bar = Bar(parent=self)
app = TestApp()
- app.initialize(['--val=10'])
+ app.initialize(["--val=10"])
assert app.bar.foo.val == 10
assert len(list(app.emit_alias_help())) > 0
-if __name__ == '__main__':
+def test_logging_config(tmp_path, capsys):
+ """We should be able to configure additional log handlers."""
+ log_file = tmp_path / "log_file"
+ app = Application(
+ logging_config={
+ "version": 1,
+ "handlers": {
+ "file": {
+ "class": "logging.FileHandler",
+ "level": "DEBUG",
+ "filename": str(log_file),
+ },
+ },
+ "loggers": {
+ "Application": {
+ "level": "DEBUG",
+ "handlers": ["console", "file"],
+ },
+ },
+ }
+ )
+ # the default "console" handler + our new "file" handler
+ assert len(app.log.handlers) == 2
+
+ # log a couple of messages
+ app.log.info("info")
+ app.log.warning("warn")
+
+ # test that log messages get written to the file
+ with open(log_file) as log_handle:
+ assert log_handle.read() == "info\nwarn\n"
+
+ # test that log messages get written to stderr (default console handler)
+ assert capsys.readouterr().err == "[Application] WARNING | warn\n"
+
+
+if __name__ == "__main__":
# for test_help_output:
MyApp.launch_instance()
diff --git a/contrib/python/traitlets/py3/traitlets/config/tests/test_configurable.py b/contrib/python/traitlets/py3/traitlets/config/tests/test_configurable.py
index b8d153b53f..00b7db2136 100644
--- a/contrib/python/traitlets/py3/traitlets/config/tests/test_configurable.py
+++ b/contrib/python/traitlets/py3/traitlets/config/tests/test_configurable.py
@@ -14,20 +14,29 @@ from traitlets.config.configurable import (
LoggingConfigurable,
SingletonConfigurable,
)
+from traitlets.config.loader import Config
from traitlets.log import get_logger
from traitlets.traitlets import (
- Integer, Float, Unicode, List, Dict, Set, Enum, FuzzyEnum,
- CaselessStrEnum, _deprecations_shown, validate,
+ CaselessStrEnum,
+ Dict,
+ Enum,
+ Float,
+ FuzzyEnum,
+ Integer,
+ List,
+ Set,
+ Unicode,
+ _deprecations_shown,
+ validate,
)
-from traitlets.config.loader import Config
-
from traitlets.tests._warnings import expected_warnings
+
class MyConfigurable(Configurable):
a = Integer(1, help="The integer a.").tag(config=True)
b = Float(1.0, help="The integer b.").tag(config=True)
- c = Unicode('no config')
+ c = Unicode("no config")
mc_help = """MyConfigurable(Configurable) options
@@ -39,7 +48,7 @@ mc_help = """MyConfigurable(Configurable) options
The integer b.
Default: 1.0"""
-mc_help_inst="""MyConfigurable(Configurable) options
+mc_help_inst = """MyConfigurable(Configurable) options
------------------------------------
--MyConfigurable.a=<Integer>
The integer a.
@@ -52,22 +61,24 @@ mc_help_inst="""MyConfigurable(Configurable) options
mc_help = mc_help.replace("<Integer>", "<Int>")
mc_help_inst = mc_help_inst.replace("<Integer>", "<Int>")
+
class Foo(Configurable):
a = Integer(0, help="The integer a.").tag(config=True)
- b = Unicode('nope').tag(config=True)
+ b = Unicode("nope").tag(config=True)
flist = List([]).tag(config=True)
fdict = Dict().tag(config=True)
class Bar(Foo):
- b = Unicode('gotit', help="The string b.").tag(config=False)
+ b = Unicode("gotit", help="The string b.").tag(config=False)
c = Float(help="The string c.").tag(config=True)
- bset = Set([]).tag(config=True, multiplicity='+')
- bset_values = Set([2,1,5]).tag(config=True, multiplicity='+')
- bdict = Dict().tag(config=True, multiplicity='+')
- bdict_values = Dict({1:'a','0':'b',5:'c'}).tag(config=True, multiplicity='+')
+ bset = Set([]).tag(config=True, multiplicity="+")
+ bset_values = Set([2, 1, 5]).tag(config=True, multiplicity="+")
+ bdict = Dict().tag(config=True, multiplicity="+")
+ bdict_values = Dict({1: "a", "0": "b", 5: "c"}).tag(config=True, multiplicity="+")
+
-foo_help="""Foo(Configurable) options
+foo_help = """Foo(Configurable) options
-------------------------
--Foo.a=<Int>
The integer a.
@@ -79,7 +90,7 @@ foo_help="""Foo(Configurable) options
--Foo.flist=<list-item-1>...
Default: []"""
-bar_help="""Bar(Foo) options
+bar_help = """Bar(Foo) options
----------------
--Bar.a=<Int>
The integer a.
@@ -102,7 +113,6 @@ bar_help="""Bar(Foo) options
class TestConfigurable(TestCase):
-
def test_default(self):
c1 = Configurable()
c2 = Configurable(config=c1.config)
@@ -112,8 +122,8 @@ class TestConfigurable(TestCase):
def test_custom(self):
config = Config()
- config.foo = 'foo'
- config.bar = 'bar'
+ config.foo = "foo"
+ config.bar = "bar"
c1 = Configurable(config=config)
c2 = Configurable(config=c1.config)
c3 = Configurable(config=c2.config)
@@ -142,14 +152,14 @@ class TestConfigurable(TestCase):
config = Config()
config.Foo.a = 10
config.Foo.b = "wow"
- config.Bar.b = 'later'
+ config.Bar.b = "later"
config.Bar.c = 100.0
f = Foo(config=config)
- with expected_warnings(['`b` not recognized']):
+ with expected_warnings(["`b` not recognized"]):
b = Bar(config=f.config)
self.assertEqual(f.a, 10)
- self.assertEqual(f.b, 'wow')
- self.assertEqual(b.b, 'gotit')
+ self.assertEqual(f.b, "wow")
+ self.assertEqual(b.b, "gotit")
self.assertEqual(b.c, 100.0)
def test_override1(self):
@@ -159,22 +169,22 @@ class TestConfigurable(TestCase):
c = MyConfigurable(a=3, config=config)
self.assertEqual(c.a, 3)
self.assertEqual(c.b, config.MyConfigurable.b)
- self.assertEqual(c.c, 'no config')
+ self.assertEqual(c.c, "no config")
def test_override2(self):
config = Config()
config.Foo.a = 1
- config.Bar.b = 'or' # Up above b is config=False, so this won't do it.
+ config.Bar.b = "or" # Up above b is config=False, so this won't do it.
config.Bar.c = 10.0
- with expected_warnings(['`b` not recognized']):
+ with expected_warnings(["`b` not recognized"]):
c = Bar(config=config)
self.assertEqual(c.a, config.Foo.a)
- self.assertEqual(c.b, 'gotit')
+ self.assertEqual(c.b, "gotit")
self.assertEqual(c.c, config.Bar.c)
- with expected_warnings(['`b` not recognized']):
- c = Bar(a=2, b='and', c=20.0, config=config)
+ with expected_warnings(["`b` not recognized"]):
+ c = Bar(a=2, b="and", c=20.0, config=config)
self.assertEqual(c.a, 2)
- self.assertEqual(c.b, 'and')
+ self.assertEqual(c.b, "and")
self.assertEqual(c.c, 20.0)
def test_help(self):
@@ -188,8 +198,7 @@ class TestConfigurable(TestCase):
def test_generated_config_enum_comments(self):
class MyConf(Configurable):
- an_enum = Enum('Choice1 choice2'.split(),
- help="Many choices.").tag(config=True)
+ an_enum = Enum("Choice1 choice2".split(), help="Many choices.").tag(config=True)
help_str = "Many choices."
enum_choices_str = "Choices: any of ['Choice1', 'choice2']"
@@ -207,9 +216,8 @@ class TestConfigurable(TestCase):
self.assertIn(help_str, cls_cfg)
self.assertIn(enum_choices_str, cls_cfg)
self.assertNotIn(or_none_str, cls_help)
- ## Check order of Help-msg <--> Choices sections
- self.assertGreater(cls_cfg.index(enum_choices_str),
- cls_cfg.index(help_str))
+ # Check order of Help-msg <--> Choices sections
+ self.assertGreater(cls_cfg.index(enum_choices_str), cls_cfg.index(help_str))
rst_help = MyConf.class_config_rst_doc()
@@ -218,10 +226,12 @@ class TestConfigurable(TestCase):
self.assertNotIn(or_none_str, rst_help)
class MyConf2(Configurable):
- an_enum = Enum('Choice1 choice2'.split(),
- allow_none=True,
- default_value='choice2',
- help="Many choices.").tag(config=True)
+ an_enum = Enum(
+ "Choice1 choice2".split(),
+ allow_none=True,
+ default_value="choice2",
+ help="Many choices.",
+ ).tag(config=True)
defaults_str = "Default: 'choice2'"
@@ -231,9 +241,8 @@ class TestConfigurable(TestCase):
self.assertIn(enum_choices_str, cls2_msg)
self.assertIn(or_none_str, cls2_msg)
self.assertIn(defaults_str, cls2_msg)
- ## Check order of Default <--> Choices sections
- self.assertGreater(cls2_msg.index(defaults_str),
- cls2_msg.index(enum_choices_str))
+ # Check order of Default <--> Choices sections
+ self.assertGreater(cls2_msg.index(defaults_str), cls2_msg.index(enum_choices_str))
cls2_cfg = MyConf2.class_config_section()
@@ -241,9 +250,8 @@ class TestConfigurable(TestCase):
self.assertIn(enum_choices_str, cls2_cfg)
self.assertIn(or_none_str, cls2_cfg)
self.assertIn(defaults_str, cls2_cfg)
- ## Check order of Default <--> Choices sections
- self.assertGreater(cls2_cfg.index(defaults_str),
- cls2_cfg.index(enum_choices_str))
+ # Check order of Default <--> Choices sections
+ self.assertGreater(cls2_cfg.index(defaults_str), cls2_cfg.index(enum_choices_str))
def test_generated_config_strenum_comments(self):
help_str = "Many choices."
@@ -251,13 +259,14 @@ class TestConfigurable(TestCase):
or_none_str = "or None"
class MyConf3(Configurable):
- an_enum = CaselessStrEnum('Choice1 choice2'.split(),
- allow_none=True,
- default_value='choice2',
- help="Many choices.").tag(config=True)
+ an_enum = CaselessStrEnum(
+ "Choice1 choice2".split(),
+ allow_none=True,
+ default_value="choice2",
+ help="Many choices.",
+ ).tag(config=True)
- enum_choices_str = ("Choices: any of ['Choice1', 'choice2'] "
- "(case-insensitive)")
+ enum_choices_str = "Choices: any of ['Choice1', 'choice2'] (case-insensitive)"
cls3_msg = MyConf3.class_get_help()
@@ -265,9 +274,8 @@ class TestConfigurable(TestCase):
self.assertIn(enum_choices_str, cls3_msg)
self.assertIn(or_none_str, cls3_msg)
self.assertIn(defaults_str, cls3_msg)
- ## Check order of Default <--> Choices sections
- self.assertGreater(cls3_msg.index(defaults_str),
- cls3_msg.index(enum_choices_str))
+ # Check order of Default <--> Choices sections
+ self.assertGreater(cls3_msg.index(defaults_str), cls3_msg.index(enum_choices_str))
cls3_cfg = MyConf3.class_config_section()
@@ -275,18 +283,18 @@ class TestConfigurable(TestCase):
self.assertIn(enum_choices_str, cls3_cfg)
self.assertIn(or_none_str, cls3_cfg)
self.assertIn(defaults_str, cls3_cfg)
- ## Check order of Default <--> Choices sections
- self.assertGreater(cls3_cfg.index(defaults_str),
- cls3_cfg.index(enum_choices_str))
+ # Check order of Default <--> Choices sections
+ self.assertGreater(cls3_cfg.index(defaults_str), cls3_cfg.index(enum_choices_str))
class MyConf4(Configurable):
- an_enum = FuzzyEnum('Choice1 choice2'.split(),
- allow_none=True,
- default_value='choice2',
- help="Many choices.").tag(config=True)
+ an_enum = FuzzyEnum(
+ "Choice1 choice2".split(),
+ allow_none=True,
+ default_value="choice2",
+ help="Many choices.",
+ ).tag(config=True)
- enum_choices_str = ("Choices: any case-insensitive prefix "
- "of ['Choice1', 'choice2']")
+ enum_choices_str = "Choices: any case-insensitive prefix of ['Choice1', 'choice2']"
cls4_msg = MyConf4.class_get_help()
@@ -294,9 +302,8 @@ class TestConfigurable(TestCase):
self.assertIn(enum_choices_str, cls4_msg)
self.assertIn(or_none_str, cls4_msg)
self.assertIn(defaults_str, cls4_msg)
- ## Check order of Default <--> Choices sections
- self.assertGreater(cls4_msg.index(defaults_str),
- cls4_msg.index(enum_choices_str))
+ # Check order of Default <--> Choices sections
+ self.assertGreater(cls4_msg.index(defaults_str), cls4_msg.index(enum_choices_str))
cls4_cfg = MyConf4.class_config_section()
@@ -304,16 +311,15 @@ class TestConfigurable(TestCase):
self.assertIn(enum_choices_str, cls4_cfg)
self.assertIn(or_none_str, cls4_cfg)
self.assertIn(defaults_str, cls4_cfg)
- ## Check order of Default <--> Choices sections
- self.assertGreater(cls4_cfg.index(defaults_str),
- cls4_cfg.index(enum_choices_str))
-
+ # Check order of Default <--> Choices sections
+ self.assertGreater(cls4_cfg.index(defaults_str), cls4_cfg.index(enum_choices_str))
class TestSingletonConfigurable(TestCase):
-
def test_instance(self):
- class Foo(SingletonConfigurable): pass
+ class Foo(SingletonConfigurable):
+ pass
+
self.assertEqual(Foo.initialized(), False)
foo = Foo.instance()
self.assertEqual(Foo.initialized(), True)
@@ -321,8 +327,12 @@ class TestSingletonConfigurable(TestCase):
self.assertEqual(SingletonConfigurable._instance, None)
def test_inheritance(self):
- class Bar(SingletonConfigurable): pass
- class Bam(Bar): pass
+ class Bar(SingletonConfigurable):
+ pass
+
+ class Bam(Bar):
+ pass
+
self.assertEqual(Bar.initialized(), False)
self.assertEqual(Bam.initialized(), False)
bam = Bam.instance()
@@ -334,10 +344,13 @@ class TestSingletonConfigurable(TestCase):
class TestLoggingConfigurable(TestCase):
-
def test_parent_logger(self):
- class Parent(LoggingConfigurable): pass
- class Child(LoggingConfigurable): pass
+ class Parent(LoggingConfigurable):
+ pass
+
+ class Child(LoggingConfigurable):
+ pass
+
log = get_logger().getChild("TestLoggingConfigurable")
parent = Parent(log=log)
@@ -351,8 +364,12 @@ class TestLoggingConfigurable(TestCase):
self.assertEqual(child.log, log)
def test_parent_not_logging_configurable(self):
- class Parent(Configurable): pass
- class Child(LoggingConfigurable): pass
+ class Parent(Configurable):
+ pass
+
+ class Child(LoggingConfigurable):
+ pass
+
parent = Parent()
child = Child(parent=parent)
self.assertEqual(child.log, get_logger())
@@ -361,175 +378,191 @@ class TestLoggingConfigurable(TestCase):
class MyParent(Configurable):
pass
+
class MyParent2(MyParent):
pass
-class TestParentConfigurable(TestCase):
+class TestParentConfigurable(TestCase):
def test_parent_config(self):
- cfg = Config({
- 'MyParent' : {
- 'MyConfigurable' : {
- 'b' : 2.0,
+ cfg = Config(
+ {
+ "MyParent": {
+ "MyConfigurable": {
+ "b": 2.0,
+ }
}
}
- })
+ )
parent = MyParent(config=cfg)
myc = MyConfigurable(parent=parent)
self.assertEqual(myc.b, parent.config.MyParent.MyConfigurable.b)
def test_parent_inheritance(self):
- cfg = Config({
- 'MyParent' : {
- 'MyConfigurable' : {
- 'b' : 2.0,
+ cfg = Config(
+ {
+ "MyParent": {
+ "MyConfigurable": {
+ "b": 2.0,
+ }
}
}
- })
+ )
parent = MyParent2(config=cfg)
myc = MyConfigurable(parent=parent)
self.assertEqual(myc.b, parent.config.MyParent.MyConfigurable.b)
def test_multi_parent(self):
- cfg = Config({
- 'MyParent2' : {
- 'MyParent' : {
- 'MyConfigurable' : {
- 'b' : 2.0,
- }
- },
- # this one shouldn't count
- 'MyConfigurable' : {
- 'b' : 3.0,
- },
+ cfg = Config(
+ {
+ "MyParent2": {
+ "MyParent": {
+ "MyConfigurable": {
+ "b": 2.0,
+ }
+ },
+ # this one shouldn't count
+ "MyConfigurable": {
+ "b": 3.0,
+ },
+ }
}
- })
+ )
parent2 = MyParent2(config=cfg)
parent = MyParent(parent=parent2)
myc = MyConfigurable(parent=parent)
self.assertEqual(myc.b, parent.config.MyParent2.MyParent.MyConfigurable.b)
def test_parent_priority(self):
- cfg = Config({
- 'MyConfigurable' : {
- 'b' : 2.0,
- },
- 'MyParent' : {
- 'MyConfigurable' : {
- 'b' : 3.0,
- }
- },
- 'MyParent2' : {
- 'MyConfigurable' : {
- 'b' : 4.0,
- }
+ cfg = Config(
+ {
+ "MyConfigurable": {
+ "b": 2.0,
+ },
+ "MyParent": {
+ "MyConfigurable": {
+ "b": 3.0,
+ }
+ },
+ "MyParent2": {
+ "MyConfigurable": {
+ "b": 4.0,
+ }
+ },
}
- })
+ )
parent = MyParent2(config=cfg)
myc = MyConfigurable(parent=parent)
self.assertEqual(myc.b, parent.config.MyParent2.MyConfigurable.b)
def test_multi_parent_priority(self):
- cfg = Config({
- 'MyConfigurable': {
- 'b': 2.0,
- },
- 'MyParent': {
- 'MyConfigurable': {
- 'b': 3.0,
+ cfg = Config(
+ {
+ "MyConfigurable": {
+ "b": 2.0,
},
- },
- 'MyParent2': {
- 'MyConfigurable': {
- 'b': 4.0,
+ "MyParent": {
+ "MyConfigurable": {
+ "b": 3.0,
+ },
},
- 'MyParent': {
- 'MyConfigurable': {
- 'b': 5.0,
+ "MyParent2": {
+ "MyConfigurable": {
+ "b": 4.0,
+ },
+ "MyParent": {
+ "MyConfigurable": {
+ "b": 5.0,
+ },
},
},
- },
- })
+ }
+ )
parent2 = MyParent2(config=cfg)
parent = MyParent2(parent=parent2)
myc = MyConfigurable(parent=parent)
self.assertEqual(myc.b, parent.config.MyParent2.MyParent.MyConfigurable.b)
+
class Containers(Configurable):
lis = List().tag(config=True)
+
def _lis_default(self):
return [-1]
s = Set().tag(config=True)
+
def _s_default(self):
- return {'a'}
+ return {"a"}
d = Dict().tag(config=True)
+
def _d_default(self):
- return {'a' : 'b'}
+ return {"a": "b"}
+
class TestConfigContainers(TestCase):
def test_extend(self):
c = Config()
c.Containers.lis.extend(list(range(5)))
obj = Containers(config=c)
- self.assertEqual(obj.lis, list(range(-1,5)))
+ self.assertEqual(obj.lis, list(range(-1, 5)))
def test_insert(self):
c = Config()
- c.Containers.lis.insert(0, 'a')
- c.Containers.lis.insert(1, 'b')
+ c.Containers.lis.insert(0, "a")
+ c.Containers.lis.insert(1, "b")
obj = Containers(config=c)
- self.assertEqual(obj.lis, ['a', 'b', -1])
+ self.assertEqual(obj.lis, ["a", "b", -1])
def test_prepend(self):
c = Config()
- c.Containers.lis.prepend([1,2])
- c.Containers.lis.prepend([2,3])
+ c.Containers.lis.prepend([1, 2])
+ c.Containers.lis.prepend([2, 3])
obj = Containers(config=c)
- self.assertEqual(obj.lis, [2,3,1,2,-1])
+ self.assertEqual(obj.lis, [2, 3, 1, 2, -1])
def test_prepend_extend(self):
c = Config()
- c.Containers.lis.prepend([1,2])
- c.Containers.lis.extend([2,3])
+ c.Containers.lis.prepend([1, 2])
+ c.Containers.lis.extend([2, 3])
obj = Containers(config=c)
- self.assertEqual(obj.lis, [1,2,-1,2,3])
+ self.assertEqual(obj.lis, [1, 2, -1, 2, 3])
def test_append_extend(self):
c = Config()
- c.Containers.lis.append([1,2])
- c.Containers.lis.extend([2,3])
+ c.Containers.lis.append([1, 2])
+ c.Containers.lis.extend([2, 3])
obj = Containers(config=c)
- self.assertEqual(obj.lis, [-1,[1,2],2,3])
+ self.assertEqual(obj.lis, [-1, [1, 2], 2, 3])
def test_extend_append(self):
c = Config()
- c.Containers.lis.extend([2,3])
- c.Containers.lis.append([1,2])
+ c.Containers.lis.extend([2, 3])
+ c.Containers.lis.append([1, 2])
obj = Containers(config=c)
- self.assertEqual(obj.lis, [-1,2,3,[1,2]])
+ self.assertEqual(obj.lis, [-1, 2, 3, [1, 2]])
def test_insert_extend(self):
c = Config()
c.Containers.lis.insert(0, 1)
- c.Containers.lis.extend([2,3])
+ c.Containers.lis.extend([2, 3])
obj = Containers(config=c)
- self.assertEqual(obj.lis, [1,-1,2,3])
+ self.assertEqual(obj.lis, [1, -1, 2, 3])
def test_set_update(self):
c = Config()
- c.Containers.s.update({0,1,2})
+ c.Containers.s.update({0, 1, 2})
c.Containers.s.update({3})
obj = Containers(config=c)
- self.assertEqual(obj.s, {'a', 0, 1, 2, 3})
+ self.assertEqual(obj.s, {"a", 0, 1, 2, 3})
def test_dict_update(self):
c = Config()
- c.Containers.d.update({'c' : 'd'})
- c.Containers.d.update({'e' : 'f'})
+ c.Containers.d.update({"c": "d"})
+ c.Containers.d.update({"e": "f"})
obj = Containers(config=c)
- self.assertEqual(obj.d, {'a':'b', 'c':'d', 'e':'f'})
+ self.assertEqual(obj.d, {"a": "b", "c": "d", "e": "f"})
def test_update_twice(self):
c = Config()
@@ -562,6 +595,7 @@ class TestConfigContainers(TestCase):
class DefaultConfigurable(Configurable):
a = Integer().tag(config=True)
+
def _config_default(self):
if SomeSingleton.initialized():
return SomeSingleton.instance().config
@@ -581,14 +615,17 @@ class TestConfigContainers(TestCase):
def test_config_default_deprecated(self):
"""Make sure configurables work even with the deprecations in traitlets"""
+
class SomeSingleton(SingletonConfigurable):
pass
# reset deprecation limiter
_deprecations_shown.clear()
with expected_warnings([]):
+
class DefaultConfigurable(Configurable):
a = Integer(config=True)
+
def _config_default(self):
if SomeSingleton.initialized():
return SomeSingleton.instance().config
@@ -613,68 +650,67 @@ class TestConfigContainers(TestCase):
# - kwargs are set before config
# - kwargs have priority over config
class A(Configurable):
- a = Unicode('default', config=True)
- b = Unicode('default', config=True)
- c = Unicode('default', config=True)
- c_during_config = Unicode('never')
- @validate('b')
+ a = Unicode("default", config=True)
+ b = Unicode("default", config=True)
+ c = Unicode("default", config=True)
+ c_during_config = Unicode("never")
+
+ @validate("b")
def _record_c(self, proposal):
# setting b from config records c's value at the time
self.c_during_config = self.c
return proposal.value
cfg = Config()
- cfg.A.a = 'a-config'
- cfg.A.b = 'b-config'
- obj = A(a='a-kwarg', c='c-kwarg', config=cfg)
- assert obj.a == 'a-kwarg'
- assert obj.b == 'b-config'
- assert obj.c == 'c-kwarg'
- assert obj.c_during_config == 'c-kwarg'
+ cfg.A.a = "a-config"
+ cfg.A.b = "b-config"
+ obj = A(a="a-kwarg", c="c-kwarg", config=cfg)
+ assert obj.a == "a-kwarg"
+ assert obj.b == "b-config"
+ assert obj.c == "c-kwarg"
+ assert obj.c_during_config == "c-kwarg"
class TestLogger(TestCase):
-
class A(LoggingConfigurable):
- foo = Integer(config=True)
- bar = Integer(config=True)
- baz = Integer(config=True)
+ foo = Integer(config=True)
+ bar = Integer(config=True)
+ baz = Integer(config=True)
- @mark.skipif(not hasattr(TestCase, 'assertLogs'), reason='requires TestCase.assertLogs')
+ @mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs")
def test_warn_match(self):
- logger = logging.getLogger('test_warn_match')
- cfg = Config({'A': {'bat': 5}})
+ logger = logging.getLogger("test_warn_match")
+ cfg = Config({"A": {"bat": 5}})
with self.assertLogs(logger, logging.WARNING) as captured:
TestLogger.A(config=cfg, log=logger)
- output = '\n'.join(captured.output)
- self.assertIn('Did you mean one of: `bar, baz`?', output)
- self.assertIn('Config option `bat` not recognized by `A`.', output)
+ output = "\n".join(captured.output)
+ self.assertIn("Did you mean one of: `bar, baz`?", output)
+ self.assertIn("Config option `bat` not recognized by `A`.", output)
- cfg = Config({'A': {'fool': 5}})
+ cfg = Config({"A": {"fool": 5}})
with self.assertLogs(logger, logging.WARNING) as captured:
TestLogger.A(config=cfg, log=logger)
- output = '\n'.join(captured.output)
- self.assertIn('Config option `fool` not recognized by `A`.', output)
- self.assertIn('Did you mean `foo`?', output)
+ output = "\n".join(captured.output)
+ self.assertIn("Config option `fool` not recognized by `A`.", output)
+ self.assertIn("Did you mean `foo`?", output)
- cfg = Config({'A': {'totally_wrong': 5}})
+ cfg = Config({"A": {"totally_wrong": 5}})
with self.assertLogs(logger, logging.WARNING) as captured:
TestLogger.A(config=cfg, log=logger)
- output = '\n'.join(captured.output)
- self.assertIn('Config option `totally_wrong` not recognized by `A`.', output)
- self.assertNotIn('Did you mean', output)
+ output = "\n".join(captured.output)
+ self.assertIn("Config option `totally_wrong` not recognized by `A`.", output)
+ self.assertNotIn("Did you mean", output)
- def test_logger_adapter(self):
- logger = logging.getLogger("test_logger_adapter")
- adapter = logging.LoggerAdapter(logger, {"key": "adapted"})
- with self.assertLogs(logger, logging.INFO) as captured:
- app = Application(log=adapter, log_level=logging.INFO)
- app.log_format = "%(key)s %(message)s"
- app.log.info("test message")
+def test_logger_adapter(caplog, capsys):
+ logger = logging.getLogger("Application")
+ adapter = logging.LoggerAdapter(logger, {"key": "adapted"})
- output = "\n".join(captured.output)
- assert "adapted test message" in output
+ app = Application(log=adapter, log_level=logging.INFO)
+ app.log_format = "%(key)s %(message)s"
+ app.log.info("test message")
+
+ assert "adapted test message" in capsys.readouterr().err
diff --git a/contrib/python/traitlets/py3/traitlets/config/tests/test_loader.py b/contrib/python/traitlets/py3/traitlets/config/tests/test_loader.py
index 103eeeff6d..c26e699106 100644
--- a/contrib/python/traitlets/py3/traitlets/config/tests/test_loader.py
+++ b/contrib/python/traitlets/py3/traitlets/config/tests/test_loader.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
"""Tests for traitlets.config.loader"""
# Copyright (c) IPython Development Team.
@@ -13,24 +12,17 @@ from unittest import TestCase
import pytest
+from traitlets import Dict, Integer, List, Tuple, Unicode
+from traitlets.config import Configurable
from traitlets.config.loader import (
+ ArgParseConfigLoader,
Config,
- LazyConfigValue,
- PyFileConfigLoader,
JSONFileConfigLoader,
KeyValueConfigLoader,
- ArgParseConfigLoader,
KVArgParseConfigLoader,
+ LazyConfigValue,
+ PyFileConfigLoader,
)
-from traitlets import (
- List,
- Tuple,
- Dict,
- Unicode,
- Integer,
-)
-from traitlets.config import Configurable
-
pyfile = """
c = get_config()
@@ -70,7 +62,8 @@ json2file = """
"""
import logging
-log = logging.getLogger('devnull')
+
+log = logging.getLogger("devnull")
log.setLevel(0)
@@ -80,11 +73,11 @@ class TestFileCL(TestCase):
self.assertEqual(config.b, 20)
self.assertEqual(config.Foo.Bar.value, 10)
self.assertEqual(config.Foo.Bam.value, list(range(10)))
- self.assertEqual(config.D.C.value, 'hi there')
+ self.assertEqual(config.D.C.value, "hi there")
def test_python(self):
- fd, fname = mkstemp('.py', prefix='μnïcø∂e')
- f = os.fdopen(fd, 'w')
+ fd, fname = mkstemp(".py", prefix="μnïcø∂e")
+ f = os.fdopen(fd, "w")
f.write(pyfile)
f.close()
# Unlink the file
@@ -93,8 +86,8 @@ class TestFileCL(TestCase):
self._check_conf(config)
def test_json(self):
- fd, fname = mkstemp('.json', prefix='μnïcø∂e')
- f = os.fdopen(fd, 'w')
+ fd, fname = mkstemp(".json", prefix="μnïcø∂e")
+ f = os.fdopen(fd, "w")
f.write(json1file)
f.close()
# Unlink the file
@@ -104,14 +97,14 @@ class TestFileCL(TestCase):
def test_context_manager(self):
- fd, fname = mkstemp('.json', prefix='μnïcø∂e')
- f = os.fdopen(fd, 'w')
- f.write('{}')
+ fd, fname = mkstemp(".json", prefix="μnïcø∂e")
+ f = os.fdopen(fd, "w")
+ f.write("{}")
f.close()
cl = JSONFileConfigLoader(fname, log=log)
- value = 'context_manager'
+ value = "context_manager"
with cl as c:
c.MyAttr.value = value
@@ -119,13 +112,13 @@ class TestFileCL(TestCase):
self.assertEqual(cl.config.MyAttr.value, value)
# check that another loader does see the change
- cl2 = JSONFileConfigLoader(fname, log=log)
+ _ = JSONFileConfigLoader(fname, log=log)
self.assertEqual(cl.config.MyAttr.value, value)
def test_json_context_bad_write(self):
- fd, fname = mkstemp('.json', prefix='μnïcø∂e')
- f = os.fdopen(fd, 'w')
- f.write('{}')
+ fd, fname = mkstemp(".json", prefix="μnïcø∂e")
+ f = os.fdopen(fd, "w")
+ f.write("{}")
f.close()
with JSONFileConfigLoader(fname, log=log) as config:
@@ -138,7 +131,7 @@ class TestFileCL(TestCase):
loader = JSONFileConfigLoader(fname, log=log)
cfg = loader.load_config()
assert cfg.A.b == 1
- assert 'cant_json' not in cfg.A
+ assert "cant_json" not in cfg.A
def test_collision(self):
a = Config()
@@ -150,27 +143,36 @@ class TestFileCL(TestCase):
b.A.trait1 = 1
self.assertEqual(a.collisions(b), {})
b.A.trait1 = 0
- self.assertEqual(a.collisions(b), {
- 'A': {
- 'trait1': "1 ignored, using 0",
- }
- })
- self.assertEqual(b.collisions(a), {
- 'A': {
- 'trait1': "0 ignored, using 1",
- }
- })
+ self.assertEqual(
+ a.collisions(b),
+ {
+ "A": {
+ "trait1": "1 ignored, using 0",
+ }
+ },
+ )
+ self.assertEqual(
+ b.collisions(a),
+ {
+ "A": {
+ "trait1": "0 ignored, using 1",
+ }
+ },
+ )
a.A.trait2 = 3
- self.assertEqual(b.collisions(a), {
- 'A': {
- 'trait1': "0 ignored, using 1",
- 'trait2': "2 ignored, using 3",
- }
- })
+ self.assertEqual(
+ b.collisions(a),
+ {
+ "A": {
+ "trait1": "0 ignored, using 1",
+ "trait2": "2 ignored, using 3",
+ }
+ },
+ )
def test_v2raise(self):
- fd, fname = mkstemp('.json', prefix='μnïcø∂e')
- f = os.fdopen(fd, 'w')
+ fd, fname = mkstemp(".json", prefix="μnïcø∂e")
+ f = os.fdopen(fd, "w")
f.write(json2file)
f.close()
# Unlink the file
@@ -182,67 +184,66 @@ class TestFileCL(TestCase):
def _parse_int_or_str(v):
try:
return int(v)
- except:
+ except Exception:
return str(v)
class MyLoader1(ArgParseConfigLoader):
def _add_arguments(self, aliases=None, flags=None, classes=None):
p = self.parser
- p.add_argument('-f', '--foo', dest='Global.foo', type=str)
- p.add_argument('-b', dest='MyClass.bar', type=int)
- p.add_argument('-n', dest='n', action='store_true')
- p.add_argument('Global.bam', type=str)
- p.add_argument('--list1', action='append', type=_parse_int_or_str)
- p.add_argument('--list2', nargs='+', type=int)
+ p.add_argument("-f", "--foo", dest="Global.foo", type=str)
+ p.add_argument("-b", dest="MyClass.bar", type=int)
+ p.add_argument("-n", dest="n", action="store_true")
+ p.add_argument("Global.bam", type=str)
+ p.add_argument("--list1", action="append", type=_parse_int_or_str)
+ p.add_argument("--list2", nargs="+", type=int)
class MyLoader2(ArgParseConfigLoader):
def _add_arguments(self, aliases=None, flags=None, classes=None):
- subparsers = self.parser.add_subparsers(dest='subparser_name')
- subparser1 = subparsers.add_parser('1')
- subparser1.add_argument('-x', dest='Global.x')
- subparser2 = subparsers.add_parser('2')
- subparser2.add_argument('y')
+ subparsers = self.parser.add_subparsers(dest="subparser_name")
+ subparser1 = subparsers.add_parser("1")
+ subparser1.add_argument("-x", dest="Global.x")
+ subparser2 = subparsers.add_parser("2")
+ subparser2.add_argument("y")
class TestArgParseCL(TestCase):
-
def test_basic(self):
cl = MyLoader1()
- config = cl.load_config('-f hi -b 10 -n wow'.split())
- self.assertEqual(config.Global.foo, 'hi')
+ config = cl.load_config("-f hi -b 10 -n wow".split())
+ self.assertEqual(config.Global.foo, "hi")
self.assertEqual(config.MyClass.bar, 10)
self.assertEqual(config.n, True)
- self.assertEqual(config.Global.bam, 'wow')
- config = cl.load_config(['wow'])
- self.assertEqual(list(config.keys()), ['Global'])
- self.assertEqual(list(config.Global.keys()), ['bam'])
- self.assertEqual(config.Global.bam, 'wow')
+ self.assertEqual(config.Global.bam, "wow")
+ config = cl.load_config(["wow"])
+ self.assertEqual(list(config.keys()), ["Global"])
+ self.assertEqual(list(config.Global.keys()), ["bam"])
+ self.assertEqual(config.Global.bam, "wow")
def test_add_arguments(self):
cl = MyLoader2()
- config = cl.load_config('2 frobble'.split())
- self.assertEqual(config.subparser_name, '2')
- self.assertEqual(config.y, 'frobble')
- config = cl.load_config('1 -x frobble'.split())
- self.assertEqual(config.subparser_name, '1')
- self.assertEqual(config.Global.x, 'frobble')
+ config = cl.load_config("2 frobble".split())
+ self.assertEqual(config.subparser_name, "2")
+ self.assertEqual(config.y, "frobble")
+ config = cl.load_config("1 -x frobble".split())
+ self.assertEqual(config.subparser_name, "1")
+ self.assertEqual(config.Global.x, "frobble")
def test_argv(self):
- cl = MyLoader1(argv='-f hi -b 10 -n wow'.split())
+ cl = MyLoader1(argv="-f hi -b 10 -n wow".split())
config = cl.load_config()
- self.assertEqual(config.Global.foo, 'hi')
+ self.assertEqual(config.Global.foo, "hi")
self.assertEqual(config.MyClass.bar, 10)
self.assertEqual(config.n, True)
- self.assertEqual(config.Global.bam, 'wow')
+ self.assertEqual(config.Global.bam, "wow")
def test_list_args(self):
cl = MyLoader1()
- config = cl.load_config('--list1 1 wow --list2 1 2 3 --list1 B'.split())
- self.assertEqual(list(config.Global.keys()), ['bam'])
- self.assertEqual(config.Global.bam, 'wow')
- self.assertEqual(config.list1, [1, 'B'])
+ config = cl.load_config("--list1 1 wow --list2 1 2 3 --list1 B".split())
+ self.assertEqual(list(config.Global.keys()), ["bam"])
+ self.assertEqual(config.Global.bam, "wow")
+ self.assertEqual(config.list1, [1, "B"])
self.assertEqual(config.list2, [1, 2, 3])
@@ -272,52 +273,54 @@ class TestKeyValueCL(TestCase):
def test_eval(self):
cl = self.klass(log=log)
- config = cl.load_config('--C.str_trait=all --C.int_trait=5 --C.list_trait=["hello",5]'.split())
+ config = cl.load_config(
+ '--C.str_trait=all --C.int_trait=5 --C.list_trait=["hello",5]'.split()
+ )
c = C(config=config)
- assert c.str_trait == 'all'
+ assert c.str_trait == "all"
assert c.int_trait == 5
assert c.list_trait == ["hello", 5]
def test_basic(self):
cl = self.klass(log=log)
- argv = [ '--' + s[2:] for s in pyfile.split('\n') if s.startswith('c.') ]
+ argv = ["--" + s[2:] for s in pyfile.split("\n") if s.startswith("c.")]
config = cl.load_config(argv)
- assert config.a == '10'
- assert config.b == '20'
- assert config.Foo.Bar.value == '10'
+ assert config.a == "10"
+ assert config.b == "20"
+ assert config.Foo.Bar.value == "10"
# non-literal expressions are not evaluated
- self.assertEqual(config.Foo.Bam.value, 'list(range(10))')
- self.assertEqual(Unicode().from_string(config.D.C.value), 'hi there')
+ self.assertEqual(config.Foo.Bam.value, "list(range(10))")
+ self.assertEqual(Unicode().from_string(config.D.C.value), "hi there")
def test_expanduser(self):
cl = self.klass(log=log)
- argv = ['--a=~/1/2/3', '--b=~', '--c=~/', '--d="~/"']
+ argv = ["--a=~/1/2/3", "--b=~", "--c=~/", '--d="~/"']
config = cl.load_config(argv)
u = Unicode()
- self.assertEqual(u.from_string(config.a), os.path.expanduser('~/1/2/3'))
- self.assertEqual(u.from_string(config.b), os.path.expanduser('~'))
- self.assertEqual(u.from_string(config.c), os.path.expanduser('~/'))
- self.assertEqual(u.from_string(config.d), '~/')
+ self.assertEqual(u.from_string(config.a), os.path.expanduser("~/1/2/3"))
+ self.assertEqual(u.from_string(config.b), os.path.expanduser("~"))
+ self.assertEqual(u.from_string(config.c), os.path.expanduser("~/"))
+ self.assertEqual(u.from_string(config.d), "~/")
def test_extra_args(self):
cl = self.klass(log=log)
- config = cl.load_config(['--a=5', 'b', 'd', '--c=10'])
- self.assertEqual(cl.extra_args, ['b', 'd'])
- assert config.a == '5'
- assert config.c == '10'
- config = cl.load_config(['--', '--a=5', '--c=10'])
- self.assertEqual(cl.extra_args, ['--a=5', '--c=10'])
+ config = cl.load_config(["--a=5", "b", "d", "--c=10"])
+ self.assertEqual(cl.extra_args, ["b", "d"])
+ assert config.a == "5"
+ assert config.c == "10"
+ config = cl.load_config(["--", "--a=5", "--c=10"])
+ self.assertEqual(cl.extra_args, ["--a=5", "--c=10"])
cl = self.klass(log=log)
- config = cl.load_config(['extra', '--a=2', '--c=1', '--', '-'])
- self.assertEqual(cl.extra_args, ['extra', '-'])
+ config = cl.load_config(["extra", "--a=2", "--c=1", "--", "-"])
+ self.assertEqual(cl.extra_args, ["extra", "-"])
def test_unicode_args(self):
cl = self.klass(log=log)
- argv = ['--a=épsîlön']
+ argv = ["--a=épsîlön"]
config = cl.load_config(argv)
print(config, cl.extra_args)
- self.assertEqual(config.a, 'épsîlön')
+ self.assertEqual(config.a, "épsîlön")
def test_list_append(self):
cl = self.klass(log=log)
@@ -351,15 +354,15 @@ class TestKeyValueCL(TestCase):
class CBase(Configurable):
a = List().tag(config=True)
- b = List(Integer()).tag(config=True, multiplicity='*')
- c = List().tag(config=True, multiplicity='append')
+ b = List(Integer()).tag(config=True, multiplicity="*")
+ c = List().tag(config=True, multiplicity="append")
adict = Dict().tag(config=True)
class CSub(CBase):
d = Tuple().tag(config=True)
- e = Tuple().tag(config=True, multiplicity='+')
- bdict = Dict().tag(config=True, multiplicity='*')
+ e = Tuple().tag(config=True, multiplicity="+")
+ bdict = Dict().tag(config=True, multiplicity="*")
class TestArgParseKVCL(TestKeyValueCL):
@@ -381,61 +384,63 @@ class TestArgParseKVCL(TestKeyValueCL):
def test_unicode_alias(self):
cl = self.klass(log=log)
- argv = ['--a=épsîlön']
- config = cl.load_config(argv, aliases=dict(a='A.a'))
+ argv = ["--a=épsîlön"]
+ config = cl.load_config(argv, aliases=dict(a="A.a"))
print(dict(config))
print(cl.extra_args)
print(cl.aliases)
- self.assertEqual(config.A.a, 'épsîlön')
+ self.assertEqual(config.A.a, "épsîlön")
def test_expanduser2(self):
cl = self.klass(log=log)
- argv = ['-a', '~/1/2/3', '--b', "'~/1/2/3'"]
- config = cl.load_config(argv, aliases=dict(a='A.a', b='A.b'))
+ argv = ["-a", "~/1/2/3", "--b", "'~/1/2/3'"]
+ config = cl.load_config(argv, aliases=dict(a="A.a", b="A.b"))
class A(Configurable):
a = Unicode(config=True)
b = Unicode(config=True)
a = A(config=config)
- self.assertEqual(a.a, os.path.expanduser('~/1/2/3'))
- self.assertEqual(a.b, '~/1/2/3')
+ self.assertEqual(a.a, os.path.expanduser("~/1/2/3"))
+ self.assertEqual(a.b, "~/1/2/3")
def test_eval(self):
cl = self.klass(log=log)
- argv = ['-c', 'a=5']
- config = cl.load_config(argv, aliases=dict(c='A.c'))
+ argv = ["-c", "a=5"]
+ config = cl.load_config(argv, aliases=dict(c="A.c"))
self.assertEqual(config.A.c, "a=5")
def test_seq_traits(self):
cl = self.klass(log=log, classes=(CBase, CSub))
- aliases = {'a3': 'CBase.c', 'a5': 'CSub.e'}
- argv = ("--CBase.a A --CBase.a 2 --CBase.b 1 --CBase.b 3 --a3 AA --CBase.c BB "
- "--CSub.d 1 --CSub.d BBB --CSub.e 1 --CSub.e=bcd a b c ").split()
+ aliases = {"a3": "CBase.c", "a5": "CSub.e"}
+ argv = (
+ "--CBase.a A --CBase.a 2 --CBase.b 1 --CBase.b 3 --a3 AA --CBase.c BB "
+ "--CSub.d 1 --CSub.d BBB --CSub.e 1 --CSub.e=bcd a b c "
+ ).split()
config = cl.load_config(argv, aliases=aliases)
assert cl.extra_args == ["a", "b", "c"]
- assert config.CBase.a == ['A', '2']
+ assert config.CBase.a == ["A", "2"]
assert config.CBase.b == [1, 3]
- self.assertEqual(config.CBase.c, ['AA', 'BB'])
+ self.assertEqual(config.CBase.c, ["AA", "BB"])
- assert config.CSub.d == ('1', 'BBB')
- assert config.CSub.e == ('1', 'bcd')
+ assert config.CSub.d == ("1", "BBB")
+ assert config.CSub.e == ("1", "bcd")
def test_seq_traits_single_empty_string(self):
- cl = self.klass(log=log, classes=(CBase, ))
- aliases = {'seqopt': 'CBase.c'}
- argv = ['--seqopt', '']
+ cl = self.klass(log=log, classes=(CBase,))
+ aliases = {"seqopt": "CBase.c"}
+ argv = ["--seqopt", ""]
config = cl.load_config(argv, aliases=aliases)
- self.assertEqual(config.CBase.c, [''])
+ self.assertEqual(config.CBase.c, [""])
def test_dict_traits(self):
cl = self.klass(log=log, classes=(CBase, CSub))
- aliases = {'D': 'CBase.adict', 'E': 'CSub.bdict'}
+ aliases = {"D": "CBase.adict", "E": "CSub.bdict"}
argv = ["-D", "k1=v1", "-D=k2=2", "-D", "k3=v 3", "-E", "k=v", "-E", "22=222"]
config = cl.load_config(argv, aliases=aliases)
c = CSub(config=config)
- assert c.adict == {'k1': 'v1', 'k2': '2', 'k3': 'v 3'}
- assert c.bdict == {'k': 'v', '22': '222'}
+ assert c.adict == {"k1": "v1", "k2": "2", "k3": "v 3"}
+ assert c.bdict == {"k": "v", "22": "222"}
def test_mixed_seq_positional(self):
aliases = {"c": "Class.trait"}
@@ -461,22 +466,21 @@ class TestArgParseKVCL(TestKeyValueCL):
class TestConfig(TestCase):
-
def test_setget(self):
c = Config()
c.a = 10
self.assertEqual(c.a, 10)
- self.assertEqual('b' in c, False)
+ self.assertEqual("b" in c, False)
def test_auto_section(self):
c = Config()
- self.assertNotIn('A', c)
- assert not c._has_section('A')
+ self.assertNotIn("A", c)
+ assert not c._has_section("A")
A = c.A
- A.foo = 'hi there'
- self.assertIn('A', c)
- assert c._has_section('A')
- self.assertEqual(c.A.foo, 'hi there')
+ A.foo = "hi there"
+ self.assertIn("A", c)
+ assert c._has_section("A")
+ self.assertEqual(c.A.foo, "hi there")
del c.A
self.assertEqual(c.A, Config())
@@ -511,10 +515,10 @@ class TestConfig(TestCase):
c1 = Config()
c1.Foo.bar = 10
c1.Foo.bam = 30
- c1.a = 'asdf'
+ c1.a = "asdf"
c1.b = range(10)
- c1.Test.logger = logging.Logger('test')
- c1.Test.get_logger = logging.getLogger('test')
+ c1.Test.logger = logging.Logger("test")
+ c1.Test.get_logger = logging.getLogger("test")
c2 = copy.deepcopy(c1)
self.assertEqual(c1, c2)
self.assertTrue(c1 is not c2)
@@ -528,33 +532,33 @@ class TestConfig(TestCase):
c1.format = "json"
def test_fromdict(self):
- c1 = Config({'Foo' : {'bar' : 1}})
+ c1 = Config({"Foo": {"bar": 1}})
self.assertEqual(c1.Foo.__class__, Config)
self.assertEqual(c1.Foo.bar, 1)
def test_fromdictmerge(self):
c1 = Config()
- c2 = Config({'Foo' : {'bar' : 1}})
+ c2 = Config({"Foo": {"bar": 1}})
c1.merge(c2)
self.assertEqual(c1.Foo.__class__, Config)
self.assertEqual(c1.Foo.bar, 1)
def test_fromdictmerge2(self):
- c1 = Config({'Foo' : {'baz' : 2}})
- c2 = Config({'Foo' : {'bar' : 1}})
+ c1 = Config({"Foo": {"baz": 2}})
+ c2 = Config({"Foo": {"bar": 1}})
c1.merge(c2)
self.assertEqual(c1.Foo.__class__, Config)
self.assertEqual(c1.Foo.bar, 1)
self.assertEqual(c1.Foo.baz, 2)
- self.assertNotIn('baz', c2.Foo)
+ self.assertNotIn("baz", c2.Foo)
def test_contains(self):
- c1 = Config({'Foo' : {'baz' : 2}})
- c2 = Config({'Foo' : {'bar' : 1}})
- self.assertIn('Foo', c1)
- self.assertIn('Foo.baz', c1)
- self.assertIn('Foo.bar', c2)
- self.assertNotIn('Foo.bar', c1)
+ c1 = Config({"Foo": {"baz": 2}})
+ c2 = Config({"Foo": {"bar": 1}})
+ self.assertIn("Foo", c1)
+ self.assertIn("Foo.baz", c1)
+ self.assertIn("Foo.bar", c2)
+ self.assertNotIn("Foo.bar", c1)
def test_pickle_config(self):
cfg = Config()
@@ -565,53 +569,52 @@ class TestConfig(TestCase):
def test_getattr_section(self):
cfg = Config()
- self.assertNotIn('Foo', cfg)
+ self.assertNotIn("Foo", cfg)
Foo = cfg.Foo
assert isinstance(Foo, Config)
- self.assertIn('Foo', cfg)
+ self.assertIn("Foo", cfg)
def test_getitem_section(self):
cfg = Config()
- self.assertNotIn('Foo', cfg)
- Foo = cfg['Foo']
+ self.assertNotIn("Foo", cfg)
+ Foo = cfg["Foo"]
assert isinstance(Foo, Config)
- self.assertIn('Foo', cfg)
+ self.assertIn("Foo", cfg)
def test_getattr_not_section(self):
cfg = Config()
- self.assertNotIn('foo', cfg)
+ self.assertNotIn("foo", cfg)
foo = cfg.foo
assert isinstance(foo, LazyConfigValue)
- self.assertIn('foo', cfg)
+ self.assertIn("foo", cfg)
def test_getattr_private_missing(self):
cfg = Config()
- self.assertNotIn('_repr_html_', cfg)
+ self.assertNotIn("_repr_html_", cfg)
with self.assertRaises(AttributeError):
_ = cfg._repr_html_
- self.assertNotIn('_repr_html_', cfg)
+ self.assertNotIn("_repr_html_", cfg)
self.assertEqual(len(cfg), 0)
def test_lazy_config_repr(self):
cfg = Config()
cfg.Class.lazy.append(1)
cfg_repr = repr(cfg)
- assert '<LazyConfigValue' in cfg_repr
+ assert "<LazyConfigValue" in cfg_repr
assert "extend" in cfg_repr
assert " [1]}>" in cfg_repr
- assert 'value=' not in cfg_repr
+ assert "value=" not in cfg_repr
cfg.Class.lazy.get_value([0])
repr2 = repr(cfg)
- assert repr([0,1]) in repr2
- assert 'value=' in repr2
-
+ assert repr([0, 1]) in repr2
+ assert "value=" in repr2
def test_getitem_not_section(self):
cfg = Config()
- self.assertNotIn('foo', cfg)
- foo = cfg['foo']
+ self.assertNotIn("foo", cfg)
+ foo = cfg["foo"]
assert isinstance(foo, LazyConfigValue)
- self.assertIn('foo', cfg)
+ self.assertIn("foo", cfg)
def test_merge_no_copies(self):
c = Config()
@@ -623,7 +626,6 @@ class TestConfig(TestCase):
self.assertEqual(c.Foo.trait, [1])
self.assertEqual(c2.Foo.trait, [1])
-
def test_merge_multi_lazy(self):
"""
With multiple config files (systemwide and users), we want compounding.
@@ -641,10 +643,8 @@ class TestConfig(TestCase):
c.merge(c1)
c.merge(c2)
- self.assertEqual(c.Foo.trait, [1,2] )
-
+ self.assertEqual(c.Foo.trait, [1, 2])
-
def test_merge_multi_lazyII(self):
"""
With multiple config files (systemwide and users), we want compounding.
@@ -661,7 +661,7 @@ class TestConfig(TestCase):
c.merge(c1)
c.merge(c2)
- self.assertEqual(c.Foo.trait._extend, [1,2] )
+ self.assertEqual(c.Foo.trait._extend, [1, 2])
def test_merge_multi_lazy_III(self):
"""
@@ -679,7 +679,7 @@ class TestConfig(TestCase):
c.merge(c1)
c.merge(c2)
- self.assertEqual(c.Foo.trait, [0, 1] )
+ self.assertEqual(c.Foo.trait, [0, 1])
def test_merge_multi_lazy_IV(self):
"""
diff --git a/contrib/python/traitlets/py3/traitlets/log.py b/contrib/python/traitlets/py3/traitlets/log.py
index af86b325f5..016529fcac 100644
--- a/contrib/python/traitlets/py3/traitlets/log.py
+++ b/contrib/python/traitlets/py3/traitlets/log.py
@@ -7,6 +7,7 @@ import logging
_logger = None
+
def get_logger():
"""Grab the global logger instance.
@@ -17,10 +18,11 @@ def get_logger():
if _logger is None:
from .config import Application
+
if Application.initialized():
_logger = Application.instance().log
else:
- _logger = logging.getLogger('traitlets')
+ _logger = logging.getLogger("traitlets")
# Add a NullHandler to silence warnings about not being
# initialized, per best practice for libraries.
_logger.addHandler(logging.NullHandler())
diff --git a/contrib/python/traitlets/py3/traitlets/py.typed b/contrib/python/traitlets/py3/traitlets/py.typed
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/contrib/python/traitlets/py3/traitlets/py.typed
diff --git a/contrib/python/traitlets/py3/traitlets/tests/_warnings.py b/contrib/python/traitlets/py3/traitlets/tests/_warnings.py
index 05e916806f..e3c3a0ac6d 100644
--- a/contrib/python/traitlets/py3/traitlets/tests/_warnings.py
+++ b/contrib/python/traitlets/py3/traitlets/tests/_warnings.py
@@ -1,7 +1,7 @@
# From scikit-image: https://github.com/scikit-image/scikit-image/blob/c2f8c4ab123ebe5f7b827bc495625a32bb225c10/skimage/_shared/_warnings.py
# Licensed under modified BSD license
-__all__ = ['all_warnings', 'expected_warnings']
+__all__ = ["all_warnings", "expected_warnings"]
import inspect
import os
@@ -21,16 +21,19 @@ def all_warnings():
>>> import warnings
>>> def foo():
... warnings.warn(RuntimeWarning("bar"))
+
We raise the warning once, while the warning filter is set to "once".
Hereafter, the warning is invisible, even with custom filters:
>>> with warnings.catch_warnings():
... warnings.simplefilter('once')
... foo()
+
We can now run ``foo()`` without a warning being raised:
- >>> from numpy.testing import assert_warns
- >>> foo()
+ >>> from numpy.testing import assert_warns # doctest: +SKIP
+ >>> foo() # doctest: +SKIP
+
To catch the warning, we call in the help of ``all_warnings``:
- >>> with all_warnings():
+ >>> with all_warnings(): # doctest: +SKIP
... assert_warns(RuntimeWarning, foo)
"""
@@ -46,17 +49,18 @@ def all_warnings():
frame = inspect.currentframe()
if frame:
for f in inspect.getouterframes(frame):
- f[0].f_locals['__warningregistry__'] = {}
+ f[0].f_locals["__warningregistry__"] = {}
del frame
- for mod_name, mod in list(sys.modules.items()):
+ for _, mod in list(sys.modules.items()):
try:
mod.__warningregistry__.clear()
except AttributeError:
pass
- with warnings.catch_warnings(record=True) as w, \
- mock.patch.dict(os.environ, {'TRAITLETS_ALL_DEPRECATIONS': '1'}):
+ with warnings.catch_warnings(record=True) as w, mock.patch.dict(
+ os.environ, {"TRAITLETS_ALL_DEPRECATIONS": "1"}
+ ):
warnings.simplefilter("always")
yield w
@@ -72,18 +76,18 @@ def expected_warnings(matching):
Examples
--------
- >>> from skimage import data, img_as_ubyte, img_as_float
- >>> with expected_warnings(["precision loss"]):
- ... d = img_as_ubyte(img_as_float(data.coins()))
+ >>> from skimage import data, img_as_ubyte, img_as_float # doctest: +SKIP
+ >>> with expected_warnings(["precision loss"]): # doctest: +SKIP
+ ... d = img_as_ubyte(img_as_float(data.coins())) # doctest: +SKIP
Notes
-----
Uses `all_warnings` to ensure all warnings are raised.
Upon exiting, it checks the recorded warnings for the desired matching
- pattern(s).
+ pattern(s).
Raises a ValueError if any match was not found or an unexpected
- warning was raised.
- Allows for three types of behaviors: "and", "or", and "optional" matches.
+ warning was raised.
+ Allows for three types of behaviors: "and", "or", and "optional" matches.
This is done to accomodate different build enviroments or loop conditions
that may produce different warnings. The behaviors can be combined.
If you pass multiple patterns, you get an orderless "and", where all of the
@@ -95,7 +99,7 @@ def expected_warnings(matching):
# enter context
yield w
# exited user context, check the recorded warnings
- remaining = [m for m in matching if not r'\A\Z' in m.split('|')]
+ remaining = [m for m in matching if r"\A\Z" not in m.split("|")]
for warn in w:
found = False
for match in matching:
@@ -104,7 +108,7 @@ def expected_warnings(matching):
if match in remaining:
remaining.remove(match)
if not found:
- raise ValueError('Unexpected warning: %s' % str(warn.message))
+ raise ValueError("Unexpected warning: %s" % str(warn.message))
if len(remaining) > 0:
- msg = 'No warning raised matching:\n%s' % '\n'.join(remaining)
+ msg = "No warning raised matching:\n%s" % "\n".join(remaining)
raise ValueError(msg)
diff --git a/contrib/python/traitlets/py3/traitlets/tests/test_traitlets.py b/contrib/python/traitlets/py3/traitlets/tests/test_traitlets.py
index e42dbc01d0..4b145afd02 100644
--- a/contrib/python/traitlets/py3/traitlets/tests/test_traitlets.py
+++ b/contrib/python/traitlets/py3/traitlets/tests/test_traitlets.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
"""Tests for traitlets.traitlets."""
# Copyright (c) IPython Development Team.
@@ -13,85 +12,85 @@ from unittest import TestCase
import pytest
-from traitlets.tests._warnings import expected_warnings
from traitlets import (
- HasTraits,
- MetaHasTraits,
- TraitType,
+ All,
Any,
+ BaseDescriptor,
Bool,
+ Bytes,
+ Callable,
CBytes,
- Dict,
- Enum,
- Int,
+ CFloat,
CInt,
- Long,
CLong,
- Integer,
- Float,
- CFloat,
Complex,
- Bytes,
- Unicode,
- TraitError,
- Union,
- Callable,
- All,
- Undefined,
- Set,
- Type,
- This,
+ CRegExp,
+ CUnicode,
+ Dict,
+ DottedObjectName,
+ Enum,
+ Float,
+ ForwardDeclaredInstance,
+ ForwardDeclaredType,
+ HasDescriptors,
+ HasTraits,
Instance,
- TCPAddress,
+ Int,
+ Integer,
List,
+ Long,
+ MetaHasTraits,
+ ObjectName,
Set,
+ TCPAddress,
+ This,
+ TraitError,
+ TraitType,
Tuple,
- ObjectName,
- DottedObjectName,
- CRegExp,
- link,
+ Type,
+ Undefined,
+ Unicode,
+ Union,
+ default,
directional_link,
- ForwardDeclaredType,
- ForwardDeclaredInstance,
- validate,
+ link,
observe,
- default,
observe_compat,
- BaseDescriptor,
- HasDescriptors,
- CUnicode,
+ validate,
)
from traitlets.utils import cast_unicode
+from traitlets.tests._warnings import expected_warnings
+
def change_dict(*ordered_values):
- change_names = ('name', 'old', 'new', 'owner', 'type')
+ change_names = ("name", "old", "new", "owner", "type")
return dict(zip(change_names, ordered_values))
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# Helper classes for testing
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
class HasTraitsStub(HasTraits):
-
def notify_change(self, change):
- self._notify_name = change['name']
- self._notify_old = change['old']
- self._notify_new = change['new']
- self._notify_type = change['type']
+ self._notify_name = change["name"]
+ self._notify_old = change["old"]
+ self._notify_new = change["new"]
+ self._notify_type = change["type"]
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Test classes
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
class TestTraitType(TestCase):
-
def test_get_undefined(self):
class A(HasTraits):
a = TraitType
+
a = A()
assert a.a is Undefined
@@ -102,7 +101,7 @@ class TestTraitType(TestCase):
a = A()
a.a = 10
self.assertEqual(a.a, 10)
- self.assertEqual(a._notify_name, 'a')
+ self.assertEqual(a._notify_name, "a")
self.assertEqual(a._notify_old, Undefined)
self.assertEqual(a._notify_new, 10)
@@ -110,6 +109,7 @@ class TestTraitType(TestCase):
class MyTT(TraitType):
def validate(self, inst, value):
return -1
+
class A(HasTraitsStub):
tt = MyTT
@@ -123,35 +123,43 @@ class TestTraitType(TestCase):
if isinstance(value, int):
return value
self.error(obj, value)
+
class A(HasTraits):
tt = MyIntTT(10)
+
a = A()
self.assertEqual(a.tt, 10)
# Defaults are validated when the HasTraits is instantiated
class B(HasTraits):
- tt = MyIntTT('bad default')
- self.assertRaises(TraitError, getattr, B(), 'tt')
+ tt = MyIntTT("bad default")
+
+ self.assertRaises(TraitError, getattr, B(), "tt")
def test_info(self):
class A(HasTraits):
tt = TraitType
+
a = A()
- self.assertEqual(A.tt.info(), 'any value')
+ self.assertEqual(A.tt.info(), "any value")
def test_error(self):
class A(HasTraits):
tt = TraitType()
+
a = A()
self.assertRaises(TraitError, A.tt.error, a, 10)
def test_deprecated_dynamic_initializer(self):
class A(HasTraits):
x = Int(10)
+
def _x_default(self):
return 11
+
class B(A):
x = Int(20)
+
class C(A):
def _x_default(self):
return 21
@@ -159,36 +167,38 @@ class TestTraitType(TestCase):
a = A()
self.assertEqual(a._trait_values, {})
self.assertEqual(a.x, 11)
- self.assertEqual(a._trait_values, {'x': 11})
+ self.assertEqual(a._trait_values, {"x": 11})
b = B()
self.assertEqual(b.x, 20)
- self.assertEqual(b._trait_values, {'x': 20})
+ self.assertEqual(b._trait_values, {"x": 20})
c = C()
self.assertEqual(c._trait_values, {})
self.assertEqual(c.x, 21)
- self.assertEqual(c._trait_values, {'x': 21})
+ self.assertEqual(c._trait_values, {"x": 21})
# Ensure that the base class remains unmolested when the _default
# initializer gets overridden in a subclass.
a = A()
c = C()
self.assertEqual(a._trait_values, {})
self.assertEqual(a.x, 11)
- self.assertEqual(a._trait_values, {'x': 11})
+ self.assertEqual(a._trait_values, {"x": 11})
def test_deprecated_method_warnings(self):
with expected_warnings([]):
+
class ShouldntWarn(HasTraits):
x = Integer()
- @default('x')
+
+ @default("x")
def _x_default(self):
return 10
- @validate('x')
+ @validate("x")
def _x_validate(self, proposal):
return proposal.value
- @observe('x')
+ @observe("x")
def _x_changed(self, change):
pass
@@ -197,7 +207,8 @@ class TestTraitType(TestCase):
assert obj.x == 5
- with expected_warnings(['@validate', '@observe']) as w:
+ with expected_warnings(["@validate", "@observe"]) as w:
+
class ShouldWarn(HasTraits):
x = Integer()
@@ -216,11 +227,10 @@ class TestTraitType(TestCase):
assert obj.x == 5
def test_dynamic_initializer(self):
-
class A(HasTraits):
x = Int(10)
- @default('x')
+ @default("x")
def _default_x(self):
return 11
@@ -228,114 +238,124 @@ class TestTraitType(TestCase):
x = Int(20)
class C(A):
-
- @default('x')
+ @default("x")
def _default_x(self):
return 21
a = A()
self.assertEqual(a._trait_values, {})
self.assertEqual(a.x, 11)
- self.assertEqual(a._trait_values, {'x': 11})
+ self.assertEqual(a._trait_values, {"x": 11})
b = B()
self.assertEqual(b.x, 20)
- self.assertEqual(b._trait_values, {'x': 20})
+ self.assertEqual(b._trait_values, {"x": 20})
c = C()
self.assertEqual(c._trait_values, {})
self.assertEqual(c.x, 21)
- self.assertEqual(c._trait_values, {'x': 21})
+ self.assertEqual(c._trait_values, {"x": 21})
# Ensure that the base class remains unmolested when the _default
# initializer gets overridden in a subclass.
a = A()
c = C()
self.assertEqual(a._trait_values, {})
self.assertEqual(a.x, 11)
- self.assertEqual(a._trait_values, {'x': 11})
+ self.assertEqual(a._trait_values, {"x": 11})
def test_tag_metadata(self):
class MyIntTT(TraitType):
- metadata = {'a': 1, 'b': 2}
+ metadata = {"a": 1, "b": 2}
+
a = MyIntTT(10).tag(b=3, c=4)
- self.assertEqual(a.metadata, {'a': 1, 'b': 3, 'c': 4})
+ self.assertEqual(a.metadata, {"a": 1, "b": 3, "c": 4})
def test_metadata_localized_instance(self):
class MyIntTT(TraitType):
- metadata = {'a': 1, 'b': 2}
+ metadata = {"a": 1, "b": 2}
+
a = MyIntTT(10)
b = MyIntTT(10)
- a.metadata['c'] = 3
+ a.metadata["c"] = 3
# make sure that changing a's metadata didn't change b's metadata
- self.assertNotIn('c', b.metadata)
+ self.assertNotIn("c", b.metadata)
def test_union_metadata(self):
class Foo(HasTraits):
- bar = (Int().tag(ta=1) | Dict().tag(ta=2, ti='b')).tag(ti='a')
+ bar = (Int().tag(ta=1) | Dict().tag(ta=2, ti="b")).tag(ti="a")
+
foo = Foo()
# At this point, no value has been set for bar, so value-specific
# is not set.
- self.assertEqual(foo.trait_metadata('bar', 'ta'), None)
- self.assertEqual(foo.trait_metadata('bar', 'ti'), 'a')
+ self.assertEqual(foo.trait_metadata("bar", "ta"), None)
+ self.assertEqual(foo.trait_metadata("bar", "ti"), "a")
foo.bar = {}
- self.assertEqual(foo.trait_metadata('bar', 'ta'), 2)
- self.assertEqual(foo.trait_metadata('bar', 'ti'), 'b')
+ self.assertEqual(foo.trait_metadata("bar", "ta"), 2)
+ self.assertEqual(foo.trait_metadata("bar", "ti"), "b")
foo.bar = 1
- self.assertEqual(foo.trait_metadata('bar', 'ta'), 1)
- self.assertEqual(foo.trait_metadata('bar', 'ti'), 'a')
+ self.assertEqual(foo.trait_metadata("bar", "ta"), 1)
+ self.assertEqual(foo.trait_metadata("bar", "ti"), "a")
def test_union_default_value(self):
class Foo(HasTraits):
bar = Union([Dict(), Int()], default_value=1)
+
foo = Foo()
self.assertEqual(foo.bar, 1)
def test_union_validation_priority(self):
class Foo(HasTraits):
bar = Union([CInt(), Unicode()])
+
foo = Foo()
- foo.bar = '1'
+ foo.bar = "1"
# validation in order of the TraitTypes given
self.assertEqual(foo.bar, 1)
def test_union_trait_default_value(self):
class Foo(HasTraits):
bar = Union([Dict(), Int()])
+
self.assertEqual(Foo().bar, {})
def test_deprecated_metadata_access(self):
class MyIntTT(TraitType):
- metadata = {'a': 1, 'b': 2}
+ metadata = {"a": 1, "b": 2}
+
a = MyIntTT(10)
- with expected_warnings(["use the instance .metadata dictionary directly"]*2):
- a.set_metadata('key', 'value')
- v = a.get_metadata('key')
- self.assertEqual(v, 'value')
- with expected_warnings(["use the instance .help string directly"]*2):
- a.set_metadata('help', 'some help')
- v = a.get_metadata('help')
- self.assertEqual(v, 'some help')
+ with expected_warnings(["use the instance .metadata dictionary directly"] * 2):
+ a.set_metadata("key", "value")
+ v = a.get_metadata("key")
+ self.assertEqual(v, "value")
+ with expected_warnings(["use the instance .help string directly"] * 2):
+ a.set_metadata("help", "some help")
+ v = a.get_metadata("help")
+ self.assertEqual(v, "some help")
def test_trait_types_deprecated(self):
with expected_warnings(["Traits should be given as instances"]):
+
class C(HasTraits):
t = Int
def test_trait_types_list_deprecated(self):
with expected_warnings(["Traits should be given as instances"]):
+
class C(HasTraits):
t = List(Int)
def test_trait_types_tuple_deprecated(self):
with expected_warnings(["Traits should be given as instances"]):
+
class C(HasTraits):
t = Tuple(Int)
def test_trait_types_dict_deprecated(self):
with expected_warnings(["Traits should be given as instances"]):
+
class C(HasTraits):
t = Dict(Int)
-class TestHasDescriptorsMeta(TestCase):
+class TestHasDescriptorsMeta(TestCase):
def test_metaclass(self):
self.assertEqual(type(HasTraits), MetaHasTraits)
@@ -344,59 +364,59 @@ class TestHasDescriptorsMeta(TestCase):
a = A()
self.assertEqual(type(a.__class__), MetaHasTraits)
- self.assertEqual(a.a,0)
+ self.assertEqual(a.a, 0)
a.a = 10
- self.assertEqual(a.a,10)
+ self.assertEqual(a.a, 10)
class B(HasTraits):
b = Int()
b = B()
- self.assertEqual(b.b,0)
+ self.assertEqual(b.b, 0)
b.b = 10
- self.assertEqual(b.b,10)
+ self.assertEqual(b.b, 10)
class C(HasTraits):
c = Int(30)
c = C()
- self.assertEqual(c.c,30)
+ self.assertEqual(c.c, 30)
c.c = 10
- self.assertEqual(c.c,10)
+ self.assertEqual(c.c, 10)
def test_this_class(self):
class A(HasTraits):
t = This()
tt = This()
+
class B(A):
tt = This()
ttt = This()
+
self.assertEqual(A.t.this_class, A)
self.assertEqual(B.t.this_class, A)
self.assertEqual(B.tt.this_class, B)
self.assertEqual(B.ttt.this_class, B)
-class TestHasDescriptors(TestCase):
+class TestHasDescriptors(TestCase):
def test_setup_instance(self):
-
class FooDescriptor(BaseDescriptor):
-
def instance_init(self, inst):
- foo = inst.foo # instance should have the attr
+ foo = inst.foo # instance should have the attr
class HasFooDescriptors(HasDescriptors):
fd = FooDescriptor()
def setup_instance(self, *args, **kwargs):
- self.foo = kwargs.get('foo', None)
- super(HasFooDescriptors, self).setup_instance(*args, **kwargs)
+ self.foo = kwargs.get("foo", None)
+ super().setup_instance(*args, **kwargs)
- hfd = HasFooDescriptors(foo='bar')
+ hfd = HasFooDescriptors(foo="bar")
-class TestHasTraitsNotify(TestCase):
+class TestHasTraitsNotify(TestCase):
def setUp(self):
self._notify1 = []
self._notify2 = []
@@ -408,7 +428,6 @@ class TestHasTraitsNotify(TestCase):
self._notify2.append((name, old, new))
def test_notify_all(self):
-
class A(HasTraits):
a = Int()
b = Float()
@@ -416,37 +435,35 @@ class TestHasTraitsNotify(TestCase):
a = A()
a.on_trait_change(self.notify1)
a.a = 0
- self.assertEqual(len(self._notify1),0)
+ self.assertEqual(len(self._notify1), 0)
a.b = 0.0
- self.assertEqual(len(self._notify1),0)
+ self.assertEqual(len(self._notify1), 0)
a.a = 10
- self.assertTrue(('a',0,10) in self._notify1)
+ self.assertTrue(("a", 0, 10) in self._notify1)
a.b = 10.0
- self.assertTrue(('b',0.0,10.0) in self._notify1)
- self.assertRaises(TraitError,setattr,a,'a','bad string')
- self.assertRaises(TraitError,setattr,a,'b','bad string')
+ self.assertTrue(("b", 0.0, 10.0) in self._notify1)
+ self.assertRaises(TraitError, setattr, a, "a", "bad string")
+ self.assertRaises(TraitError, setattr, a, "b", "bad string")
self._notify1 = []
- a.on_trait_change(self.notify1,remove=True)
+ a.on_trait_change(self.notify1, remove=True)
a.a = 20
a.b = 20.0
- self.assertEqual(len(self._notify1),0)
+ self.assertEqual(len(self._notify1), 0)
def test_notify_one(self):
-
class A(HasTraits):
a = Int()
b = Float()
a = A()
- a.on_trait_change(self.notify1, 'a')
+ a.on_trait_change(self.notify1, "a")
a.a = 0
- self.assertEqual(len(self._notify1),0)
+ self.assertEqual(len(self._notify1), 0)
a.a = 10
- self.assertTrue(('a',0,10) in self._notify1)
- self.assertRaises(TraitError,setattr,a,'a','bad string')
+ self.assertTrue(("a", 0, 10) in self._notify1)
+ self.assertRaises(TraitError, setattr, a, "a", "bad string")
def test_subclass(self):
-
class A(HasTraits):
a = Int()
@@ -454,15 +471,14 @@ class TestHasTraitsNotify(TestCase):
b = Float()
b = B()
- self.assertEqual(b.a,0)
- self.assertEqual(b.b,0.0)
+ self.assertEqual(b.a, 0)
+ self.assertEqual(b.b, 0.0)
b.a = 100
b.b = 100.0
- self.assertEqual(b.a,100)
- self.assertEqual(b.b,100.0)
+ self.assertEqual(b.a, 100)
+ self.assertEqual(b.b, 100.0)
def test_notify_subclass(self):
-
class A(HasTraits):
a = Int()
@@ -470,54 +486,58 @@ class TestHasTraitsNotify(TestCase):
b = Float()
b = B()
- b.on_trait_change(self.notify1, 'a')
- b.on_trait_change(self.notify2, 'b')
+ b.on_trait_change(self.notify1, "a")
+ b.on_trait_change(self.notify2, "b")
b.a = 0
b.b = 0.0
- self.assertEqual(len(self._notify1),0)
- self.assertEqual(len(self._notify2),0)
+ self.assertEqual(len(self._notify1), 0)
+ self.assertEqual(len(self._notify2), 0)
b.a = 10
b.b = 10.0
- self.assertTrue(('a',0,10) in self._notify1)
- self.assertTrue(('b',0.0,10.0) in self._notify2)
+ self.assertTrue(("a", 0, 10) in self._notify1)
+ self.assertTrue(("b", 0.0, 10.0) in self._notify2)
def test_static_notify(self):
-
class A(HasTraits):
a = Int()
_notify1 = []
+
def _a_changed(self, name, old, new):
self._notify1.append((name, old, new))
a = A()
a.a = 0
# This is broken!!!
- self.assertEqual(len(a._notify1),0)
+ self.assertEqual(len(a._notify1), 0)
a.a = 10
- self.assertTrue(('a',0,10) in a._notify1)
+ self.assertTrue(("a", 0, 10) in a._notify1)
class B(A):
b = Float()
_notify2 = []
+
def _b_changed(self, name, old, new):
self._notify2.append((name, old, new))
b = B()
b.a = 10
b.b = 10.0
- self.assertTrue(('a',0,10) in b._notify1)
- self.assertTrue(('b',0.0,10.0) in b._notify2)
+ self.assertTrue(("a", 0, 10) in b._notify1)
+ self.assertTrue(("b", 0.0, 10.0) in b._notify2)
def test_notify_args(self):
-
def callback0():
self.cb = ()
+
def callback1(name):
self.cb = (name,)
+
def callback2(name, new):
self.cb = (name, new)
+
def callback3(name, old, new):
self.cb = (name, old, new)
+
def callback4(name, old, new, obj):
self.cb = (name, old, new, obj)
@@ -525,45 +545,44 @@ class TestHasTraitsNotify(TestCase):
a = Int()
a = A()
- a.on_trait_change(callback0, 'a')
+ a.on_trait_change(callback0, "a")
a.a = 10
- self.assertEqual(self.cb,())
- a.on_trait_change(callback0, 'a', remove=True)
+ self.assertEqual(self.cb, ())
+ a.on_trait_change(callback0, "a", remove=True)
- a.on_trait_change(callback1, 'a')
+ a.on_trait_change(callback1, "a")
a.a = 100
- self.assertEqual(self.cb,('a',))
- a.on_trait_change(callback1, 'a', remove=True)
+ self.assertEqual(self.cb, ("a",))
+ a.on_trait_change(callback1, "a", remove=True)
- a.on_trait_change(callback2, 'a')
+ a.on_trait_change(callback2, "a")
a.a = 1000
- self.assertEqual(self.cb,('a',1000))
- a.on_trait_change(callback2, 'a', remove=True)
+ self.assertEqual(self.cb, ("a", 1000))
+ a.on_trait_change(callback2, "a", remove=True)
- a.on_trait_change(callback3, 'a')
+ a.on_trait_change(callback3, "a")
a.a = 10000
- self.assertEqual(self.cb,('a',1000,10000))
- a.on_trait_change(callback3, 'a', remove=True)
+ self.assertEqual(self.cb, ("a", 1000, 10000))
+ a.on_trait_change(callback3, "a", remove=True)
- a.on_trait_change(callback4, 'a')
+ a.on_trait_change(callback4, "a")
a.a = 100000
- self.assertEqual(self.cb,('a',10000,100000,a))
- self.assertEqual(len(a._trait_notifiers['a']['change']), 1)
- a.on_trait_change(callback4, 'a', remove=True)
+ self.assertEqual(self.cb, ("a", 10000, 100000, a))
+ self.assertEqual(len(a._trait_notifiers["a"]["change"]), 1)
+ a.on_trait_change(callback4, "a", remove=True)
- self.assertEqual(len(a._trait_notifiers['a']['change']), 0)
+ self.assertEqual(len(a._trait_notifiers["a"]["change"]), 0)
def test_notify_only_once(self):
-
class A(HasTraits):
- listen_to = ['a']
+ listen_to = ["a"]
a = Int(0)
b = 0
def __init__(self, **kwargs):
- super(A, self).__init__(**kwargs)
- self.on_trait_change(self.listener1, ['a'])
+ super().__init__(**kwargs)
+ self.on_trait_change(self.listener1, ["a"])
def listener1(self, name, old, new):
self.b += 1
@@ -574,7 +593,7 @@ class TestHasTraitsNotify(TestCase):
d = 0
def __init__(self, **kwargs):
- super(B, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.on_trait_change(self.listener2)
def listener2(self, name, old, new):
@@ -591,8 +610,8 @@ class TestHasTraitsNotify(TestCase):
self.assertEqual(b.b, b.c)
self.assertEqual(b.b, b.d)
-class TestObserveDecorator(TestCase):
+class TestObserveDecorator(TestCase):
def setUp(self):
self._notify1 = []
self._notify2 = []
@@ -604,7 +623,6 @@ class TestObserveDecorator(TestCase):
self._notify2.append(change)
def test_notify_all(self):
-
class A(HasTraits):
a = Int()
b = Float()
@@ -612,40 +630,38 @@ class TestObserveDecorator(TestCase):
a = A()
a.observe(self.notify1)
a.a = 0
- self.assertEqual(len(self._notify1),0)
+ self.assertEqual(len(self._notify1), 0)
a.b = 0.0
- self.assertEqual(len(self._notify1),0)
+ self.assertEqual(len(self._notify1), 0)
a.a = 10
- change = change_dict('a', 0, 10, a, 'change')
+ change = change_dict("a", 0, 10, a, "change")
self.assertTrue(change in self._notify1)
a.b = 10.0
- change = change_dict('b', 0.0, 10.0, a, 'change')
+ change = change_dict("b", 0.0, 10.0, a, "change")
self.assertTrue(change in self._notify1)
- self.assertRaises(TraitError,setattr,a,'a','bad string')
- self.assertRaises(TraitError,setattr,a,'b','bad string')
+ self.assertRaises(TraitError, setattr, a, "a", "bad string")
+ self.assertRaises(TraitError, setattr, a, "b", "bad string")
self._notify1 = []
a.unobserve(self.notify1)
a.a = 20
a.b = 20.0
- self.assertEqual(len(self._notify1),0)
+ self.assertEqual(len(self._notify1), 0)
def test_notify_one(self):
-
class A(HasTraits):
a = Int()
b = Float()
a = A()
- a.observe(self.notify1, 'a')
+ a.observe(self.notify1, "a")
a.a = 0
- self.assertEqual(len(self._notify1),0)
+ self.assertEqual(len(self._notify1), 0)
a.a = 10
- change = change_dict('a', 0, 10, a, 'change')
+ change = change_dict("a", 0, 10, a, "change")
self.assertTrue(change in self._notify1)
- self.assertRaises(TraitError,setattr,a,'a','bad string')
+ self.assertRaises(TraitError, setattr, a, "a", "bad string")
def test_subclass(self):
-
class A(HasTraits):
a = Int()
@@ -653,15 +669,14 @@ class TestObserveDecorator(TestCase):
b = Float()
b = B()
- self.assertEqual(b.a,0)
- self.assertEqual(b.b,0.0)
+ self.assertEqual(b.a, 0)
+ self.assertEqual(b.b, 0.0)
b.a = 100
b.b = 100.0
- self.assertEqual(b.a,100)
- self.assertEqual(b.b,100.0)
+ self.assertEqual(b.a, 100)
+ self.assertEqual(b.b, 100.0)
def test_notify_subclass(self):
-
class A(HasTraits):
a = Int()
@@ -669,28 +684,27 @@ class TestObserveDecorator(TestCase):
b = Float()
b = B()
- b.observe(self.notify1, 'a')
- b.observe(self.notify2, 'b')
+ b.observe(self.notify1, "a")
+ b.observe(self.notify2, "b")
b.a = 0
b.b = 0.0
- self.assertEqual(len(self._notify1),0)
- self.assertEqual(len(self._notify2),0)
+ self.assertEqual(len(self._notify1), 0)
+ self.assertEqual(len(self._notify2), 0)
b.a = 10
b.b = 10.0
- change = change_dict('a', 0, 10, b, 'change')
+ change = change_dict("a", 0, 10, b, "change")
self.assertTrue(change in self._notify1)
- change = change_dict('b', 0.0, 10.0, b, 'change')
+ change = change_dict("b", 0.0, 10.0, b, "change")
self.assertTrue(change in self._notify2)
def test_static_notify(self):
-
class A(HasTraits):
a = Int()
b = Int()
_notify1 = []
_notify_any = []
- @observe('a')
+ @observe("a")
def _a_changed(self, change):
self._notify1.append(change)
@@ -700,34 +714,35 @@ class TestObserveDecorator(TestCase):
a = A()
a.a = 0
- self.assertEqual(len(a._notify1),0)
+ self.assertEqual(len(a._notify1), 0)
a.a = 10
- change = change_dict('a', 0, 10, a, 'change')
+ change = change_dict("a", 0, 10, a, "change")
self.assertTrue(change in a._notify1)
a.b = 1
self.assertEqual(len(a._notify_any), 2)
- change = change_dict('b', 0, 1, a, 'change')
+ change = change_dict("b", 0, 1, a, "change")
self.assertTrue(change in a._notify_any)
class B(A):
b = Float()
_notify2 = []
- @observe('b')
+
+ @observe("b")
def _b_changed(self, change):
self._notify2.append(change)
b = B()
b.a = 10
b.b = 10.0
- change = change_dict('a', 0, 10, b, 'change')
+ change = change_dict("a", 0, 10, b, "change")
self.assertTrue(change in b._notify1)
- change = change_dict('b', 0.0, 10.0, b, 'change')
+ change = change_dict("b", 0.0, 10.0, b, "change")
self.assertTrue(change in b._notify2)
def test_notify_args(self):
-
def callback0():
self.cb = ()
+
def callback1(change):
self.cb = change
@@ -735,31 +750,30 @@ class TestObserveDecorator(TestCase):
a = Int()
a = A()
- a.on_trait_change(callback0, 'a')
+ a.on_trait_change(callback0, "a")
a.a = 10
- self.assertEqual(self.cb,())
- a.unobserve(callback0, 'a')
+ self.assertEqual(self.cb, ())
+ a.unobserve(callback0, "a")
- a.observe(callback1, 'a')
+ a.observe(callback1, "a")
a.a = 100
- change = change_dict('a', 10, 100, a, 'change')
+ change = change_dict("a", 10, 100, a, "change")
self.assertEqual(self.cb, change)
- self.assertEqual(len(a._trait_notifiers['a']['change']), 1)
- a.unobserve(callback1, 'a')
+ self.assertEqual(len(a._trait_notifiers["a"]["change"]), 1)
+ a.unobserve(callback1, "a")
- self.assertEqual(len(a._trait_notifiers['a']['change']), 0)
+ self.assertEqual(len(a._trait_notifiers["a"]["change"]), 0)
def test_notify_only_once(self):
-
class A(HasTraits):
- listen_to = ['a']
+ listen_to = ["a"]
a = Int(0)
b = 0
def __init__(self, **kwargs):
- super(A, self).__init__(**kwargs)
- self.observe(self.listener1, ['a'])
+ super().__init__(**kwargs)
+ self.observe(self.listener1, ["a"])
def listener1(self, change):
self.b += 1
@@ -770,13 +784,13 @@ class TestObserveDecorator(TestCase):
d = 0
def __init__(self, **kwargs):
- super(B, self).__init__(**kwargs)
+ super().__init__(**kwargs)
self.observe(self.listener2)
def listener2(self, change):
self.c += 1
- @observe('a')
+ @observe("a")
def _a_changed(self, change):
self.d += 1
@@ -790,65 +804,72 @@ class TestObserveDecorator(TestCase):
class TestHasTraits(TestCase):
-
def test_trait_names(self):
class A(HasTraits):
i = Int()
f = Float()
+
a = A()
- self.assertEqual(sorted(a.trait_names()),['f','i'])
- self.assertEqual(sorted(A.class_trait_names()),['f','i'])
- self.assertTrue(a.has_trait('f'))
- self.assertFalse(a.has_trait('g'))
+ self.assertEqual(sorted(a.trait_names()), ["f", "i"])
+ self.assertEqual(sorted(A.class_trait_names()), ["f", "i"])
+ self.assertTrue(a.has_trait("f"))
+ self.assertFalse(a.has_trait("g"))
def test_trait_has_value(self):
class A(HasTraits):
i = Int()
f = Float()
+
a = A()
- self.assertFalse(a.trait_has_value('f'))
- self.assertFalse(a.trait_has_value('g'))
+ self.assertFalse(a.trait_has_value("f"))
+ self.assertFalse(a.trait_has_value("g"))
a.i = 1
a.f
- self.assertTrue(a.trait_has_value('i'))
- self.assertTrue(a.trait_has_value('f'))
+ self.assertTrue(a.trait_has_value("i"))
+ self.assertTrue(a.trait_has_value("f"))
def test_trait_metadata_deprecated(self):
- with expected_warnings([r'metadata should be set using the \.tag\(\) method']):
+ with expected_warnings([r"metadata should be set using the \.tag\(\) method"]):
+
class A(HasTraits):
- i = Int(config_key='MY_VALUE')
+ i = Int(config_key="MY_VALUE")
+
a = A()
- self.assertEqual(a.trait_metadata('i','config_key'), 'MY_VALUE')
+ self.assertEqual(a.trait_metadata("i", "config_key"), "MY_VALUE")
def test_trait_metadata(self):
class A(HasTraits):
- i = Int().tag(config_key='MY_VALUE')
+ i = Int().tag(config_key="MY_VALUE")
+
a = A()
- self.assertEqual(a.trait_metadata('i','config_key'), 'MY_VALUE')
+ self.assertEqual(a.trait_metadata("i", "config_key"), "MY_VALUE")
def test_trait_metadata_default(self):
class A(HasTraits):
i = Int()
+
a = A()
- self.assertEqual(a.trait_metadata('i', 'config_key'), None)
- self.assertEqual(a.trait_metadata('i', 'config_key', 'default'), 'default')
+ self.assertEqual(a.trait_metadata("i", "config_key"), None)
+ self.assertEqual(a.trait_metadata("i", "config_key", "default"), "default")
def test_traits(self):
class A(HasTraits):
i = Int()
f = Float()
+
a = A()
self.assertEqual(a.traits(), dict(i=A.i, f=A.f))
self.assertEqual(A.class_traits(), dict(i=A.i, f=A.f))
def test_traits_metadata(self):
class A(HasTraits):
- i = Int().tag(config_key='VALUE1', other_thing='VALUE2')
- f = Float().tag(config_key='VALUE3', other_thing='VALUE2')
+ i = Int().tag(config_key="VALUE1", other_thing="VALUE2")
+ f = Float().tag(config_key="VALUE3", other_thing="VALUE2")
j = Int(0)
+
a = A()
self.assertEqual(a.traits(), dict(i=A.i, f=A.f, j=A.j))
- traits = a.traits(config_key='VALUE1', other_thing='VALUE2')
+ traits = a.traits(config_key="VALUE1", other_thing="VALUE2")
self.assertEqual(traits, dict(i=A.i))
# This passes, but it shouldn't because I am replicating a bug in
@@ -857,14 +878,16 @@ class TestHasTraits(TestCase):
self.assertEqual(traits, dict(i=A.i, f=A.f, j=A.j))
def test_traits_metadata_deprecated(self):
- with expected_warnings([r'metadata should be set using the \.tag\(\) method']*2):
+ with expected_warnings([r"metadata should be set using the \.tag\(\) method"] * 2):
+
class A(HasTraits):
- i = Int(config_key='VALUE1', other_thing='VALUE2')
- f = Float(config_key='VALUE3', other_thing='VALUE2')
+ i = Int(config_key="VALUE1", other_thing="VALUE2")
+ f = Float(config_key="VALUE3", other_thing="VALUE2")
j = Int(0)
+
a = A()
self.assertEqual(a.traits(), dict(i=A.i, f=A.f, j=A.j))
- traits = a.traits(config_key='VALUE1', other_thing='VALUE2')
+ traits = a.traits(config_key="VALUE1", other_thing="VALUE2")
self.assertEqual(traits, dict(i=A.i))
# This passes, but it shouldn't because I am replicating a bug in
@@ -872,11 +895,11 @@ class TestHasTraits(TestCase):
traits = a.traits(config_key=lambda v: True)
self.assertEqual(traits, dict(i=A.i, f=A.f, j=A.j))
-
def test_init(self):
class A(HasTraits):
i = Int()
x = Float()
+
a = A(i=1, x=10.0)
self.assertEqual(a.i, 1)
self.assertEqual(a.x, 10.0)
@@ -884,8 +907,9 @@ class TestHasTraits(TestCase):
def test_positional_args(self):
class A(HasTraits):
i = Int(0)
+
def __init__(self, i):
- super(A, self).__init__()
+ super().__init__()
self.i = i
a = A(5)
@@ -893,16 +917,17 @@ class TestHasTraits(TestCase):
# should raise TypeError if no positional arg given
self.assertRaises(TypeError, A)
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# Tests for specific trait types
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
class TestType(TestCase):
-
def test_default(self):
+ class B:
+ pass
- class B(object): pass
class A(HasTraits):
klass = Type(allow_none=True)
@@ -911,12 +936,15 @@ class TestType(TestCase):
a.klass = B
self.assertEqual(a.klass, B)
- self.assertRaises(TraitError, setattr, a, 'klass', 10)
+ self.assertRaises(TraitError, setattr, a, "klass", 10)
def test_default_options(self):
+ class B:
+ pass
+
+ class C(B):
+ pass
- class B(object): pass
- class C(B): pass
class A(HasTraits):
# Different possible combinations of options for default_value
# and klass. default_value=None is only valid with allow_none=True.
@@ -949,70 +977,75 @@ class TestType(TestCase):
self.assertIs(a.k6, C)
def test_value(self):
+ class B:
+ pass
+
+ class C:
+ pass
- class B(object): pass
- class C(object): pass
class A(HasTraits):
klass = Type(B)
a = A()
self.assertEqual(a.klass, B)
- self.assertRaises(TraitError, setattr, a, 'klass', C)
- self.assertRaises(TraitError, setattr, a, 'klass', object)
+ self.assertRaises(TraitError, setattr, a, "klass", C)
+ self.assertRaises(TraitError, setattr, a, "klass", object)
a.klass = B
def test_allow_none(self):
+ class B:
+ pass
+
+ class C(B):
+ pass
- class B(object): pass
- class C(B): pass
class A(HasTraits):
klass = Type(B)
a = A()
self.assertEqual(a.klass, B)
- self.assertRaises(TraitError, setattr, a, 'klass', None)
+ self.assertRaises(TraitError, setattr, a, "klass", None)
a.klass = C
self.assertEqual(a.klass, C)
def test_validate_klass(self):
-
class A(HasTraits):
- klass = Type('no strings allowed')
+ klass = Type("no strings allowed")
self.assertRaises(ImportError, A)
class A(HasTraits):
- klass = Type('rub.adub.Duck')
+ klass = Type("rub.adub.Duck")
self.assertRaises(ImportError, A)
def test_validate_default(self):
+ class B:
+ pass
- class B(object): pass
class A(HasTraits):
- klass = Type('bad default', B)
+ klass = Type("bad default", B)
self.assertRaises(ImportError, A)
class C(HasTraits):
klass = Type(None, B)
- self.assertRaises(TraitError, getattr, C(), 'klass')
+ self.assertRaises(TraitError, getattr, C(), "klass")
def test_str_klass(self):
-
class A(HasTraits):
klass = Type("traitlets.config.Config")
from traitlets.config import Config
+
a = A()
a.klass = Config
self.assertEqual(a.klass, Config)
- self.assertRaises(TraitError, setattr, a, 'klass', 10)
+ self.assertRaises(TraitError, setattr, a, "klass", 10)
def test_set_str_klass(self):
-
class A(HasTraits):
klass = Type()
@@ -1021,12 +1054,17 @@ class TestType(TestCase):
self.assertEqual(a.klass, Config)
-class TestInstance(TestCase):
+class TestInstance(TestCase):
def test_basic(self):
- class Foo(object): pass
- class Bar(Foo): pass
- class Bah(object): pass
+ class Foo:
+ pass
+
+ class Bar(Foo):
+ pass
+
+ class Bah:
+ pass
class A(HasTraits):
inst = Instance(Foo, allow_none=True)
@@ -1037,14 +1075,19 @@ class TestInstance(TestCase):
self.assertTrue(isinstance(a.inst, Foo))
a.inst = Bar()
self.assertTrue(isinstance(a.inst, Foo))
- self.assertRaises(TraitError, setattr, a, 'inst', Foo)
- self.assertRaises(TraitError, setattr, a, 'inst', Bar)
- self.assertRaises(TraitError, setattr, a, 'inst', Bah())
+ self.assertRaises(TraitError, setattr, a, "inst", Foo)
+ self.assertRaises(TraitError, setattr, a, "inst", Bar)
+ self.assertRaises(TraitError, setattr, a, "inst", Bah())
def test_default_klass(self):
- class Foo(object): pass
- class Bar(Foo): pass
- class Bah(object): pass
+ class Foo:
+ pass
+
+ class Bar(Foo):
+ pass
+
+ class Bah:
+ pass
class FooInstance(Instance):
klass = Foo
@@ -1058,45 +1101,56 @@ class TestInstance(TestCase):
self.assertTrue(isinstance(a.inst, Foo))
a.inst = Bar()
self.assertTrue(isinstance(a.inst, Foo))
- self.assertRaises(TraitError, setattr, a, 'inst', Foo)
- self.assertRaises(TraitError, setattr, a, 'inst', Bar)
- self.assertRaises(TraitError, setattr, a, 'inst', Bah())
+ self.assertRaises(TraitError, setattr, a, "inst", Foo)
+ self.assertRaises(TraitError, setattr, a, "inst", Bar)
+ self.assertRaises(TraitError, setattr, a, "inst", Bah())
def test_unique_default_value(self):
- class Foo(object): pass
+ class Foo:
+ pass
+
class A(HasTraits):
- inst = Instance(Foo,(),{})
+ inst = Instance(Foo, (), {})
a = A()
b = A()
self.assertTrue(a.inst is not b.inst)
def test_args_kw(self):
- class Foo(object):
- def __init__(self, c): self.c = c
- class Bar(object): pass
- class Bah(object):
+ class Foo:
+ def __init__(self, c):
+ self.c = c
+
+ class Bar:
+ pass
+
+ class Bah:
def __init__(self, c, d):
- self.c = c; self.d = d
+ self.c = c
+ self.d = d
class A(HasTraits):
inst = Instance(Foo, (10,))
+
a = A()
self.assertEqual(a.inst.c, 10)
class B(HasTraits):
inst = Instance(Bah, args=(10,), kw=dict(d=20))
+
b = B()
self.assertEqual(b.inst.c, 10)
self.assertEqual(b.inst.d, 20)
class C(HasTraits):
inst = Instance(Foo, allow_none=True)
+
c = C()
self.assertTrue(c.inst is None)
def test_bad_default(self):
- class Foo(object): pass
+ class Foo:
+ pass
class A(HasTraits):
inst = Instance(Foo)
@@ -1106,7 +1160,8 @@ class TestInstance(TestCase):
a.inst
def test_instance(self):
- class Foo(object): pass
+ class Foo:
+ pass
def inner():
class A(HasTraits):
@@ -1116,7 +1171,6 @@ class TestInstance(TestCase):
class TestThis(TestCase):
-
def test_this_class(self):
class Foo(HasTraits):
this = This()
@@ -1126,7 +1180,7 @@ class TestThis(TestCase):
g = Foo()
f.this = g
self.assertEqual(f.this, g)
- self.assertRaises(TraitError, setattr, f, 'this', 10)
+ self.assertRaises(TraitError, setattr, f, "this", 10)
def test_this_inst(self):
class Foo(HasTraits):
@@ -1139,8 +1193,10 @@ class TestThis(TestCase):
def test_subclass(self):
class Foo(HasTraits):
t = This()
+
class Bar(Foo):
pass
+
f = Foo()
b = Bar()
f.t = b
@@ -1151,28 +1207,27 @@ class TestThis(TestCase):
def test_subclass_override(self):
class Foo(HasTraits):
t = This()
+
class Bar(Foo):
t = This()
+
f = Foo()
b = Bar()
f.t = b
self.assertEqual(f.t, b)
- self.assertRaises(TraitError, setattr, b, 't', f)
+ self.assertRaises(TraitError, setattr, b, "t", f)
def test_this_in_container(self):
-
class Tree(HasTraits):
value = Unicode()
leaves = List(This())
- tree = Tree(
- value='foo',
- leaves=[Tree(value='bar'), Tree(value='buzz')]
- )
+ tree = Tree(value="foo", leaves=[Tree(value="bar"), Tree(value="buzz")])
with self.assertRaises(TraitError):
tree.leaves = [1, 2]
+
class TraitTestBase(TestCase):
"""A best testing class for basic trait types."""
@@ -1183,13 +1238,13 @@ class TraitTestBase(TestCase):
return value
def test_good_values(self):
- if hasattr(self, '_good_values'):
+ if hasattr(self, "_good_values"):
for value in self._good_values:
self.assign(value)
self.assertEqual(self.obj.value, self.coerce(value))
def test_bad_values(self):
- if hasattr(self, '_bad_values'):
+ if hasattr(self, "_bad_values"):
for value in self._bad_values:
try:
self.assertRaises(TraitError, self.assign, value)
@@ -1197,29 +1252,32 @@ class TraitTestBase(TestCase):
assert False, value
def test_default_value(self):
- if hasattr(self, '_default_value'):
+ if hasattr(self, "_default_value"):
self.assertEqual(self._default_value, self.obj.value)
def test_allow_none(self):
- if (hasattr(self, '_bad_values') and hasattr(self, '_good_values') and
- None in self._bad_values):
- trait=self.obj.traits()['value']
+ if (
+ hasattr(self, "_bad_values")
+ and hasattr(self, "_good_values")
+ and None in self._bad_values
+ ):
+ trait = self.obj.traits()["value"]
try:
trait.allow_none = True
self._bad_values.remove(None)
- #skip coerce. Allow None casts None to None.
+ # skip coerce. Allow None casts None to None.
self.assign(None)
- self.assertEqual(self.obj.value,None)
+ self.assertEqual(self.obj.value, None)
self.test_good_values()
self.test_bad_values()
finally:
- #tear down
+ # tear down
trait.allow_none = False
self._bad_values.append(None)
def tearDown(self):
# restore default value after tests, if set
- if hasattr(self, '_default_value'):
+ if hasattr(self, "_default_value"):
self.obj.value = self._default_value
@@ -1227,150 +1285,192 @@ class AnyTrait(HasTraits):
value = Any()
+
class AnyTraitTest(TraitTestBase):
obj = AnyTrait()
_default_value = None
- _good_values = [10.0, 'ten', [10], {'ten': 10},(10,), None, 1j]
- _bad_values = []
+ _good_values = [10.0, "ten", [10], {"ten": 10}, (10,), None, 1j]
+ _bad_values = []
+
class UnionTrait(HasTraits):
value = Union([Type(), Bool()])
+
class UnionTraitTest(TraitTestBase):
obj = UnionTrait(value="traitlets.config.Config")
_good_values = [int, float, True]
_bad_values = [[], (0,), 1j]
+
class CallableTrait(HasTraits):
value = Callable()
+
class CallableTraitTest(TraitTestBase):
obj = CallableTrait(value=lambda x: type(x))
_good_values = [int, sorted, lambda x: print(x)]
- _bad_values = [[], 1, '']
+ _bad_values = [[], 1, ""]
+
class OrTrait(HasTraits):
value = Bool() | Unicode()
+
class OrTraitTest(TraitTestBase):
obj = OrTrait()
- _good_values = [True, False, 'ten']
+ _good_values = [True, False, "ten"]
_bad_values = [[], (0,), 1j]
+
class IntTrait(HasTraits):
value = Int(99, min=-100)
+
class TestInt(TraitTestBase):
obj = IntTrait()
_default_value = 99
- _good_values = [10, -10]
- _bad_values = ['ten', [10], {'ten': 10}, (10,), None, 1j,
- 10.1, -10.1, '10L', '-10L', '10.1', '-10.1',
- '10', '-10', -200]
+ _good_values = [10, -10]
+ _bad_values = [
+ "ten",
+ [10],
+ {"ten": 10},
+ (10,),
+ None,
+ 1j,
+ 10.1,
+ -10.1,
+ "10L",
+ "-10L",
+ "10.1",
+ "-10.1",
+ "10",
+ "-10",
+ -200,
+ ]
class CIntTrait(HasTraits):
- value = CInt('5')
+ value = CInt("5")
+
class TestCInt(TraitTestBase):
obj = CIntTrait()
_default_value = 5
- _good_values = ['10', '-10', 10, 10.0, -10.0, 10.1]
- _bad_values = ['ten', [10], {'ten': 10},(10,),
- None, 1j, '10.1']
+ _good_values = ["10", "-10", 10, 10.0, -10.0, 10.1]
+ _bad_values = ["ten", [10], {"ten": 10}, (10,), None, 1j, "10.1"]
def coerce(self, n):
return int(n)
class MinBoundCIntTrait(HasTraits):
- value = CInt('5', min=3)
+ value = CInt("5", min=3)
+
class TestMinBoundCInt(TestCInt):
obj = MinBoundCIntTrait()
_default_value = 5
- _good_values = [3, 3.0, '3']
- _bad_values = [2.6, 2, -3, -3.0]
+ _good_values = [3, 3.0, "3"]
+ _bad_values = [2.6, 2, -3, -3.0]
class LongTrait(HasTraits):
value = Long(99)
+
class TestLong(TraitTestBase):
obj = LongTrait()
_default_value = 99
- _good_values = [10, -10]
- _bad_values = ['ten', [10], {'ten': 10},(10,),
- None, 1j, 10.1, -10.1, '10', '-10', '10L', '-10L', '10.1',
- '-10.1']
+ _good_values = [10, -10]
+ _bad_values = [
+ "ten",
+ [10],
+ {"ten": 10},
+ (10,),
+ None,
+ 1j,
+ 10.1,
+ -10.1,
+ "10",
+ "-10",
+ "10L",
+ "-10L",
+ "10.1",
+ "-10.1",
+ ]
class MinBoundLongTrait(HasTraits):
value = Long(99, min=5)
+
class TestMinBoundLong(TraitTestBase):
obj = MinBoundLongTrait()
_default_value = 99
- _good_values = [5, 10]
- _bad_values = [4, -10]
+ _good_values = [5, 10]
+ _bad_values = [4, -10]
class MaxBoundLongTrait(HasTraits):
value = Long(5, max=10)
+
class TestMaxBoundLong(TraitTestBase):
obj = MaxBoundLongTrait()
_default_value = 5
- _good_values = [10, -2]
- _bad_values = [11, 20]
+ _good_values = [10, -2]
+ _bad_values = [11, 20]
class CLongTrait(HasTraits):
- value = CLong('5')
+ value = CLong("5")
+
class TestCLong(TraitTestBase):
obj = CLongTrait()
_default_value = 5
- _good_values = ['10', '-10', 10, 10.0, -10.0, 10.1]
- _bad_values = ['ten', [10], {'ten': 10},(10,),
- None, 1j, '10.1']
+ _good_values = ["10", "-10", 10, 10.0, -10.0, 10.1]
+ _bad_values = ["ten", [10], {"ten": 10}, (10,), None, 1j, "10.1"]
def coerce(self, n):
return int(n)
class MaxBoundCLongTrait(HasTraits):
- value = CLong('5', max=10)
+ value = CLong("5", max=10)
+
class TestMaxBoundCLong(TestCLong):
obj = MaxBoundCLongTrait()
_default_value = 5
- _good_values = [10, '10', 10.3]
- _bad_values = [11.0, '11']
+ _good_values = [10, "10", 10.3]
+ _bad_values = [11.0, "11"]
class IntegerTrait(HasTraits):
value = Integer(1)
+
class TestInteger(TestLong):
obj = IntegerTrait()
_default_value = 1
@@ -1382,51 +1482,67 @@ class TestInteger(TestLong):
class MinBoundIntegerTrait(HasTraits):
value = Integer(5, min=3)
+
class TestMinBoundInteger(TraitTestBase):
obj = MinBoundIntegerTrait()
_default_value = 5
- _good_values = 3, 20
- _bad_values = [2, -10]
+ _good_values = 3, 20
+ _bad_values = [2, -10]
class MaxBoundIntegerTrait(HasTraits):
value = Integer(1, max=3)
+
class TestMaxBoundInteger(TraitTestBase):
obj = MaxBoundIntegerTrait()
_default_value = 1
- _good_values = 3, -2
- _bad_values = [4, 10]
+ _good_values = 3, -2
+ _bad_values = [4, 10]
class FloatTrait(HasTraits):
value = Float(99.0, max=200.0)
+
class TestFloat(TraitTestBase):
obj = FloatTrait()
_default_value = 99.0
- _good_values = [10, -10, 10.1, -10.1]
- _bad_values = ['ten', [10], {'ten': 10}, (10,), None,
- 1j, '10', '-10', '10L', '-10L', '10.1', '-10.1', 201.0]
+ _good_values = [10, -10, 10.1, -10.1]
+ _bad_values = [
+ "ten",
+ [10],
+ {"ten": 10},
+ (10,),
+ None,
+ 1j,
+ "10",
+ "-10",
+ "10L",
+ "-10L",
+ "10.1",
+ "-10.1",
+ 201.0,
+ ]
class CFloatTrait(HasTraits):
- value = CFloat('99.0', max=200.0)
+ value = CFloat("99.0", max=200.0)
+
class TestCFloat(TraitTestBase):
obj = CFloatTrait()
_default_value = 99.0
- _good_values = [10, 10.0, 10.5, '10.0', '10', '-10']
- _bad_values = ['ten', [10], {'ten': 10}, (10,), None, 1j,
- 200.1, '200.1']
+ _good_values = [10, 10.0, 10.5, "10.0", "10", "-10"]
+ _bad_values = ["ten", [10], {"ten": 10}, (10,), None, 1j, 200.1, "200.1"]
def coerce(self, v):
return float(v)
@@ -1434,47 +1550,55 @@ class TestCFloat(TraitTestBase):
class ComplexTrait(HasTraits):
- value = Complex(99.0-99.0j)
+ value = Complex(99.0 - 99.0j)
+
class TestComplex(TraitTestBase):
obj = ComplexTrait()
- _default_value = 99.0-99.0j
- _good_values = [10, -10, 10.1, -10.1, 10j, 10+10j, 10-10j,
- 10.1j, 10.1+10.1j, 10.1-10.1j]
- _bad_values = ['10L', '-10L', 'ten', [10], {'ten': 10},(10,), None]
+ _default_value = 99.0 - 99.0j
+ _good_values = [
+ 10,
+ -10,
+ 10.1,
+ -10.1,
+ 10j,
+ 10 + 10j,
+ 10 - 10j,
+ 10.1j,
+ 10.1 + 10.1j,
+ 10.1 - 10.1j,
+ ]
+ _bad_values = ["10L", "-10L", "ten", [10], {"ten": 10}, (10,), None]
class BytesTrait(HasTraits):
- value = Bytes(b'string')
+ value = Bytes(b"string")
+
class TestBytes(TraitTestBase):
obj = BytesTrait()
- _default_value = b'string'
- _good_values = [b'10', b'-10', b'10L',
- b'-10L', b'10.1', b'-10.1', b'string']
- _bad_values = [10, -10, 10.1, -10.1, 1j, [10],
- ['ten'],{'ten': 10},(10,), None, 'string']
+ _default_value = b"string"
+ _good_values = [b"10", b"-10", b"10L", b"-10L", b"10.1", b"-10.1", b"string"]
+ _bad_values = [10, -10, 10.1, -10.1, 1j, [10], ["ten"], {"ten": 10}, (10,), None, "string"]
class UnicodeTrait(HasTraits):
- value = Unicode('unicode')
+ value = Unicode("unicode")
class TestUnicode(TraitTestBase):
obj = UnicodeTrait()
- _default_value = 'unicode'
- _good_values = ['10', '-10', '10L', '-10L', '10.1',
- '-10.1', '', 'string', "€", b"bytestring"]
- _bad_values = [10, -10, 10.1, -10.1, 1j,
- [10], ['ten'], {'ten': 10},(10,), None]
+ _default_value = "unicode"
+ _good_values = ["10", "-10", "10L", "-10L", "10.1", "-10.1", "", "string", "€", b"bytestring"]
+ _bad_values = [10, -10, 10.1, -10.1, 1j, [10], ["ten"], {"ten": 10}, (10,), None]
def coerce(self, v):
return cast_unicode(v)
@@ -1483,19 +1607,34 @@ class TestUnicode(TraitTestBase):
class ObjectNameTrait(HasTraits):
value = ObjectName("abc")
+
class TestObjectName(TraitTestBase):
obj = ObjectNameTrait()
_default_value = "abc"
_good_values = ["a", "gh", "g9", "g_", "_G", "a345_"]
- _bad_values = [1, "", "€", "9g", "!", "#abc", "aj@", "a.b", "a()", "a[0]",
- None, object(), object]
+ _bad_values = [
+ 1,
+ "",
+ "€",
+ "9g",
+ "!",
+ "#abc",
+ "aj@",
+ "a.b",
+ "a()",
+ "a[0]",
+ None,
+ object(),
+ object,
+ ]
_good_values.append("þ") # þ=1 is valid in Python 3 (PEP 3131).
class DottedObjectNameTrait(HasTraits):
value = DottedObjectName("a.b")
+
class TestDottedObjectName(TraitTestBase):
obj = DottedObjectNameTrait()
@@ -1509,13 +1648,14 @@ class TestDottedObjectName(TraitTestBase):
class TCPAddressTrait(HasTraits):
value = TCPAddress()
+
class TestTCPAddress(TraitTestBase):
obj = TCPAddressTrait()
- _default_value = ('127.0.0.1',0)
- _good_values = [('localhost',0),('192.168.0.1',1000),('www.google.com',80)]
- _bad_values = [(0,0),('localhost',10.0),('localhost',-1), None]
+ _default_value = ("127.0.0.1", 0)
+ _good_values = [("localhost", 0), ("192.168.0.1", 1000), ("www.google.com", 80)]
+ _bad_values = [(0, 0), ("localhost", 10.0), ("localhost", -1), None]
class ListTrait(HasTraits):
@@ -1528,8 +1668,8 @@ class TestList(TraitTestBase):
obj = ListTrait()
_default_value = []
- _good_values = [[], [1], list(range(10)), (1,2)]
- _bad_values = [10, [1,'a'], 'a']
+ _good_values = [[], [1], list(range(10)), (1, 2)]
+ _bad_values = [10, [1, "a"], "a"]
def coerce(self, value):
if value is not None:
@@ -1537,13 +1677,15 @@ class TestList(TraitTestBase):
return value
-class Foo(object):
+class Foo:
pass
+
class NoneInstanceListTrait(HasTraits):
value = List(Instance(Foo))
+
class TestNoneInstanceList(TraitTestBase):
obj = NoneInstanceListTrait()
@@ -1555,7 +1697,8 @@ class TestNoneInstanceList(TraitTestBase):
class InstanceListTrait(HasTraits):
- value = List(Instance(__name__+'.Foo'))
+ value = List(Instance(__name__ + ".Foo"))
+
class TestInstanceList(TraitTestBase):
@@ -1563,53 +1706,66 @@ class TestInstanceList(TraitTestBase):
def test_klass(self):
"""Test that the instance klass is properly assigned."""
- self.assertIs(self.obj.traits()['value']._trait.klass, Foo)
+ self.assertIs(self.obj.traits()["value"]._trait.klass, Foo)
_default_value = []
_good_values = [[Foo(), Foo()], []]
- _bad_values = [['1', 2,], '1', [Foo], None]
+ _bad_values = [
+ [
+ "1",
+ 2,
+ ],
+ "1",
+ [Foo],
+ None,
+ ]
+
class UnionListTrait(HasTraits):
value = List(Int() | Bool())
+
class TestUnionListTrait(TraitTestBase):
obj = UnionListTrait()
_default_value = []
_good_values = [[True, 1], [False, True]]
- _bad_values = [[1, 'True'], False]
+ _bad_values = [[1, "True"], False]
class LenListTrait(HasTraits):
value = List(Int(), [0], minlen=1, maxlen=2)
+
class TestLenList(TraitTestBase):
obj = LenListTrait()
_default_value = [0]
- _good_values = [[1], [1,2], (1,2)]
- _bad_values = [10, [1,'a'], 'a', [], list(range(3))]
+ _good_values = [[1], [1, 2], (1, 2)]
+ _bad_values = [10, [1, "a"], "a", [], list(range(3))]
def coerce(self, value):
if value is not None:
value = list(value)
return value
+
class TupleTrait(HasTraits):
value = Tuple(Int(allow_none=True), default_value=(1,))
+
class TestTupleTrait(TraitTestBase):
obj = TupleTrait()
_default_value = (1,)
_good_values = [(1,), (0,), [1]]
- _bad_values = [10, (1, 2), ('a'), (), None]
+ _bad_values = [10, (1, 2), ("a"), (), None]
def coerce(self, value):
if value is not None:
@@ -1618,20 +1774,22 @@ class TestTupleTrait(TraitTestBase):
def test_invalid_args(self):
self.assertRaises(TypeError, Tuple, 5)
- self.assertRaises(TypeError, Tuple, default_value='hello')
- t = Tuple(Int(), CBytes(), default_value=(1,5))
+ self.assertRaises(TypeError, Tuple, default_value="hello")
+ t = Tuple(Int(), CBytes(), default_value=(1, 5))
+
class LooseTupleTrait(HasTraits):
- value = Tuple((1,2,3))
+ value = Tuple((1, 2, 3))
+
class TestLooseTupleTrait(TraitTestBase):
obj = LooseTupleTrait()
- _default_value = (1,2,3)
- _good_values = [(1,), [1], (0,), tuple(range(5)), tuple('hello'), ('a',5), ()]
- _bad_values = [10, 'hello', {}, None]
+ _default_value = (1, 2, 3)
+ _good_values = [(1,), [1], (0,), tuple(range(5)), tuple("hello"), ("a", 5), ()]
+ _bad_values = [10, "hello", {}, None]
def coerce(self, value):
if value is not None:
@@ -1640,25 +1798,34 @@ class TestLooseTupleTrait(TraitTestBase):
def test_invalid_args(self):
self.assertRaises(TypeError, Tuple, 5)
- self.assertRaises(TypeError, Tuple, default_value='hello')
- t = Tuple(Int(), CBytes(), default_value=(1,5))
+ self.assertRaises(TypeError, Tuple, default_value="hello")
+ t = Tuple(Int(), CBytes(), default_value=(1, 5))
class MultiTupleTrait(HasTraits):
- value = Tuple(Int(), Bytes(), default_value=[99,b'bottles'])
+ value = Tuple(Int(), Bytes(), default_value=[99, b"bottles"])
+
class TestMultiTuple(TraitTestBase):
obj = MultiTupleTrait()
- _default_value = (99,b'bottles')
- _good_values = [(1,b'a'), (2,b'b')]
- _bad_values = ((),10, b'a', (1,b'a',3), (b'a',1), (1, 'a'))
+ _default_value = (99, b"bottles")
+ _good_values = [(1, b"a"), (2, b"b")]
+ _bad_values = ((), 10, b"a", (1, b"a", 3), (b"a", 1), (1, "a"))
@pytest.mark.parametrize(
- "Trait", (List, Tuple, Set, Dict, Integer, Unicode,),
+ "Trait",
+ (
+ List,
+ Tuple,
+ Set,
+ Dict,
+ Integer,
+ Unicode,
+ ),
)
def test_allow_none_default_value(Trait):
class C(HasTraits):
@@ -1709,92 +1876,89 @@ def test_subclass_default_value(Trait, default_value):
class CRegExpTrait(HasTraits):
- value = CRegExp(r'')
+ value = CRegExp(r"")
class TestCRegExp(TraitTestBase):
-
def coerce(self, value):
return re.compile(value)
obj = CRegExpTrait()
- _default_value = re.compile(r'')
- _good_values = [r'\d+', re.compile(r'\d+')]
- _bad_values = ['(', None, ()]
+ _default_value = re.compile(r"")
+ _good_values = [r"\d+", re.compile(r"\d+")]
+ _bad_values = ["(", None, ()]
+
class DictTrait(HasTraits):
value = Dict()
+
def test_dict_assignment():
- d = dict()
+ d = {}
c = DictTrait()
c.value = d
- d['a'] = 5
+ d["a"] = 5
assert d == c.value
assert c.value is d
class UniformlyValueValidatedDictTrait(HasTraits):
- value = Dict(trait=Unicode(),
- default_value={'foo': '1'})
+ value = Dict(trait=Unicode(), default_value={"foo": "1"})
class TestInstanceUniformlyValueValidatedDict(TraitTestBase):
obj = UniformlyValueValidatedDictTrait()
- _default_value = {'foo': '1'}
- _good_values = [{'foo': '0', 'bar': '1'}]
- _bad_values = [{'foo': 0, 'bar': '1'}]
+ _default_value = {"foo": "1"}
+ _good_values = [{"foo": "0", "bar": "1"}]
+ _bad_values = [{"foo": 0, "bar": "1"}]
class NonuniformlyValueValidatedDictTrait(HasTraits):
- value = Dict(traits={'foo': Int()},
- default_value={'foo': 1})
+ value = Dict(traits={"foo": Int()}, default_value={"foo": 1})
class TestInstanceNonuniformlyValueValidatedDict(TraitTestBase):
obj = NonuniformlyValueValidatedDictTrait()
- _default_value = {'foo': 1}
- _good_values = [{'foo': 0, 'bar': '1'}, {'foo': 0, 'bar': 1}]
- _bad_values = [{'foo': '0', 'bar': '1'}]
+ _default_value = {"foo": 1}
+ _good_values = [{"foo": 0, "bar": "1"}, {"foo": 0, "bar": 1}]
+ _bad_values = [{"foo": "0", "bar": "1"}]
class KeyValidatedDictTrait(HasTraits):
- value = Dict(key_trait=Unicode(),
- default_value={'foo': '1'})
+ value = Dict(key_trait=Unicode(), default_value={"foo": "1"})
class TestInstanceKeyValidatedDict(TraitTestBase):
obj = KeyValidatedDictTrait()
- _default_value = {'foo': '1'}
- _good_values = [{'foo': '0', 'bar': '1'}]
- _bad_values = [{'foo': '0', 0: '1'}]
+ _default_value = {"foo": "1"}
+ _good_values = [{"foo": "0", "bar": "1"}]
+ _bad_values = [{"foo": "0", 0: "1"}]
class FullyValidatedDictTrait(HasTraits):
- value = Dict(trait=Unicode(),
- key_trait=Unicode(),
- traits={'foo': Int()},
- default_value={'foo': 1})
+ value = Dict(
+ trait=Unicode(), key_trait=Unicode(), traits={"foo": Int()}, default_value={"foo": 1}
+ )
class TestInstanceFullyValidatedDict(TraitTestBase):
obj = FullyValidatedDictTrait()
- _default_value = {'foo': 1}
- _good_values = [{'foo': 0, 'bar': '1'}, {'foo': 1, 'bar': '2'}]
- _bad_values = [{'foo': 0, 'bar': 1}, {'foo': '0', 'bar': '1'}, {'foo': 0, 0: '1'}]
+ _default_value = {"foo": 1}
+ _good_values = [{"foo": 0, "bar": "1"}, {"foo": 1, "bar": "2"}]
+ _bad_values = [{"foo": 0, "bar": 1}, {"foo": "0", "bar": "1"}, {"foo": 0, 0: "1"}]
def test_dict_default_value():
@@ -1807,36 +1971,35 @@ def test_dict_default_value():
foo = Foo()
assert foo.d1 == {}
- assert foo.d2 == {}
+ assert foo.d2 == {}
assert foo.d1 is not foo.d2
class TestValidationHook(TestCase):
-
def test_parity_trait(self):
"""Verify that the early validation hook is effective"""
class Parity(HasTraits):
value = Int(0)
- parity = Enum(['odd', 'even'], default_value='even')
+ parity = Enum(["odd", "even"], default_value="even")
- @validate('value')
+ @validate("value")
def _value_validate(self, proposal):
- value = proposal['value']
- if self.parity == 'even' and value % 2:
- raise TraitError('Expected an even number')
- if self.parity == 'odd' and (value % 2 == 0):
- raise TraitError('Expected an odd number')
+ value = proposal["value"]
+ if self.parity == "even" and value % 2:
+ raise TraitError("Expected an even number")
+ if self.parity == "odd" and (value % 2 == 0):
+ raise TraitError("Expected an odd number")
return value
u = Parity()
- u.parity = 'odd'
+ u.parity = "odd"
u.value = 1 # OK
with self.assertRaises(TraitError):
u.value = 2 # Trait Error
- u.parity = 'even'
+ u.parity = "even"
u.value = 2 # OK
def test_multiple_validate(self):
@@ -1847,12 +2010,12 @@ class TestValidationHook(TestCase):
odd = Int(1)
even = Int(0)
- @validate('odd', 'even')
+ @validate("odd", "even")
def check_valid(self, proposal):
- if proposal['trait'].name == 'odd' and not proposal['value'] % 2:
- raise TraitError('odd should be odd')
- if proposal['trait'].name == 'even' and proposal['value'] % 2:
- raise TraitError('even should be even')
+ if proposal["trait"].name == "odd" and not proposal["value"] % 2:
+ raise TraitError("odd should be odd")
+ if proposal["trait"].name == "even" and proposal["value"] % 2:
+ raise TraitError("even should be even")
u = OddEven()
u.odd = 3 # OK
@@ -1864,20 +2027,19 @@ class TestValidationHook(TestCase):
u.even = 3 # Trait Error
-
class TestLink(TestCase):
-
def test_connect_same(self):
"""Verify two traitlets of the same type can be linked together using link."""
# Create two simple classes with Int traitlets.
class A(HasTraits):
value = Int()
+
a = A(value=9)
b = A(value=8)
# Conenct the two classes.
- c = link((a, 'value'), (b, 'value'))
+ c = link((a, "value"), (b, "value"))
# Make sure the values are the same at the point of linking.
self.assertEqual(a.value, b.value)
@@ -1894,13 +2056,15 @@ class TestLink(TestCase):
# Create two simple classes with Int traitlets.
class A(HasTraits):
value = Int()
+
class B(HasTraits):
count = Int()
+
a = A(value=9)
b = B(count=8)
# Conenct the two classes.
- c = link((a, 'value'), (b, 'count'))
+ c = link((a, "value"), (b, "count"))
# Make sure the values are the same at the point of linking.
self.assertEqual(a.value, b.count)
@@ -1917,11 +2081,12 @@ class TestLink(TestCase):
# Create two simple classes with Int traitlets.
class A(HasTraits):
value = Int()
+
a = A(value=9)
b = A(value=8)
# Connect the two classes.
- c = link((a, 'value'), (b, 'value'))
+ c = link((a, "value"), (b, "value"))
a.value = 4
c.unlink()
@@ -1939,35 +2104,41 @@ class TestLink(TestCase):
# Create two simple classes with Int traitlets.
class A(HasTraits):
value = Int()
+
class B(HasTraits):
count = Int()
+
a = A(value=9)
b = B(count=8)
# Register callbacks that count.
callback_count = []
+
def a_callback(name, old, new):
- callback_count.append('a')
- a.on_trait_change(a_callback, 'value')
+ callback_count.append("a")
+
+ a.on_trait_change(a_callback, "value")
+
def b_callback(name, old, new):
- callback_count.append('b')
- b.on_trait_change(b_callback, 'count')
+ callback_count.append("b")
+
+ b.on_trait_change(b_callback, "count")
# Connect the two classes.
- c = link((a, 'value'), (b, 'count'))
+ c = link((a, "value"), (b, "count"))
# Make sure b's count was set to a's value once.
- self.assertEqual(''.join(callback_count), 'b')
+ self.assertEqual("".join(callback_count), "b")
del callback_count[:]
# Make sure a's value was set to b's count once.
b.count = 5
- self.assertEqual(''.join(callback_count), 'ba')
+ self.assertEqual("".join(callback_count), "ba")
del callback_count[:]
# Make sure b's count was set to a's value once.
a.value = 4
- self.assertEqual(''.join(callback_count), 'ab')
+ self.assertEqual("".join(callback_count), "ab")
del callback_count[:]
def test_tranform(self):
@@ -1976,12 +2147,12 @@ class TestLink(TestCase):
# Create two simple classes with Int traitlets.
class A(HasTraits):
value = Int()
+
a = A(value=9)
b = A(value=8)
# Conenct the two classes.
- c = link((a, 'value'), (b, 'value'),
- transform=(lambda x: 2 * x, lambda x: int(x / 2.)))
+ c = link((a, "value"), (b, "value"), transform=(lambda x: 2 * x, lambda x: int(x / 2.0)))
# Make sure the values are correct at the point of linking.
self.assertEqual(b.value, 2 * a.value)
@@ -2004,12 +2175,12 @@ class TestLink(TestCase):
self.i = change.new * 2
mc = MyClass()
- l = link((mc, "i"), (mc, "j"))
- self.assertRaises(TraitError, setattr, mc, 'i', 2)
+ l = link((mc, "i"), (mc, "j")) # noqa
+ self.assertRaises(TraitError, setattr, mc, "i", 2)
def test_link_broken_at_target(self):
class MyClass(HasTraits):
- i =Int()
+ i = Int()
j = Int()
@observe("i")
@@ -2017,8 +2188,9 @@ class TestLink(TestCase):
self.j = change.new * 2
mc = MyClass()
- l = link((mc, "i"), (mc, "j"))
- self.assertRaises(TraitError, setattr, mc, 'j', 2)
+ l = link((mc, "i"), (mc, "j")) # noqa
+ self.assertRaises(TraitError, setattr, mc, "j", 2)
+
class TestDirectionalLink(TestCase):
def test_connect_same(self):
@@ -2027,11 +2199,12 @@ class TestDirectionalLink(TestCase):
# Create two simple classes with Int traitlets.
class A(HasTraits):
value = Int()
+
a = A(value=9)
b = A(value=8)
# Conenct the two classes.
- c = directional_link((a, 'value'), (b, 'value'))
+ c = directional_link((a, "value"), (b, "value"))
# Make sure the values are the same at the point of linking.
self.assertEqual(a.value, b.value)
@@ -2049,11 +2222,12 @@ class TestDirectionalLink(TestCase):
# Create two simple classes with Int traitlets.
class A(HasTraits):
value = Int()
+
a = A(value=9)
b = A(value=8)
# Conenct the two classes.
- c = directional_link((a, 'value'), (b, 'value'), lambda x: 2 * x)
+ c = directional_link((a, "value"), (b, "value"), lambda x: 2 * x)
# Make sure the values are correct at the point of linking.
self.assertEqual(b.value, 2 * a.value)
@@ -2071,13 +2245,15 @@ class TestDirectionalLink(TestCase):
# Create two simple classes with Int traitlets.
class A(HasTraits):
value = Int()
+
class B(HasTraits):
count = Int()
+
a = A(value=9)
b = B(count=8)
# Conenct the two classes.
- c = directional_link((a, 'value'), (b, 'count'))
+ c = directional_link((a, "value"), (b, "count"))
# Make sure the values are the same at the point of linking.
self.assertEqual(a.value, b.count)
@@ -2095,11 +2271,12 @@ class TestDirectionalLink(TestCase):
# Create two simple classes with Int traitlets.
class A(HasTraits):
value = Int()
+
a = A(value=9)
b = A(value=8)
# Connect the two classes.
- c = directional_link((a, 'value'), (b, 'value'))
+ c = directional_link((a, "value"), (b, "value"))
a.value = 4
c.unlink()
@@ -2111,21 +2288,26 @@ class TestDirectionalLink(TestCase):
a.value += 1
self.assertEqual(a.value, b.value)
+
class Pickleable(HasTraits):
i = Int()
- @observe('i')
- def _i_changed(self, change): pass
- @validate('i')
+
+ @observe("i")
+ def _i_changed(self, change):
+ pass
+
+ @validate("i")
def _i_validate(self, commit):
- return commit['value']
+ return commit["value"]
j = Int()
def __init__(self):
with self.hold_trait_notifications():
self.i = 1
- self.on_trait_change(self._i_changed, 'i')
+ self.on_trait_change(self._i_changed, "i")
+
def test_pickle_hastraits():
c = Pickleable()
@@ -2155,7 +2337,7 @@ def test_hold_trait_notifications():
def _b_validate(self, value, trait):
if value != 0:
- raise TraitError('Only 0 is a valid value')
+ raise TraitError("Only 0 is a valid value")
return value
# Test context manager and nesting
@@ -2181,25 +2363,24 @@ def test_hold_trait_notifications():
assert changes == [(0, 4)]
# Test roll-back
try:
- with t.hold_trait_notifications():
- t.b = 1 # raises a Trait error
- except:
+ with t.hold_trait_notifications():
+ t.b = 1 # raises a Trait error
+ except Exception:
pass
assert t.b == 0
class RollBack(HasTraits):
bar = Int()
+
def _bar_validate(self, value, trait):
if value:
- raise TraitError('foobar')
+ raise TraitError("foobar")
return value
class TestRollback(TestCase):
-
def test_roll_back(self):
-
def assign_rollback():
RollBack(bar=1)
@@ -2238,7 +2419,7 @@ class OrderTraits(HasTraits):
i = Unicode()
j = Unicode()
k = Unicode()
- l = Unicode()
+ l = Unicode() # noqa
def _notify(self, name, old, new):
"""check the value of all traits when each trait change is triggered
@@ -2248,44 +2429,45 @@ class OrderTraits(HasTraits):
"""
# check the value of the other traits
# when a given trait change notification fires
- self.notified[name] = {
- c: getattr(self, c) for c in 'abcdefghijkl'
- }
+ self.notified[name] = {c: getattr(self, c) for c in "abcdefghijkl"}
def __init__(self, **kwargs):
self.on_trait_change(self._notify)
- super(OrderTraits, self).__init__(**kwargs)
+ super().__init__(**kwargs)
+
def test_notification_order():
- d = {c:c for c in 'abcdefghijkl'}
+ d = {c: c for c in "abcdefghijkl"}
obj = OrderTraits()
assert obj.notified == {}
obj = OrderTraits(**d)
- notifications = {
- c: d for c in 'abcdefghijkl'
- }
+ notifications = {c: d for c in "abcdefghijkl"}
assert obj.notified == notifications
-
###
# Traits for Forward Declaration Tests
###
class ForwardDeclaredInstanceTrait(HasTraits):
- value = ForwardDeclaredInstance('ForwardDeclaredBar', allow_none=True)
+ value = ForwardDeclaredInstance("ForwardDeclaredBar", allow_none=True)
+
class ForwardDeclaredTypeTrait(HasTraits):
- value = ForwardDeclaredType('ForwardDeclaredBar', allow_none=True)
+ value = ForwardDeclaredType("ForwardDeclaredBar", allow_none=True)
+
class ForwardDeclaredInstanceListTrait(HasTraits):
- value = List(ForwardDeclaredInstance('ForwardDeclaredBar'))
+ value = List(ForwardDeclaredInstance("ForwardDeclaredBar"))
+
class ForwardDeclaredTypeListTrait(HasTraits):
- value = List(ForwardDeclaredType('ForwardDeclaredBar'))
+ value = List(ForwardDeclaredType("ForwardDeclaredBar"))
+
+
###
# End Traits for Forward Declaration Tests
###
@@ -2293,11 +2475,14 @@ class ForwardDeclaredTypeListTrait(HasTraits):
###
# Classes for Forward Declaration Tests
###
-class ForwardDeclaredBar(object):
+class ForwardDeclaredBar:
pass
+
class ForwardDeclaredBarSub(ForwardDeclaredBar):
pass
+
+
###
# End Classes for Forward Declaration Tests
###
@@ -2310,14 +2495,16 @@ class TestForwardDeclaredInstanceTrait(TraitTestBase):
obj = ForwardDeclaredInstanceTrait()
_default_value = None
_good_values = [None, ForwardDeclaredBar(), ForwardDeclaredBarSub()]
- _bad_values = ['foo', 3, ForwardDeclaredBar, ForwardDeclaredBarSub]
+ _bad_values = ["foo", 3, ForwardDeclaredBar, ForwardDeclaredBarSub]
+
class TestForwardDeclaredTypeTrait(TraitTestBase):
obj = ForwardDeclaredTypeTrait()
_default_value = None
_good_values = [None, ForwardDeclaredBar, ForwardDeclaredBarSub]
- _bad_values = ['foo', 3, ForwardDeclaredBar(), ForwardDeclaredBarSub()]
+ _bad_values = ["foo", 3, ForwardDeclaredBar(), ForwardDeclaredBarSub()]
+
class TestForwardDeclaredInstanceList(TraitTestBase):
@@ -2325,7 +2512,7 @@ class TestForwardDeclaredInstanceList(TraitTestBase):
def test_klass(self):
"""Test that the instance klass is properly assigned."""
- self.assertIs(self.obj.traits()['value']._trait.klass, ForwardDeclaredBar)
+ self.assertIs(self.obj.traits()["value"]._trait.klass, ForwardDeclaredBar)
_default_value = []
_good_values = [
@@ -2335,20 +2522,21 @@ class TestForwardDeclaredInstanceList(TraitTestBase):
_bad_values = [
ForwardDeclaredBar(),
[ForwardDeclaredBar(), 3, None],
- '1',
+ "1",
# Note that this is the type, not an instance.
[ForwardDeclaredBar],
[None],
None,
]
+
class TestForwardDeclaredTypeList(TraitTestBase):
obj = ForwardDeclaredTypeListTrait()
def test_klass(self):
"""Test that the instance klass is properly assigned."""
- self.assertIs(self.obj.traits()['value']._trait.klass, ForwardDeclaredBar)
+ self.assertIs(self.obj.traits()["value"]._trait.klass, ForwardDeclaredBar)
_default_value = []
_good_values = [
@@ -2358,18 +2546,20 @@ class TestForwardDeclaredTypeList(TraitTestBase):
_bad_values = [
ForwardDeclaredBar,
[ForwardDeclaredBar, 3],
- '1',
+ "1",
# Note that this is an instance, not the type.
[ForwardDeclaredBar()],
[None],
None,
]
+
+
###
# End Forward Declaration Tests
###
-class TestDynamicTraits(TestCase):
+class TestDynamicTraits(TestCase):
def setUp(self):
self._notify1 = []
@@ -2377,30 +2567,29 @@ class TestDynamicTraits(TestCase):
self._notify1.append((name, old, new))
def test_notify_all(self):
-
class A(HasTraits):
pass
a = A()
- self.assertTrue(not hasattr(a, 'x'))
- self.assertTrue(not hasattr(a, 'y'))
+ self.assertTrue(not hasattr(a, "x"))
+ self.assertTrue(not hasattr(a, "y"))
# Dynamically add trait x.
a.add_traits(x=Int())
- self.assertTrue(hasattr(a, 'x'))
- self.assertTrue(isinstance(a, (A, )))
+ self.assertTrue(hasattr(a, "x"))
+ self.assertTrue(isinstance(a, (A,)))
# Dynamically add trait y.
a.add_traits(y=Float())
- self.assertTrue(hasattr(a, 'y'))
- self.assertTrue(isinstance(a, (A, )))
+ self.assertTrue(hasattr(a, "y"))
+ self.assertTrue(isinstance(a, (A,)))
self.assertEqual(a.__class__.__name__, A.__name__)
# Create a new instance and verify that x and y
# aren't defined.
b = A()
- self.assertTrue(not hasattr(b, 'x'))
- self.assertTrue(not hasattr(b, 'y'))
+ self.assertTrue(not hasattr(b, "x"))
+ self.assertTrue(not hasattr(b, "y"))
# Verify that notification works like normal.
a.on_trait_change(self.notify1)
@@ -2409,11 +2598,11 @@ class TestDynamicTraits(TestCase):
a.y = 0.0
self.assertEqual(len(self._notify1), 0)
a.x = 10
- self.assertTrue(('x', 0, 10) in self._notify1)
+ self.assertTrue(("x", 0, 10) in self._notify1)
a.y = 10.0
- self.assertTrue(('y', 0.0, 10.0) in self._notify1)
- self.assertRaises(TraitError, setattr, a, 'x', 'bad string')
- self.assertRaises(TraitError, setattr, a, 'y', 'bad string')
+ self.assertTrue(("y", 0.0, 10.0) in self._notify1)
+ self.assertRaises(TraitError, setattr, a, "x", "bad string")
+ self.assertRaises(TraitError, setattr, a, "y", "bad string")
self._notify1 = []
a.on_trait_change(self.notify1, remove=True)
a.x = 20
@@ -2423,24 +2612,24 @@ class TestDynamicTraits(TestCase):
def test_enum_no_default():
class C(HasTraits):
- t = Enum(['a', 'b'])
+ t = Enum(["a", "b"])
c = C()
- c.t = 'a'
- assert c.t == 'a'
+ c.t = "a"
+ assert c.t == "a"
c = C()
with pytest.raises(TraitError):
t = c.t
- c = C(t='b')
- assert c.t == 'b'
+ c = C(t="b")
+ assert c.t == "b"
def test_default_value_repr():
class C(HasTraits):
- t = Type('traitlets.HasTraits')
+ t = Type("traitlets.HasTraits")
t2 = Type(HasTraits)
n = Integer(0)
lis = List()
@@ -2448,26 +2637,27 @@ def test_default_value_repr():
assert C.t.default_value_repr() == "'traitlets.HasTraits'"
assert C.t2.default_value_repr() == "'traitlets.traitlets.HasTraits'"
- assert C.n.default_value_repr() == '0'
- assert C.lis.default_value_repr() == '[]'
- assert C.d.default_value_repr() == '{}'
+ assert C.n.default_value_repr() == "0"
+ assert C.lis.default_value_repr() == "[]"
+ assert C.d.default_value_repr() == "{}"
class TransitionalClass(HasTraits):
d = Any()
- @default('d')
+
+ @default("d")
def _d_default(self):
return TransitionalClass
parent_super = False
calls_super = Integer(0)
- @default('calls_super')
+ @default("calls_super")
def _calls_super_default(self):
return -1
- @observe('calls_super')
+ @observe("calls_super")
@observe_compat
def _calls_super_changed(self, change):
self.parent_super = change
@@ -2475,7 +2665,7 @@ class TransitionalClass(HasTraits):
parent_override = False
overrides = Integer(0)
- @observe('overrides')
+ @observe("overrides")
@observe_compat
def _overrides_changed(self, change):
self.parent_override = change
@@ -2486,11 +2676,13 @@ class SubClass(TransitionalClass):
return SubClass
subclass_super = False
+
def _calls_super_changed(self, name, old, new):
self.subclass_super = True
- super(SubClass, self)._calls_super_changed(name, old, new)
+ super()._calls_super_changed(name, old, new)
subclass_override = False
+
def _overrides_changed(self, name, old, new):
self.subclass_override = True
@@ -2510,7 +2702,8 @@ class DefinesHandler(HasTraits):
parent_called = False
trait = Integer()
- @observe('trait')
+
+ @observe("trait")
def handler(self, change):
self.parent_called = True
@@ -2518,7 +2711,7 @@ class DefinesHandler(HasTraits):
class OverridesHandler(DefinesHandler):
child_called = False
- @observe('trait')
+ @observe("trait")
def handler(self, change):
self.child_called = True
@@ -2548,10 +2741,11 @@ def test_subclass_override_not_registered():
class AddsHandler(DefinesHandler):
child_called = False
- @observe('trait')
+ @observe("trait")
def child_handler(self, change):
self.child_called = True
+
def test_subclass_add_observer():
obj = AddsHandler()
obj.trait = 5
@@ -2560,27 +2754,27 @@ def test_subclass_add_observer():
def test_observe_iterables():
-
class C(HasTraits):
i = Integer()
s = Unicode()
c = C()
recorded = {}
+
def record(change):
- recorded['change'] = change
+ recorded["change"] = change
# observe with names=set
- c.observe(record, names={'i', 's'})
+ c.observe(record, names={"i", "s"})
c.i = 5
- assert recorded['change'].name == 'i'
- assert recorded['change'].new == 5
- c.s = 'hi'
- assert recorded['change'].name == 's'
- assert recorded['change'].new == 'hi'
+ assert recorded["change"].name == "i"
+ assert recorded["change"].new == 5
+ c.s = "hi"
+ assert recorded["change"].name == "s"
+ assert recorded["change"].new == "hi"
# observe with names=custom container with iter, contains
- class MyContainer(object):
+ class MyContainer:
def __init__(self, container):
self.container = container
@@ -2590,17 +2784,17 @@ def test_observe_iterables():
def __contains__(self, key):
return key in self.container
- c.observe(record, names=MyContainer({'i', 's'}))
+ c.observe(record, names=MyContainer({"i", "s"}))
c.i = 10
- assert recorded['change'].name == 'i'
- assert recorded['change'].new == 10
- c.s = 'ok'
- assert recorded['change'].name == 's'
- assert recorded['change'].new == 'ok'
+ assert recorded["change"].name == "i"
+ assert recorded["change"].new == 10
+ c.s = "ok"
+ assert recorded["change"].name == "s"
+ assert recorded["change"].new == "ok"
def test_super_args():
- class SuperRecorder(object):
+ class SuperRecorder:
def __init__(self, *args, **kwargs):
self.super_args = args
self.super_kwargs = kwargs
@@ -2608,12 +2802,13 @@ def test_super_args():
class SuperHasTraits(HasTraits, SuperRecorder):
i = Integer()
- obj = SuperHasTraits('a1', 'a2', b=10, i=5, c='x')
- assert obj.i == 5
- assert not hasattr(obj, 'b')
- assert not hasattr(obj, 'c')
- assert obj.super_args == ('a1' , 'a2')
- assert obj.super_kwargs == {'b': 10 , 'c': 'x'}
+ obj = SuperHasTraits("a1", "a2", b=10, i=5, c="x")
+ assert obj.i == 5
+ assert not hasattr(obj, "b")
+ assert not hasattr(obj, "c")
+ assert obj.super_args == ("a1", "a2")
+ assert obj.super_kwargs == {"b": 10, "c": "x"}
+
def test_super_bad_args():
class SuperHasTraits(HasTraits):
@@ -2622,22 +2817,23 @@ def test_super_bad_args():
w = ["Passing unrecognized arguments"]
with expected_warnings(w):
obj = SuperHasTraits(a=1, b=2)
- assert obj.a == 1
- assert not hasattr(obj, 'b')
+ assert obj.a == 1
+ assert not hasattr(obj, "b")
def test_default_mro():
"""Verify that default values follow mro"""
+
class Base(HasTraits):
- trait = Unicode('base')
- attr = 'base'
+ trait = Unicode("base")
+ attr = "base"
class A(Base):
pass
class B(Base):
- trait = Unicode('B')
- attr = 'B'
+ trait = Unicode("B")
+ attr = "B"
class AB(A, B):
pass
@@ -2645,12 +2841,12 @@ def test_default_mro():
class BA(B, A):
pass
- assert A().trait == 'base'
- assert A().attr == 'base'
- assert BA().trait == 'B'
- assert BA().attr == 'B'
- assert AB().trait == 'B'
- assert AB().attr == 'B'
+ assert A().trait == "base"
+ assert A().attr == "base"
+ assert BA().trait == "B"
+ assert BA().attr == "B"
+ assert AB().trait == "B"
+ assert AB().attr == "B"
def test_cls_self_argument():
@@ -2663,35 +2859,40 @@ def test_cls_self_argument():
def test_override_default():
class C(HasTraits):
- a = Unicode('hard default')
+ a = Unicode("hard default")
+
def _a_default(self):
- return 'default method'
+ return "default method"
- C._a_default = lambda self: 'overridden'
+ C._a_default = lambda self: "overridden"
c = C()
- assert c.a == 'overridden'
+ assert c.a == "overridden"
+
def test_override_default_decorator():
class C(HasTraits):
- a = Unicode('hard default')
- @default('a')
+ a = Unicode("hard default")
+
+ @default("a")
def _a_default(self):
- return 'default method'
+ return "default method"
- C._a_default = lambda self: 'overridden'
+ C._a_default = lambda self: "overridden"
c = C()
- assert c.a == 'overridden'
+ assert c.a == "overridden"
+
def test_override_default_instance():
class C(HasTraits):
- a = Unicode('hard default')
- @default('a')
+ a = Unicode("hard default")
+
+ @default("a")
def _a_default(self):
- return 'default method'
+ return "default method"
c = C()
- c._a_default = lambda self: 'overridden'
- assert c.a == 'overridden'
+ c._a_default = lambda self: "overridden"
+ assert c.a == "overridden"
def test_copy_HasTraits():
diff --git a/contrib/python/traitlets/py3/traitlets/tests/test_traitlets_enum.py b/contrib/python/traitlets/py3/traitlets/tests/test_traitlets_enum.py
index 769e830b33..892a8451a1 100644
--- a/contrib/python/traitlets/py3/traitlets/tests/test_traitlets_enum.py
+++ b/contrib/python/traitlets/py3/traitlets/tests/test_traitlets_enum.py
@@ -3,21 +3,23 @@
Test the trait-type ``UseEnum``.
"""
-import unittest
import enum
-from traitlets import HasTraits, TraitError, Enum, UseEnum, CaselessStrEnum, FuzzyEnum
+import unittest
+from traitlets import CaselessStrEnum, Enum, FuzzyEnum, HasTraits, TraitError, UseEnum
# -----------------------------------------------------------------------------
# TEST SUPPORT:
# -----------------------------------------------------------------------------
+
class Color(enum.Enum):
red = 1
green = 2
blue = 3
yellow = 4
+
class OtherColor(enum.Enum):
red = 0
green = 1
@@ -30,7 +32,7 @@ class CSColor(enum.Enum):
YeLLoW = 4
-color_choices = 'red Green BLUE YeLLoW'.split()
+color_choices = "red Green BLUE YeLLoW".split()
# -----------------------------------------------------------------------------
@@ -49,7 +51,7 @@ class TestUseEnum(unittest.TestCase):
def test_assign_all_enum_values(self):
# pylint: disable=no-member
- enum_values = [value for value in Color.__members__.values()]
+ enum_values = [value for value in Color.__members__.values()]
for value in enum_values:
self.assertIsInstance(value, Color)
example = self.Example()
@@ -107,8 +109,7 @@ class TestUseEnum(unittest.TestCase):
def test_assign_enum_value_number(self):
# -- CONVERT: number => Enum value (item)
# pylint: disable=no-member
- enum_numbers = [enum_val.value
- for enum_val in Color.__members__.values()]
+ enum_numbers = [enum_val.value for enum_val in Color.__members__.values()]
for value in enum_numbers:
self.assertIsInstance(value, int)
example = self.Example()
@@ -142,12 +143,12 @@ class TestUseEnum(unittest.TestCase):
example = Example2()
self.assertEqual(example.color, Color.green)
-
def test_ctor_with_default_value_none_and_not_allow_none(self):
# -- IMPLICIT: default_value = Color.red (first enum-value)
class Example2(HasTraits):
color1 = UseEnum(Color, default_value=None, allow_none=False)
color2 = UseEnum(Color, default_value=None)
+
example = Example2()
self.assertEqual(example.color1, Color.red)
self.assertEqual(example.color2, Color.red)
@@ -189,51 +190,50 @@ class TestUseEnum(unittest.TestCase):
example.color = "BAD_VALUE"
def test_info(self):
- import sys
-
choices = color_choices
+
class Example(HasTraits):
enum1 = Enum(choices, allow_none=False)
enum2 = CaselessStrEnum(choices, allow_none=False)
enum3 = FuzzyEnum(choices, allow_none=False)
enum4 = UseEnum(CSColor, allow_none=False)
- for i in range(1,5):
- attr = 'enum%s' % i
+ for i in range(1, 5):
+ attr = "enum%s" % i
enum = getattr(Example, attr)
enum.allow_none = True
info = enum.info()
- self.assertEqual(len(info.split(', ')), len(choices), info.split(', '))
- self.assertIn('or None', info)
+ self.assertEqual(len(info.split(", ")), len(choices), info.split(", "))
+ self.assertIn("or None", info)
info = enum.info_rst()
- self.assertEqual(len(info.split('|')), len(choices), info.split('|'))
- self.assertIn('or `None`', info)
- ## Check no single `\` exists.
- self.assertNotRegex(info, r'\b\\\b')
+ self.assertEqual(len(info.split("|")), len(choices), info.split("|"))
+ self.assertIn("or `None`", info)
+ # Check no single `\` exists.
+ self.assertNotRegex(info, r"\b\\\b")
enum.allow_none = False
info = enum.info()
- self.assertEqual(len(info.split(', ')), len(choices), info.split(', '))
- self.assertNotIn('None', info)
+ self.assertEqual(len(info.split(", ")), len(choices), info.split(", "))
+ self.assertNotIn("None", info)
info = enum.info_rst()
- self.assertEqual(len(info.split('|')), len(choices), info.split('|'))
- self.assertNotIn('None', info)
- ## Check no single `\` exists.
- self.assertNotRegex(info, r'\b\\\b')
-
+ self.assertEqual(len(info.split("|")), len(choices), info.split("|"))
+ self.assertNotIn("None", info)
+ # Check no single `\` exists.
+ self.assertNotRegex(info, r"\b\\\b")
# -----------------------------------------------------------------------------
# TESTSUITE:
# -----------------------------------------------------------------------------
+
class TestFuzzyEnum(unittest.TestCase):
- ## Check mostly `validate()`, Ctor must be checked on generic `Enum`
+ # Check mostly `validate()`, Ctor must be checked on generic `Enum`
# or `CaselessStrEnum`.
def test_search_all_prefixes__overwrite(self):
@@ -276,8 +276,7 @@ class TestFuzzyEnum(unittest.TestCase):
def test_search_substrings__overwrite(self):
class FuzzyExample(HasTraits):
- color = FuzzyEnum(color_choices, help="Color enum",
- substring_matching=True)
+ color = FuzzyEnum(color_choices, help="Color enum", substring_matching=True)
example = FuzzyExample()
for color in color_choices:
@@ -295,8 +294,7 @@ class TestFuzzyEnum(unittest.TestCase):
def test_search_substrings__ctor(self):
class FuzzyExample(HasTraits):
- color = FuzzyEnum(color_choices, help="Color enum",
- substring_matching=True)
+ color = FuzzyEnum(color_choices, help="Color enum", substring_matching=True)
color = color_choices[-1] # 'YeLLoW'
for end in (-1, len(color)):
@@ -314,52 +312,55 @@ class TestFuzzyEnum(unittest.TestCase):
def test_assign_other_raises(self):
def new_trait_class(case_sensitive, substring_matching):
class Example(HasTraits):
- color = FuzzyEnum(color_choices,
- case_sensitive=case_sensitive,
- substring_matching=substring_matching)
+ color = FuzzyEnum(
+ color_choices,
+ case_sensitive=case_sensitive,
+ substring_matching=substring_matching,
+ )
return Example
example = new_trait_class(case_sensitive=False, substring_matching=False)()
with self.assertRaises(TraitError):
- example.color = ''
+ example.color = ""
with self.assertRaises(TraitError):
- example.color = 'BAD COLOR'
+ example.color = "BAD COLOR"
with self.assertRaises(TraitError):
- example.color = 'ed'
+ example.color = "ed"
example = new_trait_class(case_sensitive=True, substring_matching=False)()
with self.assertRaises(TraitError):
- example.color = ''
+ example.color = ""
with self.assertRaises(TraitError):
- example.color = 'Red' # not 'red'
+ example.color = "Red" # not 'red'
example = new_trait_class(case_sensitive=True, substring_matching=True)()
with self.assertRaises(TraitError):
- example.color = ''
+ example.color = ""
with self.assertRaises(TraitError):
- example.color = 'BAD COLOR'
+ example.color = "BAD COLOR"
with self.assertRaises(TraitError):
- example.color = 'green' # not 'Green'
+ example.color = "green" # not 'Green'
with self.assertRaises(TraitError):
- example.color = 'lue' # not (b)'LUE'
+ example.color = "lue" # not (b)'LUE'
with self.assertRaises(TraitError):
- example.color = 'lUE' # not (b)'LUE'
+ example.color = "lUE" # not (b)'LUE'
example = new_trait_class(case_sensitive=False, substring_matching=True)()
with self.assertRaises(TraitError):
- example.color = ''
+ example.color = ""
with self.assertRaises(TraitError):
- example.color = 'BAD COLOR'
+ example.color = "BAD COLOR"
def test_ctor_with_default_value(self):
- def new_trait_class(default_value,
- case_sensitive, substring_matching):
+ def new_trait_class(default_value, case_sensitive, substring_matching):
class Example(HasTraits):
- color = FuzzyEnum(color_choices,
- default_value=default_value,
- case_sensitive=case_sensitive,
- substring_matching=substring_matching)
+ color = FuzzyEnum(
+ color_choices,
+ default_value=default_value,
+ case_sensitive=case_sensitive,
+ substring_matching=substring_matching,
+ )
return Example
@@ -374,7 +375,6 @@ class TestFuzzyEnum(unittest.TestCase):
example = new_trait_class(color, True, False)()
self.assertEqual(example.color, color)
- ## FIXME: default value not validated!
- #with self.assertRaises(TraitError):
+ # FIXME: default value not validated!
+ # with self.assertRaises(TraitError):
# example = new_trait_class(color.lower(), True, False)
-
diff --git a/contrib/python/traitlets/py3/traitlets/tests/utils.py b/contrib/python/traitlets/py3/traitlets/tests/utils.py
index c5ac591435..1a4caf7a5c 100644
--- a/contrib/python/traitlets/py3/traitlets/tests/utils.py
+++ b/contrib/python/traitlets/py3/traitlets/tests/utils.py
@@ -1,25 +1,25 @@
-from subprocess import Popen, PIPE
import sys
+from subprocess import PIPE, Popen
import os
def get_output_error_code(cmd):
"""Get stdout, stderr, and exit code from running a command"""
env = os.environ.copy()
- env['Y_PYTHON_ENTRY_POINT'] = ':main'
+ env["Y_PYTHON_ENTRY_POINT"] = ":main"
p = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env)
out, err = p.communicate()
- out = out.decode('utf8', 'replace')
- err = err.decode('utf8', 'replace')
+ out = out.decode("utf8", "replace")
+ err = err.decode("utf8", "replace")
return out, err, p.returncode
def check_help_output(pkg, subcommand=None):
"""test that `python -m PKG [subcommand] -h` works"""
- cmd = [sys.executable, '-m', pkg]
+ cmd = [sys.executable, "-m", pkg]
if subcommand:
cmd.extend(subcommand)
- cmd.append('-h')
+ cmd.append("-h")
out, err, rc = get_output_error_code(cmd)
assert rc == 0, err
assert "Traceback" not in err
@@ -30,10 +30,10 @@ def check_help_output(pkg, subcommand=None):
def check_help_all_output(pkg, subcommand=None):
"""test that `python -m PKG --help-all` works"""
- cmd = [sys.executable, '-m', pkg]
+ cmd = [sys.executable, "-m", pkg]
if subcommand:
cmd.extend(subcommand)
- cmd.append('--help-all')
+ cmd.append("--help-all")
out, err, rc = get_output_error_code(cmd)
assert rc == 0, err
assert "Traceback" not in err
diff --git a/contrib/python/traitlets/py3/traitlets/traitlets.py b/contrib/python/traitlets/py3/traitlets/traitlets.py
index 6bdf7414d3..0927222163 100644
--- a/contrib/python/traitlets/py3/traitlets/traitlets.py
+++ b/contrib/python/traitlets/py3/traitlets/traitlets.py
@@ -39,21 +39,22 @@ Inheritance diagram:
# Adapted from enthought.traits, Copyright (c) Enthought, Inc.,
# also under the terms of the Modified BSD License.
-from ast import literal_eval
import contextlib
+import enum
import inspect
import os
import re
import sys
import types
-import enum
+import typing as t
+from ast import literal_eval
from warnings import warn, warn_explicit
+from .utils.bunch import Bunch
+from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getargspec
from .utils.importstring import import_item
from .utils.sentinel import Sentinel
-from .utils.bunch import Bunch
-from .utils.descriptions import describe, class_of, add_article, repr_type
SequenceTypes = (list, tuple, set, frozenset)
@@ -63,69 +64,117 @@ ClassTypes = (type,)
# exports:
__all__ = [
- "default",
- "validate",
- "observe",
- "observe_compat",
- "link",
- "directional_link",
- "dlink",
- "Undefined",
"All",
- "NoDefaultSpecified",
- "TraitError",
+ "Any",
+ "BaseDescriptor",
+ "Bool",
+ "Bytes",
+ "CBool",
+ "CBytes",
+ "CComplex",
+ "CFloat",
+ "CInt",
+ "CRegExp",
+ "CUnicode",
+ "Callable",
+ "CaselessStrEnum",
+ "ClassBasedTraitType",
+ "Complex",
+ "Container",
+ "DefaultHandler",
+ "Dict",
+ "DottedObjectName",
+ "Enum",
+ "EventHandler",
+ "Float",
+ "ForwardDeclaredInstance",
+ "ForwardDeclaredMixin",
+ "ForwardDeclaredType",
+ "FuzzyEnum",
"HasDescriptors",
"HasTraits",
+ "Instance",
+ "Int",
+ "List",
"MetaHasDescriptors",
"MetaHasTraits",
- "BaseDescriptor",
+ "ObjectName",
+ "ObserveHandler",
+ "Set",
+ "TCPAddress",
+ "This",
+ "TraitError",
"TraitType",
+ "Tuple",
+ "Type",
+ "Unicode",
+ "Undefined",
+ "Union",
+ "UseEnum",
+ "ValidateHandler",
+ "default",
+ "directional_link",
+ "dlink",
+ "link",
+ "observe",
+ "observe_compat",
"parse_notifier_name",
+ "validate",
]
# any TraitType subclass (that doesn't start with _) will be added automatically
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Basic classes
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
-Undefined = Sentinel('Undefined', 'traitlets',
-'''
+Undefined = Sentinel(
+ "Undefined",
+ "traitlets",
+ """
Used in Traitlets to specify that no defaults are set in kwargs
-'''
+""",
)
-All = Sentinel('All', 'traitlets',
-'''
+All = Sentinel(
+ "All",
+ "traitlets",
+ """
Used in Traitlets to listen to all types of notification or to notifications
from all trait attributes.
-'''
+""",
)
# Deprecated alias
NoDefaultSpecified = Undefined
+
class TraitError(Exception):
pass
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# Utilities
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
_name_re = re.compile(r"[a-zA-Z_][a-zA-Z0-9_]*$")
+
def isidentifier(s):
return s.isidentifier()
+
_deprecations_shown = set()
+
+
def _should_warn(key):
"""Add our own checks for too many deprecation warnings.
Limit to once per package.
"""
- env_flag = os.environ.get('TRAITLETS_ALL_DEPRECATIONS')
- if env_flag and env_flag != '0':
+ env_flag = os.environ.get("TRAITLETS_ALL_DEPRECATIONS")
+ if env_flag and env_flag != "0":
return True
if key not in _deprecations_shown:
@@ -134,6 +183,7 @@ def _should_warn(key):
else:
return False
+
def _deprecated_method(method, cls, method_name, msg):
"""Show deprecation warning about a magic method definition.
@@ -149,7 +199,7 @@ def _deprecated_method(method, cls, method_name, msg):
cls = parent
break
# limit deprecation messages to once per package
- package_name = cls.__module__.split('.', 1)[0]
+ package_name = cls.__module__.split(".", 1)[0]
key = (package_name, msg)
if not _should_warn(key):
return
@@ -158,10 +208,11 @@ def _deprecated_method(method, cls, method_name, msg):
lineno = inspect.getsourcelines(method)[1] or 0
except (OSError, TypeError) as e:
# Failed to inspect for some reason
- warn(warn_msg + ('\n(inspection failed) %s' % e), DeprecationWarning)
+ warn(warn_msg + ("\n(inspection failed) %s" % e), DeprecationWarning)
else:
warn_explicit(warn_msg, DeprecationWarning, fname, lineno)
+
def _safe_literal_eval(s):
"""Safely evaluate an expression
@@ -174,11 +225,10 @@ def _safe_literal_eval(s):
except (NameError, SyntaxError, ValueError):
return s
+
def is_trait(t):
- """ Returns whether the given value is an instance or subclass of TraitType.
- """
- return (isinstance(t, TraitType) or
- (isinstance(t, type) and issubclass(t, TraitType)))
+ """Returns whether the given value is an instance or subclass of TraitType."""
+ return isinstance(t, TraitType) or (isinstance(t, type) and issubclass(t, TraitType))
def parse_notifier_name(names):
@@ -187,13 +237,13 @@ def parse_notifier_name(names):
Examples
--------
>>> parse_notifier_name([])
- [All]
+ [traitlets.All]
>>> parse_notifier_name("a")
['a']
>>> parse_notifier_name(["a", "b"])
['a', 'b']
>>> parse_notifier_name(All)
- [All]
+ [traitlets.All]
"""
if names is All or isinstance(names, str):
return [names]
@@ -207,11 +257,15 @@ def parse_notifier_name(names):
class _SimpleTest:
- def __init__ ( self, value ): self.value = value
- def __call__ ( self, test ):
+ def __init__(self, value):
+ self.value = value
+
+ def __call__(self, test):
return test == self.value
+
def __repr__(self):
return "<SimpleTest(%r)" % self.value
+
def __str__(self):
return self.__repr__()
@@ -235,18 +289,22 @@ def getmembers(object, predicate=None):
results.sort()
return results
+
def _validate_link(*tuples):
"""Validate arguments for traitlet link functions"""
- for t in tuples:
- if not len(t) == 2:
- raise TypeError("Each linked traitlet must be specified as (HasTraits, 'trait_name'), not %r" % t)
- obj, trait_name = t
+ for tup in tuples:
+ if not len(tup) == 2:
+ raise TypeError(
+ "Each linked traitlet must be specified as (HasTraits, 'trait_name'), not %r" % t
+ )
+ obj, trait_name = tup
if not isinstance(obj, HasTraits):
raise TypeError("Each object must be HasTraits, not %r" % type(obj))
- if not trait_name in obj.traits():
- raise TypeError("%r has no trait %r" % (obj, trait_name))
+ if trait_name not in obj.traits():
+ raise TypeError(f"{obj!r} has no trait {trait_name!r}")
+
-class link(object):
+class link:
"""Link traits from different objects together so they remain in sync.
Parameters
@@ -258,23 +316,35 @@ class link(object):
Examples
--------
+ >>> class X(HasTraits):
+ ... value = Int()
+
+ >>> src = X(value=1)
+ >>> tgt = X(value=42)
>>> c = link((src, "value"), (tgt, "value"))
- >>> src.value = 5 # updates other objects as well
+
+ Setting source updates target objects:
+ >>> src.value = 5
+ >>> tgt.value
+ 5
"""
+
updating = False
def __init__(self, source, target, transform=None):
_validate_link(source, target)
self.source, self.target = source, target
- self._transform, self._transform_inv = (
- transform if transform else (lambda x: x,) * 2)
+ self._transform, self._transform_inv = transform if transform else (lambda x: x,) * 2
self.link()
def link(self):
try:
- setattr(self.target[0], self.target[1],
- self._transform(getattr(self.source[0], self.source[1])))
+ setattr(
+ self.target[0],
+ self.target[1],
+ self._transform(getattr(self.source[0], self.source[1])),
+ )
finally:
self.source[0].observe(self._update_target, names=self.source[1])
@@ -296,25 +366,26 @@ class link(object):
if getattr(self.source[0], self.source[1]) != change.new:
raise TraitError(
"Broken link {}: the source value changed while updating "
- "the target.".format(self))
+ "the target.".format(self)
+ )
def _update_source(self, change):
if self.updating:
return
with self._busy_updating():
- setattr(self.source[0], self.source[1],
- self._transform_inv(change.new))
+ setattr(self.source[0], self.source[1], self._transform_inv(change.new))
if getattr(self.target[0], self.target[1]) != change.new:
raise TraitError(
"Broken link {}: the target value changed while updating "
- "the source.".format(self))
+ "the source.".format(self)
+ )
def unlink(self):
self.source[0].unobserve(self._update_target, names=self.source[1])
self.target[0].unobserve(self._update_source, names=self.target[1])
-class directional_link(object):
+class directional_link:
"""Link the trait of a source object with traits of target objects.
Parameters
@@ -326,10 +397,25 @@ class directional_link(object):
Examples
--------
+ >>> class X(HasTraits):
+ ... value = Int()
+
+ >>> src = X(value=1)
+ >>> tgt = X(value=42)
>>> c = directional_link((src, "value"), (tgt, "value"))
- >>> src.value = 5 # updates target objects
- >>> tgt.value = 6 # does not update source object
+
+ Setting source updates target objects:
+ >>> src.value = 5
+ >>> tgt.value
+ 5
+
+ Setting target does not update source object:
+ >>> tgt.value = 6
+ >>> src.value
+ 5
+
"""
+
updating = False
def __init__(self, source, target, transform=None):
@@ -340,8 +426,11 @@ class directional_link(object):
def link(self):
try:
- setattr(self.target[0], self.target[1],
- self._transform(getattr(self.source[0], self.source[1])))
+ setattr(
+ self.target[0],
+ self.target[1],
+ self._transform(getattr(self.source[0], self.source[1])),
+ )
finally:
self.source[0].observe(self._update, names=self.source[1])
@@ -357,21 +446,21 @@ class directional_link(object):
if self.updating:
return
with self._busy_updating():
- setattr(self.target[0], self.target[1],
- self._transform(change.new))
+ setattr(self.target[0], self.target[1], self._transform(change.new))
def unlink(self):
self.source[0].unobserve(self._update, names=self.source[1])
+
dlink = directional_link
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Base Descriptor Class
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
-class BaseDescriptor(object):
+class BaseDescriptor:
"""Base descriptor class
Notes
@@ -390,8 +479,8 @@ class BaseDescriptor(object):
accept superclasses for :class:`This` values.
"""
- name = None
- this_class = None
+ name: t.Optional[str] = None
+ this_class: t.Optional[t.Type[t.Any]] = None
def class_init(self, cls, name):
"""Part of the initialization which may depend on the underlying
@@ -423,25 +512,31 @@ class BaseDescriptor(object):
class TraitType(BaseDescriptor):
- """A base class for all trait types.
- """
+ """A base class for all trait types."""
- metadata = {}
+ metadata: t.Dict[str, t.Any] = {}
allow_none = False
read_only = False
- info_text = 'any value'
- default_value = Undefined
+ info_text = "any value"
+ default_value: t.Optional[t.Any] = Undefined
- def __init__(self, default_value=Undefined, allow_none=False, read_only=None, help=None,
- config=None, **kwargs):
+ def __init__(
+ self,
+ default_value=Undefined,
+ allow_none=False,
+ read_only=None,
+ help=None,
+ config=None,
+ **kwargs,
+ ):
"""Declare a traitlet.
If *allow_none* is True, None is a valid value in addition to any
values that are normally valid. The default is up to the subclass.
For most trait types, the default value for ``allow_none`` is False.
-
+
If *read_only* is True, attempts to directly modify a trait attribute raises a TraitError.
-
+
Extra metadata can be associated with the traitlet using the .tag() convenience method
or by using the traitlet instance's .metadata dictionary.
"""
@@ -451,23 +546,28 @@ class TraitType(BaseDescriptor):
self.allow_none = allow_none
if read_only is not None:
self.read_only = read_only
- self.help = help if help is not None else ''
+ self.help = help if help is not None else ""
if len(kwargs) > 0:
stacklevel = 1
f = inspect.currentframe()
# count supers to determine stacklevel for warning
- while f.f_code.co_name == '__init__':
+ assert f is not None
+ while f.f_code.co_name == "__init__":
stacklevel += 1
f = f.f_back
- mod = f.f_globals.get('__name__') or ''
- pkg = mod.split('.', 1)[0]
- key = tuple(['metadata-tag', pkg] + sorted(kwargs))
+ assert f is not None
+ mod = f.f_globals.get("__name__") or ""
+ pkg = mod.split(".", 1)[0]
+ key = tuple(["metadata-tag", pkg] + sorted(kwargs))
if _should_warn(key):
- warn("metadata %s was set from the constructor. "
- "With traitlets 4.1, metadata should be set using the .tag() method, "
- "e.g., Int().tag(key1='value1', key2='value2')" % (kwargs,),
- DeprecationWarning, stacklevel=stacklevel)
+ warn(
+ "metadata %s was set from the constructor. "
+ "With traitlets 4.1, metadata should be set using the .tag() method, "
+ "e.g., Int().tag(key1='value1', key2='value2')" % (kwargs,),
+ DeprecationWarning,
+ stacklevel=stacklevel,
+ )
if len(self.metadata) > 0:
self.metadata = self.metadata.copy()
self.metadata.update(kwargs)
@@ -476,12 +576,12 @@ class TraitType(BaseDescriptor):
else:
self.metadata = self.metadata.copy()
if config is not None:
- self.metadata['config'] = config
+ self.metadata["config"] = config
# We add help to the metadata during a deprecation period so that
# code that looks for the help string there can find it.
if help is not None:
- self.metadata['help'] = help
+ self.metadata["help"] = help
def from_string(self, s):
"""Get a value from a config string
@@ -495,7 +595,7 @@ class TraitType(BaseDescriptor):
.. versionadded:: 5.0
"""
- if self.allow_none and s == 'None':
+ if self.allow_none and s == "None":
return None
return s
@@ -509,8 +609,8 @@ class TraitType(BaseDescriptor):
"""
if self.default_value is not Undefined:
return self.default_value
- elif hasattr(self, 'make_dynamic_default'):
- return self.make_dynamic_default()
+ elif hasattr(self, "make_dynamic_default"):
+ return self.make_dynamic_default() # type:ignore[attr-defined]
else:
# Undefined will raise in TraitType.get
return self.default_value
@@ -519,15 +619,20 @@ class TraitType(BaseDescriptor):
"""DEPRECATED: Retrieve the static default value for this trait.
Use self.default_value instead
"""
- warn("get_default_value is deprecated in traitlets 4.0: use the .default_value attribute", DeprecationWarning,
- stacklevel=2)
+ warn(
+ "get_default_value is deprecated in traitlets 4.0: use the .default_value attribute",
+ DeprecationWarning,
+ stacklevel=2,
+ )
return self.default_value
def init_default_value(self, obj):
- """DEPRECATED: Set the static default value for the trait type.
- """
- warn("init_default_value is deprecated in traitlets 4.0, and may be removed in the future", DeprecationWarning,
- stacklevel=2)
+ """DEPRECATED: Set the static default value for the trait type."""
+ warn(
+ "init_default_value is deprecated in traitlets 4.0, and may be removed in the future",
+ DeprecationWarning,
+ stacklevel=2,
+ )
value = self._validate(obj, self.default_value)
obj._trait_values[self.name] = value
return value
@@ -544,22 +649,23 @@ class TraitType(BaseDescriptor):
"is deprecated in traitlets 5.0, and may cause "
"exceptions in the future.",
DeprecationWarning,
- stacklevel=2
+ stacklevel=2,
)
with obj.cross_validation_lock:
value = self._validate(obj, default)
obj._trait_values[self.name] = value
- obj._notify_observers(Bunch(
- name=self.name,
- value=value,
- owner=obj,
- type='default',
- ))
+ obj._notify_observers(
+ Bunch(
+ name=self.name,
+ value=value,
+ owner=obj,
+ type="default",
+ )
+ )
return value
except Exception:
# This should never be reached.
- raise TraitError('Unexpected error in TraitType: '
- 'default value not set properly')
+ raise TraitError("Unexpected error in TraitType: default value not set properly")
else:
return value
@@ -608,21 +714,25 @@ class TraitType(BaseDescriptor):
def _validate(self, obj, value):
if value is None and self.allow_none:
return value
- if hasattr(self, 'validate'):
- value = self.validate(obj, value)
+ if hasattr(self, "validate"):
+ value = self.validate(obj, value) # type:ignore[attr-defined]
if obj._cross_validation_lock is False:
value = self._cross_validate(obj, value)
return value
def _cross_validate(self, obj, value):
if self.name in obj._trait_validators:
- proposal = Bunch({'trait': self, 'value': value, 'owner': obj})
+ proposal = Bunch({"trait": self, "value": value, "owner": obj})
value = obj._trait_validators[self.name](obj, proposal)
- elif hasattr(obj, '_%s_validate' % self.name):
- meth_name = '_%s_validate' % self.name
+ elif hasattr(obj, "_%s_validate" % self.name):
+ meth_name = "_%s_validate" % self.name
cross_validate = getattr(obj, meth_name)
- _deprecated_method(cross_validate, obj.__class__, meth_name,
- "use @validate decorator instead.")
+ _deprecated_method(
+ cross_validate,
+ obj.__class__,
+ meth_name,
+ "use @validate decorator instead.",
+ )
value = cross_validate(value, self)
return value
@@ -668,13 +778,28 @@ class TraitType(BaseDescriptor):
# this is the root trait that must format the final message
chain = " of ".join(describe("a", t) for t in error.args[2:])
if obj is not None:
- error.args = ("The '%s' trait of %s instance contains %s which "
- "expected %s, not %s." % (self.name, describe("an", obj),
- chain, error.args[1], describe("the", error.args[0])),)
+ error.args = (
+ "The '%s' trait of %s instance contains %s which "
+ "expected %s, not %s."
+ % (
+ self.name,
+ describe("an", obj),
+ chain,
+ error.args[1],
+ describe("the", error.args[0]),
+ ),
+ )
else:
- error.args = ("The '%s' trait contains %s which "
- "expected %s, not %s." % (self.name, chain,
- error.args[1], describe("the", error.args[0])),)
+ error.args = (
+ "The '%s' trait contains %s which "
+ "expected %s, not %s."
+ % (
+ self.name,
+ chain,
+ error.args[1],
+ describe("the", error.args[0]),
+ ),
+ )
raise error
else:
# this trait caused an error
@@ -684,11 +809,18 @@ class TraitType(BaseDescriptor):
else:
# this is the root trait
if obj is not None:
- e = "The '%s' trait of %s instance expected %s, not %s." % (
- self.name, class_of(obj), self.info(), describe("the", value))
+ e = "The '{}' trait of {} instance expected {}, not {}.".format(
+ self.name,
+ class_of(obj),
+ self.info(),
+ describe("the", value),
+ )
else:
- e = "The '%s' trait expected %s, not %s." % (
- self.name, self.info(), describe("the", value))
+ e = "The '{}' trait expected {}, not {}.".format(
+ self.name,
+ self.info(),
+ describe("the", value),
+ )
raise TraitError(e)
def get_metadata(self, key, default=None):
@@ -696,7 +828,7 @@ class TraitType(BaseDescriptor):
Use .metadata[key] or .metadata.get(key, default) instead.
"""
- if key == 'help':
+ if key == "help":
msg = "use the instance .help string directly, like x.help"
else:
msg = "use the instance .metadata dictionary directly, like x.metadata[key] or x.metadata.get(key, default)"
@@ -708,7 +840,7 @@ class TraitType(BaseDescriptor):
Use .metadata[key] = value instead.
"""
- if key == 'help':
+ if key == "help":
msg = "use the instance .help string directly, like x.help = value"
else:
msg = "use the instance .metadata dictionary directly, like x.metadata[key] = value"
@@ -720,12 +852,22 @@ class TraitType(BaseDescriptor):
This allows convenient metadata tagging when initializing the trait, such as:
+ Examples
+ --------
>>> Int(0).tag(config=True, sync=True)
+ <traitlets.traitlets.Int object at ...>
+
"""
- maybe_constructor_keywords = set(metadata.keys()).intersection({'help','allow_none', 'read_only', 'default_value'})
+ maybe_constructor_keywords = set(metadata.keys()).intersection(
+ {"help", "allow_none", "read_only", "default_value"}
+ )
if maybe_constructor_keywords:
- warn('The following attributes are set in using `tag`, but seem to be constructor keywords arguments: %s '%
- maybe_constructor_keywords, UserWarning, stacklevel=2)
+ warn(
+ "The following attributes are set in using `tag`, but seem to be constructor keywords arguments: %s "
+ % maybe_constructor_keywords,
+ UserWarning,
+ stacklevel=2,
+ )
self.metadata.update(metadata)
return self
@@ -733,11 +875,13 @@ class TraitType(BaseDescriptor):
def default_value_repr(self):
return repr(self.default_value)
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# The HasTraits implementation
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
-class _CallbackWrapper(object):
+
+class _CallbackWrapper:
"""An object adapting a on_trait_change callback into an observe callback.
The comparison operator __eq__ is implemented to enable removal of wrapped
@@ -749,8 +893,8 @@ class _CallbackWrapper(object):
# Bound methods have an additional 'self' argument.
offset = -1 if isinstance(self.cb, types.MethodType) else 0
self.nargs = len(getargspec(cb)[0]) + offset
- if (self.nargs > 4):
- raise TraitError('a trait changed callback must have 0-4 arguments.')
+ if self.nargs > 4:
+ raise TraitError("a trait changed callback must have 0-4 arguments.")
def __eq__(self, other):
# The wrapper is equal to the wrapped element
@@ -772,6 +916,7 @@ class _CallbackWrapper(object):
elif self.nargs == 4:
self.cb(change.name, change.old, change.new, change.owner)
+
def _callback_wrapper(cb):
if isinstance(cb, _CallbackWrapper):
return cb
@@ -793,17 +938,20 @@ class MetaHasDescriptors(type):
# Support of deprecated behavior allowing for TraitType types
# to be used instead of TraitType instances.
if inspect.isclass(v) and issubclass(v, TraitType):
- warn("Traits should be given as instances, not types (for example, `Int()`, not `Int`)."
- " Passing types is deprecated in traitlets 4.1.",
- DeprecationWarning, stacklevel=2)
+ warn(
+ "Traits should be given as instances, not types (for example, `Int()`, not `Int`)."
+ " Passing types is deprecated in traitlets 4.1.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
classdict[k] = v()
# ----------------------------------------------------------------
- return super(MetaHasDescriptors, mcls).__new__(mcls, name, bases, classdict)
+ return super().__new__(mcls, name, bases, classdict)
def __init__(cls, name, bases, classdict):
"""Finish initializing the HasDescriptors class."""
- super(MetaHasDescriptors, cls).__init__(name, bases, classdict)
+ super().__init__(name, bases, classdict)
cls.setup_class(classdict)
def setup_class(cls, classdict):
@@ -817,7 +965,7 @@ class MetaHasDescriptors(type):
if isinstance(v, BaseDescriptor):
v.class_init(cls, k)
- for k, v in getmembers(cls):
+ for _, v in getmembers(cls):
if isinstance(v, BaseDescriptor):
v.subclass_init(cls)
@@ -827,7 +975,7 @@ class MetaHasTraits(MetaHasDescriptors):
def setup_class(cls, classdict):
cls._trait_default_generators = {}
- super(MetaHasTraits, cls).setup_class(classdict)
+ super().setup_class(classdict)
def observe(*names, type="change"):
@@ -873,21 +1021,26 @@ def observe_compat(func):
With this, `super()._foo_changed(self, name, old, new)` in subclasses will still work.
Allows adoption of new observer API without breaking subclasses that override and super.
"""
+
def compatible_observer(self, change_or_name, old=Undefined, new=Undefined):
if isinstance(change_or_name, dict):
change = change_or_name
else:
clsname = self.__class__.__name__
- warn("A parent of %s._%s_changed has adopted the new (traitlets 4.1) @observe(change) API" % (
- clsname, change_or_name), DeprecationWarning)
+ warn(
+ "A parent of %s._%s_changed has adopted the new (traitlets 4.1) @observe(change) API"
+ % (clsname, change_or_name),
+ DeprecationWarning,
+ )
change = Bunch(
- type='change',
+ type="change",
old=old,
new=new,
name=change_or_name,
owner=self,
)
return func(self, change)
+
return compatible_observer
@@ -925,7 +1078,7 @@ def validate(*names):
def default(name):
- """ A decorator which assigns a dynamic default for a Trait on a HasTraits object.
+ """A decorator which assigns a dynamic default for a Trait on a HasTraits object.
Parameters
----------
@@ -966,14 +1119,13 @@ def default(name):
class EventHandler(BaseDescriptor):
-
def _init_call(self, func):
self.func = func
return self
def __call__(self, *args, **kwargs):
"""Pass `*args` and `**kwargs` to the handler's function if it exists."""
- if hasattr(self, 'func'):
+ if hasattr(self, "func"):
return self.func(*args, **kwargs)
else:
return self._init_call(*args, **kwargs)
@@ -985,7 +1137,6 @@ class EventHandler(BaseDescriptor):
class ObserveHandler(EventHandler):
-
def __init__(self, names, type):
self.trait_names = names
self.type = type
@@ -995,7 +1146,6 @@ class ObserveHandler(EventHandler):
class ValidateHandler(EventHandler):
-
def __init__(self, names):
self.trait_names = names
@@ -1004,7 +1154,6 @@ class ValidateHandler(EventHandler):
class DefaultHandler(EventHandler):
-
def __init__(self, name):
self.trait_name = name
@@ -1014,10 +1163,9 @@ class DefaultHandler(EventHandler):
class HasDescriptors(metaclass=MetaHasDescriptors):
- """The base class for all classes that have descriptors.
- """
+ """The base class for all classes that have descriptors."""
- def __new__(*args, **kwargs):
+ def __new__(*args: t.Any, **kwargs: t.Any) -> t.Any:
# Pass cls as args[0] to allow "cls" as keyword argument
cls = args[0]
args = args[1:]
@@ -1040,7 +1188,7 @@ class HasDescriptors(metaclass=MetaHasDescriptors):
self = args[0]
args = args[1:]
- self._cross_validation_lock = False
+ self._cross_validation_lock = False # type:ignore[attr-defined]
cls = self.__class__
for key in dir(cls):
# Some descriptors raise AttributeError like zope.interface's
@@ -1056,6 +1204,10 @@ class HasDescriptors(metaclass=MetaHasDescriptors):
class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
+ _trait_values: t.Dict[str, t.Any]
+ _trait_notifiers: t.Dict[str, t.Any]
+ _trait_validators: t.Dict[str, t.Any]
+ _cross_validation_lock: bool
def setup_instance(*args, **kwargs):
# Pass self as args[0] to allow "self" as keyword argument
@@ -1065,6 +1217,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
self._trait_values = {}
self._trait_notifiers = {}
self._trait_validators = {}
+ self._cross_validation_lock = False
super(HasTraits, self).setup_instance(*args, **kwargs)
def __init__(self, *args, **kwargs):
@@ -1081,19 +1234,19 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
# passthrough args that don't set traits to super
super_kwargs[key] = value
try:
- super(HasTraits, self).__init__(*super_args, **super_kwargs)
+ super().__init__(*super_args, **super_kwargs)
except TypeError as e:
- arg_s_list = [ repr(arg) for arg in super_args ]
+ arg_s_list = [repr(arg) for arg in super_args]
for k, v in super_kwargs.items():
- arg_s_list.append("%s=%r" % (k, v))
- arg_s = ', '.join(arg_s_list)
+ arg_s_list.append(f"{k}={v!r}")
+ arg_s = ", ".join(arg_s_list)
warn(
"Passing unrecognized arguments to super({classname}).__init__({arg_s}).\n"
"{error}\n"
"This is deprecated in traitlets 4.2."
- "This error will be raised in a future release of traitlets."
- .format(
- arg_s=arg_s, classname=self.__class__.__name__,
+ "This error will be raised in a future release of traitlets.".format(
+ arg_s=arg_s,
+ classname=self.__class__.__name__,
error=e,
),
DeprecationWarning,
@@ -1105,10 +1258,10 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
# event handlers stored on an instance are
# expected to be reinstantiated during a
# recall of instance_init during __setstate__
- d['_trait_notifiers'] = {}
- d['_trait_validators'] = {}
- d['_trait_values'] = self._trait_values.copy()
- d['_cross_validation_lock'] = False # FIXME: raise if cloning locked!
+ d["_trait_notifiers"] = {}
+ d["_trait_validators"] = {}
+ d["_trait_values"] = self._trait_values.copy()
+ d["_cross_validation_lock"] = False # FIXME: raise if cloning locked!
return d
@@ -1129,7 +1282,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
if isinstance(value, EventHandler):
value.instance_init(self)
- @property
+ @property # type:ignore[misc]
@contextlib.contextmanager
def cross_validation_lock(self):
"""
@@ -1162,16 +1315,15 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
yield
return
else:
- cache = {}
- notify_change = self.notify_change
+ cache: t.Dict[str, t.Any] = {}
def compress(past_changes, change):
"""Merges the provided change with the last if possible."""
if past_changes is None:
return [change]
else:
- if past_changes[-1]['type'] == 'change' and change.type == 'change':
- past_changes[-1]['new'] = change.new
+ if past_changes[-1]["type"] == "change" and change.type == "change":
+ past_changes[-1]["new"] = change.new
else:
# In case of changes other than 'change', append the notification.
past_changes.append(change)
@@ -1184,7 +1336,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
try:
# Replace notify_change with `hold`, caching and compressing
# notifications, disable cross validation and yield.
- self.notify_change = hold
+ self.notify_change = hold # type:ignore[assignment]
self._cross_validation_lock = True
yield
# Cross validate final values when context is released.
@@ -1194,11 +1346,11 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
self.set_trait(name, value)
except TraitError as e:
# Roll back in case of TraitError during final cross validation.
- self.notify_change = lambda x: None
+ self.notify_change = lambda x: None # type:ignore[assignment]
for name, changes in cache.items():
for change in changes[::-1]:
# TODO: Separate in a rollback function per notification type.
- if change.type == 'change':
+ if change.type == "change":
if change.old is not Undefined:
self.set_trait(name, change.old)
else:
@@ -1216,13 +1368,15 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
self.notify_change(change)
def _notify_trait(self, name, old_value, new_value):
- self.notify_change(Bunch(
- name=name,
- old=old_value,
- new=new_value,
- owner=self,
- type='change',
- ))
+ self.notify_change(
+ Bunch(
+ name=name,
+ old=old_value,
+ new=new_value,
+ owner=self,
+ type="change",
+ )
+ )
def notify_change(self, change):
"""Notify observers of a change event"""
@@ -1238,16 +1392,24 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
callables = []
callables.extend(self._trait_notifiers.get(name, {}).get(type, []))
callables.extend(self._trait_notifiers.get(name, {}).get(All, []))
- callables.extend(self._trait_notifiers.get(All, {}).get(type, []))
- callables.extend(self._trait_notifiers.get(All, {}).get(All, []))
+ callables.extend(
+ self._trait_notifiers.get(All, {}).get(type, []) # type:ignore[call-overload]
+ )
+ callables.extend(
+ self._trait_notifiers.get(All, {}).get(All, []) # type:ignore[call-overload]
+ )
# Now static ones
- magic_name = '_%s_changed' % name
+ magic_name = "_%s_changed" % name
if event.type == "change" and hasattr(self, magic_name):
class_value = getattr(self.__class__, magic_name)
if not isinstance(class_value, ObserveHandler):
- _deprecated_method(class_value, self.__class__, magic_name,
- "use @observe and @unobserve instead.")
+ _deprecated_method(
+ class_value,
+ self.__class__,
+ magic_name,
+ "use @observe and @unobserve instead.",
+ )
cb = getattr(self, magic_name)
# Only append the magic method if it was not manually registered
if cb not in callables:
@@ -1267,7 +1429,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
def _add_notifiers(self, handler, name, type):
if name not in self._trait_notifiers:
- nlist = []
+ nlist: t.List[t.Any] = []
self._trait_notifiers[name] = {type: nlist}
else:
if type not in self._trait_notifiers[name]:
@@ -1315,8 +1477,11 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
If False (the default), then install the handler. If True
then unintall it.
"""
- warn("on_trait_change is deprecated in traitlets 4.1: use observe instead",
- DeprecationWarning, stacklevel=2)
+ warn(
+ "on_trait_change is deprecated in traitlets 4.1: use observe instead",
+ DeprecationWarning,
+ stacklevel=2,
+ )
if name is None:
name = All
if remove:
@@ -1324,7 +1489,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
else:
self.observe(_callback_wrapper(handler), names=name)
- def observe(self, handler, names=All, type='change'):
+ def observe(self, handler, names=All, type="change"):
"""Setup a handler to be called when a trait changes.
This is used to setup dynamic notifications of trait changes.
@@ -1354,7 +1519,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
for n in names:
self._add_notifiers(handler, n, type)
- def unobserve(self, handler, names=All, type='change'):
+ def unobserve(self, handler, names=All, type="change"):
"""Remove a trait change handler.
This is used to unregister handlers to trait change notifications.
@@ -1379,7 +1544,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
"""Remove trait change handlers of any type for the specified name.
If name is not specified, removes all trait notifiers."""
if name is All:
- self._trait_notifiers = {}
+ self._trait_notifiers: t.Dict[str, t.Any] = {}
else:
try:
del self._trait_notifiers[name]
@@ -1407,12 +1572,16 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
The names of the traits that should be cross-validated
"""
for name in names:
- magic_name = '_%s_validate' % name
+ magic_name = "_%s_validate" % name
if hasattr(self, magic_name):
class_value = getattr(self.__class__, magic_name)
if not isinstance(class_value, ValidateHandler):
- _deprecated_method(class_value, self.__class__, magic_name,
- "use @validate decorator instead.")
+ _deprecated_method(
+ class_value,
+ self.__class__,
+ magic_name,
+ "use @validate decorator instead.",
+ )
for name in names:
self._trait_validators[name] = handler
@@ -1421,8 +1590,8 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
cls = self.__class__
attrs = {"__module__": cls.__module__}
if hasattr(cls, "__qualname__"):
- # __qualname__ introduced in Python 3.3 (see PEP 3155)
- attrs["__qualname__"] = cls.__qualname__
+ # __qualname__ introduced in Python 3.3 (see PEP 3155)
+ attrs["__qualname__"] = cls.__qualname__
attrs.update(traits)
self.__class__ = type(cls.__name__, (cls,), attrs)
for trait in traits.values():
@@ -1432,8 +1601,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
"""Forcibly sets trait attribute, including read-only attributes."""
cls = self.__class__
if not self.has_trait(name):
- raise TraitError("Class %s does not have a trait named %s" %
- (cls.__name__, name))
+ raise TraitError(f"Class {cls.__name__} does not have a trait named {name}")
else:
getattr(cls, name).set(self, value)
@@ -1463,8 +1631,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
the output. If a metadata key doesn't exist, None will be passed
to the function.
"""
- traits = dict([memb for memb in getmembers(cls) if
- isinstance(memb[1], TraitType)])
+ traits = dict([memb for memb in getmembers(cls) if isinstance(memb[1], TraitType)])
if len(metadata) == 0:
return traits
@@ -1488,8 +1655,11 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
Works like `class_traits`, except for excluding traits from parents.
"""
sup = super(cls, cls)
- return {n: t for (n, t) in cls.class_traits(**metadata).items()
- if getattr(sup, n, None) is not t}
+ return {
+ n: t
+ for (n, t) in cls.class_traits(**metadata).items()
+ if getattr(sup, n, None) is not t
+ }
def has_trait(self, name):
"""Returns True if the object has a trait with the specified name."""
@@ -1544,7 +1714,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
Walk the MRO to resolve the correct default generator according to inheritance.
"""
- method_name = '_%s_default' % name
+ method_name = "_%s_default" % name
if method_name in self.__dict__:
return getattr(self, method_name)
cls = self.__class__
@@ -1553,15 +1723,15 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
# truncate mro to the class on which the trait is defined
mro = cls.mro()
try:
- mro = mro[:mro.index(trait.this_class) + 1]
+ mro = mro[: mro.index(trait.this_class) + 1] # type:ignore[arg-type]
except ValueError:
# this_class not in mro
pass
for c in mro:
if method_name in c.__dict__:
return getattr(c, method_name)
- if name in c.__dict__.get('_trait_default_generators', {}):
- return c._trait_default_generators[name]
+ if name in c.__dict__.get("_trait_default_generators", {}):
+ return c._trait_default_generators[name] # type:ignore[attr-defined]
return trait.default
def trait_defaults(self, *names, **metadata):
@@ -1573,8 +1743,7 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
depend on the current state of the object."""
for n in names:
if not self.has_trait(n):
- raise TraitError("'%s' is not a trait of '%s' "
- "instances" % (n, type(self).__name__))
+ raise TraitError(f"'{n}' is not a trait of '{type(self).__name__}' instances")
if len(names) == 1 and len(metadata) == 0:
return self._get_trait_default_generator(names[0])(self)
@@ -1605,8 +1774,9 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
the output. If a metadata key doesn't exist, None will be passed
to the function.
"""
- traits = dict([memb for memb in getmembers(self.__class__) if
- isinstance(memb[1], TraitType)])
+ traits = dict(
+ [memb for memb in getmembers(self.__class__) if isinstance(memb[1], TraitType)]
+ )
if len(metadata) == 0:
return traits
@@ -1628,9 +1798,10 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
try:
trait = getattr(self.__class__, traitname)
except AttributeError:
- raise TraitError("Class %s does not have a trait named %s" %
- (self.__class__.__name__, traitname))
- metadata_name = '_' + traitname + '_metadata'
+ raise TraitError(
+ f"Class {self.__class__.__name__} does not have a trait named {traitname}"
+ )
+ metadata_name = "_" + traitname + "_metadata"
if hasattr(self, metadata_name) and key in getattr(self, metadata_name):
return getattr(self, metadata_name).get(key, default)
else:
@@ -1643,8 +1814,11 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
Works like ``event_handlers``, except for excluding traits from parents.
"""
sup = super(cls, cls)
- return {n: e for (n, e) in cls.events(name).items()
- if getattr(sup, n, None) is not e}
+ return {
+ n: e
+ for (n, e) in cls.events(name).items() # type:ignore[attr-defined]
+ if getattr(sup, n, None) is not e
+ }
@classmethod
def trait_events(cls, name=None):
@@ -1665,20 +1839,21 @@ class HasTraits(HasDescriptors, metaclass=MetaHasTraits):
if isinstance(v, EventHandler):
if name is None:
events[k] = v
- elif name in v.trait_names:
+ elif name in v.trait_names: # type:ignore[attr-defined]
events[k] = v
- elif hasattr(v, 'tags'):
- if cls.trait_names(**v.tags):
+ elif hasattr(v, "tags"):
+ if cls.trait_names(**v.tags): # type:ignore[attr-defined]
events[k] = v
return events
-#-----------------------------------------------------------------------------
+
+# -----------------------------------------------------------------------------
# Actual TraitTypes implementations/subclasses
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# TraitTypes subclasses for handling classes and instances of classes
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
class ClassBasedTraitType(TraitType):
@@ -1747,10 +1922,12 @@ class Type(ClassBasedTraitType):
try:
value = self._resolve_string(value)
except ImportError:
- raise TraitError("The '%s' trait of %s instance must be a type, but "
- "%r could not be imported" % (self.name, obj, value))
+ raise TraitError(
+ "The '%s' trait of %s instance must be a type, but "
+ "%r could not be imported" % (self.name, obj, value)
+ )
try:
- if issubclass(value, self.klass):
+ if issubclass(value, self.klass): # type:ignore[arg-type]
return value
except Exception:
pass
@@ -1758,14 +1935,14 @@ class Type(ClassBasedTraitType):
self.error(obj, value)
def info(self):
- """ Returns a description of the trait."""
+ """Returns a description of the trait."""
if isinstance(self.klass, str):
klass = self.klass
else:
- klass = self.klass.__module__ + '.' + self.klass.__name__
+ klass = self.klass.__module__ + "." + self.klass.__name__
result = "a subclass of '%s'" % klass
if self.allow_none:
- return result + ' or None'
+ return result + " or None"
return result
def instance_init(self, obj):
@@ -1780,10 +1957,11 @@ class Type(ClassBasedTraitType):
def default_value_repr(self):
value = self.default_value
+ assert value is not None
if isinstance(value, str):
return repr(value)
else:
- return repr(f'{value.__module__}.{value.__name__}')
+ return repr(f"{value.__module__}.{value.__name__}")
class Instance(ClassBasedTraitType):
@@ -1831,8 +2009,7 @@ class Instance(ClassBasedTraitType):
if (klass is not None) and (inspect.isclass(klass) or isinstance(klass, str)):
self.klass = klass
else:
- raise TraitError('The klass attribute must be a class'
- ' not: %r' % klass)
+ raise TraitError("The klass attribute must be a class not: %r" % klass)
if (kw is not None) and not isinstance(kw, dict):
raise TraitError("The 'kw' argument must be a dict or None.")
@@ -1842,10 +2019,11 @@ class Instance(ClassBasedTraitType):
self.default_args = args
self.default_kwargs = kw
- super(Instance, self).__init__(**kwargs)
+ super().__init__(**kwargs)
def validate(self, obj, value):
- if isinstance(value, self.klass):
+ assert self.klass is not None
+ if isinstance(value, self.klass): # type:ignore[arg-type]
return value
else:
self.error(obj, value)
@@ -1856,7 +2034,7 @@ class Instance(ClassBasedTraitType):
else:
result = describe("a", self.klass)
if self.allow_none:
- result += ' or None'
+ result += " or None"
return result
def instance_init(self, obj):
@@ -1870,8 +2048,10 @@ class Instance(ClassBasedTraitType):
def make_dynamic_default(self):
if (self.default_args is None) and (self.default_kwargs is None):
return None
- return self.klass(*(self.default_args or ()),
- **(self.default_kwargs or {}))
+ assert self.klass is not None
+ return self.klass(
+ *(self.default_args or ()), **(self.default_kwargs or {})
+ ) # type:ignore[operator]
def default_value_repr(self):
return repr(self.make_dynamic_default())
@@ -1880,23 +2060,25 @@ class Instance(ClassBasedTraitType):
return _safe_literal_eval(s)
-class ForwardDeclaredMixin(object):
+class ForwardDeclaredMixin:
"""
Mixin for forward-declared versions of Instance and Type.
"""
+
def _resolve_string(self, string):
"""
Find the specified class name by looking for it in the module in which
our this_class attribute was defined.
"""
- modname = self.this_class.__module__
- return import_item('.'.join([modname, string]))
+ modname = self.this_class.__module__ # type:ignore[attr-defined]
+ return import_item(".".join([modname, string]))
class ForwardDeclaredType(ForwardDeclaredMixin, Type):
"""
Forward-declared version of Type.
"""
+
pass
@@ -1904,6 +2086,7 @@ class ForwardDeclaredInstance(ForwardDeclaredMixin, Instance):
"""
Forward-declared version of Instance.
"""
+
pass
@@ -1915,15 +2098,16 @@ class This(ClassBasedTraitType):
always validate default values, ``allow_none`` is *always* true.
"""
- info_text = 'an instance of the same type as the receiver or None'
+ info_text = "an instance of the same type as the receiver or None"
def __init__(self, **kwargs):
- super(This, self).__init__(None, **kwargs)
+ super().__init__(None, **kwargs)
def validate(self, obj, value):
# What if value is a superclass of obj.__class__? This is
# complicated if it was the superclass that defined the This
# trait.
+ assert self.this_class is not None
if isinstance(value, self.this_class) or (value is None):
return value
else:
@@ -1952,13 +2136,13 @@ class Union(TraitType):
"""
self.trait_types = list(trait_types)
self.info_text = " or ".join([tt.info() for tt in self.trait_types])
- super(Union, self).__init__(**kwargs)
+ super().__init__(**kwargs)
def default(self, obj=None):
- default = super(Union, self).default(obj)
- for t in self.trait_types:
+ default = super().default(obj)
+ for trait in self.trait_types:
if default is Undefined:
- default = t.default(obj)
+ default = trait.default(obj)
else:
break
return default
@@ -1966,12 +2150,12 @@ class Union(TraitType):
def class_init(self, cls, name):
for trait_type in reversed(self.trait_types):
trait_type.class_init(cls, None)
- super(Union, self).class_init(cls, name)
+ super().class_init(cls, name)
def instance_init(self, obj):
for trait_type in reversed(self.trait_types):
trait_type.instance_init(obj)
- super(Union, self).instance_init(obj)
+ super().instance_init(obj)
def validate(self, obj, value):
with obj.cross_validation_lock:
@@ -1980,7 +2164,7 @@ class Union(TraitType):
v = trait_type._validate(obj, value)
# In the case of an element trait, the name is None
if self.name is not None:
- setattr(obj, '_' + self.name + '_metadata', trait_type.metadata)
+ setattr(obj, "_" + self.name + "_metadata", trait_type.metadata)
return v
except TraitError:
continue
@@ -1993,16 +2177,17 @@ class Union(TraitType):
return Union(self.trait_types + [other])
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Basic TraitTypes implementations/subclasses
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
class Any(TraitType):
"""A trait which allows any value."""
- default_value = None
+
+ default_value: t.Optional[t.Any] = None
allow_none = True
- info_text = 'any value'
+ info_text = "any value"
def _validate_bounds(trait, obj, value):
@@ -2017,15 +2202,17 @@ def _validate_bounds(trait, obj, value):
"The value of the '{name}' trait of {klass} instance should "
"not be less than {min_bound}, but a value of {value} was "
"specified".format(
- name=trait.name, klass=class_of(obj),
- value=value, min_bound=trait.min))
+ name=trait.name, klass=class_of(obj), value=value, min_bound=trait.min
+ )
+ )
if trait.max is not None and value > trait.max:
raise TraitError(
"The value of the '{name}' trait of {klass} instance should "
"not be greater than {max_bound}, but a value of {value} was "
"specified".format(
- name=trait.name, klass=class_of(obj),
- value=value, max_bound=trait.max))
+ name=trait.name, klass=class_of(obj), value=value, max_bound=trait.max
+ )
+ )
return value
@@ -2033,13 +2220,12 @@ class Int(TraitType):
"""An int trait."""
default_value = 0
- info_text = 'an int'
+ info_text = "an int"
def __init__(self, default_value=Undefined, allow_none=False, **kwargs):
- self.min = kwargs.pop('min', None)
- self.max = kwargs.pop('max', None)
- super(Int, self).__init__(default_value=default_value,
- allow_none=allow_none, **kwargs)
+ self.min = kwargs.pop("min", None)
+ self.max = kwargs.pop("max", None)
+ super().__init__(default_value=default_value, allow_none=allow_none, **kwargs)
def validate(self, obj, value):
if not isinstance(value, int):
@@ -2047,7 +2233,7 @@ class Int(TraitType):
return _validate_bounds(self, obj, value)
def from_string(self, s):
- if self.allow_none and s == 'None':
+ if self.allow_none and s == "None":
return None
return int(s)
@@ -2071,13 +2257,12 @@ class Float(TraitType):
"""A float trait."""
default_value = 0.0
- info_text = 'a float'
+ info_text = "a float"
def __init__(self, default_value=Undefined, allow_none=False, **kwargs):
- self.min = kwargs.pop('min', -float('inf'))
- self.max = kwargs.pop('max', float('inf'))
- super(Float, self).__init__(default_value=default_value,
- allow_none=allow_none, **kwargs)
+ self.min = kwargs.pop("min", -float("inf"))
+ self.max = kwargs.pop("max", float("inf"))
+ super().__init__(default_value=default_value, allow_none=allow_none, **kwargs)
def validate(self, obj, value):
if isinstance(value, int):
@@ -2087,7 +2272,7 @@ class Float(TraitType):
return _validate_bounds(self, obj, value)
def from_string(self, s):
- if self.allow_none and s == 'None':
+ if self.allow_none and s == "None":
return None
return float(s)
@@ -2107,7 +2292,7 @@ class Complex(TraitType):
"""A trait for complex numbers."""
default_value = 0.0 + 0.0j
- info_text = 'a complex number'
+ info_text = "a complex number"
def validate(self, obj, value):
if isinstance(value, complex):
@@ -2117,7 +2302,7 @@ class Complex(TraitType):
self.error(obj, value)
def from_string(self, s):
- if self.allow_none and s == 'None':
+ if self.allow_none and s == "None":
return None
return complex(s)
@@ -2125,20 +2310,21 @@ class Complex(TraitType):
class CComplex(Complex):
"""A casting version of the complex number trait."""
- def validate (self, obj, value):
+ def validate(self, obj, value):
try:
return complex(value)
except Exception:
self.error(obj, value)
+
# We should always be explicit about whether we're using bytes or unicode, both
# for Python 3 conversion and for reliable unicode behaviour on Python 2. So
# we don't have a Str type.
class Bytes(TraitType):
"""A trait for byte strings."""
- default_value = b''
- info_text = 'a bytes object'
+ default_value = b""
+ info_text = "a bytes object"
def validate(self, obj, value):
if isinstance(value, bytes):
@@ -2157,7 +2343,8 @@ class Bytes(TraitType):
warn(
"Supporting extra quotes around Bytes is deprecated in traitlets 5.0. "
"Use %r instead of %r." % (s, old_s),
- FutureWarning)
+ FutureWarning,
+ )
break
return s.encode("utf8")
@@ -2175,22 +2362,22 @@ class CBytes(Bytes):
class Unicode(TraitType):
"""A trait for unicode strings."""
- default_value = ''
- info_text = 'a unicode string'
+ default_value = ""
+ info_text = "a unicode string"
def validate(self, obj, value):
if isinstance(value, str):
return value
if isinstance(value, bytes):
try:
- return value.decode('ascii', 'strict')
+ return value.decode("ascii", "strict")
except UnicodeDecodeError:
msg = "Could not decode {!r} for unicode trait '{}' of {} instance."
raise TraitError(msg.format(value, self.name, class_of(obj)))
self.error(obj, value)
def from_string(self, s):
- if self.allow_none and s == 'None':
+ if self.allow_none and s == "None":
return None
s = os.path.expanduser(s)
if len(s) >= 2:
@@ -2202,11 +2389,11 @@ class Unicode(TraitType):
warn(
"Supporting extra quotes around strings is deprecated in traitlets 5.0. "
"You can use %r instead of %r if you require traitlets >=5." % (s, old_s),
- FutureWarning)
+ FutureWarning,
+ )
return s
-
class CUnicode(Unicode):
"""A casting version of the unicode trait."""
@@ -2221,9 +2408,10 @@ class ObjectName(TraitType):
"""A string holding a valid object name in this version of Python.
This does not check that the name exists in any scope."""
+
info_text = "a valid object identifier in Python"
- coerce_str = staticmethod(lambda _,s: s)
+ coerce_str = staticmethod(lambda _, s: s) # type:ignore[no-any-return]
def validate(self, obj, value):
value = self.coerce_str(obj, value)
@@ -2233,17 +2421,18 @@ class ObjectName(TraitType):
self.error(obj, value)
def from_string(self, s):
- if self.allow_none and s == 'None':
+ if self.allow_none and s == "None":
return None
return s
+
class DottedObjectName(ObjectName):
"""A string holding a valid dotted object name in Python, such as A.b3._c"""
+
def validate(self, obj, value):
value = self.coerce_str(obj, value)
- if isinstance(value, str) and all(isidentifier(a)
- for a in value.split('.')):
+ if isinstance(value, str) and all(isidentifier(a) for a in value.split(".")):
return value
self.error(obj, value)
@@ -2252,7 +2441,7 @@ class Bool(TraitType):
"""A boolean (True, False) trait."""
default_value = False
- info_text = 'a boolean'
+ info_text = "a boolean"
def validate(self, obj, value):
if isinstance(value, bool):
@@ -2265,12 +2454,12 @@ class Bool(TraitType):
self.error(obj, value)
def from_string(self, s):
- if self.allow_none and s == 'None':
+ if self.allow_none and s == "None":
return None
s = s.lower()
- if s in {'true', '1'}:
+ if s in {"true", "1"}:
return True
- elif s in {'false', '0'}:
+ elif s in {"false", "0"}:
return False
else:
raise ValueError("%r is not 1, 0, true, or false")
@@ -2291,30 +2480,28 @@ class Enum(TraitType):
def __init__(self, values, default_value=Undefined, **kwargs):
self.values = values
- if kwargs.get('allow_none', False) and default_value is Undefined:
+ if kwargs.get("allow_none", False) and default_value is Undefined:
default_value = None
- super(Enum, self).__init__(default_value, **kwargs)
+ super().__init__(default_value, **kwargs)
def validate(self, obj, value):
if value in self.values:
- return value
+ return value
self.error(obj, value)
def _choices_str(self, as_rst=False):
- """ Returns a description of the trait choices (not none)."""
+ """Returns a description of the trait choices (not none)."""
choices = self.values
if as_rst:
- choices = '|'.join('``%r``' % x for x in choices)
+ choices = "|".join("``%r``" % x for x in choices)
else:
choices = repr(list(choices))
return choices
def _info(self, as_rst=False):
- """ Returns a description of the trait."""
- none = (' or %s' % ('`None`' if as_rst else 'None')
- if self.allow_none else
- '')
- return 'any of %s%s' % (self._choices_str(as_rst), none)
+ """Returns a description of the trait."""
+ none = " or %s" % ("`None`" if as_rst else "None") if self.allow_none else ""
+ return f"any of {self._choices_str(as_rst)}{none}"
def info(self):
return self._info(as_rst=False)
@@ -2345,11 +2532,9 @@ class CaselessStrEnum(Enum):
self.error(obj, value)
def _info(self, as_rst=False):
- """ Returns a description of the trait."""
- none = (' or %s' % ('`None`' if as_rst else 'None')
- if self.allow_none else
- '')
- return 'any of %s (case-insensitive)%s' % (self._choices_str(as_rst), none)
+ """Returns a description of the trait."""
+ none = " or %s" % ("`None`" if as_rst else "None") if self.allow_none else ""
+ return f"any of {self._choices_str(as_rst)} (case-insensitive){none}"
def info(self):
return self._info(as_rst=False)
@@ -2365,8 +2550,14 @@ class FuzzyEnum(Enum):
#: If True, choices match anywhere in the string, otherwise match prefixes.
substring_matching = False
- def __init__(self, values, default_value=Undefined,
- case_sensitive=False, substring_matching=False, **kwargs):
+ def __init__(
+ self,
+ values,
+ default_value=Undefined,
+ case_sensitive=False,
+ substring_matching=False,
+ **kwargs,
+ ):
self.case_sensitive = case_sensitive
self.substring_matching = substring_matching
super().__init__(values, default_value=default_value, **kwargs)
@@ -2377,9 +2568,11 @@ class FuzzyEnum(Enum):
conv_func = (lambda c: c) if self.case_sensitive else lambda c: c.lower()
substring_matching = self.substring_matching
- match_func = ((lambda v, c: v in c)
- if substring_matching
- else (lambda v, c: c.startswith(v)))
+ match_func = (
+ (lambda v, c: v in c)
+ if substring_matching
+ else (lambda v, c: c.startswith(v)) # type:ignore[no-any-return]
+ )
value = conv_func(value)
choices = self.values
matches = [match_func(value, conv_func(c)) for c in choices]
@@ -2391,15 +2584,11 @@ class FuzzyEnum(Enum):
self.error(obj, value)
def _info(self, as_rst=False):
- """ Returns a description of the trait."""
- none = (' or %s' % ('`None`' if as_rst else 'None')
- if self.allow_none else
- '')
- case = 'sensitive' if self.case_sensitive else 'insensitive'
- substr = 'substring' if self.substring_matching else 'prefix'
- return 'any case-%s %s of %s%s' % (case, substr,
- self._choices_str(as_rst),
- none)
+ """Returns a description of the trait."""
+ none = " or %s" % ("`None`" if as_rst else "None") if self.allow_none else ""
+ case = "sensitive" if self.case_sensitive else "insensitive"
+ substr = "substring" if self.substring_matching else "prefix"
+ return f"any case-{case} {substr} of {self._choices_str(as_rst)}{none}"
def info(self):
return self._info(as_rst=False)
@@ -2414,11 +2603,11 @@ class Container(Instance):
To be subclassed by overriding klass.
"""
- klass = None
- _cast_types = ()
+ klass: t.Optional[t.Union[str, t.Type[t.Any]]] = None
+ _cast_types: t.Any = ()
_valid_defaults = SequenceTypes
_trait = None
- _literal_from_string_pairs = ("[]", "()")
+ _literal_from_string_pairs: t.Any = ("[]", "()")
def __init__(self, trait=None, default_value=Undefined, **kwargs):
"""Create a container trait type from a list, set, or tuple.
@@ -2468,7 +2657,7 @@ class Container(Instance):
default_value = Undefined
if default_value is Undefined:
- args = ()
+ args: t.Any = ()
elif default_value is None:
# default_value back on kwargs for super() to handle
args = ()
@@ -2476,9 +2665,7 @@ class Container(Instance):
elif isinstance(default_value, self._valid_defaults):
args = (default_value,)
else:
- raise TypeError(
- "default value of %s was %s" % (self.__class__.__name__, default_value)
- )
+ raise TypeError(f"default value of {self.__class__.__name__} was {default_value}")
if is_trait(trait):
if isinstance(trait, type):
@@ -2490,16 +2677,15 @@ class Container(Instance):
)
self._trait = trait() if isinstance(trait, type) else trait
elif trait is not None:
- raise TypeError(
- "`trait` must be a Trait or None, got %s" % repr_type(trait)
- )
+ raise TypeError("`trait` must be a Trait or None, got %s" % repr_type(trait))
- super(Container, self).__init__(klass=self.klass, args=args, **kwargs)
+ super().__init__(klass=self.klass, args=args, **kwargs)
def validate(self, obj, value):
if isinstance(value, self._cast_types):
- value = self.klass(value)
- value = super(Container, self).validate(obj, value)
+ assert self.klass is not None
+ value = self.klass(value) # type:ignore[operator]
+ value = super().validate(obj, value)
if value is None:
return value
@@ -2518,17 +2704,18 @@ class Container(Instance):
self.error(obj, v, error)
else:
validated.append(v)
- return self.klass(validated)
+ assert self.klass is not None
+ return self.klass(validated) # type:ignore[operator]
def class_init(self, cls, name):
if isinstance(self._trait, TraitType):
self._trait.class_init(cls, None)
- super(Container, self).class_init(cls, name)
+ super().class_init(cls, name)
def instance_init(self, obj):
if isinstance(self._trait, TraitType):
self._trait.instance_init(obj)
- super(Container, self).instance_init(obj)
+ super().instance_init(obj)
def from_string(self, s):
"""Load value from a single string"""
@@ -2545,6 +2732,7 @@ class Container(Instance):
This is where we parse CLI configuration
"""
+ assert self.klass is not None
if len(s_list) == 1:
# check for deprecated --Class.trait="['a', 'b', 'c']"
r = s_list[0]
@@ -2558,7 +2746,7 @@ class Container(Instance):
clsname = self.this_class.__name__ + "."
else:
clsname = ""
-
+ assert self.name is not None
warn(
"--{0}={1} for containers is deprecated in traitlets 5.0. "
"You can pass `--{0} item` ... multiple times to add items to a list.".format(
@@ -2566,16 +2754,17 @@ class Container(Instance):
),
FutureWarning,
)
- return self.klass(literal_eval(r))
+ return self.klass(literal_eval(r)) # type:ignore[operator]
sig = inspect.signature(self.item_from_string)
if "index" in sig.parameters:
item_from_string = self.item_from_string
else:
# backward-compat: allow item_from_string to ignore index arg
- item_from_string = lambda s, index=None: self.item_from_string(s)
+ item_from_string = lambda s, index=None: self.item_from_string(s) # noqa[E371]
+
return self.klass(
[item_from_string(s, index=idx) for idx, s in enumerate(s_list)]
- )
+ ) # type:ignore[operator]
def item_from_string(self, s, index=None):
"""Cast a single item from a string
@@ -2590,8 +2779,9 @@ class Container(Instance):
class List(Container):
"""An instance of a Python list."""
+
klass = list
- _cast_types = (tuple,)
+ _cast_types: t.Any = (tuple,)
def __init__(
self,
@@ -2629,12 +2819,13 @@ class List(Container):
"""
self._minlen = minlen
self._maxlen = maxlen
- super(List, self).__init__(trait=trait, default_value=default_value,
- **kwargs)
+ super().__init__(trait=trait, default_value=default_value, **kwargs)
def length_error(self, obj, value):
- e = "The '%s' trait of %s instance must be of length %i <= L <= %i, but a value of %s was specified." \
+ e = (
+ "The '%s' trait of %s instance must be of length %i <= L <= %i, but a value of %s was specified."
% (self.name, class_of(obj), self._minlen, self._maxlen, value)
+ )
raise TraitError(e)
def validate_elements(self, obj, value):
@@ -2642,7 +2833,7 @@ class List(Container):
if length < self._minlen or length > self._maxlen:
self.length_error(obj, value)
- return super(List, self).validate_elements(obj, value)
+ return super().validate_elements(obj, value)
def set(self, obj, value):
if isinstance(value, str):
@@ -2653,7 +2844,8 @@ class List(Container):
class Set(List):
"""An instance of a Python set."""
- klass = set
+
+ klass = set # type:ignore[assignment]
_cast_types = (tuple, list)
_literal_from_string_pairs = ("[]", "()", "{}")
@@ -2693,14 +2885,14 @@ class Set(List):
maxlen : Int [ default sys.maxsize ]
The maximum length of the input list
"""
- super(Set, self).__init__(trait, default_value, minlen, maxlen, **kwargs)
+ super().__init__(trait, default_value, minlen, maxlen, **kwargs)
def default_value_repr(self):
# Ensure default value is sorted for a reproducible build
list_repr = repr(sorted(self.make_dynamic_default()))
- if list_repr == '[]':
- return 'set()'
- return '{'+list_repr[1:-1]+'}'
+ if list_repr == "[]":
+ return "set()"
+ return "{" + list_repr[1:-1] + "}"
class Tuple(Container):
@@ -2759,7 +2951,7 @@ class Tuple(Container):
default_value = Undefined
if default_value is Undefined:
- args = ()
+ args: t.Any = ()
elif default_value is None:
# default_value back on kwargs for super() to handle
args = ()
@@ -2767,9 +2959,7 @@ class Tuple(Container):
elif isinstance(default_value, self._valid_defaults):
args = (default_value,)
else:
- raise TypeError(
- "default value of %s was %s" % (self.__class__.__name__, default_value)
- )
+ raise TypeError(f"default value of {self.__class__.__name__} was {default_value}")
self._traits = []
for trait in traits:
@@ -2804,14 +2994,16 @@ class Tuple(Container):
# nothing to validate
return value
if len(value) != len(self._traits):
- e = "The '%s' trait of %s instance requires %i elements, but a value of %s was specified." \
+ e = (
+ "The '%s' trait of %s instance requires %i elements, but a value of %s was specified."
% (self.name, class_of(obj), len(self._traits), repr_type(value))
+ )
raise TraitError(e)
validated = []
- for t, v in zip(self._traits, value):
+ for trait, v in zip(self._traits, value):
try:
- v = t._validate(obj, v)
+ v = trait._validate(obj, v)
except TraitError as error:
self.error(obj, v, error)
else:
@@ -2845,11 +3037,18 @@ class Dict(Instance):
.. versionchanged:: 5.0
Deprecated ambiguous ``trait``, ``traits`` args in favor of ``value_trait``, ``per_key_traits``.
"""
+
_value_trait = None
_key_trait = None
- def __init__(self, value_trait=None, per_key_traits=None, key_trait=None, default_value=Undefined,
- **kwargs):
+ def __init__(
+ self,
+ value_trait=None,
+ per_key_traits=None,
+ key_trait=None,
+ default_value=Undefined,
+ **kwargs,
+ ):
"""Create a dict trait type from a Python dict.
The default value is created by doing ``dict(default_value)``,
@@ -2874,23 +3073,26 @@ class Dict(Instance):
Examples
--------
- >>> d = Dict(Unicode())
a dict whose values must be text
+ >>> d = Dict(Unicode())
- >>> d2 = Dict(per_key_traits={"n": Integer(), "s": Unicode()})
d2['n'] must be an integer
d2['s'] must be text
+ >>> d2 = Dict(per_key_traits={"n": Integer(), "s": Unicode()})
- >>> d3 = Dict(value_trait=Integer(), key_trait=Unicode())
d3's keys must be text
d3's values must be integers
+ >>> d3 = Dict(value_trait=Integer(), key_trait=Unicode())
+
"""
# handle deprecated keywords
- trait = kwargs.pop('trait', None)
+ trait = kwargs.pop("trait", None)
if trait is not None:
if value_trait is not None:
- raise TypeError("Found a value for both `value_trait` and its deprecated alias `trait`.")
+ raise TypeError(
+ "Found a value for both `value_trait` and its deprecated alias `trait`."
+ )
value_trait = trait
warn(
"Keyword `trait` is deprecated in traitlets 5.0, use `value_trait` instead",
@@ -2900,7 +3102,9 @@ class Dict(Instance):
traits = kwargs.pop("traits", None)
if traits is not None:
if per_key_traits is not None:
- raise TypeError("Found a value for both `per_key_traits` and its deprecated alias `traits`.")
+ raise TypeError(
+ "Found a value for both `per_key_traits` and its deprecated alias `traits`."
+ )
per_key_traits = traits
warn(
"Keyword `traits` is deprecated in traitlets 5.0, use `per_key_traits` instead",
@@ -2923,30 +3127,38 @@ class Dict(Instance):
if default_value is Undefined:
default_value = {}
if default_value is None:
- args = None
+ args: t.Any = None
elif isinstance(default_value, dict):
args = (default_value,)
elif isinstance(default_value, SequenceTypes):
args = (default_value,)
else:
- raise TypeError('default value of Dict was %s' % default_value)
+ raise TypeError("default value of Dict was %s" % default_value)
# Case where a type of TraitType is provided rather than an instance
if is_trait(value_trait):
if isinstance(value_trait, type):
- warn("Traits should be given as instances, not types (for example, `Int()`, not `Int`)"
- " Passing types is deprecated in traitlets 4.1.",
- DeprecationWarning, stacklevel=2)
+ warn(
+ "Traits should be given as instances, not types (for example, `Int()`, not `Int`)"
+ " Passing types is deprecated in traitlets 4.1.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
value_trait = value_trait()
self._value_trait = value_trait
elif value_trait is not None:
- raise TypeError("`value_trait` must be a Trait or None, got %s" % repr_type(value_trait))
+ raise TypeError(
+ "`value_trait` must be a Trait or None, got %s" % repr_type(value_trait)
+ )
if is_trait(key_trait):
if isinstance(key_trait, type):
- warn("Traits should be given as instances, not types (for example, `Int()`, not `Int`)"
- " Passing types is deprecated in traitlets 4.1.",
- DeprecationWarning, stacklevel=2)
+ warn(
+ "Traits should be given as instances, not types (for example, `Int()`, not `Int`)"
+ " Passing types is deprecated in traitlets 4.1.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
key_trait = key_trait()
self._key_trait = key_trait
elif key_trait is not None:
@@ -2954,15 +3166,18 @@ class Dict(Instance):
self._per_key_traits = per_key_traits
- super(Dict, self).__init__(klass=dict, args=args, **kwargs)
+ super().__init__(klass=dict, args=args, **kwargs)
- def element_error(self, obj, element, validator, side='Values'):
- e = side + " of the '%s' trait of %s instance must be %s, but a value of %s was specified." \
+ def element_error(self, obj, element, validator, side="Values"):
+ e = (
+ side
+ + " of the '%s' trait of %s instance must be %s, but a value of %s was specified."
% (self.name, class_of(obj), validator.info(), repr_type(element))
+ )
raise TraitError(e)
def validate(self, obj, value):
- value = super(Dict, self).validate(obj, value)
+ value = super().validate(obj, value)
if value is None:
return value
value = self.validate_elements(obj, value)
@@ -2981,17 +3196,17 @@ class Dict(Instance):
if key_trait:
try:
key = key_trait._validate(obj, key)
- except TraitError as error:
- self.element_error(obj, key, key_trait, 'Keys')
+ except TraitError:
+ self.element_error(obj, key, key_trait, "Keys")
active_value_trait = per_key_override.get(key, value_trait)
if active_value_trait:
try:
v = active_value_trait._validate(obj, v)
except TraitError:
- self.element_error(obj, v, active_value_trait, 'Values')
+ self.element_error(obj, v, active_value_trait, "Values")
validated[key] = v
- return self.klass(validated)
+ return self.klass(validated) # type:ignore
def class_init(self, cls, name):
if isinstance(self._value_trait, TraitType):
@@ -3001,7 +3216,7 @@ class Dict(Instance):
if self._per_key_traits is not None:
for trait in self._per_key_traits.values():
trait.class_init(cls, None)
- super(Dict, self).class_init(cls, name)
+ super().class_init(cls, name)
def instance_init(self, obj):
if isinstance(self._value_trait, TraitType):
@@ -3011,7 +3226,7 @@ class Dict(Instance):
if self._per_key_traits is not None:
for trait in self._per_key_traits.values():
trait.instance_init(obj)
- super(Dict, self).instance_init(obj)
+ super().instance_init(obj)
def from_string(self, s):
"""Load value from a single string"""
@@ -3036,11 +3251,7 @@ class Dict(Instance):
"""
if len(s_list) == 1 and s_list[0] == "None" and self.allow_none:
return None
- if (
- len(s_list) == 1
- and s_list[0].startswith("{")
- and s_list[0].endswith("}")
- ):
+ if len(s_list) == 1 and s_list[0].startswith("{") and s_list[0].endswith("}"):
warn(
"--{0}={1} for dict-traits is deprecated in traitlets 5.0. "
"You can pass --{0} <key=value> ... multiple times to add items to a dict.".format(
@@ -3068,10 +3279,13 @@ class Dict(Instance):
which will be merged in :meth:`.from_string_list`.
"""
- if '=' not in s:
+ if "=" not in s:
raise TraitError(
"'%s' options must have the form 'key=value', got %s"
- % (self.__class__.__name__, repr(s),)
+ % (
+ self.__class__.__name__,
+ repr(s),
+ )
)
key, value = s.split("=", 1)
@@ -3092,8 +3306,8 @@ class TCPAddress(TraitType):
This allows for both IPv4 IP addresses as well as hostnames.
"""
- default_value = ('127.0.0.1', 0)
- info_text = 'an (ip, port) tuple'
+ default_value = ("127.0.0.1", 0)
+ info_text = "an (ip, port) tuple"
def validate(self, obj, value):
if isinstance(value, tuple):
@@ -3105,11 +3319,11 @@ class TCPAddress(TraitType):
self.error(obj, value)
def from_string(self, s):
- if self.allow_none and s == 'None':
+ if self.allow_none and s == "None":
return None
- if ':' not in s:
- raise ValueError('Require `ip:port`, got %r' % s)
- ip, port = s.split(':', 1)
+ if ":" not in s:
+ raise ValueError("Require `ip:port`, got %r" % s)
+ ip, port = s.split(":", 1)
port = int(port)
return (ip, port)
@@ -3120,7 +3334,7 @@ class CRegExp(TraitType):
Accepts both strings and compiled regular expressions. The resulting
attribute will be a compiled regular expression."""
- info_text = 'a regular expression'
+ info_text = "a regular expression"
def validate(self, obj, value):
try:
@@ -3155,16 +3369,16 @@ class UseEnum(TraitType):
entity.color = 3 # USE: number (as int)
assert entity.color is Color.green
"""
- default_value = None
+
+ default_value: t.Optional[enum.Enum] = None
info_text = "Trait type adapter to a Enum class"
def __init__(self, enum_class, default_value=None, **kwargs):
- assert issubclass(enum_class, enum.Enum), \
- "REQUIRE: enum.Enum, but was: %r" % enum_class
+ assert issubclass(enum_class, enum.Enum), "REQUIRE: enum.Enum, but was: %r" % enum_class
allow_none = kwargs.get("allow_none", False)
if default_value is None and not allow_none:
default_value = list(enum_class.__members__.values())[0]
- super(UseEnum, self).__init__(default_value=default_value, **kwargs)
+ super().__init__(default_value=default_value, **kwargs)
self.enum_class = enum_class
self.name_prefix = enum_class.__name__ + "."
@@ -3207,19 +3421,17 @@ class UseEnum(TraitType):
self.error(obj, value)
def _choices_str(self, as_rst=False):
- """ Returns a description of the trait choices (not none)."""
+ """Returns a description of the trait choices (not none)."""
choices = self.enum_class.__members__.keys()
if as_rst:
- return '|'.join('``%r``' % x for x in choices)
+ return "|".join("``%r``" % x for x in choices)
else:
return repr(list(choices)) # Listify because py3.4- prints odict-class
def _info(self, as_rst=False):
- """ Returns a description of the trait."""
- none = (' or %s' % ('`None`' if as_rst else 'None')
- if self.allow_none else
- '')
- return 'any of %s%s' % (self._choices_str(as_rst), none)
+ """Returns a description of the trait."""
+ none = " or %s" % ("`None`" if as_rst else "None") if self.allow_none else ""
+ return f"any of {self._choices_str(as_rst)}{none}"
def info(self):
return self._info(as_rst=False)
@@ -3228,7 +3440,6 @@ class UseEnum(TraitType):
return self._info(as_rst=True)
-
class Callable(TraitType):
"""A trait which is callable.
@@ -3237,7 +3448,7 @@ class Callable(TraitType):
Classes are callable, as are instances
with a __call__() method."""
- info_text = 'a callable'
+ info_text = "a callable"
def validate(self, obj, value):
if callable(value):
@@ -3252,7 +3463,8 @@ def _add_all():
do in a function to avoid iterating through globals while defining local variables
"""
for _name, _value in globals().items():
- if not _name.startswith('_') and isinstance(_value, type) and issubclass(_value, TraitType):
+ if not _name.startswith("_") and isinstance(_value, type) and issubclass(_value, TraitType):
__all__.append(_name)
+
_add_all()
diff --git a/contrib/python/traitlets/py3/traitlets/utils/__init__.py b/contrib/python/traitlets/py3/traitlets/utils/__init__.py
index 0fbba3d358..1bf11b2e1e 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/__init__.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/__init__.py
@@ -1,9 +1,10 @@
import os
+
# vestigal things from IPython_genutils.
-def cast_unicode(s, encoding='utf-8'):
+def cast_unicode(s, encoding="utf-8"):
if isinstance(s, bytes):
- return s.decode(encoding, 'replace')
+ return s.decode(encoding, "replace")
return s
@@ -58,9 +59,7 @@ def filefind(filename, path_dirs=None):
if os.path.isfile(testname):
return os.path.abspath(testname)
- raise IOError(
- "File %r does not exist in any of the search paths: %r" % (filename, path_dirs)
- )
+ raise OSError(f"File {filename!r} does not exist in any of the search paths: {path_dirs!r}")
def expand_path(s):
diff --git a/contrib/python/traitlets/py3/traitlets/utils/bunch.py b/contrib/python/traitlets/py3/traitlets/utils/bunch.py
index 2edb830ad6..7982bbb93c 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/bunch.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/bunch.py
@@ -6,20 +6,21 @@ attribute-access of items on a dict.
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
-class Bunch(dict):
+
+class Bunch(dict): # type:ignore[type-arg]
"""A dict with attribute-access"""
+
def __getattr__(self, key):
try:
return self.__getitem__(key)
except KeyError:
raise AttributeError(key)
-
+
def __setattr__(self, key, value):
self.__setitem__(key, value)
-
+
def __dir__(self):
# py2-compat: can't use super because dict doesn't have __dir__
names = dir({})
names.extend(self.keys())
return names
-
diff --git a/contrib/python/traitlets/py3/traitlets/utils/decorators.py b/contrib/python/traitlets/py3/traitlets/utils/decorators.py
index 656f968c8d..60b9ab24b3 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/decorators.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/decorators.py
@@ -1,8 +1,7 @@
"""Useful decorators for Traitlets users."""
import copy
-
-from inspect import Signature, Parameter, signature
+from inspect import Parameter, Signature, signature
from ..traitlets import Undefined
@@ -17,7 +16,7 @@ def signature_has_traits(cls):
traits = [
(name, _get_default(value.default_value))
for name, value in cls.class_traits().items()
- if not name.startswith('_')
+ if not name.startswith("_")
]
# Taking the __init__ signature, as the cls signature is not initialized yet
@@ -33,7 +32,10 @@ def signature_has_traits(cls):
# Copy the parameter
parameter = copy.copy(old_signature.parameters[parameter_name])
- if parameter.kind is Parameter.POSITIONAL_ONLY or parameter.kind is Parameter.POSITIONAL_OR_KEYWORD:
+ if (
+ parameter.kind is Parameter.POSITIONAL_ONLY
+ or parameter.kind is Parameter.POSITIONAL_OR_KEYWORD
+ ):
old_positional_parameters.append(parameter)
elif parameter.kind is Parameter.VAR_POSITIONAL:
@@ -49,8 +51,9 @@ def signature_has_traits(cls):
# because it can't accept traits as keyword arguments
if old_var_keyword_parameter is None:
raise RuntimeError(
- 'The {} constructor does not take **kwargs, which means that the signature can not be expanded with trait names'
- .format(cls)
+ "The {} constructor does not take **kwargs, which means that the signature can not be expanded with trait names".format(
+ cls
+ )
)
new_parameters = []
diff --git a/contrib/python/traitlets/py3/traitlets/utils/descriptions.py b/contrib/python/traitlets/py3/traitlets/utils/descriptions.py
index 7b2996491f..232eb0e728 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/descriptions.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/descriptions.py
@@ -46,11 +46,11 @@ def describe(article, value, name=None, verbose=False, capital=False):
Definite description:
>>> describe("the", object())
- "the object at '0x10741f1b0'"
+ "the object at '...'"
>>> describe("the", object)
- "the type 'object'"
+ 'the object object'
>>> describe("the", type(object))
- "the type 'type'"
+ 'the type type'
Definitely named description:
@@ -71,7 +71,7 @@ def describe(article, value, name=None, verbose=False, capital=False):
if article == "the" or (article is None and not inspect.isclass(value)):
if name is not None:
- result = "{} {}".format(typename, name)
+ result = f"{typename} {name}"
if article is not None:
return add_article(result, True, capital)
else:
@@ -86,7 +86,10 @@ def describe(article, value, name=None, verbose=False, capital=False):
elif isinstance(value, types.MethodType):
name = value.__func__.__name__
tick_wrap = True
- elif type(value).__repr__ in (object.__repr__, type.__repr__):
+ elif type(value).__repr__ in (
+ object.__repr__,
+ type.__repr__,
+ ): # type:ignore[comparison-overlap]
name = "at '%s'" % hex(id(value))
verbose = False
else:
@@ -96,24 +99,24 @@ def describe(article, value, name=None, verbose=False, capital=False):
name = _prefix(value) + name
if tick_wrap:
name = name.join("''")
- return describe(article, value, name=name,
- verbose=verbose, capital=capital)
+ return describe(article, value, name=name, verbose=verbose, capital=capital)
elif article in ("a", "an") or article is None:
if article is None:
return typename
return add_article(typename, False, capital)
else:
- raise ValueError("The 'article' argument should "
- "be 'the', 'a', 'an', or None not %r" % article)
+ raise ValueError(
+ "The 'article' argument should be 'the', 'a', 'an', or None not %r" % article
+ )
+
-
def _prefix(value):
if isinstance(value, types.MethodType):
- name = describe(None, value.__self__, verbose=True) + '.'
+ name = describe(None, value.__self__, verbose=True) + "."
else:
module = inspect.getmodule(value)
if module is not None and module.__name__ != "builtins":
- name = module.__name__ + '.'
+ name = module.__name__ + "."
else:
name = ""
return name
@@ -150,11 +153,11 @@ def add_article(name, definite=False, capital=False):
if definite:
result = "the " + name
else:
- first_letters = re.compile(r'[\W_]+').sub('', name)
- if first_letters[:1].lower() in 'aeiou':
- result = 'an ' + name
+ first_letters = re.compile(r"[\W_]+").sub("", name)
+ if first_letters[:1].lower() in "aeiou":
+ result = "an " + name
else:
- result = 'a ' + name
+ result = "a " + name
if capital:
return result[0].upper() + result[1:]
else:
@@ -167,5 +170,5 @@ def repr_type(obj):
error messages.
"""
the_type = type(obj)
- msg = '{!r} {!r}'.format(obj, the_type)
+ msg = f"{obj!r} {the_type!r}"
return msg
diff --git a/contrib/python/traitlets/py3/traitlets/utils/getargspec.py b/contrib/python/traitlets/py3/traitlets/utils/getargspec.py
index 22511437bd..e2b1f235c8 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/getargspec.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/getargspec.py
@@ -1,6 +1,6 @@
"""
getargspec excerpted from:
-
+
sphinx.util.inspect
~~~~~~~~~~~~~~~~~~~
Helpers for inspecting Python modules.
@@ -9,10 +9,10 @@
"""
import inspect
+from functools import partial
# Unmodified from sphinx below this line
-from functools import partial
def getargspec(func):
"""Like inspect.getargspec but supports functools.partial as well."""
@@ -26,7 +26,7 @@ def getargspec(func):
kwoargs = list(argspec[4])
kwodefs = dict(argspec[5] or {})
if func.args:
- args = args[len(func.args):]
+ args = args[len(func.args) :]
for arg in func.keywords or ():
try:
i = args.index(arg) - len(args)
@@ -35,16 +35,15 @@ def getargspec(func):
del defaults[i]
except IndexError:
pass
- except ValueError: # must be a kwonly arg
+ except ValueError: # must be a kwonly arg
i = kwoargs.index(arg)
del kwoargs[i]
del kwodefs[arg]
- return inspect.FullArgSpec(args, argspec[1], argspec[2],
- tuple(defaults), kwoargs,
- kwodefs, argspec[6])
- while hasattr(func, '__wrapped__'):
+ return inspect.FullArgSpec(
+ args, argspec[1], argspec[2], tuple(defaults), kwoargs, kwodefs, argspec[6]
+ )
+ while hasattr(func, "__wrapped__"):
func = func.__wrapped__
if not inspect.isfunction(func):
- raise TypeError('%r is not a Python function' % func)
+ raise TypeError("%r is not a Python function" % func)
return inspect.getfullargspec(func)
-
diff --git a/contrib/python/traitlets/py3/traitlets/utils/importstring.py b/contrib/python/traitlets/py3/traitlets/utils/importstring.py
index defad8f183..7258e20bbe 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/importstring.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/importstring.py
@@ -23,7 +23,7 @@ def import_item(name):
"""
if not isinstance(name, str):
raise TypeError("import_item accepts strings, not '%s'." % type(name))
- parts = name.rsplit('.', 1)
+ parts = name.rsplit(".", 1)
if len(parts) == 2:
# called with 'foo.bar....'
package, obj = parts
@@ -31,7 +31,7 @@ def import_item(name):
try:
pak = getattr(module, obj)
except AttributeError:
- raise ImportError('No module named %s' % obj)
+ raise ImportError("No module named %s" % obj)
return pak
else:
# called with un-dotted string
diff --git a/contrib/python/traitlets/py3/traitlets/utils/nested_update.py b/contrib/python/traitlets/py3/traitlets/utils/nested_update.py
new file mode 100644
index 0000000000..7f09e171a3
--- /dev/null
+++ b/contrib/python/traitlets/py3/traitlets/utils/nested_update.py
@@ -0,0 +1,38 @@
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
+
+
+def nested_update(this, that):
+ """Merge two nested dictionaries.
+
+ Effectively a recursive ``dict.update``.
+
+ Examples
+ --------
+ Merge two flat dictionaries:
+ >>> nested_update(
+ ... {'a': 1, 'b': 2},
+ ... {'b': 3, 'c': 4}
+ ... )
+ {'a': 1, 'b': 3, 'c': 4}
+
+ Merge two nested dictionaries:
+ >>> nested_update(
+ ... {'x': {'a': 1, 'b': 2}, 'y': 5, 'z': 6},
+ ... {'x': {'b': 3, 'c': 4}, 'z': 7, '0': 8},
+ ... )
+ {'x': {'a': 1, 'b': 3, 'c': 4}, 'y': 5, 'z': 7, '0': 8}
+
+ """
+ for key, value in this.items():
+ if isinstance(value, dict):
+ if key in that and isinstance(that[key], dict):
+ nested_update(this[key], that[key])
+ elif key in that:
+ this[key] = that[key]
+
+ for key, value in that.items():
+ if key not in this:
+ this[key] = value
+
+ return this
diff --git a/contrib/python/traitlets/py3/traitlets/utils/sentinel.py b/contrib/python/traitlets/py3/traitlets/utils/sentinel.py
index 0760bec8b5..75e000f81b 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/sentinel.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/sentinel.py
@@ -4,8 +4,7 @@
# Distributed under the terms of the Modified BSD License.
-class Sentinel(object):
-
+class Sentinel:
def __init__(self, name, module, docstring=None):
self.name = name
self.module = module
@@ -13,7 +12,7 @@ class Sentinel(object):
self.__doc__ = docstring
def __repr__(self):
- return str(self.module) + '.' + self.name
+ return str(self.module) + "." + self.name
def __copy__(self):
return self
diff --git a/contrib/python/traitlets/py3/traitlets/utils/tests/test_bunch.py b/contrib/python/traitlets/py3/traitlets/utils/tests/test_bunch.py
index 3f71fab957..223124d7d5 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/tests/test_bunch.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/tests/test_bunch.py
@@ -1,14 +1,16 @@
from traitlets.utils.bunch import Bunch
+
def test_bunch():
b = Bunch(x=5, y=10)
- assert 'y' in b
- assert 'x' in b
+ assert "y" in b
+ assert "x" in b
assert b.x == 5
- b['a'] = 'hi'
- assert b.a == 'hi'
+ b["a"] = "hi"
+ assert b.a == "hi"
+
def test_bunch_dir():
b = Bunch(x=5, y=10)
- assert 'x' in dir(b)
- assert 'keys' in dir(b)
+ assert "x" in dir(b)
+ assert "keys" in dir(b)
diff --git a/contrib/python/traitlets/py3/traitlets/utils/tests/test_decorators.py b/contrib/python/traitlets/py3/traitlets/utils/tests/test_decorators.py
index aafd372f3c..5410c20137 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/tests/test_decorators.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/tests/test_decorators.py
@@ -1,69 +1,66 @@
+from inspect import Parameter, signature
from unittest import TestCase
-from inspect import Signature, Parameter, signature
-
from traitlets.traitlets import HasTraits, Int, Unicode
-
from traitlets.utils.decorators import signature_has_traits
class TestExpandSignature(TestCase):
-
def test_no_init(self):
@signature_has_traits
class Foo(HasTraits):
number1 = Int()
number2 = Int()
- value = Unicode('Hello')
+ value = Unicode("Hello")
parameters = signature(Foo).parameters
parameter_names = list(parameters)
- self.assertIs(parameters['args'].kind, Parameter.VAR_POSITIONAL)
- self.assertEqual('args', parameter_names[0])
+ self.assertIs(parameters["args"].kind, Parameter.VAR_POSITIONAL)
+ self.assertEqual("args", parameter_names[0])
- self.assertIs(parameters['number1'].kind, Parameter.KEYWORD_ONLY)
- self.assertIs(parameters['number2'].kind, Parameter.KEYWORD_ONLY)
- self.assertIs(parameters['value'].kind, Parameter.KEYWORD_ONLY)
+ self.assertIs(parameters["number1"].kind, Parameter.KEYWORD_ONLY)
+ self.assertIs(parameters["number2"].kind, Parameter.KEYWORD_ONLY)
+ self.assertIs(parameters["value"].kind, Parameter.KEYWORD_ONLY)
- self.assertIs(parameters['kwargs'].kind, Parameter.VAR_KEYWORD)
- self.assertEqual('kwargs', parameter_names[-1])
+ self.assertIs(parameters["kwargs"].kind, Parameter.VAR_KEYWORD)
+ self.assertEqual("kwargs", parameter_names[-1])
- f = Foo(number1=32, value='World')
+ f = Foo(number1=32, value="World")
self.assertEqual(f.number1, 32)
self.assertEqual(f.number2, 0)
- self.assertEqual(f.value, 'World')
+ self.assertEqual(f.value, "World")
def test_partial_init(self):
@signature_has_traits
class Foo(HasTraits):
number1 = Int()
number2 = Int()
- value = Unicode('Hello')
+ value = Unicode("Hello")
def __init__(self, arg1, **kwargs):
self.arg1 = arg1
- super(Foo, self).__init__(**kwargs)
+ super().__init__(**kwargs)
parameters = signature(Foo).parameters
parameter_names = list(parameters)
- self.assertIs(parameters['arg1'].kind, Parameter.POSITIONAL_OR_KEYWORD)
- self.assertEqual('arg1', parameter_names[0])
+ self.assertIs(parameters["arg1"].kind, Parameter.POSITIONAL_OR_KEYWORD)
+ self.assertEqual("arg1", parameter_names[0])
- self.assertIs(parameters['number1'].kind, Parameter.KEYWORD_ONLY)
- self.assertIs(parameters['number2'].kind, Parameter.KEYWORD_ONLY)
- self.assertIs(parameters['value'].kind, Parameter.KEYWORD_ONLY)
+ self.assertIs(parameters["number1"].kind, Parameter.KEYWORD_ONLY)
+ self.assertIs(parameters["number2"].kind, Parameter.KEYWORD_ONLY)
+ self.assertIs(parameters["value"].kind, Parameter.KEYWORD_ONLY)
- self.assertIs(parameters['kwargs'].kind, Parameter.VAR_KEYWORD)
- self.assertEqual('kwargs', parameter_names[-1])
+ self.assertIs(parameters["kwargs"].kind, Parameter.VAR_KEYWORD)
+ self.assertEqual("kwargs", parameter_names[-1])
- f = Foo(1, number1=32, value='World')
+ f = Foo(1, number1=32, value="World")
self.assertEqual(f.arg1, 1)
self.assertEqual(f.number1, 32)
self.assertEqual(f.number2, 0)
- self.assertEqual(f.value, 'World')
+ self.assertEqual(f.value, "World")
def test_duplicate_init(self):
@signature_has_traits
@@ -74,12 +71,12 @@ class TestExpandSignature(TestCase):
def __init__(self, number1, **kwargs):
self.test = number1
- super(Foo, self).__init__(number1=number1, **kwargs)
+ super().__init__(number1=number1, **kwargs)
parameters = signature(Foo).parameters
parameter_names = list(parameters)
- self.assertListEqual(parameter_names, ['number1', 'number2', 'kwargs'])
+ self.assertListEqual(parameter_names, ["number1", "number2", "kwargs"])
f = Foo(number1=32, number2=36)
self.assertEqual(f.test, 32)
@@ -91,7 +88,7 @@ class TestExpandSignature(TestCase):
class Foo(HasTraits):
number1 = Int()
number2 = Int()
- value = Unicode('Hello')
+ value = Unicode("Hello")
def __init__(self, arg1, arg2=None, *pos_args, **kw_args):
self.arg1 = arg1
@@ -99,37 +96,38 @@ class TestExpandSignature(TestCase):
self.pos_args = pos_args
self.kw_args = kw_args
- super(Foo, self).__init__(*pos_args, **kw_args)
+ super().__init__(*pos_args, **kw_args)
parameters = signature(Foo).parameters
parameter_names = list(parameters)
- self.assertIs(parameters['arg1'].kind, Parameter.POSITIONAL_OR_KEYWORD)
- self.assertEqual('arg1', parameter_names[0])
+ self.assertIs(parameters["arg1"].kind, Parameter.POSITIONAL_OR_KEYWORD)
+ self.assertEqual("arg1", parameter_names[0])
- self.assertIs(parameters['arg2'].kind, Parameter.POSITIONAL_OR_KEYWORD)
- self.assertEqual('arg2', parameter_names[1])
+ self.assertIs(parameters["arg2"].kind, Parameter.POSITIONAL_OR_KEYWORD)
+ self.assertEqual("arg2", parameter_names[1])
- self.assertIs(parameters['pos_args'].kind, Parameter.VAR_POSITIONAL)
- self.assertEqual('pos_args', parameter_names[2])
+ self.assertIs(parameters["pos_args"].kind, Parameter.VAR_POSITIONAL)
+ self.assertEqual("pos_args", parameter_names[2])
- self.assertIs(parameters['number1'].kind, Parameter.KEYWORD_ONLY)
- self.assertIs(parameters['number2'].kind, Parameter.KEYWORD_ONLY)
- self.assertIs(parameters['value'].kind, Parameter.KEYWORD_ONLY)
+ self.assertIs(parameters["number1"].kind, Parameter.KEYWORD_ONLY)
+ self.assertIs(parameters["number2"].kind, Parameter.KEYWORD_ONLY)
+ self.assertIs(parameters["value"].kind, Parameter.KEYWORD_ONLY)
- self.assertIs(parameters['kw_args'].kind, Parameter.VAR_KEYWORD)
- self.assertEqual('kw_args', parameter_names[-1])
+ self.assertIs(parameters["kw_args"].kind, Parameter.VAR_KEYWORD)
+ self.assertEqual("kw_args", parameter_names[-1])
- f = Foo(1, 3, 45, 'hey', number1=32, value='World')
+ f = Foo(1, 3, 45, "hey", number1=32, value="World")
self.assertEqual(f.arg1, 1)
self.assertEqual(f.arg2, 3)
- self.assertTupleEqual(f.pos_args, (45, 'hey'))
+ self.assertTupleEqual(f.pos_args, (45, "hey"))
self.assertEqual(f.number1, 32)
self.assertEqual(f.number2, 0)
- self.assertEqual(f.value, 'World')
+ self.assertEqual(f.value, "World")
def test_no_kwargs(self):
with self.assertRaises(RuntimeError):
+
@signature_has_traits
class Foo(HasTraits):
number1 = Int()
diff --git a/contrib/python/traitlets/py3/traitlets/utils/tests/test_importstring.py b/contrib/python/traitlets/py3/traitlets/utils/tests/test_importstring.py
index fb3266942f..a3a74c3214 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/tests/test_importstring.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/tests/test_importstring.py
@@ -12,18 +12,15 @@ from traitlets.utils.importstring import import_item
class TestImportItem(TestCase):
-
def test_import_unicode(self):
- self.assertIs(os, import_item('os'))
- self.assertIs(os.path, import_item('os.path'))
- self.assertIs(os.path.join, import_item('os.path.join'))
+ self.assertIs(os, import_item("os"))
+ self.assertIs(os.path, import_item("os.path"))
+ self.assertIs(os.path.join, import_item("os.path.join"))
def test_bad_input(self):
- class NotAString(object):
+ class NotAString:
pass
- msg = (
- "import_item accepts strings, "
- "not '%s'." % NotAString
- )
+
+ msg = "import_item accepts strings, not '%s'." % NotAString
with self.assertRaisesRegex(TypeError, msg):
import_item(NotAString())
diff --git a/contrib/python/traitlets/py3/traitlets/utils/text.py b/contrib/python/traitlets/py3/traitlets/utils/text.py
index 92464a5a6c..c7d49edece 100644
--- a/contrib/python/traitlets/py3/traitlets/utils/text.py
+++ b/contrib/python/traitlets/py3/traitlets/utils/text.py
@@ -3,8 +3,10 @@ Utilities imported from ipython_genutils
"""
import re
-from textwrap import dedent, indent as _indent
import textwrap
+from textwrap import dedent
+from textwrap import indent as _indent
+from typing import List
def indent(val):
@@ -12,7 +14,7 @@ def indent(val):
return res
-def wrap_paragraphs(text: str, ncols=80):
+def wrap_paragraphs(text: str, ncols: int = 80) -> List[str]:
"""Wrap multiple paragraphs to fit a specified width.
This is equivalent to textwrap.wrap, but with support for multiple