# Buggy code
def save(
    self,
    fname_or_handle,
    separately=None,
    sep_limit=10 * 1024**2,
    ignore=frozenset(),
    pickle_protocol=2,
):
    """Save the object to a file.

    Parameters
    ----------
    fname_or_handle : str or file-like
        Path to output file or already opened file-like object. If the object is a file handle,
        no special array handling will be performed, all attributes will be saved to the same file.
    separately : list of str or None, optional
        If None, automatically detect large numpy/scipy.sparse arrays in the object being stored, and store
        them into separate files. This prevent memory errors for large objects, and also allows
        `memory-mapping <https://en.wikipedia.org/wiki/Mmap>`_ the large arrays for efficient
        loading and sharing the large arrays in RAM between multiple processes.

        If list of str: store these attributes into separate files. The automated size check
        is not performed in this case.
    sep_limit : int, optional
        Don't store arrays smaller than this separately. In bytes.
    ignore : frozenset of str, optional
        Attributes that shouldn't be stored at all.
    pickle_protocol : int, optional
        Protocol number for pickle.

    See Also
    --------
    :meth:`~gensim.utils.SaveLoad.load`
        Load object from file.

    """
    self.add_lifecycle_event(
        "saving",
        fname_or_handle=str(fname_or_handle),
        separately=str(separately),
        sep_limit=sep_limit,
        ignore=ignore,
    )
    try:
        _pickle.dump(self, fname_or_handle, protocol=pickle_protocol)
        logger.info("saved %s object", self.__class__.__name__)
    except TypeError:  # `fname_or_handle` does not have write attribute
        self._smart_save(
            fname_or_handle,
            separately,
            sep_limit,
            ignore,
            pickle_protocol=pickle_protocol,
        )


# Traceback (FileNotFoundError)
[INFO]  2018-01-21T20:44:59.613Z    f2689816-feeb-11e7-b397-b7ff2947dcec    testing keys in event dict
[INFO]  2018-01-21T20:44:59.614Z    f2689816-feeb-11e7-b397-b7ff2947dcec    loading model from s3://data-d2v/trained_models/model_law
[INFO]  2018-01-21T20:44:59.614Z    f2689816-feeb-11e7-b397-b7ff2947dcec    loading Doc2Vec object from s3://data-d2v/trained_models/model_law
[INFO]  2018-01-21T20:44:59.650Z    f2689816-feeb-11e7-b397-b7ff2947dcec    Found credentials in environment variables.
[INFO]  2018-01-21T20:44:59.707Z    f2689816-feeb-11e7-b397-b7ff2947dcec    Starting new HTTPS connection (1): s3.eu-west-1.amazonaws.com
[INFO]  2018-01-21T20:44:59.801Z    f2689816-feeb-11e7-b397-b7ff2947dcec    Starting new HTTPS connection (2): s3.eu-west-1.amazonaws.com
[INFO]  2018-01-21T20:45:35.830Z    f2689816-feeb-11e7-b397-b7ff2947dcec    loading wv recursively from s3://data-d2v/trained_models/model_law.wv.* with mmap=None
[INFO]  2018-01-21T20:45:35.830Z    f2689816-feeb-11e7-b397-b7ff2947dcec    loading syn0 from s3://data-d2v/trained_models/model_law.wv.syn0.npy with mmap=None
[Errno 2] No such file or directory: 's3://data-d2v/trained_models/model_law.wv.syn0.npy': FileNotFoundError
Traceback (most recent call last):
File "/var/task/handler.py", line 20, in infer_handler
event['input_text'], event['model_file'], inferred_docs=10)
File "/var/task/infer_doc.py", line 26, in infer_docs
model = load_model(model_file)
File "/var/task/infer_doc.py", line 21, in load_model
return Doc2Vec.load(model_file)
File "/var/task/gensim/models/word2vec.py", line 1569, in load
model = super(Word2Vec, cls).load(*args, **kwargs)
File "/var/task/gensim/utils.py", line 282, in load
obj._load_specials(fname, mmap, compress, subname)
File "/var/task/gensim/models/word2vec.py", line 1593, in _load_specials
super(Word2Vec, self)._load_specials(*args, **kwargs)
File "/var/task/gensim/utils.py", line 301, in _load_specials
getattr(self, attrib)._load_specials(cfname, mmap, compress, subname)
File "/var/task/gensim/utils.py", line 312, in _load_specials
val = np.load(subname(fname, attrib), mmap_mode=mmap)
File "/var/task/numpy/lib/npyio.py", line 372, in load
fid = open(file, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 's3://data-d2v/trained_models/model_law.wv.syn0.npy'

# Fixed code
def save(
    self,
    fname_or_handle,
    separately=None,
    sep_limit=10 * 1024**2,
    ignore=frozenset(),
    pickle_protocol=PICKLE_PROTOCOL,
):
    """Save the object to a file.

    Parameters
    ----------
    fname_or_handle : str or file-like
        Path to output file or already opened file-like object. If the object is a file handle,
        no special array handling will be performed, all attributes will be saved to the same file.
    separately : list of str or None, optional
        If None, automatically detect large numpy/scipy.sparse arrays in the object being stored, and store
        them into separate files. This prevent memory errors for large objects, and also allows
        `memory-mapping <https://en.wikipedia.org/wiki/Mmap>`_ the large arrays for efficient
        loading and sharing the large arrays in RAM between multiple processes.

        If list of str: store these attributes into separate files. The automated size check
        is not performed in this case.
    sep_limit : int, optional
        Don't store arrays smaller than this separately. In bytes.
    ignore : frozenset of str, optional
        Attributes that shouldn't be stored at all.
    pickle_protocol : int, optional
        Protocol number for pickle.

    See Also
    --------
    :meth:`~gensim.utils.SaveLoad.load`
        Load object from file.

    """
    self.add_lifecycle_event(
        "saving",
        fname_or_handle=str(fname_or_handle),
        separately=str(separately),
        sep_limit=sep_limit,
        ignore=ignore,
    )
    try:
        _pickle.dump(self, fname_or_handle, protocol=pickle_protocol)
        logger.info("saved %s object", self.__class__.__name__)
    except TypeError:  # `fname_or_handle` does not have write attribute
        self._smart_save(
            fname_or_handle,
            separately,
            sep_limit,
            ignore,
            pickle_protocol=pickle_protocol,
        )