moto/moto/sagemaker/validators.py
jweite 1b80b0a810
Sagemaker models (#3105)
* First failing test, and enough framework to run it.

* Rudimentary passing test.

* Sagemaker Notebook Support, take-1: create, describe, start, stop, delete.

* Added list_tags.

* Merged in model support from https://github.com/porthunt/moto/tree/sagemaker-support.

* Re-org'd

* Fixed up describe_model exception when no matching model.

* Segregated tests by Sagemaker entity.  Model arn check by regex..

* Python2 compabitility changes.

* Added sagemaker to list of known backends.  Corrected urls.

* Added sagemaker special case to moto.server.infer_service_region_host due to irregular url format (use of 'api' subdomain) to support server mode.

* Changes for PR 3105 comments of July 10, 2020

* PR3105 July 10, 2020, 8:55 AM EDT comment: dropped unnecessary re-addition of arn when formulating model list response.

* PR 3105 July 15, 2020 9:10 AM EDT Comment: clean-up SageMakerModelBackend.describe_models logic for finding the model in the dict.

* Optimized imports

Co-authored-by: Joseph Weitekamp <jweite@amazon.com>
2020-07-16 13:12:25 +01:00

21 lines
538 B
Python

def is_integer_between(x, mn=None, mx=None, optional=False):
if optional and x is None:
return True
try:
if mn is not None and mx is not None:
return int(x) >= mn and int(x) < mx
elif mn is not None:
return int(x) >= mn
elif mx is not None:
return int(x) < mx
else:
return True
except ValueError:
return False
def is_one_of(x, choices, optional=False):
if optional and x is None:
return True
return x in choices