repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
kivy/python-for-android
pythonforandroid/build.py
Context.get_libs_dir
def get_libs_dir(self, arch): '''The libs dir for a given arch.''' ensure_dir(join(self.libs_dir, arch)) return join(self.libs_dir, arch)
python
def get_libs_dir(self, arch): '''The libs dir for a given arch.''' ensure_dir(join(self.libs_dir, arch)) return join(self.libs_dir, arch)
[ "def", "get_libs_dir", "(", "self", ",", "arch", ")", ":", "ensure_dir", "(", "join", "(", "self", ".", "libs_dir", ",", "arch", ")", ")", "return", "join", "(", "self", ".", "libs_dir", ",", "arch", ")" ]
The libs dir for a given arch.
[ "The", "libs", "dir", "for", "a", "given", "arch", "." ]
8e0e8056bc22e4d5bd3398a6b0301f38ff167933
https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/build.py#L479-L482
train
kivy/python-for-android
pythonforandroid/logger.py
shorten_string
def shorten_string(string, max_width): ''' make limited length string in form: "the string is very lo...(and 15 more)" ''' string_len = len(string) if string_len <= max_width: return string visible = max_width - 16 - int(log10(string_len)) # expected suffix len "...(and XXXXX more)...
python
def shorten_string(string, max_width): ''' make limited length string in form: "the string is very lo...(and 15 more)" ''' string_len = len(string) if string_len <= max_width: return string visible = max_width - 16 - int(log10(string_len)) # expected suffix len "...(and XXXXX more)...
[ "def", "shorten_string", "(", "string", ",", "max_width", ")", ":", "string_len", "=", "len", "(", "string", ")", "if", "string_len", "<=", "max_width", ":", "return", "string", "visible", "=", "max_width", "-", "16", "-", "int", "(", "log10", "(", "stri...
make limited length string in form: "the string is very lo...(and 15 more)"
[ "make", "limited", "length", "string", "in", "form", ":", "the", "string", "is", "very", "lo", "...", "(", "and", "15", "more", ")" ]
8e0e8056bc22e4d5bd3398a6b0301f38ff167933
https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/logger.py#L106-L120
train
kivy/python-for-android
pythonforandroid/logger.py
shprint
def shprint(command, *args, **kwargs): '''Runs the command (which should be an sh.Command instance), while logging the output.''' kwargs["_iter"] = True kwargs["_out_bufsize"] = 1 kwargs["_err_to_out"] = True kwargs["_bg"] = True is_critical = kwargs.pop('_critical', False) tail_n = kwar...
python
def shprint(command, *args, **kwargs): '''Runs the command (which should be an sh.Command instance), while logging the output.''' kwargs["_iter"] = True kwargs["_out_bufsize"] = 1 kwargs["_err_to_out"] = True kwargs["_bg"] = True is_critical = kwargs.pop('_critical', False) tail_n = kwar...
[ "def", "shprint", "(", "command", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"_iter\"", "]", "=", "True", "kwargs", "[", "\"_out_bufsize\"", "]", "=", "1", "kwargs", "[", "\"_err_to_out\"", "]", "=", "True", "kwargs", "[", ...
Runs the command (which should be an sh.Command instance), while logging the output.
[ "Runs", "the", "command", "(", "which", "should", "be", "an", "sh", ".", "Command", "instance", ")", "while", "logging", "the", "output", "." ]
8e0e8056bc22e4d5bd3398a6b0301f38ff167933
https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/logger.py#L142-L243
train
kivy/python-for-android
pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py
_ActionsContainer.add_argument
def add_argument(self, *args, **kwargs): """ add_argument(dest, ..., name=value, ...) add_argument(option_string, option_string, ..., name=value, ...) """ # if no positional args are supplied or only one is supplied and # it doesn't look like an option string, par...
python
def add_argument(self, *args, **kwargs): """ add_argument(dest, ..., name=value, ...) add_argument(option_string, option_string, ..., name=value, ...) """ # if no positional args are supplied or only one is supplied and # it doesn't look like an option string, par...
[ "def", "add_argument", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# if no positional args are supplied or only one is supplied and\r", "# it doesn't look like an option string, parse a positional\r", "# argument\r", "chars", "=", "self", ".", "prefix_c...
add_argument(dest, ..., name=value, ...) add_argument(option_string, option_string, ..., name=value, ...)
[ "add_argument", "(", "dest", "...", "name", "=", "value", "...", ")", "add_argument", "(", "option_string", "option_string", "...", "name", "=", "value", "...", ")" ]
8e0e8056bc22e4d5bd3398a6b0301f38ff167933
https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py#L1276-L1314
train
kivy/python-for-android
pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py
ArgumentParser.error
def error(self, message): """error(message: string) Prints a usage message incorporating the message to stderr and exits. If you override this in a subclass, it should not return -- it should either exit or raise an exception. """ self.print_usage(_sys....
python
def error(self, message): """error(message: string) Prints a usage message incorporating the message to stderr and exits. If you override this in a subclass, it should not return -- it should either exit or raise an exception. """ self.print_usage(_sys....
[ "def", "error", "(", "self", ",", "message", ")", ":", "self", ".", "print_usage", "(", "_sys", ".", "stderr", ")", "self", ".", "exit", "(", "2", ",", "_", "(", "'%s: error: %s\\n'", ")", "%", "(", "self", ".", "prog", ",", "message", ")", ")" ]
error(message: string) Prints a usage message incorporating the message to stderr and exits. If you override this in a subclass, it should not return -- it should either exit or raise an exception.
[ "error", "(", "message", ":", "string", ")", "Prints", "a", "usage", "message", "incorporating", "the", "message", "to", "stderr", "and", "exits", ".", "If", "you", "override", "this", "in", "a", "subclass", "it", "should", "not", "return", "--", "it", "...
8e0e8056bc22e4d5bd3398a6b0301f38ff167933
https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py#L2348-L2358
train
kennethreitz/records
records.py
isexception
def isexception(obj): """Given an object, return a boolean indicating whether it is an instance or subclass of :py:class:`Exception`. """ if isinstance(obj, Exception): return True if isclass(obj) and issubclass(obj, Exception): return True return False
python
def isexception(obj): """Given an object, return a boolean indicating whether it is an instance or subclass of :py:class:`Exception`. """ if isinstance(obj, Exception): return True if isclass(obj) and issubclass(obj, Exception): return True return False
[ "def", "isexception", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "Exception", ")", ":", "return", "True", "if", "isclass", "(", "obj", ")", "and", "issubclass", "(", "obj", ",", "Exception", ")", ":", "return", "True", "return", "False"...
Given an object, return a boolean indicating whether it is an instance or subclass of :py:class:`Exception`.
[ "Given", "an", "object", "return", "a", "boolean", "indicating", "whether", "it", "is", "an", "instance", "or", "subclass", "of", ":", "py", ":", "class", ":", "Exception", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L16-L24
train
kennethreitz/records
records.py
_reduce_datetimes
def _reduce_datetimes(row): """Receives a row, converts datetimes to strings.""" row = list(row) for i in range(len(row)): if hasattr(row[i], 'isoformat'): row[i] = row[i].isoformat() return tuple(row)
python
def _reduce_datetimes(row): """Receives a row, converts datetimes to strings.""" row = list(row) for i in range(len(row)): if hasattr(row[i], 'isoformat'): row[i] = row[i].isoformat() return tuple(row)
[ "def", "_reduce_datetimes", "(", "row", ")", ":", "row", "=", "list", "(", "row", ")", "for", "i", "in", "range", "(", "len", "(", "row", ")", ")", ":", "if", "hasattr", "(", "row", "[", "i", "]", ",", "'isoformat'", ")", ":", "row", "[", "i", ...
Receives a row, converts datetimes to strings.
[ "Receives", "a", "row", "converts", "datetimes", "to", "strings", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L424-L432
train
kennethreitz/records
records.py
Record.as_dict
def as_dict(self, ordered=False): """Returns the row as a dictionary, as ordered.""" items = zip(self.keys(), self.values()) return OrderedDict(items) if ordered else dict(items)
python
def as_dict(self, ordered=False): """Returns the row as a dictionary, as ordered.""" items = zip(self.keys(), self.values()) return OrderedDict(items) if ordered else dict(items)
[ "def", "as_dict", "(", "self", ",", "ordered", "=", "False", ")", ":", "items", "=", "zip", "(", "self", ".", "keys", "(", ")", ",", "self", ".", "values", "(", ")", ")", "return", "OrderedDict", "(", "items", ")", "if", "ordered", "else", "dict", ...
Returns the row as a dictionary, as ordered.
[ "Returns", "the", "row", "as", "a", "dictionary", "as", "ordered", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L81-L85
train
kennethreitz/records
records.py
Record.dataset
def dataset(self): """A Tablib Dataset containing the row.""" data = tablib.Dataset() data.headers = self.keys() row = _reduce_datetimes(self.values()) data.append(row) return data
python
def dataset(self): """A Tablib Dataset containing the row.""" data = tablib.Dataset() data.headers = self.keys() row = _reduce_datetimes(self.values()) data.append(row) return data
[ "def", "dataset", "(", "self", ")", ":", "data", "=", "tablib", ".", "Dataset", "(", ")", "data", ".", "headers", "=", "self", ".", "keys", "(", ")", "row", "=", "_reduce_datetimes", "(", "self", ".", "values", "(", ")", ")", "data", ".", "append",...
A Tablib Dataset containing the row.
[ "A", "Tablib", "Dataset", "containing", "the", "row", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L88-L96
train
kennethreitz/records
records.py
RecordCollection.dataset
def dataset(self): """A Tablib Dataset representation of the RecordCollection.""" # Create a new Tablib Dataset. data = tablib.Dataset() # If the RecordCollection is empty, just return the empty set # Check number of rows by typecasting to list if len(list(self)) == 0: ...
python
def dataset(self): """A Tablib Dataset representation of the RecordCollection.""" # Create a new Tablib Dataset. data = tablib.Dataset() # If the RecordCollection is empty, just return the empty set # Check number of rows by typecasting to list if len(list(self)) == 0: ...
[ "def", "dataset", "(", "self", ")", ":", "# Create a new Tablib Dataset.", "data", "=", "tablib", ".", "Dataset", "(", ")", "# If the RecordCollection is empty, just return the empty set", "# Check number of rows by typecasting to list", "if", "len", "(", "list", "(", "self...
A Tablib Dataset representation of the RecordCollection.
[ "A", "Tablib", "Dataset", "representation", "of", "the", "RecordCollection", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L170-L188
train
kennethreitz/records
records.py
RecordCollection.all
def all(self, as_dict=False, as_ordereddict=False): """Returns a list of all rows for the RecordCollection. If they haven't been fetched yet, consume the iterator and cache the results.""" # By calling list it calls the __iter__ method rows = list(self) if as_dict: ...
python
def all(self, as_dict=False, as_ordereddict=False): """Returns a list of all rows for the RecordCollection. If they haven't been fetched yet, consume the iterator and cache the results.""" # By calling list it calls the __iter__ method rows = list(self) if as_dict: ...
[ "def", "all", "(", "self", ",", "as_dict", "=", "False", ",", "as_ordereddict", "=", "False", ")", ":", "# By calling list it calls the __iter__ method", "rows", "=", "list", "(", "self", ")", "if", "as_dict", ":", "return", "[", "r", ".", "as_dict", "(", ...
Returns a list of all rows for the RecordCollection. If they haven't been fetched yet, consume the iterator and cache the results.
[ "Returns", "a", "list", "of", "all", "rows", "for", "the", "RecordCollection", ".", "If", "they", "haven", "t", "been", "fetched", "yet", "consume", "the", "iterator", "and", "cache", "the", "results", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L190-L202
train
kennethreitz/records
records.py
RecordCollection.first
def first(self, default=None, as_dict=False, as_ordereddict=False): """Returns a single record for the RecordCollection, or `default`. If `default` is an instance or subclass of Exception, then raise it instead of returning it.""" # Try to get a record, or return/raise default. ...
python
def first(self, default=None, as_dict=False, as_ordereddict=False): """Returns a single record for the RecordCollection, or `default`. If `default` is an instance or subclass of Exception, then raise it instead of returning it.""" # Try to get a record, or return/raise default. ...
[ "def", "first", "(", "self", ",", "default", "=", "None", ",", "as_dict", "=", "False", ",", "as_ordereddict", "=", "False", ")", ":", "# Try to get a record, or return/raise default.", "try", ":", "record", "=", "self", "[", "0", "]", "except", "IndexError", ...
Returns a single record for the RecordCollection, or `default`. If `default` is an instance or subclass of Exception, then raise it instead of returning it.
[ "Returns", "a", "single", "record", "for", "the", "RecordCollection", "or", "default", ".", "If", "default", "is", "an", "instance", "or", "subclass", "of", "Exception", "then", "raise", "it", "instead", "of", "returning", "it", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L207-L226
train
kennethreitz/records
records.py
RecordCollection.one
def one(self, default=None, as_dict=False, as_ordereddict=False): """Returns a single record for the RecordCollection, ensuring that it is the only record, or returns `default`. If `default` is an instance or subclass of Exception, then raise it instead of returning it.""" # Ensure that...
python
def one(self, default=None, as_dict=False, as_ordereddict=False): """Returns a single record for the RecordCollection, ensuring that it is the only record, or returns `default`. If `default` is an instance or subclass of Exception, then raise it instead of returning it.""" # Ensure that...
[ "def", "one", "(", "self", ",", "default", "=", "None", ",", "as_dict", "=", "False", ",", "as_ordereddict", "=", "False", ")", ":", "# Ensure that we don't have more than one row.", "try", ":", "self", "[", "1", "]", "except", "IndexError", ":", "return", "...
Returns a single record for the RecordCollection, ensuring that it is the only record, or returns `default`. If `default` is an instance or subclass of Exception, then raise it instead of returning it.
[ "Returns", "a", "single", "record", "for", "the", "RecordCollection", "ensuring", "that", "it", "is", "the", "only", "record", "or", "returns", "default", ".", "If", "default", "is", "an", "instance", "or", "subclass", "of", "Exception", "then", "raise", "it...
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L228-L241
train
kennethreitz/records
records.py
Database.get_connection
def get_connection(self): """Get a connection to this Database. Connections are retrieved from a pool. """ if not self.open: raise exc.ResourceClosedError('Database closed.') return Connection(self._engine.connect())
python
def get_connection(self): """Get a connection to this Database. Connections are retrieved from a pool. """ if not self.open: raise exc.ResourceClosedError('Database closed.') return Connection(self._engine.connect())
[ "def", "get_connection", "(", "self", ")", ":", "if", "not", "self", ".", "open", ":", "raise", "exc", ".", "ResourceClosedError", "(", "'Database closed.'", ")", "return", "Connection", "(", "self", ".", "_engine", ".", "connect", "(", ")", ")" ]
Get a connection to this Database. Connections are retrieved from a pool.
[ "Get", "a", "connection", "to", "this", "Database", ".", "Connections", "are", "retrieved", "from", "a", "pool", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L285-L292
train
kennethreitz/records
records.py
Database.query
def query(self, query, fetchall=False, **params): """Executes the given SQL query against the Database. Parameters can, optionally, be provided. Returns a RecordCollection, which can be iterated over to get result rows as dictionaries. """ with self.get_connection() as conn: ...
python
def query(self, query, fetchall=False, **params): """Executes the given SQL query against the Database. Parameters can, optionally, be provided. Returns a RecordCollection, which can be iterated over to get result rows as dictionaries. """ with self.get_connection() as conn: ...
[ "def", "query", "(", "self", ",", "query", ",", "fetchall", "=", "False", ",", "*", "*", "params", ")", ":", "with", "self", ".", "get_connection", "(", ")", "as", "conn", ":", "return", "conn", ".", "query", "(", "query", ",", "fetchall", ",", "*"...
Executes the given SQL query against the Database. Parameters can, optionally, be provided. Returns a RecordCollection, which can be iterated over to get result rows as dictionaries.
[ "Executes", "the", "given", "SQL", "query", "against", "the", "Database", ".", "Parameters", "can", "optionally", "be", "provided", ".", "Returns", "a", "RecordCollection", "which", "can", "be", "iterated", "over", "to", "get", "result", "rows", "as", "diction...
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L294-L300
train
kennethreitz/records
records.py
Database.bulk_query
def bulk_query(self, query, *multiparams): """Bulk insert or update.""" with self.get_connection() as conn: conn.bulk_query(query, *multiparams)
python
def bulk_query(self, query, *multiparams): """Bulk insert or update.""" with self.get_connection() as conn: conn.bulk_query(query, *multiparams)
[ "def", "bulk_query", "(", "self", ",", "query", ",", "*", "multiparams", ")", ":", "with", "self", ".", "get_connection", "(", ")", "as", "conn", ":", "conn", ".", "bulk_query", "(", "query", ",", "*", "multiparams", ")" ]
Bulk insert or update.
[ "Bulk", "insert", "or", "update", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L302-L306
train
kennethreitz/records
records.py
Database.query_file
def query_file(self, path, fetchall=False, **params): """Like Database.query, but takes a filename to load a query from.""" with self.get_connection() as conn: return conn.query_file(path, fetchall, **params)
python
def query_file(self, path, fetchall=False, **params): """Like Database.query, but takes a filename to load a query from.""" with self.get_connection() as conn: return conn.query_file(path, fetchall, **params)
[ "def", "query_file", "(", "self", ",", "path", ",", "fetchall", "=", "False", ",", "*", "*", "params", ")", ":", "with", "self", ".", "get_connection", "(", ")", "as", "conn", ":", "return", "conn", ".", "query_file", "(", "path", ",", "fetchall", ",...
Like Database.query, but takes a filename to load a query from.
[ "Like", "Database", ".", "query", "but", "takes", "a", "filename", "to", "load", "a", "query", "from", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L308-L312
train
kennethreitz/records
records.py
Database.bulk_query_file
def bulk_query_file(self, path, *multiparams): """Like Database.bulk_query, but takes a filename to load a query from.""" with self.get_connection() as conn: conn.bulk_query_file(path, *multiparams)
python
def bulk_query_file(self, path, *multiparams): """Like Database.bulk_query, but takes a filename to load a query from.""" with self.get_connection() as conn: conn.bulk_query_file(path, *multiparams)
[ "def", "bulk_query_file", "(", "self", ",", "path", ",", "*", "multiparams", ")", ":", "with", "self", ".", "get_connection", "(", ")", "as", "conn", ":", "conn", ".", "bulk_query_file", "(", "path", ",", "*", "multiparams", ")" ]
Like Database.bulk_query, but takes a filename to load a query from.
[ "Like", "Database", ".", "bulk_query", "but", "takes", "a", "filename", "to", "load", "a", "query", "from", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L314-L318
train
kennethreitz/records
records.py
Database.transaction
def transaction(self): """A context manager for executing a transaction on this Database.""" conn = self.get_connection() tx = conn.transaction() try: yield conn tx.commit() except: tx.rollback() finally: conn.close()
python
def transaction(self): """A context manager for executing a transaction on this Database.""" conn = self.get_connection() tx = conn.transaction() try: yield conn tx.commit() except: tx.rollback() finally: conn.close()
[ "def", "transaction", "(", "self", ")", ":", "conn", "=", "self", ".", "get_connection", "(", ")", "tx", "=", "conn", ".", "transaction", "(", ")", "try", ":", "yield", "conn", "tx", ".", "commit", "(", ")", "except", ":", "tx", ".", "rollback", "(...
A context manager for executing a transaction on this Database.
[ "A", "context", "manager", "for", "executing", "a", "transaction", "on", "this", "Database", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L321-L332
train
kennethreitz/records
records.py
Connection.query
def query(self, query, fetchall=False, **params): """Executes the given SQL query against the connected Database. Parameters can, optionally, be provided. Returns a RecordCollection, which can be iterated over to get result rows as dictionaries. """ # Execute the given query. ...
python
def query(self, query, fetchall=False, **params): """Executes the given SQL query against the connected Database. Parameters can, optionally, be provided. Returns a RecordCollection, which can be iterated over to get result rows as dictionaries. """ # Execute the given query. ...
[ "def", "query", "(", "self", ",", "query", ",", "fetchall", "=", "False", ",", "*", "*", "params", ")", ":", "# Execute the given query.", "cursor", "=", "self", ".", "_conn", ".", "execute", "(", "text", "(", "query", ")", ",", "*", "*", "params", "...
Executes the given SQL query against the connected Database. Parameters can, optionally, be provided. Returns a RecordCollection, which can be iterated over to get result rows as dictionaries.
[ "Executes", "the", "given", "SQL", "query", "against", "the", "connected", "Database", ".", "Parameters", "can", "optionally", "be", "provided", ".", "Returns", "a", "RecordCollection", "which", "can", "be", "iterated", "over", "to", "get", "result", "rows", "...
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L355-L374
train
kennethreitz/records
records.py
Connection.bulk_query
def bulk_query(self, query, *multiparams): """Bulk insert or update.""" self._conn.execute(text(query), *multiparams)
python
def bulk_query(self, query, *multiparams): """Bulk insert or update.""" self._conn.execute(text(query), *multiparams)
[ "def", "bulk_query", "(", "self", ",", "query", ",", "*", "multiparams", ")", ":", "self", ".", "_conn", ".", "execute", "(", "text", "(", "query", ")", ",", "*", "multiparams", ")" ]
Bulk insert or update.
[ "Bulk", "insert", "or", "update", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L376-L379
train
kennethreitz/records
records.py
Connection.query_file
def query_file(self, path, fetchall=False, **params): """Like Connection.query, but takes a filename to load a query from.""" # If path doesn't exists if not os.path.exists(path): raise IOError("File '{}' not found!".format(path)) # If it's a directory if os.path.is...
python
def query_file(self, path, fetchall=False, **params): """Like Connection.query, but takes a filename to load a query from.""" # If path doesn't exists if not os.path.exists(path): raise IOError("File '{}' not found!".format(path)) # If it's a directory if os.path.is...
[ "def", "query_file", "(", "self", ",", "path", ",", "fetchall", "=", "False", ",", "*", "*", "params", ")", ":", "# If path doesn't exists", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "IOError", "(", "\"File '{}' not f...
Like Connection.query, but takes a filename to load a query from.
[ "Like", "Connection", ".", "query", "but", "takes", "a", "filename", "to", "load", "a", "query", "from", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L381-L397
train
kennethreitz/records
records.py
Connection.bulk_query_file
def bulk_query_file(self, path, *multiparams): """Like Connection.bulk_query, but takes a filename to load a query from. """ # If path doesn't exists if not os.path.exists(path): raise IOError("File '{}'' not found!".format(path)) # If it's a directory ...
python
def bulk_query_file(self, path, *multiparams): """Like Connection.bulk_query, but takes a filename to load a query from. """ # If path doesn't exists if not os.path.exists(path): raise IOError("File '{}'' not found!".format(path)) # If it's a directory ...
[ "def", "bulk_query_file", "(", "self", ",", "path", ",", "*", "multiparams", ")", ":", "# If path doesn't exists", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "IOError", "(", "\"File '{}'' not found!\"", ".", "format", "(",...
Like Connection.bulk_query, but takes a filename to load a query from.
[ "Like", "Connection", ".", "bulk_query", "but", "takes", "a", "filename", "to", "load", "a", "query", "from", "." ]
ecd857266c5e7830d657cbe0196816314790563b
https://github.com/kennethreitz/records/blob/ecd857266c5e7830d657cbe0196816314790563b/records.py#L399-L416
train
seatgeek/fuzzywuzzy
fuzzywuzzy/process.py
extractWithoutOrder
def extractWithoutOrder(query, choices, processor=default_processor, scorer=default_scorer, score_cutoff=0): """Select the best match in a list or dictionary of choices. Find best matches in a list or dictionary of choices, return a generator of tuples containing the match and its score. If a dictionary ...
python
def extractWithoutOrder(query, choices, processor=default_processor, scorer=default_scorer, score_cutoff=0): """Select the best match in a list or dictionary of choices. Find best matches in a list or dictionary of choices, return a generator of tuples containing the match and its score. If a dictionary ...
[ "def", "extractWithoutOrder", "(", "query", ",", "choices", ",", "processor", "=", "default_processor", ",", "scorer", "=", "default_scorer", ",", "score_cutoff", "=", "0", ")", ":", "# Catch generators without lengths", "def", "no_process", "(", "x", ")", ":", ...
Select the best match in a list or dictionary of choices. Find best matches in a list or dictionary of choices, return a generator 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 w...
[ "Select", "the", "best", "match", "in", "a", "list", "or", "dictionary", "of", "choices", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L16-L119
train
seatgeek/fuzzywuzzy
fuzzywuzzy/process.py
extract
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 ...
python
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", ")", ":", "sl", "=", "extractWithoutOrder", "(", "query", ",", "choices", ",", "processor", ",", "scor...
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...
[ "Select", "the", "best", "match", "in", "a", "list", "or", "dictionary", "of", "choices", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L122-L169
train
seatgeek/fuzzywuzzy
fuzzywuzzy/process.py
extractBests
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...
python
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", ")", ":", "best_list", "=", "extractWithoutOrder", "(", "query", ","...
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...
[ "Get", "a", "list", "of", "the", "best", "matches", "to", "a", "collection", "of", "choices", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L172-L194
train
seatgeek/fuzzywuzzy
fuzzywuzzy/process.py
extractOne
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...
python
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", ")", ":", "best_list", "=", "extractWithoutOrder", "(", "query", ",", "choices", ",", "processor...
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...
[ "Find", "the", "single", "best", "match", "above", "a", "score", "in", "a", "list", "of", "choices", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L197-L222
train
seatgeek/fuzzywuzzy
fuzzywuzzy/process.py
dedupe
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...
python
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", ")", ":", "extractor", "=", "[", "]", "# iterate over items in *contains_dupes*", "for", "item", "in", "contains_dupes", ":", "# return all dup...
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...
[ "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", ...
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/process.py#L225-L285
train
seatgeek/fuzzywuzzy
fuzzywuzzy/utils.py
make_type_consistent
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...
python
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", "isinstance", "(", "s1", ",", "str", ")", "and", "isinstance", "(", "s2", ",", "str", ")", ":", "return", "s1", ",", "s2", "elif", "isinstance", "(", "s1", ",", "unicode", ")", "a...
If both objects aren't either both string or unicode instances force them to unicode
[ "If", "both", "objects", "aren", "t", "either", "both", "string", "or", "unicode", "instances", "force", "them", "to", "unicode" ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/utils.py#L73-L82
train
seatgeek/fuzzywuzzy
fuzzywuzzy/utils.py
full_process
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...
python
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", ")", ":", "if", "force_ascii", ":", "s", "=", "asciidammit", "(", "s", ")", "# Keep only Letters and Numbers (see Unicode docs).", "string_out", "=", "StringProcessor", ".", "replace_non_letters_non_nu...
Process string by -- removing all but letters and numbers -- trim whitespace -- force to lower case if force_ascii == True, force convert to ascii
[ "Process", "string", "by", "--", "removing", "all", "but", "letters", "and", "numbers", "--", "trim", "whitespace", "--", "force", "to", "lower", "case", "if", "force_ascii", "==", "True", "force", "convert", "to", "ascii" ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/utils.py#L85-L100
train
seatgeek/fuzzywuzzy
fuzzywuzzy/fuzz.py
partial_ratio
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...
python
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", ")", ":", "s1", ",", "s2", "=", "utils", ".", "make_type_consistent", "(", "s1", ",", "s2", ")", "if", "len", "(", "s1", ")", "<=", "len", "(", "s2", ")", ":", "shorter", "=", "s1", "longer", "=", "...
Return the ratio of the most similar substring as a number between 0 and 100.
[ "Return", "the", "ratio", "of", "the", "most", "similar", "substring", "as", "a", "number", "between", "0", "and", "100", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L34-L68
train
seatgeek/fuzzywuzzy
fuzzywuzzy/fuzz.py
_process_and_sort
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...
python
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", ")", ":", "# pull tokens", "ts", "=", "utils", ".", "full_process", "(", "s", ",", "force_ascii", "=", "force_ascii", ")", "if", "full_process", "else", "s", "tokens"...
Return a cleaned string with token sorted.
[ "Return", "a", "cleaned", "string", "with", "token", "sorted", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L75-L83
train
seatgeek/fuzzywuzzy
fuzzywuzzy/fuzz.py
token_sort_ratio
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)
python
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", "_token_sort", "(", "s1", ",", "s2", ",", "partial", "=", "False", ",", "force_ascii", "=", "force_ascii", ",", "full_...
Return a measure of the sequences' similarity between 0 and 100 but sorting the token before comparing.
[ "Return", "a", "measure", "of", "the", "sequences", "similarity", "between", "0", "and", "100", "but", "sorting", "the", "token", "before", "comparing", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L101-L105
train
seatgeek/fuzzywuzzy
fuzzywuzzy/fuzz.py
partial_token_sort_ratio
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)
python
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", "_token_sort", "(", "s1", ",", "s2", ",", "partial", "=", "True", ",", "force_ascii", "=", "force_ascii", ",", ...
Return the ratio of the most similar substring as a number between 0 and 100 but sorting the token before comparing.
[ "Return", "the", "ratio", "of", "the", "most", "similar", "substring", "as", "a", "number", "between", "0", "and", "100", "but", "sorting", "the", "token", "before", "comparing", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L108-L112
train
seatgeek/fuzzywuzzy
fuzzywuzzy/fuzz.py
_token_set
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...
python
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", ")", ":", "if", "not", "full_process", "and", "s1", "==", "s2", ":", "return", "100", "p1", "=", "utils", ".", ...
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
[ "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", ...
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L116-L165
train
seatgeek/fuzzywuzzy
fuzzywuzzy/fuzz.py
QRatio
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...
python
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", ")", ":", "if", "full_process", ":", "p1", "=", "utils", ".", "full_process", "(", "s1", ",", "force_ascii", "=", "force_ascii", ")", "p2", "=", ...
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...
[ "Quick", "ratio", "comparison", "between", "two", "strings", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L181-L207
train
seatgeek/fuzzywuzzy
fuzzywuzzy/fuzz.py
UQRatio
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)
python
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", ")", ":", "return", "QRatio", "(", "s1", ",", "s2", ",", "force_ascii", "=", "False", ",", "full_process", "=", "full_process", ")" ]
Unicode quick ratio Calls QRatio with force_ascii set to False :param s1: :param s2: :return: similarity ratio
[ "Unicode", "quick", "ratio" ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L210-L220
train
seatgeek/fuzzywuzzy
fuzzywuzzy/fuzz.py
WRatio
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 ...
python
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", ")", ":", "if", "full_process", ":", "p1", "=", "utils", ".", "full_process", "(", "s1", ",", "force_ascii", "=", "force_ascii", ")", "p2", "=", ...
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...
[ "Return", "a", "measure", "of", "the", "sequences", "similarity", "between", "0", "and", "100", "using", "different", "algorithms", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L224-L299
train
seatgeek/fuzzywuzzy
fuzzywuzzy/fuzz.py
UWRatio
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)
python
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", "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.
[ "Return", "a", "measure", "of", "the", "sequences", "similarity", "between", "0", "and", "100", "using", "different", "algorithms", ".", "Same", "as", "WRatio", "but", "preserving", "unicode", "." ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/fuzzywuzzy/fuzz.py#L302-L306
train
seatgeek/fuzzywuzzy
benchmarks.py
print_result_from_timeit
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...
python
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", ")", ":", "units", "=", "[", "\"s\"", ",", "\"ms\"", ",", "\"us\"", ",", "\"ns\"", "]", "duration", "=", "timeit", "(", "stmt", "...
Clean function to know how much time took the execution of one statement
[ "Clean", "function", "to", "know", "how", "much", "time", "took", "the", "execution", "of", "one", "statement" ]
778162c5a73256745eb6ae22f925bc2dbcf7c894
https://github.com/seatgeek/fuzzywuzzy/blob/778162c5a73256745eb6ae22f925bc2dbcf7c894/benchmarks.py#L47-L57
train
aws/sagemaker-python-sdk
src/sagemaker/pipeline.py
PipelineModel.deploy
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...
python
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", ")", ":", "if", "not", "self", ".", "sagemaker_session", ":", "self", ".", "sagemaker_session", "=", "Session", "(...
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 ...
[ "Deploy", "this", "Model", "to", "an", "Endpoint", "and", "optionally", "return", "a", "Predictor", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/pipeline.py#L70-L106
train
aws/sagemaker-python-sdk
src/sagemaker/pipeline.py
PipelineModel._create_sagemaker_pipeline_model
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...
python
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", ")", ":", "if", "not", "self", ".", "sagemaker_session", ":", "self", ".", "sagemaker_session", "=", "Session", "(", ")", "containers", "=", "self", ".", "pipeline_container_def", "(", ...
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...
[ "Create", "a", "SageMaker", "Model", "Entity" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/pipeline.py#L108-L124
train
aws/sagemaker-python-sdk
src/sagemaker/pipeline.py
PipelineModel.delete_model
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 ...
python
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", ")", ":", "if", "self", ".", "name", "is", "None", ":", "raise", "ValueError", "(", "'The SageMaker model must be created before attempting to delete.'", ")", "self", ".", "sagemaker_session", ".", "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.
[ "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", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/pipeline.py#L158-L167
train
aws/sagemaker-python-sdk
src/sagemaker/local/image.py
_stream_output
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 ...
python
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", ")", ":", "exit_code", "=", "None", "while", "exit_code", "is", "None", ":", "stdout", "=", "process", ".", "stdout", ".", "readline", "(", ")", ".", "decode", "(", "\"utf-8\"", ")", "sys", ".", "stdout", ".", "...
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...
[ "Stream", "the", "output", "of", "a", "process", "to", "stdout" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L570-L592
train
aws/sagemaker-python-sdk
src/sagemaker/local/image.py
_SageMakerContainer.train
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...
python
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", ")", ":", "self", ".", "container_root", "=", "self", ".", "_create_tmp_folder", "(", ")", "os", ".", "mkdir", "(", "os", ".", "path", ...
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...
[ "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...
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L87-L151
train
aws/sagemaker-python-sdk
src/sagemaker/local/image.py
_SageMakerContainer.serve
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. ...
python
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", ")", ":", "logger", ".", "info", "(", "\"serving\"", ")", "self", ".", "container_root", "=", "self", ".", "_create_tmp_folder", "(", ")", "logger", ".", "info", "(", "'creating hosting dir i...
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...
[ "Host", "a", "local", "endpoint", "using", "docker", "-", "compose", ".", "Args", ":", "primary_container", "(", "dict", ")", ":", "dictionary", "containing", "the", "container", "runtime", "settings", "for", "serving", ".", "Expected", "keys", ":", "-", "Mo...
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L153-L187
train
aws/sagemaker-python-sdk
src/sagemaker/local/image.py
_SageMakerContainer.stop_serving
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 ...
python
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", ")", ":", "if", "self", ".", "container", ":", "self", ".", "container", ".", "down", "(", ")", "self", ".", "container", ".", "join", "(", ")", "self", ".", "_cleanup", "(", ")", "# for serving we can delete everything ...
Stop the serving container. The serving container runs in async mode to allow the SDK to do other tasks.
[ "Stop", "the", "serving", "container", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L189-L199
train
aws/sagemaker-python-sdk
src/sagemaker/local/image.py
_SageMakerContainer.retrieve_artifacts
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...
python
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", ")", ":", "# We need a directory to store the artfiacts from all the nodes", "# and another one to contained the compressed final artifacts", "artifacts", "=", "os", ".", "p...
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...
[ "Get", "the", "model", "artifacts", "from", "all", "the", "container", "nodes", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L201-L256
train
aws/sagemaker-python-sdk
src/sagemaker/local/image.py
_SageMakerContainer.write_config_files
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...
python
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", ")", ":", "config_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "container_root", ",", "host", ",", "'input'", ",", "'config'", ")", "r...
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...
[ "Write", "the", "config", "files", "for", "the", "training", "containers", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L258-L289
train
aws/sagemaker-python-sdk
src/sagemaker/local/image.py
_SageMakerContainer._generate_compose_file
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...
python
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", ")", ":", "boto_session", "=", "self", ".", "sagemaker_session", ".", "boto_session", "additional_volumes", "=", "additiona...
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...
[ "Writes", "a", "config", "file", "describing", "a", "training", "/", "hosting", "environment", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L360-L416
train
aws/sagemaker-python-sdk
src/sagemaker/local/image.py
_SageMakerContainer._build_optml_volumes
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: ...
python
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", ")", ":", "volumes", "=", "[", "]", "for", "subdir", "in", "subdirs", ":", "host_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "container_root", ",", "host", ",", ...
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...
[ "Generate", "a", "list", "of", ":", "class", ":", "~sagemaker", ".", "local_session", ".", "Volume", "required", "for", "the", "container", "to", "start", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/image.py#L486-L506
train
aws/sagemaker-python-sdk
examples/cli/host/script.py
model_fn
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...
python
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", ")", ":", "symbol", "=", "mx", ".", "sym", ".", "load", "(", "'%s/model.json'", "%", "model_dir", ")", "outputs", "=", "mx", ".", "symbol", ".", "softmax", "(", "data", "=", "symbol", ",", "name", "=", "'softmax_lab...
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)
[ "Load", "the", "gluon", "model", ".", "Called", "once", "when", "hosting", "service", "starts", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/examples/cli/host/script.py#L8-L21
train
aws/sagemaker-python-sdk
examples/cli/host/script.py
transform_fn
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...
python
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", ")", ":", "# we can use content types to vary input/output handling, but", "# here we just assume json for both", "parsed", "=", "json", ".", "loads", "(", "data", ")", ...
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.
[ "Transform", "a", "request", "using", "the", "Gluon", "model", ".", "Called", "once", "per", "request", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/examples/cli/host/script.py#L24-L41
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/pca.py
PCA._prepare_for_training
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 ...
python
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", ")", ":", "num_records", "=", "None", "if", "isinstance", "(", "records", ",", "list", ")", ":", "for", "record", "in", "records...
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...
[ "Set", "hyperparameters", "needed", "for", "training", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/pca.py#L103-L129
train
aws/sagemaker-python-sdk
src/sagemaker/fw_utils.py
create_image_uri
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)...
python
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): 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...
[ "Return", "the", "ECR", "URI", "of", "an", "image", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L49-L103
train
aws/sagemaker-python-sdk
src/sagemaker/fw_utils.py
validate_source_dir
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...
python
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", ")", ":", "if", "directory", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "directory", ",", "script", ")", ")", ":", "raise", "ValueError", ...
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``.
[ "Validate", "that", "the", "source", "directory", "exists", "and", "it", "contains", "the", "user", "script" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L125-L139
train
aws/sagemaker-python-sdk
src/sagemaker/fw_utils.py
tar_and_upload_dir
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...
python
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", ")", ":", "if", "directory", "and", "directory", ".", "lower", "(...
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...
[ "Package", "source", "files", "and", "upload", "a", "compress", "tar", "file", "to", "S3", ".", "The", "S3", "location", "will", "be", "s3", ":", "//", "<bucket", ">", "/", "s3_key_prefix", "/", "sourcedir", ".", "tar", ".", "gz", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L142-L194
train
aws/sagemaker-python-sdk
src/sagemaker/fw_utils.py
framework_name_from_image
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...
python
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", ")", ":", "sagemaker_pattern", "=", "re", ".", "compile", "(", "ECR_URI_PATTERN", ")", "sagemaker_match", "=", "sagemaker_pattern", ".", "match", "(", "image_name", ")", "if", "sagemaker_match", "is", "None", ...
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...
[ "Extract", "the", "framework", "and", "Python", "version", "from", "the", "image", "name", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L205-L248
train
aws/sagemaker-python-sdk
src/sagemaker/fw_utils.py
framework_version_from_tag
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...
python
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", ")", ":", "tag_pattern", "=", "re", ".", "compile", "(", "'^(.*)-(cpu|gpu)-(py2|py3)$'", ")", "tag_match", "=", "tag_pattern", ".", "match", "(", "image_tag", ")", "return", "None", "if", "tag_match", "is", ...
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.
[ "Extract", "the", "framework", "version", "from", "the", "image", "tag", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L251-L262
train
aws/sagemaker-python-sdk
src/sagemaker/fw_utils.py
parse_s3_url
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": ...
python
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", ")", ":", "parsed_url", "=", "urlparse", "(", "url", ")", "if", "parsed_url", ".", "scheme", "!=", "\"s3\"", ":", "raise", "ValueError", "(", "\"Expecting 's3' scheme, got: {} in {}\"", ".", "format", "(", "parsed_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
[ "Returns", "an", "(", "s3", "bucket", "key", "name", "/", "prefix", ")", "tuple", "from", "a", "url", "with", "an", "s3", "scheme" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L265-L279
train
aws/sagemaker-python-sdk
src/sagemaker/fw_utils.py
model_code_key_prefix
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 ...
python
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", ")", ":", "training_job_name", "=", "sagemaker", ".", "utils", ".", "name_from_image", "(", "image", ")", "return", "'/'", ".", "join", "(", "filter", "(", "None", ...
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...
[ "Returns", "the", "s3", "key", "prefix", "for", "uploading", "code", "during", "model", "deployment" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/fw_utils.py#L282-L298
train
aws/sagemaker-python-sdk
src/sagemaker/local/local_session.py
LocalSagemakerClient.create_training_job
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...
python
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", ")", ":", "InputDataConfig", "=", "InputDataConfig", "or",...
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...
[ "Create", "a", "training", "job", "in", "Local", "Mode", "Args", ":", "TrainingJobName", "(", "str", ")", ":", "local", "training", "job", "name", ".", "AlgorithmSpecification", "(", "dict", ")", ":", "Identifies", "the", "training", "algorithm", "to", "use"...
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/local_session.py#L55-L75
train
aws/sagemaker-python-sdk
src/sagemaker/local/local_session.py
LocalSagemakerClient.describe_training_job
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: ...
python
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", ")", ":", "if", "TrainingJobName", "not", "in", "LocalSagemakerClient", ".", "_training_jobs", ":", "error_response", "=", "{", "'Error'", ":", "{", "'Code'", ":", "'ValidationException'", ",", "...
Describe a local training job. Args: TrainingJobName (str): Training job name to describe. Returns: (dict) DescribeTrainingJob Response.
[ "Describe", "a", "local", "training", "job", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/local_session.py#L77-L90
train
aws/sagemaker-python-sdk
src/sagemaker/local/local_session.py
LocalSagemakerClient.create_model
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...
python
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", "LocalSagemakerClient", ".", "_models", "[", "ModelName", "]", "=", "_LocalModel", "(", "Mode...
Create a Local Model Object Args: ModelName (str): the Model Name PrimaryContainer (dict): a SageMaker primary container definition
[ "Create", "a", "Local", "Model", "Object" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/local_session.py#L105-L112
train
aws/sagemaker-python-sdk
src/sagemaker/local/local_session.py
LocalSession._initialize
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...
python
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", ")", ":", "self", ".", "boto_session", "=", "boto_session", "or", "boto3", ".", "Session", "(", ")", "self", ".", "_region_name", "=", "self", "."...
Initialize this Local SageMaker Session.
[ "Initialize", "this", "Local", "SageMaker", "Session", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/local_session.py#L205-L216
train
aws/sagemaker-python-sdk
src/sagemaker/sklearn/model.py
SKLearnModel.prepare_container_def
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...
python
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", ")", ":", "if", "accelerator_type", ":", "raise", "ValueError", "(", "\"Accelerator types are not supported for Scikit-Learn.\"", ")", "deploy_image", "=", "self", "...
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 ...
[ "Return", "a", "container", "definition", "with", "framework", "configuration", "set", "in", "model", "environment", "variables", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/sklearn/model.py#L75-L105
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/amazon_estimator.py
upload_numpy_to_s3_shards
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...
python
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", ")", ":", "shards", "=", "_build_shards", "(", "num_shards", ",", "array", ")", "if", "labels", "is", "not", "None...
Upload the training ``array`` and ``labels`` arrays to ``num_shards`` s3 objects, stored in "s3://``bucket``/``key_prefix``/".
[ "Upload", "the", "training", "array", "and", "labels", "arrays", "to", "num_shards", "s3", "objects", "stored", "in", "s3", ":", "//", "bucket", "/", "key_prefix", "/", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L242-L275
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/amazon_estimator.py
registry
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...
python
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", ")", ":", "if", "algorithm", "in", "[", "None", ",", "'pca'", ",", "'kmeans'", ",", "'linear-learner'", ",", "'factorization-machines'", ",", "'ntm'", ",", "'randomcutforest'", ",", "'knn'",...
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
[ "Return", "docker", "registry", "for", "the", "given", "AWS", "region" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L278-L370
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/amazon_estimator.py
get_image_uri
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)
python
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", ")", ":", "repo", "=", "'{}:{}'", ".", "format", "(", "repo_name", ",", "repo_version", ")", "return", "'{}/{}'", ".", "format", "(", "registry", "(", "region_name",...
Return algorithm image URI for the given AWS region, repository name, and repository version
[ "Return", "algorithm", "image", "URI", "for", "the", "given", "AWS", "region", "repository", "name", "and", "repository", "version" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L373-L376
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/amazon_estimator.py
AmazonAlgorithmEstimatorBase._prepare_init_params_from_job_description
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...
python
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", ")", ":", "init_params", "=", "super", "(", "AmazonAlgorithmEstimatorBase", ",", "cls", ")", ".", "_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: ...
[ "Convert", "the", "job", "description", "to", "init", "params", "that", "can", "be", "handled", "by", "the", "class", "constructor" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L77-L101
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/amazon_estimator.py
AmazonAlgorithmEstimatorBase._prepare_for_training
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 ...
python
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", ")", ":", "super", "(", "AmazonAlgorithmEstimatorBase", ",", "self", ")", ".", "_prepare_for_training", "(", "job_name", "=", "job_nam...
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...
[ "Set", "hyperparameters", "needed", "for", "training", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L103-L128
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/amazon_estimator.py
AmazonAlgorithmEstimatorBase.fit
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...
python
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", ")", ":", "self", ".", "_prepare_for_training", "(", "records", ",", "job_name", "=", "job...
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 ...
[ "Fit", "this", "Estimator", "on", "serialized", "Record", "objects", "stored", "in", "S3", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L130-L160
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/amazon_estimator.py
AmazonAlgorithmEstimatorBase.record_set
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`` ...
python
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\"", ")", ":", "s3", "=", "self", ".", "sagemaker_session", ".", "boto_session", ".", "resource", "(", "'s3'", ")", "parsed_s3_url", "=", "urlparse", ...
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...
[ "Build", "a", ":", "class", ":", "~RecordSet", "from", "a", "numpy", ":", "class", ":", "~ndarray", "matrix", "and", "label", "vector", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/amazon_estimator.py#L162-L193
train
aws/sagemaker-python-sdk
src/sagemaker/local/data.py
get_data_source_instance
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...
python
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", ")", ":", "parsed_uri", "=", "urlparse", "(", "data_source", ")", "if", "parsed_uri", ".", "scheme", "==", "'file'", ":", "return", "LocalFileDataSource", "(", "parsed_uri", ".", "net...
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...
[ "Return", "an", "Instance", "of", ":", "class", ":", "sagemaker", ".", "local", ".", "data", ".", "DataSource", "that", "can", "handle", "the", "provided", "data_source", "URI", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L30-L49
train
aws/sagemaker-python-sdk
src/sagemaker/local/data.py
get_splitter_instance
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...
python
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", ")", ":", "if", "split_type", "is", "None", ":", "return", "NoneSplitter", "(", ")", "elif", "split_type", "==", "'Line'", ":", "return", "LineSplitter", "(", ")", "elif", "split_type", "==", "'RecordIO'", ":"...
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...
[ "Return", "an", "Instance", "of", ":", "class", ":", "sagemaker", ".", "local", ".", "data", ".", "Splitter", "according", "to", "the", "specified", "split_type", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L52-L70
train
aws/sagemaker-python-sdk
src/sagemaker/local/data.py
get_batch_strategy_instance
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...
python
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", ")", ":", "if", "strategy", "==", "'SingleRecord'", ":", "return", "SingleRecordStrategy", "(", "splitter", ")", "elif", "strategy", "==", "'MultiRecord'", ":", "return", "MultiRecordStrategy", ...
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...
[ "Return", "an", "Instance", "of", ":", "class", ":", "sagemaker", ".", "local", ".", "data", ".", "BatchStrategy", "according", "to", "strategy" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L73-L88
train
aws/sagemaker-python-sdk
src/sagemaker/local/data.py
LocalFileDataSource.get_file_list
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) ...
python
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", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "root_path", ")", ":", "return", "[", "os", ".", "path", ".", "join", "(", "self", ".", "root_path", ",", "f", ")", "for", "f", "in", "os", ...
Retrieve the list of absolute paths to all the files in this data source. Returns: List[str] List of absolute paths.
[ "Retrieve", "the", "list", "of", "absolute", "paths", "to", "all", "the", "files", "in", "this", "data", "source", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L119-L129
train
aws/sagemaker-python-sdk
src/sagemaker/local/data.py
LocalFileDataSource.get_root_dir
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...
python
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", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "root_path", ")", ":", "return", "self", ".", "root_path", "else", ":", "return", "os", ".", "path", ".", "dirname", "(", "self", ".", "root_path",...
Retrieve the absolute path to the root directory of this data source. Returns: str: absolute path to the root directory of this data source.
[ "Retrieve", "the", "absolute", "path", "to", "the", "root", "directory", "of", "this", "data", "source", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L131-L140
train
aws/sagemaker-python-sdk
src/sagemaker/local/data.py
RecordIOSplitter.split
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 ...
python
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", ")", ":", "with", "open", "(", "file", ",", "'rb'", ")", "as", "f", ":", "for", "record", "in", "sagemaker", ".", "amazon", ".", "common", ".", "read_recordio", "(", "f", ")", ":", "yield", "record" ]
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" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L248-L260
train
aws/sagemaker-python-sdk
src/sagemaker/local/data.py
MultiRecordStrategy.pad
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...
python
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", ")", ":", "buffer", "=", "''", "for", "element", "in", "self", ".", "splitter", ".", "split", "(", "file", ")", ":", "if", "_payload_size_within_limit", "(", "buffer", "+", "element", ","...
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...
[ "Group", "together", "as", "many", "records", "as", "possible", "to", "fit", "in", "the", "specified", "size" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L293-L313
train
aws/sagemaker-python-sdk
src/sagemaker/local/data.py
SingleRecordStrategy.pad
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...
python
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", ")", ":", "for", "element", "in", "self", ".", "splitter", ".", "split", "(", "file", ")", ":", "if", "_validate_payload_size", "(", "element", ",", "size", ")", ":", "yield", "element" ]
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...
[ "Group", "together", "as", "many", "records", "as", "possible", "to", "fit", "in", "the", "specified", "size" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/local/data.py#L321-L337
train
aws/sagemaker-python-sdk
src/sagemaker/chainer/estimator.py
Chainer.hyperparameters
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...
python
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", ")", ":", "hyperparameters", "=", "super", "(", "Chainer", ",", "self", ")", ".", "hyperparameters", "(", ")", "additional_hyperparameters", "=", "{", "Chainer", ".", "_use_mpi", ":", "self", ".", "use_mpi", ",", "Chain...
Return hyperparameters used by your custom Chainer code during training.
[ "Return", "hyperparameters", "used", "by", "your", "custom", "Chainer", "code", "during", "training", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/chainer/estimator.py#L99-L111
train
aws/sagemaker-python-sdk
src/sagemaker/chainer/estimator.py
Chainer.create_model
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 ...
python
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", ")", ":", "role", "=", "role", "or", "self", ".", "role", "return", "ChainerModel", "(", "self", "....
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...
[ "Create", "a", "SageMaker", "ChainerModel", "object", "that", "can", "be", "deployed", "to", "an", "Endpoint", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/chainer/estimator.py#L113-L137
train
aws/sagemaker-python-sdk
src/sagemaker/chainer/estimator.py
Chainer._prepare_init_params_from_job_description
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...
python
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", ")", ":", "init_params", "=", "super", "(", "Chainer", ",", "cls", ")", ".", "_prepare_init_params_from_job_description", "(", "job_details", ",...
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: ...
[ "Convert", "the", "job", "description", "to", "init", "params", "that", "can", "be", "handled", "by", "the", "class", "constructor" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/chainer/estimator.py#L140-L176
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/common.py
write_numpy_to_dense_tensor
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...
python
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", ")", ":", "# Validate shape of array and labels, resolve array and label types", "if", "not", "len", "(", "array", ".", "shape", ")", "==", "2", ":", "raise", "ValueError", ...
Writes a numpy array to a dense tensor
[ "Writes", "a", "numpy", "array", "to", "a", "dense", "tensor" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/common.py#L88-L110
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/common.py
write_spmatrix_to_sparse_tensor
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...
python
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", ")", ":", "if", "not", "issparse", "(", "array", ")", ":", "raise", "TypeError", "(", "\"Array must be sparse\"", ")", "# Validate shape of array and labels, resolve array...
Writes a scipy sparse matrix to a sparse tensor
[ "Writes", "a", "scipy", "sparse", "matrix", "to", "a", "sparse", "tensor" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/common.py#L113-L150
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/common.py
read_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
python
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", ")", ":", "records", "=", "[", "]", "for", "record_data", "in", "read_recordio", "(", "file", ")", ":", "record", "=", "Record", "(", ")", "record", ".", "ParseFromString", "(", "record_data", ")", "records", ".", "app...
Eagerly read a collection of amazon Record protobuf objects from file.
[ "Eagerly", "read", "a", "collection", "of", "amazon", "Record", "protobuf", "objects", "from", "file", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/common.py#L153-L160
train
aws/sagemaker-python-sdk
src/sagemaker/amazon/common.py
_write_recordio
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])
python
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", ")", ":", "length", "=", "len", "(", "data", ")", "f", ".", "write", "(", "struct", ".", "pack", "(", "'I'", ",", "_kmagic", ")", ")", "f", ".", "write", "(", "struct", ".", "pack", "(", "'I'", "...
Writes a single data point as a RecordIO record to the given file.
[ "Writes", "a", "single", "data", "point", "as", "a", "RecordIO", "record", "to", "the", "given", "file", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/amazon/common.py#L176-L183
train
aws/sagemaker-python-sdk
src/sagemaker/model.py
Model.prepare_container_def
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...
python
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", "sagemaker", ".", "container_def", "(", "self", ".", "image", ",", "self", ".", "model_data", ",", "se...
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 ...
[ "Return", "a", "dict", "created", "by", "sagemaker", ".", "container_def", "()", "for", "deploying", "this", "model", "to", "a", "specified", "instance", "type", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L73-L87
train
aws/sagemaker-python-sdk
src/sagemaker/model.py
Model._create_sagemaker_model
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. ...
python
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", ")", ":", "container_def", "=", "self", ".", "prepare_container_def", "(", "instance_type", ",", "accelerator_type", "=", "accelera...
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...
[ "Create", "a", "SageMaker", "Model", "Entity" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L97-L118
train
aws/sagemaker-python-sdk
src/sagemaker/model.py
Model.compile
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...
python
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", ",", "f...
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, ...
[ "Compile", "this", "Model", "with", "SageMaker", "Neo", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L162-L209
train
aws/sagemaker-python-sdk
src/sagemaker/model.py
Model.deploy
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 ...
python
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 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 ...
[ "Deploy", "this", "Model", "to", "an", "Endpoint", "and", "optionally", "return", "a", "Predictor", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L211-L283
train
aws/sagemaker-python-sdk
src/sagemaker/model.py
Model.transformer
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...
python
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", "=...
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...
[ "Return", "a", "Transformer", "that", "uses", "this", "Model", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L285-L317
train
aws/sagemaker-python-sdk
src/sagemaker/model.py
FrameworkModel.prepare_container_def
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 ...
python
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", "deploy_key_prefix", "=", "fw_utils", ".", "model_code_key_prefix", "(", "self", ".", "key_prefix", ",", "self", ".",...
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 ...
[ "Return", "a", "container", "definition", "with", "framework", "configuration", "set", "in", "model", "environment", "variables", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L408-L425
train
aws/sagemaker-python-sdk
src/sagemaker/model.py
ModelPackage._create_sagemaker_model
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...
python
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", "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...
Create a SageMaker Model Entity Args: *args: Arguments coming from the caller. This class does not require any so they are ignored.
[ "Create", "a", "SageMaker", "Model", "Entity" ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/model.py#L538-L569
train
aws/sagemaker-python-sdk
src/sagemaker/predictor.py
RealTimePredictor.predict
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 ...
python
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", ")", ":", "request_args", "=", "self", ".", "_create_request_args", "(", "data", ",", "initial_args", ")", "response", "=", "self", ".", "sagemaker_session", ".", "sagemaker_runtime_...
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...
[ "Return", "the", "inference", "from", "the", "specified", "endpoint", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/predictor.py#L62-L81
train
aws/sagemaker-python-sdk
src/sagemaker/predictor.py
RealTimePredictor.delete_endpoint
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...
python
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", ")", ":", "if", "delete_endpoint_config", ":", "self", ".", "_delete_endpoint_config", "(", ")", "self", ".", "sagemaker_session", ".", "delete_endpoint", "(", "self", ".", "endpoin...
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...
[ "Delete", "the", "Amazon", "SageMaker", "endpoint", "backing", "this", "predictor", ".", "Also", "delete", "the", "endpoint", "configuration", "attached", "to", "it", "if", "delete_endpoint_config", "is", "True", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/predictor.py#L116-L129
train
aws/sagemaker-python-sdk
src/sagemaker/predictor.py
RealTimePredictor.delete_model
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...
python
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", ")", ":", "request_failed", "=", "False", "failed_models", "=", "[", "]", "for", "model_name", "in", "self", ".", "_model_names", ":", "try", ":", "self", ".", "sagemaker_session", ".", "delete_model", "(", "model_name", "...
Deletes the Amazon SageMaker models backing this predictor.
[ "Deletes", "the", "Amazon", "SageMaker", "models", "backing", "this", "predictor", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/predictor.py#L131-L146
train
aws/sagemaker-python-sdk
src/sagemaker/analytics.py
AnalyticsMetricsBase.dataframe
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...
python
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", ")", ":", "if", "force_refresh", ":", "self", ".", "clear_cache", "(", ")", "if", "self", ".", "_dataframe", "is", "None", ":", "self", ".", "_dataframe", "=", "self", ".", "_fetch_data...
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.
[ "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", ...
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L48-L60
train
aws/sagemaker-python-sdk
src/sagemaker/analytics.py
HyperparameterTuningJobAnalytics.clear_cache
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
python
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", ")", ":", "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.
[ "Clear", "the", "object", "of", "all", "local", "caches", "of", "API", "methods", "." ]
a9e724c7d3f5572b68c3903548c792a59d99799a
https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/analytics.py#L102-L107
train