partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
extract
Select the best match in a list or dictionary of choices. Find best matches in a list or dictionary of choices, return a list of tuples containing the match and its score. If a dictionary is used, also returns the key for each match. Arguments: query: An object representing the thing we want t...
fuzzywuzzy/process.py
def extract(query, choices, processor=default_processor, scorer=default_scorer, limit=5): """Select the best match in a list or dictionary of choices. Find best matches in a list or dictionary of choices, return a list of tuples containing the match and its score. If a dictionary is used, also returns ...
def extract(query, choices, processor=default_processor, scorer=default_scorer, limit=5): """Select the best match in a list or dictionary of choices. Find best matches in a list or dictionary of choices, return a list of tuples containing the match and its score. If a dictionary is used, also returns ...
[ "Select", "the", "best", "match", "in", "a", "list", "or", "dictionary", "of", "choices", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L122-L169
[ "def", "extract", "(", "query", ",", "choices", ",", "processor", "=", "default_processor", ",", "scorer", "=", "default_scorer", ",", "limit", "=", "5", ")", ":", "sl", "=", "extractWithoutOrder", "(", "query", ",", "choices", ",", "processor", ",", "scor...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
extractBests
Get a list of the best matches to a collection of choices. Convenience function for getting the choices with best scores. Args: query: A string to match against choices: A list or dictionary of choices, suitable for use with extract(). processor: Optional function for trans...
fuzzywuzzy/process.py
def extractBests(query, choices, processor=default_processor, scorer=default_scorer, score_cutoff=0, limit=5): """Get a list of the best matches to a collection of choices. Convenience function for getting the choices with best scores. Args: query: A string to match against choices: A list...
def extractBests(query, choices, processor=default_processor, scorer=default_scorer, score_cutoff=0, limit=5): """Get a list of the best matches to a collection of choices. Convenience function for getting the choices with best scores. Args: query: A string to match against choices: A list...
[ "Get", "a", "list", "of", "the", "best", "matches", "to", "a", "collection", "of", "choices", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L172-L194
[ "def", "extractBests", "(", "query", ",", "choices", ",", "processor", "=", "default_processor", ",", "scorer", "=", "default_scorer", ",", "score_cutoff", "=", "0", ",", "limit", "=", "5", ")", ":", "best_list", "=", "extractWithoutOrder", "(", "query", ","...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
extractOne
Find the single best match above a score in a list of choices. This is a convenience method which returns the single best choice. See extract() for the full arguments list. Args: query: A string to match against choices: A list or dictionary of choices, suitable for use with ex...
fuzzywuzzy/process.py
def extractOne(query, choices, processor=default_processor, scorer=default_scorer, score_cutoff=0): """Find the single best match above a score in a list of choices. This is a convenience method which returns the single best choice. See extract() for the full arguments list. Args: query: A str...
def extractOne(query, choices, processor=default_processor, scorer=default_scorer, score_cutoff=0): """Find the single best match above a score in a list of choices. This is a convenience method which returns the single best choice. See extract() for the full arguments list. Args: query: A str...
[ "Find", "the", "single", "best", "match", "above", "a", "score", "in", "a", "list", "of", "choices", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L197-L222
[ "def", "extractOne", "(", "query", ",", "choices", ",", "processor", "=", "default_processor", ",", "scorer", "=", "default_scorer", ",", "score_cutoff", "=", "0", ")", ":", "best_list", "=", "extractWithoutOrder", "(", "query", ",", "choices", ",", "processor...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
dedupe
This convenience function takes a list of strings containing duplicates and uses fuzzy matching to identify and remove duplicates. Specifically, it uses the process.extract to identify duplicates that score greater than a user defined threshold. Then, it looks for the longest item in the duplicate list sinc...
fuzzywuzzy/process.py
def dedupe(contains_dupes, threshold=70, scorer=fuzz.token_set_ratio): """This convenience function takes a list of strings containing duplicates and uses fuzzy matching to identify and remove duplicates. Specifically, it uses the process.extract to identify duplicates that score greater than a user defined...
def dedupe(contains_dupes, threshold=70, scorer=fuzz.token_set_ratio): """This convenience function takes a list of strings containing duplicates and uses fuzzy matching to identify and remove duplicates. Specifically, it uses the process.extract to identify duplicates that score greater than a user defined...
[ "This", "convenience", "function", "takes", "a", "list", "of", "strings", "containing", "duplicates", "and", "uses", "fuzzy", "matching", "to", "identify", "and", "remove", "duplicates", ".", "Specifically", "it", "uses", "the", "process", ".", "extract", "to", ...
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L225-L285
[ "def", "dedupe", "(", "contains_dupes", ",", "threshold", "=", "70", ",", "scorer", "=", "fuzz", ".", "token_set_ratio", ")", ":", "extractor", "=", "[", "]", "# iterate over items in *contains_dupes*", "for", "item", "in", "contains_dupes", ":", "# return all dup...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
make_type_consistent
If both objects aren't either both string or unicode instances force them to unicode
fuzzywuzzy/utils.py
def make_type_consistent(s1, s2): """If both objects aren't either both string or unicode instances force them to unicode""" if isinstance(s1, str) and isinstance(s2, str): return s1, s2 elif isinstance(s1, unicode) and isinstance(s2, unicode): return s1, s2 else: return unicod...
def make_type_consistent(s1, s2): """If both objects aren't either both string or unicode instances force them to unicode""" if isinstance(s1, str) and isinstance(s2, str): return s1, s2 elif isinstance(s1, unicode) and isinstance(s2, unicode): return s1, s2 else: return unicod...
[ "If", "both", "objects", "aren", "t", "either", "both", "string", "or", "unicode", "instances", "force", "them", "to", "unicode" ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/utils.py#L73-L82
[ "def", "make_type_consistent", "(", "s1", ",", "s2", ")", ":", "if", "isinstance", "(", "s1", ",", "str", ")", "and", "isinstance", "(", "s2", ",", "str", ")", ":", "return", "s1", ",", "s2", "elif", "isinstance", "(", "s1", ",", "unicode", ")", "a...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
full_process
Process string by -- removing all but letters and numbers -- trim whitespace -- force to lower case if force_ascii == True, force convert to ascii
fuzzywuzzy/utils.py
def full_process(s, force_ascii=False): """Process string by -- removing all but letters and numbers -- trim whitespace -- force to lower case if force_ascii == True, force convert to ascii""" if force_ascii: s = asciidammit(s) # Keep only Letters and Numbers (see Un...
def full_process(s, force_ascii=False): """Process string by -- removing all but letters and numbers -- trim whitespace -- force to lower case if force_ascii == True, force convert to ascii""" if force_ascii: s = asciidammit(s) # Keep only Letters and Numbers (see Un...
[ "Process", "string", "by", "--", "removing", "all", "but", "letters", "and", "numbers", "--", "trim", "whitespace", "--", "force", "to", "lower", "case", "if", "force_ascii", "==", "True", "force", "convert", "to", "ascii" ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/utils.py#L85-L100
[ "def", "full_process", "(", "s", ",", "force_ascii", "=", "False", ")", ":", "if", "force_ascii", ":", "s", "=", "asciidammit", "(", "s", ")", "# Keep only Letters and Numbers (see Unicode docs).", "string_out", "=", "StringProcessor", ".", "replace_non_letters_non_nu...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
partial_ratio
Return the ratio of the most similar substring as a number between 0 and 100.
fuzzywuzzy/fuzz.py
def partial_ratio(s1, s2): """"Return the ratio of the most similar substring as a number between 0 and 100.""" s1, s2 = utils.make_type_consistent(s1, s2) if len(s1) <= len(s2): shorter = s1 longer = s2 else: shorter = s2 longer = s1 m = SequenceMatcher(None, s...
def partial_ratio(s1, s2): """"Return the ratio of the most similar substring as a number between 0 and 100.""" s1, s2 = utils.make_type_consistent(s1, s2) if len(s1) <= len(s2): shorter = s1 longer = s2 else: shorter = s2 longer = s1 m = SequenceMatcher(None, s...
[ "Return", "the", "ratio", "of", "the", "most", "similar", "substring", "as", "a", "number", "between", "0", "and", "100", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L34-L68
[ "def", "partial_ratio", "(", "s1", ",", "s2", ")", ":", "s1", ",", "s2", "=", "utils", ".", "make_type_consistent", "(", "s1", ",", "s2", ")", "if", "len", "(", "s1", ")", "<=", "len", "(", "s2", ")", ":", "shorter", "=", "s1", "longer", "=", "...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
_process_and_sort
Return a cleaned string with token sorted.
fuzzywuzzy/fuzz.py
def _process_and_sort(s, force_ascii, full_process=True): """Return a cleaned string with token sorted.""" # pull tokens ts = utils.full_process(s, force_ascii=force_ascii) if full_process else s tokens = ts.split() # sort tokens and join sorted_string = u" ".join(sorted(tokens)) return sor...
def _process_and_sort(s, force_ascii, full_process=True): """Return a cleaned string with token sorted.""" # pull tokens ts = utils.full_process(s, force_ascii=force_ascii) if full_process else s tokens = ts.split() # sort tokens and join sorted_string = u" ".join(sorted(tokens)) return sor...
[ "Return", "a", "cleaned", "string", "with", "token", "sorted", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L75-L83
[ "def", "_process_and_sort", "(", "s", ",", "force_ascii", ",", "full_process", "=", "True", ")", ":", "# pull tokens", "ts", "=", "utils", ".", "full_process", "(", "s", ",", "force_ascii", "=", "force_ascii", ")", "if", "full_process", "else", "s", "tokens"...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
token_sort_ratio
Return a measure of the sequences' similarity between 0 and 100 but sorting the token before comparing.
fuzzywuzzy/fuzz.py
def token_sort_ratio(s1, s2, force_ascii=True, full_process=True): """Return a measure of the sequences' similarity between 0 and 100 but sorting the token before comparing. """ return _token_sort(s1, s2, partial=False, force_ascii=force_ascii, full_process=full_process)
def token_sort_ratio(s1, s2, force_ascii=True, full_process=True): """Return a measure of the sequences' similarity between 0 and 100 but sorting the token before comparing. """ return _token_sort(s1, s2, partial=False, force_ascii=force_ascii, full_process=full_process)
[ "Return", "a", "measure", "of", "the", "sequences", "similarity", "between", "0", "and", "100", "but", "sorting", "the", "token", "before", "comparing", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L101-L105
[ "def", "token_sort_ratio", "(", "s1", ",", "s2", ",", "force_ascii", "=", "True", ",", "full_process", "=", "True", ")", ":", "return", "_token_sort", "(", "s1", ",", "s2", ",", "partial", "=", "False", ",", "force_ascii", "=", "force_ascii", ",", "full_...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
partial_token_sort_ratio
Return the ratio of the most similar substring as a number between 0 and 100 but sorting the token before comparing.
fuzzywuzzy/fuzz.py
def partial_token_sort_ratio(s1, s2, force_ascii=True, full_process=True): """Return the ratio of the most similar substring as a number between 0 and 100 but sorting the token before comparing. """ return _token_sort(s1, s2, partial=True, force_ascii=force_ascii, full_process=full_process)
def partial_token_sort_ratio(s1, s2, force_ascii=True, full_process=True): """Return the ratio of the most similar substring as a number between 0 and 100 but sorting the token before comparing. """ return _token_sort(s1, s2, partial=True, force_ascii=force_ascii, full_process=full_process)
[ "Return", "the", "ratio", "of", "the", "most", "similar", "substring", "as", "a", "number", "between", "0", "and", "100", "but", "sorting", "the", "token", "before", "comparing", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L108-L112
[ "def", "partial_token_sort_ratio", "(", "s1", ",", "s2", ",", "force_ascii", "=", "True", ",", "full_process", "=", "True", ")", ":", "return", "_token_sort", "(", "s1", ",", "s2", ",", "partial", "=", "True", ",", "force_ascii", "=", "force_ascii", ",", ...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
_token_set
Find all alphanumeric tokens in each string... - treat them as a set - construct two strings of the form: <sorted_intersection><sorted_remainder> - take ratios of those two strings - controls for unordered partial matches
fuzzywuzzy/fuzz.py
def _token_set(s1, s2, partial=True, force_ascii=True, full_process=True): """Find all alphanumeric tokens in each string... - treat them as a set - construct two strings of the form: <sorted_intersection><sorted_remainder> - take ratios of those two strings - controls fo...
def _token_set(s1, s2, partial=True, force_ascii=True, full_process=True): """Find all alphanumeric tokens in each string... - treat them as a set - construct two strings of the form: <sorted_intersection><sorted_remainder> - take ratios of those two strings - controls fo...
[ "Find", "all", "alphanumeric", "tokens", "in", "each", "string", "...", "-", "treat", "them", "as", "a", "set", "-", "construct", "two", "strings", "of", "the", "form", ":", "<sorted_intersection", ">", "<sorted_remainder", ">", "-", "take", "ratios", "of", ...
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L116-L165
[ "def", "_token_set", "(", "s1", ",", "s2", ",", "partial", "=", "True", ",", "force_ascii", "=", "True", ",", "full_process", "=", "True", ")", ":", "if", "not", "full_process", "and", "s1", "==", "s2", ":", "return", "100", "p1", "=", "utils", ".", ...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
QRatio
Quick ratio comparison between two strings. Runs full_process from utils on both strings Short circuits if either of the strings is empty after processing. :param s1: :param s2: :param force_ascii: Allow only ASCII characters (Default: True) :full_process: Process inputs, used here to avoid do...
fuzzywuzzy/fuzz.py
def QRatio(s1, s2, force_ascii=True, full_process=True): """ Quick ratio comparison between two strings. Runs full_process from utils on both strings Short circuits if either of the strings is empty after processing. :param s1: :param s2: :param force_ascii: Allow only ASCII characters (De...
def QRatio(s1, s2, force_ascii=True, full_process=True): """ Quick ratio comparison between two strings. Runs full_process from utils on both strings Short circuits if either of the strings is empty after processing. :param s1: :param s2: :param force_ascii: Allow only ASCII characters (De...
[ "Quick", "ratio", "comparison", "between", "two", "strings", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L181-L207
[ "def", "QRatio", "(", "s1", ",", "s2", ",", "force_ascii", "=", "True", ",", "full_process", "=", "True", ")", ":", "if", "full_process", ":", "p1", "=", "utils", ".", "full_process", "(", "s1", ",", "force_ascii", "=", "force_ascii", ")", "p2", "=", ...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
UQRatio
Unicode quick ratio Calls QRatio with force_ascii set to False :param s1: :param s2: :return: similarity ratio
fuzzywuzzy/fuzz.py
def UQRatio(s1, s2, full_process=True): """ Unicode quick ratio Calls QRatio with force_ascii set to False :param s1: :param s2: :return: similarity ratio """ return QRatio(s1, s2, force_ascii=False, full_process=full_process)
def UQRatio(s1, s2, full_process=True): """ Unicode quick ratio Calls QRatio with force_ascii set to False :param s1: :param s2: :return: similarity ratio """ return QRatio(s1, s2, force_ascii=False, full_process=full_process)
[ "Unicode", "quick", "ratio" ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L210-L220
[ "def", "UQRatio", "(", "s1", ",", "s2", ",", "full_process", "=", "True", ")", ":", "return", "QRatio", "(", "s1", ",", "s2", ",", "force_ascii", "=", "False", ",", "full_process", "=", "full_process", ")" ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
WRatio
Return a measure of the sequences' similarity between 0 and 100, using different algorithms. **Steps in the order they occur** #. Run full_process from utils on both strings #. Short circuit if this makes either string empty #. Take the ratio of the two processed strings (fuzz.ratio) #. Run checks...
fuzzywuzzy/fuzz.py
def WRatio(s1, s2, force_ascii=True, full_process=True): """ Return a measure of the sequences' similarity between 0 and 100, using different algorithms. **Steps in the order they occur** #. Run full_process from utils on both strings #. Short circuit if this makes either string empty #. Take ...
def WRatio(s1, s2, force_ascii=True, full_process=True): """ Return a measure of the sequences' similarity between 0 and 100, using different algorithms. **Steps in the order they occur** #. Run full_process from utils on both strings #. Short circuit if this makes either string empty #. Take ...
[ "Return", "a", "measure", "of", "the", "sequences", "similarity", "between", "0", "and", "100", "using", "different", "algorithms", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L224-L299
[ "def", "WRatio", "(", "s1", ",", "s2", ",", "force_ascii", "=", "True", ",", "full_process", "=", "True", ")", ":", "if", "full_process", ":", "p1", "=", "utils", ".", "full_process", "(", "s1", ",", "force_ascii", "=", "force_ascii", ")", "p2", "=", ...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
UWRatio
Return a measure of the sequences' similarity between 0 and 100, using different algorithms. Same as WRatio but preserving unicode.
fuzzywuzzy/fuzz.py
def UWRatio(s1, s2, full_process=True): """Return a measure of the sequences' similarity between 0 and 100, using different algorithms. Same as WRatio but preserving unicode. """ return WRatio(s1, s2, force_ascii=False, full_process=full_process)
def UWRatio(s1, s2, full_process=True): """Return a measure of the sequences' similarity between 0 and 100, using different algorithms. Same as WRatio but preserving unicode. """ return WRatio(s1, s2, force_ascii=False, full_process=full_process)
[ "Return", "a", "measure", "of", "the", "sequences", "similarity", "between", "0", "and", "100", "using", "different", "algorithms", ".", "Same", "as", "WRatio", "but", "preserving", "unicode", "." ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L302-L306
[ "def", "UWRatio", "(", "s1", ",", "s2", ",", "full_process", "=", "True", ")", ":", "return", "WRatio", "(", "s1", ",", "s2", ",", "force_ascii", "=", "False", ",", "full_process", "=", "full_process", ")" ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
print_result_from_timeit
Clean function to know how much time took the execution of one statement
benchmarks.py
def print_result_from_timeit(stmt='pass', setup='pass', number=1000000): """ Clean function to know how much time took the execution of one statement """ units = ["s", "ms", "us", "ns"] duration = timeit(stmt, setup, number=int(number)) avg_duration = duration / float(number) thousands = int...
def print_result_from_timeit(stmt='pass', setup='pass', number=1000000): """ Clean function to know how much time took the execution of one statement """ units = ["s", "ms", "us", "ns"] duration = timeit(stmt, setup, number=int(number)) avg_duration = duration / float(number) thousands = int...
[ "Clean", "function", "to", "know", "how", "much", "time", "took", "the", "execution", "of", "one", "statement" ]
seatgeek/fuzzywuzzy
python
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/benchmarks.py#L47-L57
[ "def", "print_result_from_timeit", "(", "stmt", "=", "'pass'", ",", "setup", "=", "'pass'", ",", "number", "=", "1000000", ")", ":", "units", "=", "[", "\"s\"", ",", "\"ms\"", ",", "\"us\"", ",", "\"ns\"", "]", "duration", "=", "timeit", "(", "stmt", "...
778162c5a73256745eb6ae22f925bc2dbcf7c894
train
PipelineModel.deploy
Deploy this ``Model`` to an ``Endpoint`` and optionally return a ``Predictor``. Create a SageMaker ``Model`` and ``EndpointConfig``, and deploy an ``Endpoint`` from this ``Model``. If ``self.predictor_cls`` is not None, this method returns a the result of invoking ``self.predictor_cls`` on the ...
src/sagemaker/pipeline.py
def deploy(self, initial_instance_count, instance_type, endpoint_name=None, tags=None): """Deploy this ``Model`` to an ``Endpoint`` and optionally return a ``Predictor``. Create a SageMaker ``Model`` and ``EndpointConfig``, and deploy an ``Endpoint`` from this ``Model``. If ``self.predictor_cls...
def deploy(self, initial_instance_count, instance_type, endpoint_name=None, tags=None): """Deploy this ``Model`` to an ``Endpoint`` and optionally return a ``Predictor``. Create a SageMaker ``Model`` and ``EndpointConfig``, and deploy an ``Endpoint`` from this ``Model``. If ``self.predictor_cls...
[ "Deploy", "this", "Model", "to", "an", "Endpoint", "and", "optionally", "return", "a", "Predictor", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/pipeline.py#L70-L106
[ "def", "deploy", "(", "self", ",", "initial_instance_count", ",", "instance_type", ",", "endpoint_name", "=", "None", ",", "tags", "=", "None", ")", ":", "if", "not", "self", ".", "sagemaker_session", ":", "self", ".", "sagemaker_session", "=", "Session", "(...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
PipelineModel._create_sagemaker_pipeline_model
Create a SageMaker Model Entity Args: instance_type (str): The EC2 instance type that this Model will be used for, this is only used to determine if the image needs GPU support or not. accelerator_type (str): Type of Elastic Inference accelerator to attach to an endpoint...
src/sagemaker/pipeline.py
def _create_sagemaker_pipeline_model(self, instance_type): """Create a SageMaker Model Entity Args: instance_type (str): The EC2 instance type that this Model will be used for, this is only used to determine if the image needs GPU support or not. accelerator_type...
def _create_sagemaker_pipeline_model(self, instance_type): """Create a SageMaker Model Entity Args: instance_type (str): The EC2 instance type that this Model will be used for, this is only used to determine if the image needs GPU support or not. accelerator_type...
[ "Create", "a", "SageMaker", "Model", "Entity" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/pipeline.py#L108-L124
[ "def", "_create_sagemaker_pipeline_model", "(", "self", ",", "instance_type", ")", ":", "if", "not", "self", ".", "sagemaker_session", ":", "self", ".", "sagemaker_session", "=", "Session", "(", ")", "containers", "=", "self", ".", "pipeline_container_def", "(", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
PipelineModel.delete_model
Delete the SageMaker model backing this pipeline model. This does not delete the list of SageMaker models used in multiple containers to build the inference pipeline.
src/sagemaker/pipeline.py
def delete_model(self): """Delete the SageMaker model backing this pipeline model. This does not delete the list of SageMaker models used in multiple containers to build the inference pipeline. """ if self.name is None: raise ValueError('The SageMaker model must be created ...
def delete_model(self): """Delete the SageMaker model backing this pipeline model. This does not delete the list of SageMaker models used in multiple containers to build the inference pipeline. """ if self.name is None: raise ValueError('The SageMaker model must be created ...
[ "Delete", "the", "SageMaker", "model", "backing", "this", "pipeline", "model", ".", "This", "does", "not", "delete", "the", "list", "of", "SageMaker", "models", "used", "in", "multiple", "containers", "to", "build", "the", "inference", "pipeline", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/pipeline.py#L158-L167
[ "def", "delete_model", "(", "self", ")", ":", "if", "self", ".", "name", "is", "None", ":", "raise", "ValueError", "(", "'The SageMaker model must be created before attempting to delete.'", ")", "self", ".", "sagemaker_session", ".", "delete_model", "(", "self", "."...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
_stream_output
Stream the output of a process to stdout This function takes an existing process that will be polled for output. Only stdout will be polled and sent to sys.stdout. Args: process(subprocess.Popen): a process that has been started with stdout=PIPE and stderr=STDOUT Returns (int): pr...
src/sagemaker/local/image.py
def _stream_output(process): """Stream the output of a process to stdout This function takes an existing process that will be polled for output. Only stdout will be polled and sent to sys.stdout. Args: process(subprocess.Popen): a process that has been started with stdout=PIPE and ...
def _stream_output(process): """Stream the output of a process to stdout This function takes an existing process that will be polled for output. Only stdout will be polled and sent to sys.stdout. Args: process(subprocess.Popen): a process that has been started with stdout=PIPE and ...
[ "Stream", "the", "output", "of", "a", "process", "to", "stdout" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L570-L592
[ "def", "_stream_output", "(", "process", ")", ":", "exit_code", "=", "None", "while", "exit_code", "is", "None", ":", "stdout", "=", "process", ".", "stdout", ".", "readline", "(", ")", ".", "decode", "(", "\"utf-8\"", ")", "sys", ".", "stdout", ".", "...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
_SageMakerContainer.train
Run a training job locally using docker-compose. Args: input_data_config (dict): The Input Data Configuration, this contains data such as the channels to be used for training. hyperparameters (dict): The HyperParameters for the training job. job_name (str): Na...
src/sagemaker/local/image.py
def train(self, input_data_config, output_data_config, hyperparameters, job_name): """Run a training job locally using docker-compose. Args: input_data_config (dict): The Input Data Configuration, this contains data such as the channels to be used for training. hy...
def train(self, input_data_config, output_data_config, hyperparameters, job_name): """Run a training job locally using docker-compose. Args: input_data_config (dict): The Input Data Configuration, this contains data such as the channels to be used for training. hy...
[ "Run", "a", "training", "job", "locally", "using", "docker", "-", "compose", ".", "Args", ":", "input_data_config", "(", "dict", ")", ":", "The", "Input", "Data", "Configuration", "this", "contains", "data", "such", "as", "the", "channels", "to", "be", "us...
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L87-L151
[ "def", "train", "(", "self", ",", "input_data_config", ",", "output_data_config", ",", "hyperparameters", ",", "job_name", ")", ":", "self", ".", "container_root", "=", "self", ".", "_create_tmp_folder", "(", ")", "os", ".", "mkdir", "(", "os", ".", "path", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
_SageMakerContainer.serve
Host a local endpoint using docker-compose. Args: primary_container (dict): dictionary containing the container runtime settings for serving. Expected keys: - 'ModelDataUrl' pointing to a file or s3:// location. - 'Environment' a dictionary of environm...
src/sagemaker/local/image.py
def serve(self, model_dir, environment): """Host a local endpoint using docker-compose. Args: primary_container (dict): dictionary containing the container runtime settings for serving. Expected keys: - 'ModelDataUrl' pointing to a file or s3:// location. ...
def serve(self, model_dir, environment): """Host a local endpoint using docker-compose. Args: primary_container (dict): dictionary containing the container runtime settings for serving. Expected keys: - 'ModelDataUrl' pointing to a file or s3:// location. ...
[ "Host", "a", "local", "endpoint", "using", "docker", "-", "compose", ".", "Args", ":", "primary_container", "(", "dict", ")", ":", "dictionary", "containing", "the", "container", "runtime", "settings", "for", "serving", ".", "Expected", "keys", ":", "-", "Mo...
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L153-L187
[ "def", "serve", "(", "self", ",", "model_dir", ",", "environment", ")", ":", "logger", ".", "info", "(", "\"serving\"", ")", "self", ".", "container_root", "=", "self", ".", "_create_tmp_folder", "(", ")", "logger", ".", "info", "(", "'creating hosting dir i...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
_SageMakerContainer.stop_serving
Stop the serving container. The serving container runs in async mode to allow the SDK to do other tasks.
src/sagemaker/local/image.py
def stop_serving(self): """Stop the serving container. The serving container runs in async mode to allow the SDK to do other tasks. """ if self.container: self.container.down() self.container.join() self._cleanup() # for serving we can delete ...
def stop_serving(self): """Stop the serving container. The serving container runs in async mode to allow the SDK to do other tasks. """ if self.container: self.container.down() self.container.join() self._cleanup() # for serving we can delete ...
[ "Stop", "the", "serving", "container", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L189-L199
[ "def", "stop_serving", "(", "self", ")", ":", "if", "self", ".", "container", ":", "self", ".", "container", ".", "down", "(", ")", "self", ".", "container", ".", "join", "(", ")", "self", ".", "_cleanup", "(", ")", "# for serving we can delete everything ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
_SageMakerContainer.retrieve_artifacts
Get the model artifacts from all the container nodes. Used after training completes to gather the data from all the individual containers. As the official SageMaker Training Service, it will override duplicate files if multiple containers have the same file names. Args: com...
src/sagemaker/local/image.py
def retrieve_artifacts(self, compose_data, output_data_config, job_name): """Get the model artifacts from all the container nodes. Used after training completes to gather the data from all the individual containers. As the official SageMaker Training Service, it will override duplicate files if...
def retrieve_artifacts(self, compose_data, output_data_config, job_name): """Get the model artifacts from all the container nodes. Used after training completes to gather the data from all the individual containers. As the official SageMaker Training Service, it will override duplicate files if...
[ "Get", "the", "model", "artifacts", "from", "all", "the", "container", "nodes", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L201-L256
[ "def", "retrieve_artifacts", "(", "self", ",", "compose_data", ",", "output_data_config", ",", "job_name", ")", ":", "# We need a directory to store the artfiacts from all the nodes", "# and another one to contained the compressed final artifacts", "artifacts", "=", "os", ".", "p...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
_SageMakerContainer.write_config_files
Write the config files for the training containers. This method writes the hyperparameters, resources and input data configuration files. Args: host (str): Host to write the configuration for hyperparameters (dict): Hyperparameters for training. input_data_config (d...
src/sagemaker/local/image.py
def write_config_files(self, host, hyperparameters, input_data_config): """Write the config files for the training containers. This method writes the hyperparameters, resources and input data configuration files. Args: host (str): Host to write the configuration for hyp...
def write_config_files(self, host, hyperparameters, input_data_config): """Write the config files for the training containers. This method writes the hyperparameters, resources and input data configuration files. Args: host (str): Host to write the configuration for hyp...
[ "Write", "the", "config", "files", "for", "the", "training", "containers", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L258-L289
[ "def", "write_config_files", "(", "self", ",", "host", ",", "hyperparameters", ",", "input_data_config", ")", ":", "config_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "container_root", ",", "host", ",", "'input'", ",", "'config'", ")", "r...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
_SageMakerContainer._generate_compose_file
Writes a config file describing a training/hosting environment. This method generates a docker compose configuration file, it has an entry for each container that will be created (based on self.hosts). it calls :meth:~sagemaker.local_session.SageMakerContainer._create_docker_host to generate t...
src/sagemaker/local/image.py
def _generate_compose_file(self, command, additional_volumes=None, additional_env_vars=None): """Writes a config file describing a training/hosting environment. This method generates a docker compose configuration file, it has an entry for each container that will be created (based on self.hos...
def _generate_compose_file(self, command, additional_volumes=None, additional_env_vars=None): """Writes a config file describing a training/hosting environment. This method generates a docker compose configuration file, it has an entry for each container that will be created (based on self.hos...
[ "Writes", "a", "config", "file", "describing", "a", "training", "/", "hosting", "environment", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L360-L416
[ "def", "_generate_compose_file", "(", "self", ",", "command", ",", "additional_volumes", "=", "None", ",", "additional_env_vars", "=", "None", ")", ":", "boto_session", "=", "self", ".", "sagemaker_session", ".", "boto_session", "additional_volumes", "=", "additiona...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
_SageMakerContainer._build_optml_volumes
Generate a list of :class:`~sagemaker.local_session.Volume` required for the container to start. It takes a folder with the necessary files for training and creates a list of opt volumes that the Container needs to start. Args: host (str): container for which the volumes will be ge...
src/sagemaker/local/image.py
def _build_optml_volumes(self, host, subdirs): """Generate a list of :class:`~sagemaker.local_session.Volume` required for the container to start. It takes a folder with the necessary files for training and creates a list of opt volumes that the Container needs to start. Args: ...
def _build_optml_volumes(self, host, subdirs): """Generate a list of :class:`~sagemaker.local_session.Volume` required for the container to start. It takes a folder with the necessary files for training and creates a list of opt volumes that the Container needs to start. Args: ...
[ "Generate", "a", "list", "of", ":", "class", ":", "~sagemaker", ".", "local_session", ".", "Volume", "required", "for", "the", "container", "to", "start", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L486-L506
[ "def", "_build_optml_volumes", "(", "self", ",", "host", ",", "subdirs", ")", ":", "volumes", "=", "[", "]", "for", "subdir", "in", "subdirs", ":", "host_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "container_root", ",", "host", ",", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
model_fn
Load the gluon model. Called once when hosting service starts. :param: model_dir The directory where model files are stored. :return: a model (in this case a Gluon network)
examples/cli/host/script.py
def model_fn(model_dir): """ Load the gluon model. Called once when hosting service starts. :param: model_dir The directory where model files are stored. :return: a model (in this case a Gluon network) """ symbol = mx.sym.load('%s/model.json' % model_dir) outputs = mx.symbol.softmax(data=sy...
def model_fn(model_dir): """ Load the gluon model. Called once when hosting service starts. :param: model_dir The directory where model files are stored. :return: a model (in this case a Gluon network) """ symbol = mx.sym.load('%s/model.json' % model_dir) outputs = mx.symbol.softmax(data=sy...
[ "Load", "the", "gluon", "model", ".", "Called", "once", "when", "hosting", "service", "starts", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/examples/cli/host/script.py#L8-L21
[ "def", "model_fn", "(", "model_dir", ")", ":", "symbol", "=", "mx", ".", "sym", ".", "load", "(", "'%s/model.json'", "%", "model_dir", ")", "outputs", "=", "mx", ".", "symbol", ".", "softmax", "(", "data", "=", "symbol", ",", "name", "=", "'softmax_lab...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
transform_fn
Transform a request using the Gluon model. Called once per request. :param net: The Gluon model. :param data: The request payload. :param input_content_type: The request content type. :param output_content_type: The (desired) response content type. :return: response payload and content type.
examples/cli/host/script.py
def transform_fn(net, data, input_content_type, output_content_type): """ Transform a request using the Gluon model. Called once per request. :param net: The Gluon model. :param data: The request payload. :param input_content_type: The request content type. :param output_content_type: The (desi...
def transform_fn(net, data, input_content_type, output_content_type): """ Transform a request using the Gluon model. Called once per request. :param net: The Gluon model. :param data: The request payload. :param input_content_type: The request content type. :param output_content_type: The (desi...
[ "Transform", "a", "request", "using", "the", "Gluon", "model", ".", "Called", "once", "per", "request", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/examples/cli/host/script.py#L24-L41
[ "def", "transform_fn", "(", "net", ",", "data", ",", "input_content_type", ",", "output_content_type", ")", ":", "# we can use content types to vary input/output handling, but", "# here we just assume json for both", "parsed", "=", "json", ".", "loads", "(", "data", ")", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
PCA._prepare_for_training
Set hyperparameters needed for training. Args: * records (:class:`~RecordSet`): The records to train this ``Estimator`` on. * mini_batch_size (int or None): The size of each mini-batch to use when training. If ``None``, a default value will be used. * job_nam...
src/sagemaker/amazon/pca.py
def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): """Set hyperparameters needed for training. Args: * records (:class:`~RecordSet`): The records to train this ``Estimator`` on. * mini_batch_size (int or None): The size of each mini-batch to use when ...
def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): """Set hyperparameters needed for training. Args: * records (:class:`~RecordSet`): The records to train this ``Estimator`` on. * mini_batch_size (int or None): The size of each mini-batch to use when ...
[ "Set", "hyperparameters", "needed", "for", "training", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/pca.py#L103-L129
[ "def", "_prepare_for_training", "(", "self", ",", "records", ",", "mini_batch_size", "=", "None", ",", "job_name", "=", "None", ")", ":", "num_records", "=", "None", "if", "isinstance", "(", "records", ",", "list", ")", ":", "for", "record", "in", "records...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
create_image_uri
Return the ECR URI of an image. Args: region (str): AWS region where the image is uploaded. framework (str): framework used by the image. instance_type (str): SageMaker instance type. Used to determine device type (cpu/gpu/family-specific optimized). framework_version (str): The ver...
src/sagemaker/fw_utils.py
def create_image_uri(region, framework, instance_type, framework_version, py_version=None, account='520713654638', accelerator_type=None, optimized_families=None): """Return the ECR URI of an image. Args: region (str): AWS region where the image is uploaded. framework (str)...
def create_image_uri(region, framework, instance_type, framework_version, py_version=None, account='520713654638', accelerator_type=None, optimized_families=None): """Return the ECR URI of an image. Args: region (str): AWS region where the image is uploaded. framework (str)...
[ "Return", "the", "ECR", "URI", "of", "an", "image", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L49-L103
[ "def", "create_image_uri", "(", "region", ",", "framework", ",", "instance_type", ",", "framework_version", ",", "py_version", "=", "None", ",", "account", "=", "'520713654638'", ",", "accelerator_type", "=", "None", ",", "optimized_families", "=", "None", ")", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
validate_source_dir
Validate that the source directory exists and it contains the user script Args: script (str): Script filename. directory (str): Directory containing the source file. Raises: ValueError: If ``directory`` does not exist, is not a directory, or does not contain ``script``.
src/sagemaker/fw_utils.py
def validate_source_dir(script, directory): """Validate that the source directory exists and it contains the user script Args: script (str): Script filename. directory (str): Directory containing the source file. Raises: ValueError: If ``directory`` does not exist, is not a direct...
def validate_source_dir(script, directory): """Validate that the source directory exists and it contains the user script Args: script (str): Script filename. directory (str): Directory containing the source file. Raises: ValueError: If ``directory`` does not exist, is not a direct...
[ "Validate", "that", "the", "source", "directory", "exists", "and", "it", "contains", "the", "user", "script" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L125-L139
[ "def", "validate_source_dir", "(", "script", ",", "directory", ")", ":", "if", "directory", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "directory", ",", "script", ")", ")", ":", "raise", "ValueError", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
tar_and_upload_dir
Package source files and upload a compress tar file to S3. The S3 location will be ``s3://<bucket>/s3_key_prefix/sourcedir.tar.gz``. If directory is an S3 URI, an UploadedCode object will be returned, but nothing will be uploaded to S3 (this allow reuse of code already in S3). If directory is None, th...
src/sagemaker/fw_utils.py
def tar_and_upload_dir(session, bucket, s3_key_prefix, script, directory=None, dependencies=None, kms_key=None): """Package source files and upload a compress tar file to S3. The S3 location will be ``s3://<bucket>/s3_key_prefix/sourcedir.tar.gz``. If directory is an S3 URI, an Uploa...
def tar_and_upload_dir(session, bucket, s3_key_prefix, script, directory=None, dependencies=None, kms_key=None): """Package source files and upload a compress tar file to S3. The S3 location will be ``s3://<bucket>/s3_key_prefix/sourcedir.tar.gz``. If directory is an S3 URI, an Uploa...
[ "Package", "source", "files", "and", "upload", "a", "compress", "tar", "file", "to", "S3", ".", "The", "S3", "location", "will", "be", "s3", ":", "//", "<bucket", ">", "/", "s3_key_prefix", "/", "sourcedir", ".", "tar", ".", "gz", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L142-L194
[ "def", "tar_and_upload_dir", "(", "session", ",", "bucket", ",", "s3_key_prefix", ",", "script", ",", "directory", "=", "None", ",", "dependencies", "=", "None", ",", "kms_key", "=", "None", ")", ":", "if", "directory", "and", "directory", ".", "lower", "(...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
framework_name_from_image
Extract the framework and Python version from the image name. Args: image_name (str): Image URI, which should be one of the following forms: legacy: '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<fw>-<py_ver>-<device>:<container_version>' legacy: '<acco...
src/sagemaker/fw_utils.py
def framework_name_from_image(image_name): """Extract the framework and Python version from the image name. Args: image_name (str): Image URI, which should be one of the following forms: legacy: '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<fw>-<py_ver>-<device>:<containe...
def framework_name_from_image(image_name): """Extract the framework and Python version from the image name. Args: image_name (str): Image URI, which should be one of the following forms: legacy: '<account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<fw>-<py_ver>-<device>:<containe...
[ "Extract", "the", "framework", "and", "Python", "version", "from", "the", "image", "name", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L205-L248
[ "def", "framework_name_from_image", "(", "image_name", ")", ":", "sagemaker_pattern", "=", "re", ".", "compile", "(", "ECR_URI_PATTERN", ")", "sagemaker_match", "=", "sagemaker_pattern", ".", "match", "(", "image_name", ")", "if", "sagemaker_match", "is", "None", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
framework_version_from_tag
Extract the framework version from the image tag. Args: image_tag (str): Image tag, which should take the form '<framework_version>-<device>-<py_version>' Returns: str: The framework version.
src/sagemaker/fw_utils.py
def framework_version_from_tag(image_tag): """Extract the framework version from the image tag. Args: image_tag (str): Image tag, which should take the form '<framework_version>-<device>-<py_version>' Returns: str: The framework version. """ tag_pattern = re.compile('^(.*)-(cpu|gpu...
def framework_version_from_tag(image_tag): """Extract the framework version from the image tag. Args: image_tag (str): Image tag, which should take the form '<framework_version>-<device>-<py_version>' Returns: str: The framework version. """ tag_pattern = re.compile('^(.*)-(cpu|gpu...
[ "Extract", "the", "framework", "version", "from", "the", "image", "tag", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L251-L262
[ "def", "framework_version_from_tag", "(", "image_tag", ")", ":", "tag_pattern", "=", "re", ".", "compile", "(", "'^(.*)-(cpu|gpu)-(py2|py3)$'", ")", "tag_match", "=", "tag_pattern", ".", "match", "(", "image_tag", ")", "return", "None", "if", "tag_match", "is", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
parse_s3_url
Returns an (s3 bucket, key name/prefix) tuple from a url with an s3 scheme Args: url (str): Returns: tuple: A tuple containing: str: S3 bucket name str: S3 key
src/sagemaker/fw_utils.py
def parse_s3_url(url): """Returns an (s3 bucket, key name/prefix) tuple from a url with an s3 scheme Args: url (str): Returns: tuple: A tuple containing: str: S3 bucket name str: S3 key """ parsed_url = urlparse(url) if parsed_url.scheme != "s3": ...
def parse_s3_url(url): """Returns an (s3 bucket, key name/prefix) tuple from a url with an s3 scheme Args: url (str): Returns: tuple: A tuple containing: str: S3 bucket name str: S3 key """ parsed_url = urlparse(url) if parsed_url.scheme != "s3": ...
[ "Returns", "an", "(", "s3", "bucket", "key", "name", "/", "prefix", ")", "tuple", "from", "a", "url", "with", "an", "s3", "scheme" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L265-L279
[ "def", "parse_s3_url", "(", "url", ")", ":", "parsed_url", "=", "urlparse", "(", "url", ")", "if", "parsed_url", ".", "scheme", "!=", "\"s3\"", ":", "raise", "ValueError", "(", "\"Expecting 's3' scheme, got: {} in {}\"", ".", "format", "(", "parsed_url", ".", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
model_code_key_prefix
Returns the s3 key prefix for uploading code during model deployment The location returned is a potential concatenation of 2 parts 1. code_location_key_prefix if it exists 2. model_name or a name derived from the image Args: code_location_key_prefix (str): the s3 key prefix from code_l...
src/sagemaker/fw_utils.py
def model_code_key_prefix(code_location_key_prefix, model_name, image): """Returns the s3 key prefix for uploading code during model deployment The location returned is a potential concatenation of 2 parts 1. code_location_key_prefix if it exists 2. model_name or a name derived from the image ...
def model_code_key_prefix(code_location_key_prefix, model_name, image): """Returns the s3 key prefix for uploading code during model deployment The location returned is a potential concatenation of 2 parts 1. code_location_key_prefix if it exists 2. model_name or a name derived from the image ...
[ "Returns", "the", "s3", "key", "prefix", "for", "uploading", "code", "during", "model", "deployment" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L282-L298
[ "def", "model_code_key_prefix", "(", "code_location_key_prefix", ",", "model_name", ",", "image", ")", ":", "training_job_name", "=", "sagemaker", ".", "utils", ".", "name_from_image", "(", "image", ")", "return", "'/'", ".", "join", "(", "filter", "(", "None", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
LocalSagemakerClient.create_training_job
Create a training job in Local Mode Args: TrainingJobName (str): local training job name. AlgorithmSpecification (dict): Identifies the training algorithm to use. InputDataConfig (dict): Describes the training dataset and the location where it is stored. OutputDat...
src/sagemaker/local/local_session.py
def create_training_job(self, TrainingJobName, AlgorithmSpecification, OutputDataConfig, ResourceConfig, InputDataConfig=None, **kwargs): """ Create a training job in Local Mode Args: TrainingJobName (str): local training job name. AlgorithmSpe...
def create_training_job(self, TrainingJobName, AlgorithmSpecification, OutputDataConfig, ResourceConfig, InputDataConfig=None, **kwargs): """ Create a training job in Local Mode Args: TrainingJobName (str): local training job name. AlgorithmSpe...
[ "Create", "a", "training", "job", "in", "Local", "Mode", "Args", ":", "TrainingJobName", "(", "str", ")", ":", "local", "training", "job", "name", ".", "AlgorithmSpecification", "(", "dict", ")", ":", "Identifies", "the", "training", "algorithm", "to", "use"...
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/local_session.py#L55-L75
[ "def", "create_training_job", "(", "self", ",", "TrainingJobName", ",", "AlgorithmSpecification", ",", "OutputDataConfig", ",", "ResourceConfig", ",", "InputDataConfig", "=", "None", ",", "*", "*", "kwargs", ")", ":", "InputDataConfig", "=", "InputDataConfig", "or",...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
LocalSagemakerClient.describe_training_job
Describe a local training job. Args: TrainingJobName (str): Training job name to describe. Returns: (dict) DescribeTrainingJob Response.
src/sagemaker/local/local_session.py
def describe_training_job(self, TrainingJobName): """Describe a local training job. Args: TrainingJobName (str): Training job name to describe. Returns: (dict) DescribeTrainingJob Response. """ if TrainingJobName not in LocalSagemakerClient._training_jobs: ...
def describe_training_job(self, TrainingJobName): """Describe a local training job. Args: TrainingJobName (str): Training job name to describe. Returns: (dict) DescribeTrainingJob Response. """ if TrainingJobName not in LocalSagemakerClient._training_jobs: ...
[ "Describe", "a", "local", "training", "job", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/local_session.py#L77-L90
[ "def", "describe_training_job", "(", "self", ",", "TrainingJobName", ")", ":", "if", "TrainingJobName", "not", "in", "LocalSagemakerClient", ".", "_training_jobs", ":", "error_response", "=", "{", "'Error'", ":", "{", "'Code'", ":", "'ValidationException'", ",", "...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
LocalSagemakerClient.create_model
Create a Local Model Object Args: ModelName (str): the Model Name PrimaryContainer (dict): a SageMaker primary container definition
src/sagemaker/local/local_session.py
def create_model(self, ModelName, PrimaryContainer, *args, **kwargs): # pylint: disable=unused-argument """Create a Local Model Object Args: ModelName (str): the Model Name PrimaryContainer (dict): a SageMaker primary container definition """ LocalSagemakerClien...
def create_model(self, ModelName, PrimaryContainer, *args, **kwargs): # pylint: disable=unused-argument """Create a Local Model Object Args: ModelName (str): the Model Name PrimaryContainer (dict): a SageMaker primary container definition """ LocalSagemakerClien...
[ "Create", "a", "Local", "Model", "Object" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/local_session.py#L105-L112
[ "def", "create_model", "(", "self", ",", "ModelName", ",", "PrimaryContainer", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=unused-argument", "LocalSagemakerClient", ".", "_models", "[", "ModelName", "]", "=", "_LocalModel", "(", "Mode...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
LocalSession._initialize
Initialize this Local SageMaker Session.
src/sagemaker/local/local_session.py
def _initialize(self, boto_session, sagemaker_client, sagemaker_runtime_client): """Initialize this Local SageMaker Session.""" self.boto_session = boto_session or boto3.Session() self._region_name = self.boto_session.region_name if self._region_name is None: raise ValueErr...
def _initialize(self, boto_session, sagemaker_client, sagemaker_runtime_client): """Initialize this Local SageMaker Session.""" self.boto_session = boto_session or boto3.Session() self._region_name = self.boto_session.region_name if self._region_name is None: raise ValueErr...
[ "Initialize", "this", "Local", "SageMaker", "Session", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/local_session.py#L205-L216
[ "def", "_initialize", "(", "self", ",", "boto_session", ",", "sagemaker_client", ",", "sagemaker_runtime_client", ")", ":", "self", ".", "boto_session", "=", "boto_session", "or", "boto3", ".", "Session", "(", ")", "self", ".", "_region_name", "=", "self", "."...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
SKLearnModel.prepare_container_def
Return a container definition with framework configuration set in model environment variables. Args: instance_type (str): The EC2 instance type to deploy this Model to. For example, 'ml.p2.xlarge'. accelerator_type (str): The Elastic Inference accelerator type to deploy to the instance ...
src/sagemaker/sklearn/model.py
def prepare_container_def(self, instance_type, accelerator_type=None): """Return a container definition with framework configuration set in model environment variables. Args: instance_type (str): The EC2 instance type to deploy this Model to. For example, 'ml.p2.xlarge'. acceler...
def prepare_container_def(self, instance_type, accelerator_type=None): """Return a container definition with framework configuration set in model environment variables. Args: instance_type (str): The EC2 instance type to deploy this Model to. For example, 'ml.p2.xlarge'. acceler...
[ "Return", "a", "container", "definition", "with", "framework", "configuration", "set", "in", "model", "environment", "variables", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/sklearn/model.py#L75-L105
[ "def", "prepare_container_def", "(", "self", ",", "instance_type", ",", "accelerator_type", "=", "None", ")", ":", "if", "accelerator_type", ":", "raise", "ValueError", "(", "\"Accelerator types are not supported for Scikit-Learn.\"", ")", "deploy_image", "=", "self", "...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
upload_numpy_to_s3_shards
Upload the training ``array`` and ``labels`` arrays to ``num_shards`` s3 objects, stored in "s3://``bucket``/``key_prefix``/".
src/sagemaker/amazon/amazon_estimator.py
def upload_numpy_to_s3_shards(num_shards, s3, bucket, key_prefix, array, labels=None): """Upload the training ``array`` and ``labels`` arrays to ``num_shards`` s3 objects, stored in "s3://``bucket``/``key_prefix``/".""" shards = _build_shards(num_shards, array) if labels is not None: label_shard...
def upload_numpy_to_s3_shards(num_shards, s3, bucket, key_prefix, array, labels=None): """Upload the training ``array`` and ``labels`` arrays to ``num_shards`` s3 objects, stored in "s3://``bucket``/``key_prefix``/".""" shards = _build_shards(num_shards, array) if labels is not None: label_shard...
[ "Upload", "the", "training", "array", "and", "labels", "arrays", "to", "num_shards", "s3", "objects", "stored", "in", "s3", ":", "//", "bucket", "/", "key_prefix", "/", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L242-L275
[ "def", "upload_numpy_to_s3_shards", "(", "num_shards", ",", "s3", ",", "bucket", ",", "key_prefix", ",", "array", ",", "labels", "=", "None", ")", ":", "shards", "=", "_build_shards", "(", "num_shards", ",", "array", ")", "if", "labels", "is", "not", "None...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
registry
Return docker registry for the given AWS region Note: Not all the algorithms listed below have an Amazon Estimator implemented. For full list of pre-implemented Estimators, look at: https://github.com/aws/sagemaker-python-sdk/tree/master/src/sagemaker/amazon
src/sagemaker/amazon/amazon_estimator.py
def registry(region_name, algorithm=None): """Return docker registry for the given AWS region Note: Not all the algorithms listed below have an Amazon Estimator implemented. For full list of pre-implemented Estimators, look at: https://github.com/aws/sagemaker-python-sdk/tree/master/src/sagemaker/amaz...
def registry(region_name, algorithm=None): """Return docker registry for the given AWS region Note: Not all the algorithms listed below have an Amazon Estimator implemented. For full list of pre-implemented Estimators, look at: https://github.com/aws/sagemaker-python-sdk/tree/master/src/sagemaker/amaz...
[ "Return", "docker", "registry", "for", "the", "given", "AWS", "region" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L278-L370
[ "def", "registry", "(", "region_name", ",", "algorithm", "=", "None", ")", ":", "if", "algorithm", "in", "[", "None", ",", "'pca'", ",", "'kmeans'", ",", "'linear-learner'", ",", "'factorization-machines'", ",", "'ntm'", ",", "'randomcutforest'", ",", "'knn'",...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
get_image_uri
Return algorithm image URI for the given AWS region, repository name, and repository version
src/sagemaker/amazon/amazon_estimator.py
def get_image_uri(region_name, repo_name, repo_version=1): """Return algorithm image URI for the given AWS region, repository name, and repository version""" repo = '{}:{}'.format(repo_name, repo_version) return '{}/{}'.format(registry(region_name, repo_name), repo)
def get_image_uri(region_name, repo_name, repo_version=1): """Return algorithm image URI for the given AWS region, repository name, and repository version""" repo = '{}:{}'.format(repo_name, repo_version) return '{}/{}'.format(registry(region_name, repo_name), repo)
[ "Return", "algorithm", "image", "URI", "for", "the", "given", "AWS", "region", "repository", "name", "and", "repository", "version" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L373-L376
[ "def", "get_image_uri", "(", "region_name", ",", "repo_name", ",", "repo_version", "=", "1", ")", ":", "repo", "=", "'{}:{}'", ".", "format", "(", "repo_name", ",", "repo_version", ")", "return", "'{}/{}'", ".", "format", "(", "registry", "(", "region_name",...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
AmazonAlgorithmEstimatorBase._prepare_init_params_from_job_description
Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. model_channel_name (str): Name of the channel where pre-trained model data will be downloaded. Returns: ...
src/sagemaker/amazon/amazon_estimator.py
def _prepare_init_params_from_job_description(cls, job_details, model_channel_name=None): """Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. model_channel_n...
def _prepare_init_params_from_job_description(cls, job_details, model_channel_name=None): """Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. model_channel_n...
[ "Convert", "the", "job", "description", "to", "init", "params", "that", "can", "be", "handled", "by", "the", "class", "constructor" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L77-L101
[ "def", "_prepare_init_params_from_job_description", "(", "cls", ",", "job_details", ",", "model_channel_name", "=", "None", ")", ":", "init_params", "=", "super", "(", "AmazonAlgorithmEstimatorBase", ",", "cls", ")", ".", "_prepare_init_params_from_job_description", "(", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
AmazonAlgorithmEstimatorBase._prepare_for_training
Set hyperparameters needed for training. Args: * records (:class:`~RecordSet`): The records to train this ``Estimator`` on. * mini_batch_size (int or None): The size of each mini-batch to use when training. If ``None``, a default value will be used. * job_nam...
src/sagemaker/amazon/amazon_estimator.py
def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): """Set hyperparameters needed for training. Args: * records (:class:`~RecordSet`): The records to train this ``Estimator`` on. * mini_batch_size (int or None): The size of each mini-batch to use when ...
def _prepare_for_training(self, records, mini_batch_size=None, job_name=None): """Set hyperparameters needed for training. Args: * records (:class:`~RecordSet`): The records to train this ``Estimator`` on. * mini_batch_size (int or None): The size of each mini-batch to use when ...
[ "Set", "hyperparameters", "needed", "for", "training", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L103-L128
[ "def", "_prepare_for_training", "(", "self", ",", "records", ",", "mini_batch_size", "=", "None", ",", "job_name", "=", "None", ")", ":", "super", "(", "AmazonAlgorithmEstimatorBase", ",", "self", ")", ".", "_prepare_for_training", "(", "job_name", "=", "job_nam...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
AmazonAlgorithmEstimatorBase.fit
Fit this Estimator on serialized Record objects, stored in S3. ``records`` should be an instance of :class:`~RecordSet`. This defines a collection of S3 data files to train this ``Estimator`` on. Training data is expected to be encoded as dense or sparse vectors in the "values" feature ...
src/sagemaker/amazon/amazon_estimator.py
def fit(self, records, mini_batch_size=None, wait=True, logs=True, job_name=None): """Fit this Estimator on serialized Record objects, stored in S3. ``records`` should be an instance of :class:`~RecordSet`. This defines a collection of S3 data files to train this ``Estimator`` on. Trai...
def fit(self, records, mini_batch_size=None, wait=True, logs=True, job_name=None): """Fit this Estimator on serialized Record objects, stored in S3. ``records`` should be an instance of :class:`~RecordSet`. This defines a collection of S3 data files to train this ``Estimator`` on. Trai...
[ "Fit", "this", "Estimator", "on", "serialized", "Record", "objects", "stored", "in", "S3", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L130-L160
[ "def", "fit", "(", "self", ",", "records", ",", "mini_batch_size", "=", "None", ",", "wait", "=", "True", ",", "logs", "=", "True", ",", "job_name", "=", "None", ")", ":", "self", ".", "_prepare_for_training", "(", "records", ",", "job_name", "=", "job...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
AmazonAlgorithmEstimatorBase.record_set
Build a :class:`~RecordSet` from a numpy :class:`~ndarray` matrix and label vector. For the 2D ``ndarray`` ``train``, each row is converted to a :class:`~Record` object. The vector is stored in the "values" entry of the ``features`` property of each Record. If ``labels`` is not None, each corre...
src/sagemaker/amazon/amazon_estimator.py
def record_set(self, train, labels=None, channel="train"): """Build a :class:`~RecordSet` from a numpy :class:`~ndarray` matrix and label vector. For the 2D ``ndarray`` ``train``, each row is converted to a :class:`~Record` object. The vector is stored in the "values" entry of the ``features`` ...
def record_set(self, train, labels=None, channel="train"): """Build a :class:`~RecordSet` from a numpy :class:`~ndarray` matrix and label vector. For the 2D ``ndarray`` ``train``, each row is converted to a :class:`~Record` object. The vector is stored in the "values" entry of the ``features`` ...
[ "Build", "a", ":", "class", ":", "~RecordSet", "from", "a", "numpy", ":", "class", ":", "~ndarray", "matrix", "and", "label", "vector", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L162-L193
[ "def", "record_set", "(", "self", ",", "train", ",", "labels", "=", "None", ",", "channel", "=", "\"train\"", ")", ":", "s3", "=", "self", ".", "sagemaker_session", ".", "boto_session", ".", "resource", "(", "'s3'", ")", "parsed_s3_url", "=", "urlparse", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
get_data_source_instance
Return an Instance of :class:`sagemaker.local.data.DataSource` that can handle the provided data_source URI. data_source can be either file:// or s3:// Args: data_source (str): a valid URI that points to a data source. sagemaker_session (:class:`sagemaker.session.Session`): a SageMaker Ses...
src/sagemaker/local/data.py
def get_data_source_instance(data_source, sagemaker_session): """Return an Instance of :class:`sagemaker.local.data.DataSource` that can handle the provided data_source URI. data_source can be either file:// or s3:// Args: data_source (str): a valid URI that points to a data source. sa...
def get_data_source_instance(data_source, sagemaker_session): """Return an Instance of :class:`sagemaker.local.data.DataSource` that can handle the provided data_source URI. data_source can be either file:// or s3:// Args: data_source (str): a valid URI that points to a data source. sa...
[ "Return", "an", "Instance", "of", ":", "class", ":", "sagemaker", ".", "local", ".", "data", ".", "DataSource", "that", "can", "handle", "the", "provided", "data_source", "URI", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L30-L49
[ "def", "get_data_source_instance", "(", "data_source", ",", "sagemaker_session", ")", ":", "parsed_uri", "=", "urlparse", "(", "data_source", ")", "if", "parsed_uri", ".", "scheme", "==", "'file'", ":", "return", "LocalFileDataSource", "(", "parsed_uri", ".", "net...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
get_splitter_instance
Return an Instance of :class:`sagemaker.local.data.Splitter` according to the specified `split_type`. Args: split_type (str): either 'Line' or 'RecordIO'. Can be left as None to signal no data split will happen. Returns :class:`sagemaker.local.data.Splitter`: an Instance of a S...
src/sagemaker/local/data.py
def get_splitter_instance(split_type): """Return an Instance of :class:`sagemaker.local.data.Splitter` according to the specified `split_type`. Args: split_type (str): either 'Line' or 'RecordIO'. Can be left as None to signal no data split will happen. Returns :class:`sage...
def get_splitter_instance(split_type): """Return an Instance of :class:`sagemaker.local.data.Splitter` according to the specified `split_type`. Args: split_type (str): either 'Line' or 'RecordIO'. Can be left as None to signal no data split will happen. Returns :class:`sage...
[ "Return", "an", "Instance", "of", ":", "class", ":", "sagemaker", ".", "local", ".", "data", ".", "Splitter", "according", "to", "the", "specified", "split_type", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L52-L70
[ "def", "get_splitter_instance", "(", "split_type", ")", ":", "if", "split_type", "is", "None", ":", "return", "NoneSplitter", "(", ")", "elif", "split_type", "==", "'Line'", ":", "return", "LineSplitter", "(", ")", "elif", "split_type", "==", "'RecordIO'", ":"...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
get_batch_strategy_instance
Return an Instance of :class:`sagemaker.local.data.BatchStrategy` according to `strategy` Args: strategy (str): Either 'SingleRecord' or 'MultiRecord' splitter (:class:`sagemaker.local.data.Splitter): splitter to get the data from. Returns :class:`sagemaker.local.data.BatchStrategy`: a...
src/sagemaker/local/data.py
def get_batch_strategy_instance(strategy, splitter): """Return an Instance of :class:`sagemaker.local.data.BatchStrategy` according to `strategy` Args: strategy (str): Either 'SingleRecord' or 'MultiRecord' splitter (:class:`sagemaker.local.data.Splitter): splitter to get the data from. Re...
def get_batch_strategy_instance(strategy, splitter): """Return an Instance of :class:`sagemaker.local.data.BatchStrategy` according to `strategy` Args: strategy (str): Either 'SingleRecord' or 'MultiRecord' splitter (:class:`sagemaker.local.data.Splitter): splitter to get the data from. Re...
[ "Return", "an", "Instance", "of", ":", "class", ":", "sagemaker", ".", "local", ".", "data", ".", "BatchStrategy", "according", "to", "strategy" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L73-L88
[ "def", "get_batch_strategy_instance", "(", "strategy", ",", "splitter", ")", ":", "if", "strategy", "==", "'SingleRecord'", ":", "return", "SingleRecordStrategy", "(", "splitter", ")", "elif", "strategy", "==", "'MultiRecord'", ":", "return", "MultiRecordStrategy", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
LocalFileDataSource.get_file_list
Retrieve the list of absolute paths to all the files in this data source. Returns: List[str] List of absolute paths.
src/sagemaker/local/data.py
def get_file_list(self): """Retrieve the list of absolute paths to all the files in this data source. Returns: List[str] List of absolute paths. """ if os.path.isdir(self.root_path): return [os.path.join(self.root_path, f) for f in os.listdir(self.root_path) ...
def get_file_list(self): """Retrieve the list of absolute paths to all the files in this data source. Returns: List[str] List of absolute paths. """ if os.path.isdir(self.root_path): return [os.path.join(self.root_path, f) for f in os.listdir(self.root_path) ...
[ "Retrieve", "the", "list", "of", "absolute", "paths", "to", "all", "the", "files", "in", "this", "data", "source", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L119-L129
[ "def", "get_file_list", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "root_path", ")", ":", "return", "[", "os", ".", "path", ".", "join", "(", "self", ".", "root_path", ",", "f", ")", "for", "f", "in", "os", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
LocalFileDataSource.get_root_dir
Retrieve the absolute path to the root directory of this data source. Returns: str: absolute path to the root directory of this data source.
src/sagemaker/local/data.py
def get_root_dir(self): """Retrieve the absolute path to the root directory of this data source. Returns: str: absolute path to the root directory of this data source. """ if os.path.isdir(self.root_path): return self.root_path else: return os...
def get_root_dir(self): """Retrieve the absolute path to the root directory of this data source. Returns: str: absolute path to the root directory of this data source. """ if os.path.isdir(self.root_path): return self.root_path else: return os...
[ "Retrieve", "the", "absolute", "path", "to", "the", "root", "directory", "of", "this", "data", "source", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L131-L140
[ "def", "get_root_dir", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "root_path", ")", ":", "return", "self", ".", "root_path", "else", ":", "return", "os", ".", "path", ".", "dirname", "(", "self", ".", "root_path",...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
RecordIOSplitter.split
Split a file into records using a specific strategy This RecordIOSplitter splits the data into individual RecordIO records. Args: file (str): path to the file to split Returns: generator for the individual records that were split from the file
src/sagemaker/local/data.py
def split(self, file): """Split a file into records using a specific strategy This RecordIOSplitter splits the data into individual RecordIO records. Args: file (str): path to the file to split Returns: generator for the individual records that were split from the file ...
def split(self, file): """Split a file into records using a specific strategy This RecordIOSplitter splits the data into individual RecordIO records. Args: file (str): path to the file to split Returns: generator for the individual records that were split from the file ...
[ "Split", "a", "file", "into", "records", "using", "a", "specific", "strategy" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L248-L260
[ "def", "split", "(", "self", ",", "file", ")", ":", "with", "open", "(", "file", ",", "'rb'", ")", "as", "f", ":", "for", "record", "in", "sagemaker", ".", "amazon", ".", "common", ".", "read_recordio", "(", "f", ")", ":", "yield", "record" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
train
MultiRecordStrategy.pad
Group together as many records as possible to fit in the specified size Args: file (str): file path to read the records from. size (int): maximum size in MB that each group of records will be fitted to. passing 0 means unlimited size. Returns: genera...
src/sagemaker/local/data.py
def pad(self, file, size=6): """Group together as many records as possible to fit in the specified size Args: file (str): file path to read the records from. size (int): maximum size in MB that each group of records will be fitted to. passing 0 means unlimited si...
def pad(self, file, size=6): """Group together as many records as possible to fit in the specified size Args: file (str): file path to read the records from. size (int): maximum size in MB that each group of records will be fitted to. passing 0 means unlimited si...
[ "Group", "together", "as", "many", "records", "as", "possible", "to", "fit", "in", "the", "specified", "size" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L293-L313
[ "def", "pad", "(", "self", ",", "file", ",", "size", "=", "6", ")", ":", "buffer", "=", "''", "for", "element", "in", "self", ".", "splitter", ".", "split", "(", "file", ")", ":", "if", "_payload_size_within_limit", "(", "buffer", "+", "element", ","...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
SingleRecordStrategy.pad
Group together as many records as possible to fit in the specified size This SingleRecordStrategy will not group any record and will return them one by one as long as they are within the maximum size. Args: file (str): file path to read the records from. size (int): max...
src/sagemaker/local/data.py
def pad(self, file, size=6): """Group together as many records as possible to fit in the specified size This SingleRecordStrategy will not group any record and will return them one by one as long as they are within the maximum size. Args: file (str): file path to read the r...
def pad(self, file, size=6): """Group together as many records as possible to fit in the specified size This SingleRecordStrategy will not group any record and will return them one by one as long as they are within the maximum size. Args: file (str): file path to read the r...
[ "Group", "together", "as", "many", "records", "as", "possible", "to", "fit", "in", "the", "specified", "size" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L321-L337
[ "def", "pad", "(", "self", ",", "file", ",", "size", "=", "6", ")", ":", "for", "element", "in", "self", ".", "splitter", ".", "split", "(", "file", ")", ":", "if", "_validate_payload_size", "(", "element", ",", "size", ")", ":", "yield", "element" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Chainer.hyperparameters
Return hyperparameters used by your custom Chainer code during training.
src/sagemaker/chainer/estimator.py
def hyperparameters(self): """Return hyperparameters used by your custom Chainer code during training.""" hyperparameters = super(Chainer, self).hyperparameters() additional_hyperparameters = {Chainer._use_mpi: self.use_mpi, Chainer._num_processes: self.num...
def hyperparameters(self): """Return hyperparameters used by your custom Chainer code during training.""" hyperparameters = super(Chainer, self).hyperparameters() additional_hyperparameters = {Chainer._use_mpi: self.use_mpi, Chainer._num_processes: self.num...
[ "Return", "hyperparameters", "used", "by", "your", "custom", "Chainer", "code", "during", "training", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/chainer/estimator.py#L99-L111
[ "def", "hyperparameters", "(", "self", ")", ":", "hyperparameters", "=", "super", "(", "Chainer", ",", "self", ")", ".", "hyperparameters", "(", ")", "additional_hyperparameters", "=", "{", "Chainer", ".", "_use_mpi", ":", "self", ".", "use_mpi", ",", "Chain...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Chainer.create_model
Create a SageMaker ``ChainerModel`` object that can be deployed to an ``Endpoint``. Args: role (str): The ``ExecutionRoleArn`` IAM Role ARN for the ``Model``, which is also used during transform jobs. If not specified, the role from the Estimator will be used. model_serv...
src/sagemaker/chainer/estimator.py
def create_model(self, model_server_workers=None, role=None, vpc_config_override=VPC_CONFIG_DEFAULT): """Create a SageMaker ``ChainerModel`` object that can be deployed to an ``Endpoint``. Args: role (str): The ``ExecutionRoleArn`` IAM Role ARN for the ``Model``, which is also used during ...
def create_model(self, model_server_workers=None, role=None, vpc_config_override=VPC_CONFIG_DEFAULT): """Create a SageMaker ``ChainerModel`` object that can be deployed to an ``Endpoint``. Args: role (str): The ``ExecutionRoleArn`` IAM Role ARN for the ``Model``, which is also used during ...
[ "Create", "a", "SageMaker", "ChainerModel", "object", "that", "can", "be", "deployed", "to", "an", "Endpoint", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/chainer/estimator.py#L113-L137
[ "def", "create_model", "(", "self", ",", "model_server_workers", "=", "None", ",", "role", "=", "None", ",", "vpc_config_override", "=", "VPC_CONFIG_DEFAULT", ")", ":", "role", "=", "role", "or", "self", ".", "role", "return", "ChainerModel", "(", "self", "....
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Chainer._prepare_init_params_from_job_description
Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. model_channel_name (str): Name of the channel where pre-trained model data will be downloaded. Returns: ...
src/sagemaker/chainer/estimator.py
def _prepare_init_params_from_job_description(cls, job_details, model_channel_name=None): """Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. model_channel_n...
def _prepare_init_params_from_job_description(cls, job_details, model_channel_name=None): """Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. model_channel_n...
[ "Convert", "the", "job", "description", "to", "init", "params", "that", "can", "be", "handled", "by", "the", "class", "constructor" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/chainer/estimator.py#L140-L176
[ "def", "_prepare_init_params_from_job_description", "(", "cls", ",", "job_details", ",", "model_channel_name", "=", "None", ")", ":", "init_params", "=", "super", "(", "Chainer", ",", "cls", ")", ".", "_prepare_init_params_from_job_description", "(", "job_details", ",...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
write_numpy_to_dense_tensor
Writes a numpy array to a dense tensor
src/sagemaker/amazon/common.py
def write_numpy_to_dense_tensor(file, array, labels=None): """Writes a numpy array to a dense tensor""" # Validate shape of array and labels, resolve array and label types if not len(array.shape) == 2: raise ValueError("Array must be a Matrix") if labels is not None: if not len(labels.s...
def write_numpy_to_dense_tensor(file, array, labels=None): """Writes a numpy array to a dense tensor""" # Validate shape of array and labels, resolve array and label types if not len(array.shape) == 2: raise ValueError("Array must be a Matrix") if labels is not None: if not len(labels.s...
[ "Writes", "a", "numpy", "array", "to", "a", "dense", "tensor" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/common.py#L88-L110
[ "def", "write_numpy_to_dense_tensor", "(", "file", ",", "array", ",", "labels", "=", "None", ")", ":", "# Validate shape of array and labels, resolve array and label types", "if", "not", "len", "(", "array", ".", "shape", ")", "==", "2", ":", "raise", "ValueError", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
write_spmatrix_to_sparse_tensor
Writes a scipy sparse matrix to a sparse tensor
src/sagemaker/amazon/common.py
def write_spmatrix_to_sparse_tensor(file, array, labels=None): """Writes a scipy sparse matrix to a sparse tensor""" if not issparse(array): raise TypeError("Array must be sparse") # Validate shape of array and labels, resolve array and label types if not len(array.shape) == 2: raise V...
def write_spmatrix_to_sparse_tensor(file, array, labels=None): """Writes a scipy sparse matrix to a sparse tensor""" if not issparse(array): raise TypeError("Array must be sparse") # Validate shape of array and labels, resolve array and label types if not len(array.shape) == 2: raise V...
[ "Writes", "a", "scipy", "sparse", "matrix", "to", "a", "sparse", "tensor" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/common.py#L113-L150
[ "def", "write_spmatrix_to_sparse_tensor", "(", "file", ",", "array", ",", "labels", "=", "None", ")", ":", "if", "not", "issparse", "(", "array", ")", ":", "raise", "TypeError", "(", "\"Array must be sparse\"", ")", "# Validate shape of array and labels, resolve array...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
read_records
Eagerly read a collection of amazon Record protobuf objects from file.
src/sagemaker/amazon/common.py
def read_records(file): """Eagerly read a collection of amazon Record protobuf objects from file.""" records = [] for record_data in read_recordio(file): record = Record() record.ParseFromString(record_data) records.append(record) return records
def read_records(file): """Eagerly read a collection of amazon Record protobuf objects from file.""" records = [] for record_data in read_recordio(file): record = Record() record.ParseFromString(record_data) records.append(record) return records
[ "Eagerly", "read", "a", "collection", "of", "amazon", "Record", "protobuf", "objects", "from", "file", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/common.py#L153-L160
[ "def", "read_records", "(", "file", ")", ":", "records", "=", "[", "]", "for", "record_data", "in", "read_recordio", "(", "file", ")", ":", "record", "=", "Record", "(", ")", "record", ".", "ParseFromString", "(", "record_data", ")", "records", ".", "app...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
_write_recordio
Writes a single data point as a RecordIO record to the given file.
src/sagemaker/amazon/common.py
def _write_recordio(f, data): """Writes a single data point as a RecordIO record to the given file.""" length = len(data) f.write(struct.pack('I', _kmagic)) f.write(struct.pack('I', length)) pad = (((length + 3) >> 2) << 2) - length f.write(data) f.write(padding[pad])
def _write_recordio(f, data): """Writes a single data point as a RecordIO record to the given file.""" length = len(data) f.write(struct.pack('I', _kmagic)) f.write(struct.pack('I', length)) pad = (((length + 3) >> 2) << 2) - length f.write(data) f.write(padding[pad])
[ "Writes", "a", "single", "data", "point", "as", "a", "RecordIO", "record", "to", "the", "given", "file", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/common.py#L176-L183
[ "def", "_write_recordio", "(", "f", ",", "data", ")", ":", "length", "=", "len", "(", "data", ")", "f", ".", "write", "(", "struct", ".", "pack", "(", "'I'", ",", "_kmagic", ")", ")", "f", ".", "write", "(", "struct", ".", "pack", "(", "'I'", "...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Model.prepare_container_def
Return a dict created by ``sagemaker.container_def()`` for deploying this model to a specified instance type. Subclasses can override this to provide custom container definitions for deployment to a specific instance type. Called by ``deploy()``. Args: instance_type (str): The EC2 ...
src/sagemaker/model.py
def prepare_container_def(self, instance_type, accelerator_type=None): # pylint: disable=unused-argument """Return a dict created by ``sagemaker.container_def()`` for deploying this model to a specified instance type. Subclasses can override this to provide custom container definitions for dep...
def prepare_container_def(self, instance_type, accelerator_type=None): # pylint: disable=unused-argument """Return a dict created by ``sagemaker.container_def()`` for deploying this model to a specified instance type. Subclasses can override this to provide custom container definitions for dep...
[ "Return", "a", "dict", "created", "by", "sagemaker", ".", "container_def", "()", "for", "deploying", "this", "model", "to", "a", "specified", "instance", "type", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L73-L87
[ "def", "prepare_container_def", "(", "self", ",", "instance_type", ",", "accelerator_type", "=", "None", ")", ":", "# pylint: disable=unused-argument", "return", "sagemaker", ".", "container_def", "(", "self", ".", "image", ",", "self", ".", "model_data", ",", "se...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Model._create_sagemaker_model
Create a SageMaker Model Entity Args: instance_type (str): The EC2 instance type that this Model will be used for, this is only used to determine if the image needs GPU support or not. accelerator_type (str): Type of Elastic Inference accelerator to attach to an endpoint...
src/sagemaker/model.py
def _create_sagemaker_model(self, instance_type, accelerator_type=None, tags=None): """Create a SageMaker Model Entity Args: instance_type (str): The EC2 instance type that this Model will be used for, this is only used to determine if the image needs GPU support or not. ...
def _create_sagemaker_model(self, instance_type, accelerator_type=None, tags=None): """Create a SageMaker Model Entity Args: instance_type (str): The EC2 instance type that this Model will be used for, this is only used to determine if the image needs GPU support or not. ...
[ "Create", "a", "SageMaker", "Model", "Entity" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L97-L118
[ "def", "_create_sagemaker_model", "(", "self", ",", "instance_type", ",", "accelerator_type", "=", "None", ",", "tags", "=", "None", ")", ":", "container_def", "=", "self", ".", "prepare_container_def", "(", "instance_type", ",", "accelerator_type", "=", "accelera...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Model.compile
Compile this ``Model`` with SageMaker Neo. Args: target_instance_family (str): Identifies the device that you want to run your model after compilation, for example: ml_c5. Allowed strings are: ml_c5, ml_m5, ml_c4, ml_m4, jetsontx1, jetsontx2, ml_p2, ml_p3, deeplens, ...
src/sagemaker/model.py
def compile(self, target_instance_family, input_shape, output_path, role, tags=None, job_name=None, compile_max_run=5 * 60, framework=None, framework_version=None): """Compile this ``Model`` with SageMaker Neo. Args: target_instance_family (str): Identifies the device that y...
def compile(self, target_instance_family, input_shape, output_path, role, tags=None, job_name=None, compile_max_run=5 * 60, framework=None, framework_version=None): """Compile this ``Model`` with SageMaker Neo. Args: target_instance_family (str): Identifies the device that y...
[ "Compile", "this", "Model", "with", "SageMaker", "Neo", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L162-L209
[ "def", "compile", "(", "self", ",", "target_instance_family", ",", "input_shape", ",", "output_path", ",", "role", ",", "tags", "=", "None", ",", "job_name", "=", "None", ",", "compile_max_run", "=", "5", "*", "60", ",", "framework", "=", "None", ",", "f...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Model.deploy
Deploy this ``Model`` to an ``Endpoint`` and optionally return a ``Predictor``. Create a SageMaker ``Model`` and ``EndpointConfig``, and deploy an ``Endpoint`` from this ``Model``. If ``self.predictor_cls`` is not None, this method returns a the result of invoking ``self.predictor_cls`` on the ...
src/sagemaker/model.py
def deploy(self, initial_instance_count, instance_type, accelerator_type=None, endpoint_name=None, update_endpoint=False, tags=None, kms_key=None): """Deploy this ``Model`` to an ``Endpoint`` and optionally return a ``Predictor``. Create a SageMaker ``Model`` and ``EndpointConfig``, and ...
def deploy(self, initial_instance_count, instance_type, accelerator_type=None, endpoint_name=None, update_endpoint=False, tags=None, kms_key=None): """Deploy this ``Model`` to an ``Endpoint`` and optionally return a ``Predictor``. Create a SageMaker ``Model`` and ``EndpointConfig``, and ...
[ "Deploy", "this", "Model", "to", "an", "Endpoint", "and", "optionally", "return", "a", "Predictor", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L211-L283
[ "def", "deploy", "(", "self", ",", "initial_instance_count", ",", "instance_type", ",", "accelerator_type", "=", "None", ",", "endpoint_name", "=", "None", ",", "update_endpoint", "=", "False", ",", "tags", "=", "None", ",", "kms_key", "=", "None", ")", ":",...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Model.transformer
Return a ``Transformer`` that uses this Model. Args: instance_count (int): Number of EC2 instances to use. instance_type (str): Type of EC2 instance to use, for example, 'ml.c4.xlarge'. strategy (str): The strategy used to decide how to batch records in a single request (def...
src/sagemaker/model.py
def transformer(self, instance_count, instance_type, strategy=None, assemble_with=None, output_path=None, output_kms_key=None, accept=None, env=None, max_concurrent_transforms=None, max_payload=None, tags=None, volume_kms_key=None): """Return a ``Transformer`` that uses t...
def transformer(self, instance_count, instance_type, strategy=None, assemble_with=None, output_path=None, output_kms_key=None, accept=None, env=None, max_concurrent_transforms=None, max_payload=None, tags=None, volume_kms_key=None): """Return a ``Transformer`` that uses t...
[ "Return", "a", "Transformer", "that", "uses", "this", "Model", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L285-L317
[ "def", "transformer", "(", "self", ",", "instance_count", ",", "instance_type", ",", "strategy", "=", "None", ",", "assemble_with", "=", "None", ",", "output_path", "=", "None", ",", "output_kms_key", "=", "None", ",", "accept", "=", "None", ",", "env", "=...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
FrameworkModel.prepare_container_def
Return a container definition with framework configuration set in model environment variables. This also uploads user-supplied code to S3. Args: instance_type (str): The EC2 instance type to deploy this Model to. For example, 'ml.p2.xlarge'. accelerator_type (str): The Elastic ...
src/sagemaker/model.py
def prepare_container_def(self, instance_type, accelerator_type=None): # pylint disable=unused-argument """Return a container definition with framework configuration set in model environment variables. This also uploads user-supplied code to S3. Args: instance_type (str): The EC2 ...
def prepare_container_def(self, instance_type, accelerator_type=None): # pylint disable=unused-argument """Return a container definition with framework configuration set in model environment variables. This also uploads user-supplied code to S3. Args: instance_type (str): The EC2 ...
[ "Return", "a", "container", "definition", "with", "framework", "configuration", "set", "in", "model", "environment", "variables", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L408-L425
[ "def", "prepare_container_def", "(", "self", ",", "instance_type", ",", "accelerator_type", "=", "None", ")", ":", "# pylint disable=unused-argument", "deploy_key_prefix", "=", "fw_utils", ".", "model_code_key_prefix", "(", "self", ".", "key_prefix", ",", "self", ".",...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
ModelPackage._create_sagemaker_model
Create a SageMaker Model Entity Args: *args: Arguments coming from the caller. This class does not require any so they are ignored.
src/sagemaker/model.py
def _create_sagemaker_model(self, *args): # pylint: disable=unused-argument """Create a SageMaker Model Entity Args: *args: Arguments coming from the caller. This class does not require any so they are ignored. """ if self.algorithm_arn: # When M...
def _create_sagemaker_model(self, *args): # pylint: disable=unused-argument """Create a SageMaker Model Entity Args: *args: Arguments coming from the caller. This class does not require any so they are ignored. """ if self.algorithm_arn: # When M...
[ "Create", "a", "SageMaker", "Model", "Entity" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L538-L569
[ "def", "_create_sagemaker_model", "(", "self", ",", "*", "args", ")", ":", "# pylint: disable=unused-argument", "if", "self", ".", "algorithm_arn", ":", "# When ModelPackage is created using an algorithm_arn we need to first", "# create a ModelPackage. If we had already created one t...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
RealTimePredictor.predict
Return the inference from the specified endpoint. Args: data (object): Input data for which you want the model to provide inference. If a serializer was specified when creating the RealTimePredictor, the result of the serializer is sent as input data. Otherwise the d...
src/sagemaker/predictor.py
def predict(self, data, initial_args=None): """Return the inference from the specified endpoint. Args: data (object): Input data for which you want the model to provide inference. If a serializer was specified when creating the RealTimePredictor, the result of the ...
def predict(self, data, initial_args=None): """Return the inference from the specified endpoint. Args: data (object): Input data for which you want the model to provide inference. If a serializer was specified when creating the RealTimePredictor, the result of the ...
[ "Return", "the", "inference", "from", "the", "specified", "endpoint", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/predictor.py#L62-L81
[ "def", "predict", "(", "self", ",", "data", ",", "initial_args", "=", "None", ")", ":", "request_args", "=", "self", ".", "_create_request_args", "(", "data", ",", "initial_args", ")", "response", "=", "self", ".", "sagemaker_session", ".", "sagemaker_runtime_...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
RealTimePredictor.delete_endpoint
Delete the Amazon SageMaker endpoint backing this predictor. Also delete the endpoint configuration attached to it if delete_endpoint_config is True. Args: delete_endpoint_config (bool, optional): Flag to indicate whether to delete endpoint configuration together with endpoi...
src/sagemaker/predictor.py
def delete_endpoint(self, delete_endpoint_config=True): """Delete the Amazon SageMaker endpoint backing this predictor. Also delete the endpoint configuration attached to it if delete_endpoint_config is True. Args: delete_endpoint_config (bool, optional): Flag to indicate whether to...
def delete_endpoint(self, delete_endpoint_config=True): """Delete the Amazon SageMaker endpoint backing this predictor. Also delete the endpoint configuration attached to it if delete_endpoint_config is True. Args: delete_endpoint_config (bool, optional): Flag to indicate whether to...
[ "Delete", "the", "Amazon", "SageMaker", "endpoint", "backing", "this", "predictor", ".", "Also", "delete", "the", "endpoint", "configuration", "attached", "to", "it", "if", "delete_endpoint_config", "is", "True", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/predictor.py#L116-L129
[ "def", "delete_endpoint", "(", "self", ",", "delete_endpoint_config", "=", "True", ")", ":", "if", "delete_endpoint_config", ":", "self", ".", "_delete_endpoint_config", "(", ")", "self", ".", "sagemaker_session", ".", "delete_endpoint", "(", "self", ".", "endpoin...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
RealTimePredictor.delete_model
Deletes the Amazon SageMaker models backing this predictor.
src/sagemaker/predictor.py
def delete_model(self): """Deletes the Amazon SageMaker models backing this predictor. """ request_failed = False failed_models = [] for model_name in self._model_names: try: self.sagemaker_session.delete_model(model_name) except Exception...
def delete_model(self): """Deletes the Amazon SageMaker models backing this predictor. """ request_failed = False failed_models = [] for model_name in self._model_names: try: self.sagemaker_session.delete_model(model_name) except Exception...
[ "Deletes", "the", "Amazon", "SageMaker", "models", "backing", "this", "predictor", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/predictor.py#L131-L146
[ "def", "delete_model", "(", "self", ")", ":", "request_failed", "=", "False", "failed_models", "=", "[", "]", "for", "model_name", "in", "self", ".", "_model_names", ":", "try", ":", "self", ".", "sagemaker_session", ".", "delete_model", "(", "model_name", "...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
AnalyticsMetricsBase.dataframe
A pandas dataframe with lots of interesting results about this object. Created by calling SageMaker List and Describe APIs and converting them into a convenient tabular summary. Args: force_refresh (bool): Set to True to fetch the latest data from SageMaker API.
src/sagemaker/analytics.py
def dataframe(self, force_refresh=False): """A pandas dataframe with lots of interesting results about this object. Created by calling SageMaker List and Describe APIs and converting them into a convenient tabular summary. Args: force_refresh (bool): Set to True to fetch the...
def dataframe(self, force_refresh=False): """A pandas dataframe with lots of interesting results about this object. Created by calling SageMaker List and Describe APIs and converting them into a convenient tabular summary. Args: force_refresh (bool): Set to True to fetch the...
[ "A", "pandas", "dataframe", "with", "lots", "of", "interesting", "results", "about", "this", "object", ".", "Created", "by", "calling", "SageMaker", "List", "and", "Describe", "APIs", "and", "converting", "them", "into", "a", "convenient", "tabular", "summary", ...
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L48-L60
[ "def", "dataframe", "(", "self", ",", "force_refresh", "=", "False", ")", ":", "if", "force_refresh", ":", "self", ".", "clear_cache", "(", ")", "if", "self", ".", "_dataframe", "is", "None", ":", "self", ".", "_dataframe", "=", "self", ".", "_fetch_data...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
HyperparameterTuningJobAnalytics.clear_cache
Clear the object of all local caches of API methods.
src/sagemaker/analytics.py
def clear_cache(self): """Clear the object of all local caches of API methods. """ super(HyperparameterTuningJobAnalytics, self).clear_cache() self._tuning_job_describe_result = None self._training_job_summaries = None
def clear_cache(self): """Clear the object of all local caches of API methods. """ super(HyperparameterTuningJobAnalytics, self).clear_cache() self._tuning_job_describe_result = None self._training_job_summaries = None
[ "Clear", "the", "object", "of", "all", "local", "caches", "of", "API", "methods", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L102-L107
[ "def", "clear_cache", "(", "self", ")", ":", "super", "(", "HyperparameterTuningJobAnalytics", ",", "self", ")", ".", "clear_cache", "(", ")", "self", ".", "_tuning_job_describe_result", "=", "None", "self", ".", "_training_job_summaries", "=", "None" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
train
HyperparameterTuningJobAnalytics._fetch_dataframe
Return a pandas dataframe with all the training jobs, along with their hyperparameters, results, and metadata. This also includes a column to indicate if a training job was the best seen so far.
src/sagemaker/analytics.py
def _fetch_dataframe(self): """Return a pandas dataframe with all the training jobs, along with their hyperparameters, results, and metadata. This also includes a column to indicate if a training job was the best seen so far. """ def reshape(training_summary): # Helpe...
def _fetch_dataframe(self): """Return a pandas dataframe with all the training jobs, along with their hyperparameters, results, and metadata. This also includes a column to indicate if a training job was the best seen so far. """ def reshape(training_summary): # Helpe...
[ "Return", "a", "pandas", "dataframe", "with", "all", "the", "training", "jobs", "along", "with", "their", "hyperparameters", "results", "and", "metadata", ".", "This", "also", "includes", "a", "column", "to", "indicate", "if", "a", "training", "job", "was", ...
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L109-L138
[ "def", "_fetch_dataframe", "(", "self", ")", ":", "def", "reshape", "(", "training_summary", ")", ":", "# Helper method to reshape a single training job summary into a dataframe record", "out", "=", "{", "}", "for", "k", ",", "v", "in", "training_summary", "[", "'Tune...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
HyperparameterTuningJobAnalytics.tuning_ranges
A dictionary describing the ranges of all tuned hyperparameters. The keys are the names of the hyperparameter, and the values are the ranges.
src/sagemaker/analytics.py
def tuning_ranges(self): """A dictionary describing the ranges of all tuned hyperparameters. The keys are the names of the hyperparameter, and the values are the ranges. """ out = {} for _, ranges in self.description()['HyperParameterTuningJobConfig']['ParameterRanges'].items(): ...
def tuning_ranges(self): """A dictionary describing the ranges of all tuned hyperparameters. The keys are the names of the hyperparameter, and the values are the ranges. """ out = {} for _, ranges in self.description()['HyperParameterTuningJobConfig']['ParameterRanges'].items(): ...
[ "A", "dictionary", "describing", "the", "ranges", "of", "all", "tuned", "hyperparameters", ".", "The", "keys", "are", "the", "names", "of", "the", "hyperparameter", "and", "the", "values", "are", "the", "ranges", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L141-L149
[ "def", "tuning_ranges", "(", "self", ")", ":", "out", "=", "{", "}", "for", "_", ",", "ranges", "in", "self", ".", "description", "(", ")", "[", "'HyperParameterTuningJobConfig'", "]", "[", "'ParameterRanges'", "]", ".", "items", "(", ")", ":", "for", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
HyperparameterTuningJobAnalytics.description
Call ``DescribeHyperParameterTuningJob`` for the hyperparameter tuning job. Args: force_refresh (bool): Set to True to fetch the latest data from SageMaker API. Returns: dict: The Amazon SageMaker response for ``DescribeHyperParameterTuningJob``.
src/sagemaker/analytics.py
def description(self, force_refresh=False): """Call ``DescribeHyperParameterTuningJob`` for the hyperparameter tuning job. Args: force_refresh (bool): Set to True to fetch the latest data from SageMaker API. Returns: dict: The Amazon SageMaker response for ``DescribeHyp...
def description(self, force_refresh=False): """Call ``DescribeHyperParameterTuningJob`` for the hyperparameter tuning job. Args: force_refresh (bool): Set to True to fetch the latest data from SageMaker API. Returns: dict: The Amazon SageMaker response for ``DescribeHyp...
[ "Call", "DescribeHyperParameterTuningJob", "for", "the", "hyperparameter", "tuning", "job", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L151-L166
[ "def", "description", "(", "self", ",", "force_refresh", "=", "False", ")", ":", "if", "force_refresh", ":", "self", ".", "clear_cache", "(", ")", "if", "not", "self", ".", "_tuning_job_describe_result", ":", "self", ".", "_tuning_job_describe_result", "=", "s...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
HyperparameterTuningJobAnalytics.training_job_summaries
A (paginated) list of everything from ``ListTrainingJobsForTuningJob``. Args: force_refresh (bool): Set to True to fetch the latest data from SageMaker API. Returns: dict: The Amazon SageMaker response for ``ListTrainingJobsForTuningJob``.
src/sagemaker/analytics.py
def training_job_summaries(self, force_refresh=False): """A (paginated) list of everything from ``ListTrainingJobsForTuningJob``. Args: force_refresh (bool): Set to True to fetch the latest data from SageMaker API. Returns: dict: The Amazon SageMaker response for ``List...
def training_job_summaries(self, force_refresh=False): """A (paginated) list of everything from ``ListTrainingJobsForTuningJob``. Args: force_refresh (bool): Set to True to fetch the latest data from SageMaker API. Returns: dict: The Amazon SageMaker response for ``List...
[ "A", "(", "paginated", ")", "list", "of", "everything", "from", "ListTrainingJobsForTuningJob", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L168-L196
[ "def", "training_job_summaries", "(", "self", ",", "force_refresh", "=", "False", ")", ":", "if", "force_refresh", ":", "self", ".", "clear_cache", "(", ")", "if", "self", ".", "_training_job_summaries", "is", "not", "None", ":", "return", "self", ".", "_tra...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
TrainingJobAnalytics.clear_cache
Clear the object of all local caches of API methods, so that the next time any properties are accessed they will be refreshed from the service.
src/sagemaker/analytics.py
def clear_cache(self): """Clear the object of all local caches of API methods, so that the next time any properties are accessed they will be refreshed from the service. """ super(TrainingJobAnalytics, self).clear_cache() self._data = defaultdict(list) self._time_...
def clear_cache(self): """Clear the object of all local caches of API methods, so that the next time any properties are accessed they will be refreshed from the service. """ super(TrainingJobAnalytics, self).clear_cache() self._data = defaultdict(list) self._time_...
[ "Clear", "the", "object", "of", "all", "local", "caches", "of", "API", "methods", "so", "that", "the", "next", "time", "any", "properties", "are", "accessed", "they", "will", "be", "refreshed", "from", "the", "service", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L240-L247
[ "def", "clear_cache", "(", "self", ")", ":", "super", "(", "TrainingJobAnalytics", ",", "self", ")", ".", "clear_cache", "(", ")", "self", ".", "_data", "=", "defaultdict", "(", "list", ")", "self", ".", "_time_interval", "=", "self", ".", "_determine_time...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
TrainingJobAnalytics._determine_timeinterval
Return a dictionary with two datetime objects, start_time and end_time, covering the interval of the training job
src/sagemaker/analytics.py
def _determine_timeinterval(self): """Return a dictionary with two datetime objects, start_time and end_time, covering the interval of the training job """ description = self._sage_client.describe_training_job(TrainingJobName=self.name) start_time = self._start_time or descriptio...
def _determine_timeinterval(self): """Return a dictionary with two datetime objects, start_time and end_time, covering the interval of the training job """ description = self._sage_client.describe_training_job(TrainingJobName=self.name) start_time = self._start_time or descriptio...
[ "Return", "a", "dictionary", "with", "two", "datetime", "objects", "start_time", "and", "end_time", "covering", "the", "interval", "of", "the", "training", "job" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L249-L266
[ "def", "_determine_timeinterval", "(", "self", ")", ":", "description", "=", "self", ".", "_sage_client", ".", "describe_training_job", "(", "TrainingJobName", "=", "self", ".", "name", ")", "start_time", "=", "self", ".", "_start_time", "or", "description", "["...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
TrainingJobAnalytics._fetch_metric
Fetch all the values of a named metric, and add them to _data
src/sagemaker/analytics.py
def _fetch_metric(self, metric_name): """Fetch all the values of a named metric, and add them to _data """ request = { 'Namespace': self.CLOUDWATCH_NAMESPACE, 'MetricName': metric_name, 'Dimensions': [ { 'Name': 'TrainingJob...
def _fetch_metric(self, metric_name): """Fetch all the values of a named metric, and add them to _data """ request = { 'Namespace': self.CLOUDWATCH_NAMESPACE, 'MetricName': metric_name, 'Dimensions': [ { 'Name': 'TrainingJob...
[ "Fetch", "all", "the", "values", "of", "a", "named", "metric", "and", "add", "them", "to", "_data" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L273-L306
[ "def", "_fetch_metric", "(", "self", ",", "metric_name", ")", ":", "request", "=", "{", "'Namespace'", ":", "self", ".", "CLOUDWATCH_NAMESPACE", ",", "'MetricName'", ":", "metric_name", ",", "'Dimensions'", ":", "[", "{", "'Name'", ":", "'TrainingJobName'", ",...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
TrainingJobAnalytics._add_single_metric
Store a single metric in the _data dict which can be converted to a dataframe.
src/sagemaker/analytics.py
def _add_single_metric(self, timestamp, metric_name, value): """Store a single metric in the _data dict which can be converted to a dataframe. """ # note that this method is built this way to make it possible to # support live-refreshing charts in Bokeh at some point in the futur...
def _add_single_metric(self, timestamp, metric_name, value): """Store a single metric in the _data dict which can be converted to a dataframe. """ # note that this method is built this way to make it possible to # support live-refreshing charts in Bokeh at some point in the futur...
[ "Store", "a", "single", "metric", "in", "the", "_data", "dict", "which", "can", "be", "converted", "to", "a", "dataframe", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L308-L316
[ "def", "_add_single_metric", "(", "self", ",", "timestamp", ",", "metric_name", ",", "value", ")", ":", "# note that this method is built this way to make it possible to", "# support live-refreshing charts in Bokeh at some point in the future.", "self", ".", "_data", "[", "'times...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
TrainingJobAnalytics._metric_names_for_training_job
Helper method to discover the metrics defined for a training job.
src/sagemaker/analytics.py
def _metric_names_for_training_job(self): """Helper method to discover the metrics defined for a training job. """ training_description = self._sage_client.describe_training_job(TrainingJobName=self._training_job_name) metric_definitions = training_description['AlgorithmSpecification'][...
def _metric_names_for_training_job(self): """Helper method to discover the metrics defined for a training job. """ training_description = self._sage_client.describe_training_job(TrainingJobName=self._training_job_name) metric_definitions = training_description['AlgorithmSpecification'][...
[ "Helper", "method", "to", "discover", "the", "metrics", "defined", "for", "a", "training", "job", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L318-L326
[ "def", "_metric_names_for_training_job", "(", "self", ")", ":", "training_description", "=", "self", ".", "_sage_client", ".", "describe_training_job", "(", "TrainingJobName", "=", "self", ".", "_training_job_name", ")", "metric_definitions", "=", "training_description", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
name_from_base
Append a timestamp to the provided string. This function assures that the total length of the resulting string is not longer than the specified max length, trimming the input parameter if necessary. Args: base (str): String used as prefix to generate the unique name. max_length (int): Maxi...
src/sagemaker/utils.py
def name_from_base(base, max_length=63, short=False): """Append a timestamp to the provided string. This function assures that the total length of the resulting string is not longer than the specified max length, trimming the input parameter if necessary. Args: base (str): String used as prefi...
def name_from_base(base, max_length=63, short=False): """Append a timestamp to the provided string. This function assures that the total length of the resulting string is not longer than the specified max length, trimming the input parameter if necessary. Args: base (str): String used as prefi...
[ "Append", "a", "timestamp", "to", "the", "provided", "string", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L46-L62
[ "def", "name_from_base", "(", "base", ",", "max_length", "=", "63", ",", "short", "=", "False", ")", ":", "timestamp", "=", "sagemaker_short_timestamp", "(", ")", "if", "short", "else", "sagemaker_timestamp", "(", ")", "trimmed_base", "=", "base", "[", ":", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
base_name_from_image
Extract the base name of the image to use as the 'algorithm name' for the job. Args: image (str): Image name. Returns: str: Algorithm name, as extracted from the image name.
src/sagemaker/utils.py
def base_name_from_image(image): """Extract the base name of the image to use as the 'algorithm name' for the job. Args: image (str): Image name. Returns: str: Algorithm name, as extracted from the image name. """ m = re.match("^(.+/)?([^:/]+)(:[^:]+)?$", image) algo_name = m.g...
def base_name_from_image(image): """Extract the base name of the image to use as the 'algorithm name' for the job. Args: image (str): Image name. Returns: str: Algorithm name, as extracted from the image name. """ m = re.match("^(.+/)?([^:/]+)(:[^:]+)?$", image) algo_name = m.g...
[ "Extract", "the", "base", "name", "of", "the", "image", "to", "use", "as", "the", "algorithm", "name", "for", "the", "job", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L73-L84
[ "def", "base_name_from_image", "(", "image", ")", ":", "m", "=", "re", ".", "match", "(", "\"^(.+/)?([^:/]+)(:[^:]+)?$\"", ",", "image", ")", "algo_name", "=", "m", ".", "group", "(", "2", ")", "if", "m", "else", "image", "return", "algo_name" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
train
sagemaker_timestamp
Return a timestamp with millisecond precision.
src/sagemaker/utils.py
def sagemaker_timestamp(): """Return a timestamp with millisecond precision.""" moment = time.time() moment_ms = repr(moment).split('.')[1][:3] return time.strftime("%Y-%m-%d-%H-%M-%S-{}".format(moment_ms), time.gmtime(moment))
def sagemaker_timestamp(): """Return a timestamp with millisecond precision.""" moment = time.time() moment_ms = repr(moment).split('.')[1][:3] return time.strftime("%Y-%m-%d-%H-%M-%S-{}".format(moment_ms), time.gmtime(moment))
[ "Return", "a", "timestamp", "with", "millisecond", "precision", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L87-L91
[ "def", "sagemaker_timestamp", "(", ")", ":", "moment", "=", "time", ".", "time", "(", ")", "moment_ms", "=", "repr", "(", "moment", ")", ".", "split", "(", "'.'", ")", "[", "1", "]", "[", ":", "3", "]", "return", "time", ".", "strftime", "(", "\"...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
debug
Print the function name and arguments for debugging.
src/sagemaker/utils.py
def debug(func): """Print the function name and arguments for debugging.""" @wraps(func) def wrapper(*args, **kwargs): print("{} args: {} kwargs: {}".format(func.__name__, args, kwargs)) return func(*args, **kwargs) return wrapper
def debug(func): """Print the function name and arguments for debugging.""" @wraps(func) def wrapper(*args, **kwargs): print("{} args: {} kwargs: {}".format(func.__name__, args, kwargs)) return func(*args, **kwargs) return wrapper
[ "Print", "the", "function", "name", "and", "arguments", "for", "debugging", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L99-L106
[ "def", "debug", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "\"{} args: {} kwargs: {}\"", ".", "format", "(", "func", ".", "__name__", ",", "args", ",", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
to_str
Convert the input to a string, unless it is a unicode string in Python 2. Unicode strings are supported as native strings in Python 3, but ``str()`` cannot be invoked on unicode strings in Python 2, so we need to check for that case when converting user-specified values to strings. Args: value...
src/sagemaker/utils.py
def to_str(value): """Convert the input to a string, unless it is a unicode string in Python 2. Unicode strings are supported as native strings in Python 3, but ``str()`` cannot be invoked on unicode strings in Python 2, so we need to check for that case when converting user-specified values to strings...
def to_str(value): """Convert the input to a string, unless it is a unicode string in Python 2. Unicode strings are supported as native strings in Python 3, but ``str()`` cannot be invoked on unicode strings in Python 2, so we need to check for that case when converting user-specified values to strings...
[ "Convert", "the", "input", "to", "a", "string", "unless", "it", "is", "a", "unicode", "string", "in", "Python", "2", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L123-L138
[ "def", "to_str", "(", "value", ")", ":", "if", "sys", ".", "version_info", ".", "major", "<", "3", "and", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "return", "value", "return", "str", "(", "value", ")" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
train
extract_name_from_job_arn
Returns the name used in the API given a full ARN for a training job or hyperparameter tuning job.
src/sagemaker/utils.py
def extract_name_from_job_arn(arn): """Returns the name used in the API given a full ARN for a training job or hyperparameter tuning job. """ slash_pos = arn.find('/') if slash_pos == -1: raise ValueError("Cannot parse invalid ARN: %s" % arn) return arn[(slash_pos + 1):]
def extract_name_from_job_arn(arn): """Returns the name used in the API given a full ARN for a training job or hyperparameter tuning job. """ slash_pos = arn.find('/') if slash_pos == -1: raise ValueError("Cannot parse invalid ARN: %s" % arn) return arn[(slash_pos + 1):]
[ "Returns", "the", "name", "used", "in", "the", "API", "given", "a", "full", "ARN", "for", "a", "training", "job", "or", "hyperparameter", "tuning", "job", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L141-L148
[ "def", "extract_name_from_job_arn", "(", "arn", ")", ":", "slash_pos", "=", "arn", ".", "find", "(", "'/'", ")", "if", "slash_pos", "==", "-", "1", ":", "raise", "ValueError", "(", "\"Cannot parse invalid ARN: %s\"", "%", "arn", ")", "return", "arn", "[", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
secondary_training_status_message
Returns a string contains last modified time and the secondary training job status message. Args: job_description: Returned response from DescribeTrainingJob call prev_description: Previous job description from DescribeTrainingJob call Returns: str: Job status string to be printed.
src/sagemaker/utils.py
def secondary_training_status_message(job_description, prev_description): """Returns a string contains last modified time and the secondary training job status message. Args: job_description: Returned response from DescribeTrainingJob call prev_description: Previous job description from Describ...
def secondary_training_status_message(job_description, prev_description): """Returns a string contains last modified time and the secondary training job status message. Args: job_description: Returned response from DescribeTrainingJob call prev_description: Previous job description from Describ...
[ "Returns", "a", "string", "contains", "last", "modified", "time", "and", "the", "secondary", "training", "job", "status", "message", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L177-L213
[ "def", "secondary_training_status_message", "(", "job_description", ",", "prev_description", ")", ":", "if", "job_description", "is", "None", "or", "job_description", ".", "get", "(", "'SecondaryStatusTransitions'", ")", "is", "None", "or", "len", "(", "job_descriptio...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
download_folder
Download a folder from S3 to a local path Args: bucket_name (str): S3 bucket name prefix (str): S3 prefix within the bucket that will be downloaded. Can be a single file. target (str): destination path where the downloaded items will be placed sagemaker_session (:class:`sagemaker.se...
src/sagemaker/utils.py
def download_folder(bucket_name, prefix, target, sagemaker_session): """Download a folder from S3 to a local path Args: bucket_name (str): S3 bucket name prefix (str): S3 prefix within the bucket that will be downloaded. Can be a single file. target (str): destination path where the dow...
def download_folder(bucket_name, prefix, target, sagemaker_session): """Download a folder from S3 to a local path Args: bucket_name (str): S3 bucket name prefix (str): S3 prefix within the bucket that will be downloaded. Can be a single file. target (str): destination path where the dow...
[ "Download", "a", "folder", "from", "S3", "to", "a", "local", "path" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L216-L256
[ "def", "download_folder", "(", "bucket_name", ",", "prefix", ",", "target", ",", "sagemaker_session", ")", ":", "boto_session", "=", "sagemaker_session", ".", "boto_session", "s3", "=", "boto_session", ".", "resource", "(", "'s3'", ")", "bucket", "=", "s3", "....
a9e724c7d3f5572b68c3903548c792a59d99799a
train
create_tar_file
Create a tar file containing all the source_files Args: source_files (List[str]): List of file paths that will be contained in the tar file Returns: (str): path to created tar file
src/sagemaker/utils.py
def create_tar_file(source_files, target=None): """Create a tar file containing all the source_files Args: source_files (List[str]): List of file paths that will be contained in the tar file Returns: (str): path to created tar file """ if target: filename = target els...
def create_tar_file(source_files, target=None): """Create a tar file containing all the source_files Args: source_files (List[str]): List of file paths that will be contained in the tar file Returns: (str): path to created tar file """ if target: filename = target els...
[ "Create", "a", "tar", "file", "containing", "all", "the", "source_files" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L259-L278
[ "def", "create_tar_file", "(", "source_files", ",", "target", "=", "None", ")", ":", "if", "target", ":", "filename", "=", "target", "else", ":", "_", ",", "filename", "=", "tempfile", ".", "mkstemp", "(", ")", "with", "tarfile", ".", "open", "(", "fil...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
download_file
Download a Single File from S3 into a local path Args: bucket_name (str): S3 bucket name path (str): file path within the bucket target (str): destination directory for the downloaded file. sagemaker_session (:class:`sagemaker.session.Session`): a sagemaker session to interact with ...
src/sagemaker/utils.py
def download_file(bucket_name, path, target, sagemaker_session): """Download a Single File from S3 into a local path Args: bucket_name (str): S3 bucket name path (str): file path within the bucket target (str): destination directory for the downloaded file. sagemaker_session (:c...
def download_file(bucket_name, path, target, sagemaker_session): """Download a Single File from S3 into a local path Args: bucket_name (str): S3 bucket name path (str): file path within the bucket target (str): destination directory for the downloaded file. sagemaker_session (:c...
[ "Download", "a", "Single", "File", "from", "S3", "into", "a", "local", "path" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/utils.py#L281-L295
[ "def", "download_file", "(", "bucket_name", ",", "path", ",", "target", ",", "sagemaker_session", ")", ":", "path", "=", "path", ".", "lstrip", "(", "'/'", ")", "boto_session", "=", "sagemaker_session", ".", "boto_session", "s3", "=", "boto_session", ".", "r...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Tensorboard._sync_directories
Sync to_directory with from_directory by copying each file in to_directory with new contents. Files in to_directory will be overwritten by files of the same name in from_directory. We need to keep two copies of the log directory because otherwise TensorBoard picks up temp files from `aws...
src/sagemaker/tensorflow/estimator.py
def _sync_directories(from_directory, to_directory): """Sync to_directory with from_directory by copying each file in to_directory with new contents. Files in to_directory will be overwritten by files of the same name in from_directory. We need to keep two copies of the log directory bec...
def _sync_directories(from_directory, to_directory): """Sync to_directory with from_directory by copying each file in to_directory with new contents. Files in to_directory will be overwritten by files of the same name in from_directory. We need to keep two copies of the log directory bec...
[ "Sync", "to_directory", "with", "from_directory", "by", "copying", "each", "file", "in", "to_directory", "with", "new", "contents", ".", "Files", "in", "to_directory", "will", "be", "overwritten", "by", "files", "of", "the", "same", "name", "in", "from_directory...
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/tensorflow/estimator.py#L66-L92
[ "def", "_sync_directories", "(", "from_directory", ",", "to_directory", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "to_directory", ")", ":", "os", ".", "mkdir", "(", "to_directory", ")", "for", "root", ",", "dirs", ",", "files", "in", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Tensorboard.create_tensorboard_process
Create a TensorBoard process. Returns: tuple: A tuple containing: int: The port number. process: The TensorBoard process. Raises: OSError: If no ports between 6006 and 6105 are available for starting TensorBoard.
src/sagemaker/tensorflow/estimator.py
def create_tensorboard_process(self): """Create a TensorBoard process. Returns: tuple: A tuple containing: int: The port number. process: The TensorBoard process. Raises: OSError: If no ports between 6006 and 6105 are available for starti...
def create_tensorboard_process(self): """Create a TensorBoard process. Returns: tuple: A tuple containing: int: The port number. process: The TensorBoard process. Raises: OSError: If no ports between 6006 and 6105 are available for starti...
[ "Create", "a", "TensorBoard", "process", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/tensorflow/estimator.py#L124-L151
[ "def", "create_tensorboard_process", "(", "self", ")", ":", "port", "=", "6006", "for", "_", "in", "range", "(", "100", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "[", "\"tensorboard\"", ",", "\"--logdir\"", ",", "self", ".", "logdir", ",", "...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
Tensorboard.run
Run TensorBoard process.
src/sagemaker/tensorflow/estimator.py
def run(self): """Run TensorBoard process.""" port, tensorboard_process = self.create_tensorboard_process() LOGGER.info('TensorBoard 0.1.7 at http://localhost:{}'.format(port)) while not self.estimator.checkpoint_path: self.event.wait(1) with self._temporary_director...
def run(self): """Run TensorBoard process.""" port, tensorboard_process = self.create_tensorboard_process() LOGGER.info('TensorBoard 0.1.7 at http://localhost:{}'.format(port)) while not self.estimator.checkpoint_path: self.event.wait(1) with self._temporary_director...
[ "Run", "TensorBoard", "process", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/tensorflow/estimator.py#L153-L166
[ "def", "run", "(", "self", ")", ":", "port", ",", "tensorboard_process", "=", "self", ".", "create_tensorboard_process", "(", ")", "LOGGER", ".", "info", "(", "'TensorBoard 0.1.7 at http://localhost:{}'", ".", "format", "(", "port", ")", ")", "while", "not", "...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
TensorFlow.fit
Train a model using the input training dataset. See :func:`~sagemaker.estimator.EstimatorBase.fit` for more details. Args: inputs (str or dict or sagemaker.session.s3_input): Information about the training data. This can be one of three types: * (str) - the...
src/sagemaker/tensorflow/estimator.py
def fit(self, inputs=None, wait=True, logs=True, job_name=None, run_tensorboard_locally=False): """Train a model using the input training dataset. See :func:`~sagemaker.estimator.EstimatorBase.fit` for more details. Args: inputs (str or dict or sagemaker.session.s3_input): Informat...
def fit(self, inputs=None, wait=True, logs=True, job_name=None, run_tensorboard_locally=False): """Train a model using the input training dataset. See :func:`~sagemaker.estimator.EstimatorBase.fit` for more details. Args: inputs (str or dict or sagemaker.session.s3_input): Informat...
[ "Train", "a", "model", "using", "the", "input", "training", "dataset", "." ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/tensorflow/estimator.py#L289-L338
[ "def", "fit", "(", "self", ",", "inputs", "=", "None", ",", "wait", "=", "True", ",", "logs", "=", "True", ",", "job_name", "=", "None", ",", "run_tensorboard_locally", "=", "False", ")", ":", "def", "fit_super", "(", ")", ":", "super", "(", "TensorF...
a9e724c7d3f5572b68c3903548c792a59d99799a
train
TensorFlow._prepare_init_params_from_job_description
Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. Returns: dictionary: The transformed init_params
src/sagemaker/tensorflow/estimator.py
def _prepare_init_params_from_job_description(cls, job_details, model_channel_name=None): """Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. Returns: ...
def _prepare_init_params_from_job_description(cls, job_details, model_channel_name=None): """Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. Returns: ...
[ "Convert", "the", "job", "description", "to", "init", "params", "that", "can", "be", "handled", "by", "the", "class", "constructor" ]
aws/sagemaker-python-sdk
python
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/tensorflow/estimator.py#L341-L385
[ "def", "_prepare_init_params_from_job_description", "(", "cls", ",", "job_details", ",", "model_channel_name", "=", "None", ")", ":", "init_params", "=", "super", "(", "TensorFlow", ",", "cls", ")", ".", "_prepare_init_params_from_job_description", "(", "job_details", ...
a9e724c7d3f5572b68c3903548c792a59d99799a