gurudesh/pytracebugs huggingface dataset:
# Buggy code
def _collect_internal(self) -> None:
    events = self.event_filter.get_new_entries()
    for event in events:
        self._event_occurred(event)


# Traceback (builtins.ValueError)
2020-09-23T14:29:04+0000 [twisted.internet.defer#critical] Unhandled error in Deferred:
2020-09-23T14:29:04+0000 [twisted.internet.defer#critical]
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/twisted/internet/base.py", line 1283, in run
self.mainLoop()
File "/usr/local/lib/python3.6/dist-packages/twisted/internet/base.py", line 1292, in mainLoop
self.runUntilCurrent()
File "/usr/local/lib/python3.6/dist-packages/twisted/internet/base.py", line 913, in runUntilCurrent
call.func(*call.args, call.kw)
File "/usr/local/lib/python3.6/dist-packages/twisted/internet/task.py", line 239, in call
d = defer.maybeDeferred(self.f, *self.a, self.kw)
--- <exception caught here> ---
File "/usr/local/lib/python3.6/dist-packages/twisted/internet/defer.py", line 151, in maybeDeferred
result = f(*args, **kw)
File "/usr/local/lib/python3.6/dist-packages/nucypher/utilities/prometheus/metrics.py", line 147, in collect_prometheus_metrics
collector.collect()
File "/usr/local/lib/python3.6/dist-packages/nucypher/utilities/prometheus/collector.py", line 77, in collect
self._collect_internal()
File "/usr/local/lib/python3.6/dist-packages/nucypher/utilities/prometheus/collector.py", line 303, in _collect_internal
events = self.event_filter.get_new_entries()
File "/usr/local/lib/python3.6/dist-packages/web3/_utils/filters.py", line 159, in get_new_entries
log_entries = self._filter_valid_entries(self.web3.eth.getFilterChanges(self.filter_id))
File "/usr/local/lib/python3.6/dist-packages/web3/eth.py", line 493, in getFilterChanges
RPC.eth_getFilterChanges, [filter_id],
File "/usr/local/lib/python3.6/dist-packages/web3/manager.py", line 153, in request_blocking
raise ValueError(response["error"])
builtins.ValueError: {'code': -32000, 'message': 'filter not found'}

# Fixed code
def _collect_internal(self) -> None:
    from_block = self.filter_current_from_block
    to_block = self.contract_agent.blockchain.client.block_number
    if from_block >= to_block:
        # we've already checked the latest block and waiting for a new block
        # nothing to see here
        return

    events_throttler = ContractEventsThrottler(
        agent=self.contract_agent,
        event_name=self.event_name,
        from_block=from_block,
        to_block=to_block,
        **self.filter_arguments,
    )
    for event_record in events_throttler:
        self._event_occurred(event_record.raw_event)

    # update last block checked for the next round - from/to block range is inclusive
    self.filter_current_from_block = to_block + 1
# Buggy code
def _setup_emitter(general_config):
    # Banner
    emitter = general_config.emitter
    emitter.clear()
    emitter.banner(StakeHolder.banner)

    return emitter


# Traceback (nucypher.blockchain.eth.interfaces.InterfaceError)
Traceback (most recent call last):
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/bin/nucypher", line 11, in <module>
load_entry_point('nucypher', 'console_scripts', 'nucypher')()
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/cli/options.py", line 139, in wrapper
return func(**kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/cli/options.py", line 139, in wrapper
return func(**kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/cli/options.py", line 139, in wrapper
return func(**kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/cli/commands/worklock.py", line 139, in bid
receipt = bidder.place_bid(value=value)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/actors.py", line 1557, in place_bid
receipt = self.worklock_agent.bid(checksum_address=self.checksum_address, value=value)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/decorators.py", line 71, in wrapped
return func(*args, **kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/agents.py", line 993, in bid
payload={'value': value})
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/decorators.py", line 71, in wrapped
return func(*args, **kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/interfaces.py", line 489, in send_transaction
confirmations=confirmations)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/interfaces.py", line 408, in sign_and_broadcast_transaction
raise self.InterfaceError(str(READ_ONLY_INTERFACE))
nucypher.blockchain.eth.interfaces.InterfaceError: READ_ONLY_INTERFACE

# Fixed code
def _setup_emitter(general_config):
    # Banner
    emitter = general_config.emitter
    emitter.banner(StakeHolder.banner)

    return emitter
# Buggy code
def _setup_emitter(general_config):
    emitter = general_config.emitter
    emitter.clear()
    emitter.banner(WORKLOCK_BANNER)
    return emitter


# Traceback (nucypher.blockchain.eth.interfaces.InterfaceError)
Traceback (most recent call last):
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/bin/nucypher", line 11, in <module>
load_entry_point('nucypher', 'console_scripts', 'nucypher')()
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/david/.local/share/virtualenvs/nucypher-cjt3uwkK/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/cli/options.py", line 139, in wrapper
return func(**kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/cli/options.py", line 139, in wrapper
return func(**kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/cli/options.py", line 139, in wrapper
return func(**kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/cli/commands/worklock.py", line 139, in bid
receipt = bidder.place_bid(value=value)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/actors.py", line 1557, in place_bid
receipt = self.worklock_agent.bid(checksum_address=self.checksum_address, value=value)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/decorators.py", line 71, in wrapped
return func(*args, **kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/agents.py", line 993, in bid
payload={'value': value})
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/decorators.py", line 71, in wrapped
return func(*args, **kwargs)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/interfaces.py", line 489, in send_transaction
confirmations=confirmations)
File "/Users/david/NuCypher/dev/nucypher/nucypher/blockchain/eth/interfaces.py", line 408, in sign_and_broadcast_transaction
raise self.InterfaceError(str(READ_ONLY_INTERFACE))
nucypher.blockchain.eth.interfaces.InterfaceError: READ_ONLY_INTERFACE

# Fixed code
def _setup_emitter(general_config):
    emitter = general_config.emitter
    emitter.banner(WORKLOCK_BANNER)
    return emitter
# Buggy code
def convert_token_dict(token_dict):
    """Convert the dictionary format input token to the CoNLL-U format output token. This is the reverse function of
    `convert_conll_token`.
    Input: dictionary format token, which is a dictionaries for the token.
    Output: CoNLL-U format token, which is a list for the token.
    """
    token_conll = ["_" for i in range(FIELD_NUM)]
    for key in token_dict:
        if key == ID:
            token_conll[FIELD_TO_IDX[key]] = (
                "-".join([str(x) for x in token_dict[key]])
                if isinstance(token_dict[key], tuple)
                else str(token_dict[key])
            )
        elif key in FIELD_TO_IDX:
            token_conll[FIELD_TO_IDX[key]] = str(token_dict[key])
    # when a word (not mwt token) without head is found, we insert dummy head as required by the UD eval script
    if "-" not in token_conll[FIELD_TO_IDX[ID]] and HEAD not in token_dict:
        token_conll[FIELD_TO_IDX[HEAD]] = str(
            (token_dict[ID] if isinstance(token_dict[ID], int) else token_dict[ID][0])
            - 1
        )  # evaluation script requires head: int
    return token_conll


# Traceback (TypeError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/m0re/projects/phd/stanza/stanza/utils/conll.py", line 112, in convert_dict
token_conll = CoNLL.convert_token_dict(token_dict)
File "/home/m0re/projects/phd/stanza/stanza/utils/conll.py", line 132, in convert_token_dict
token_conll[FIELD_TO_IDX[HEAD]] = str((token_dict[ID] if isinstance(token_dict[ID], int) else token_dict[ID][0]) - 1) # evaluation script requires head: int
TypeError: unsupported operand type(s) for -: 'str' and 'int'

# Fixed code
def convert_token_dict(token_dict):
    """Convert the dictionary format input token to the CoNLL-U format output token. This is the reverse function of
    `convert_conll_token`.
    Input: dictionary format token, which is a dictionaries for the token.
    Output: CoNLL-U format token, which is a list for the token.
    """
    token_conll = ["_" for i in range(FIELD_NUM)]
    for key in token_dict:
        if key == ID:
            token_conll[FIELD_TO_IDX[key]] = (
                "-".join([str(x) for x in token_dict[key]])
                if isinstance(token_dict[key], tuple)
                else str(token_dict[key])
            )
        elif key in FIELD_TO_IDX:
            token_conll[FIELD_TO_IDX[key]] = str(token_dict[key])
    # when a word (not mwt token) without head is found, we insert dummy head as required by the UD eval script
    if "-" not in token_conll[FIELD_TO_IDX[ID]] and HEAD not in token_dict:
        token_conll[FIELD_TO_IDX[HEAD]] = str(
            int(
                token_dict[ID] if isinstance(token_dict[ID], int) else token_dict[ID][0]
            )
            - 1
        )  # evaluation script requires head: int
    return token_conll
# Buggy code
def _get_next_state(endpoint):
    return endpoint.p_next_state


# Traceback (TypeError)
poseidon$ show all -4and6 --fields=[next state]
[ERROR] Exception in show_all: '<' not supported between instances of 'NoneType' and 'str'
Traceback (most recent call last):
File "/poseidon/poseidon/helpers/exception_decor.py", line 19, in wrapper
return function(*args, **kwargs)
File "/poseidon/poseidon/cli/cli.py", line 500, in show_all
arg), fields, sort_by=sort_by, max_width=max_width, unique=unique, nonzero=nonzero, output_format=output_format, ipv4_only=ipv4_only, ipv6_only=ipv6_only, ipv4_and_ipv6=ipv4_and_ipv6)
File "/poseidon/poseidon/cli/cli.py", line 439, in display_results
matrix = sorted(matrix, key=lambda endpoint: endpoint[sort_by])
TypeError: '<' not supported between instances of 'NoneType' and 'str'

# Fixed code
def _get_next_state(endpoint):
    return str(endpoint.p_next_state)
# Buggy code
def do_task(self, arg):
    """Perform task to things on the network"""
    # TODO
    flags, arg = self.parser.get_flags(arg)
    action = arg.split()[0]
    func_calls = {
        "clear": self.task_clear,
        "collect": self.task_collect,
        "ignore": self.task_ignore,
        "remove": self.task_remove,
        "set": self.task_set,
    }
    if action in func_calls:
        if len(arg.split()) > 1:
            func_calls[action](arg, flags)
        else:
            print(action.upper() + " <ID|IP|MAC>")
    else:
        print("Unknown command, try 'help task'")


# Traceback (IndexError)
[ERROR] Exception in do_show: list index out of range
Traceback (most recent call last):
File "/poseidon/poseidon/helpers/exception_decor.py", line 19, in wrapper
return function(*args, **kwargs)
File "/poseidon/poseidon/cli/cli.py", line 687, in do_show
action = arg.split()[0]
IndexError: list index out of range

# Fixed code
def do_task(self, arg):
    """Perform task to things on the network"""
    # TODO
    flags, arg = self.parser.get_flags(arg)
    if arg:
        action = arg.split()[0]
        func_calls = {
            "clear": self.task_clear,
            "collect": self.task_collect,
            "ignore": self.task_ignore,
            "remove": self.task_remove,
            "set": self.task_set,
        }
        if action in func_calls:
            if len(arg.split()) > 1:
                func_calls[action](arg, flags)
            else:
                print(action.upper() + " <ID|IP|MAC>")
        else:
            print("Unknown command, try 'help task'")
    else:
        self.help_task()
# Buggy code
def do_show(self, arg):
    """Show things on the network based on filters"""
    flags, arg = self.parser.get_flags(arg)
    action = arg.split()[0]
    func_calls = {
        "all": self.show_all,
        "authors": self.show_authors,
        "behavior": self.show_behavior,
        "history": self.show_history,
        "os": self.show_os,
        "role": self.show_role,
        "state": self.show_state,
        "what": self.show_what,
        "where": self.show_where,
    }
    if action in func_calls:
        if action in ["all", "authors"]:
            func_calls[action](arg, flags)
        elif action in ["history", "what", "where"]:
            if len(arg.split()) > 1:
                func_calls[action](arg, flags)
            else:
                print(action.upper() + " <ID|IP|MAC>")
        else:
            valid = False
            for show_comm in self.show_completions:
                if arg.startswith(show_comm):
                    valid = True
                    func_calls[action](arg, flags)
            if not valid:
                print("Unknown command, try 'help show'")
    else:
        print("Unknown command, try 'help show'")


# Traceback (IndexError)
[ERROR] Exception in do_show: list index out of range
Traceback (most recent call last):
File "/poseidon/poseidon/helpers/exception_decor.py", line 19, in wrapper
return function(*args, **kwargs)
File "/poseidon/poseidon/cli/cli.py", line 687, in do_show
action = arg.split()[0]
IndexError: list index out of range

# Fixed code
def do_show(self, arg):
    """Show things on the network based on filters"""
    flags, arg = self.parser.get_flags(arg)
    if arg:
        action = arg.split()[0]
        func_calls = {
            "all": self.show_all,
            "authors": self.show_authors,
            "behavior": self.show_behavior,
            "history": self.show_history,
            "os": self.show_os,
            "role": self.show_role,
            "state": self.show_state,
            "what": self.show_what,
            "where": self.show_where,
        }
        if action in func_calls:
            if action in ["all", "authors"]:
                func_calls[action](arg, flags)
            elif action in ["history", "what", "where"]:
                if len(arg.split()) > 1:
                    func_calls[action](arg, flags)
                else:
                    print(action.upper() + " <ID|IP|MAC>")
            else:
                valid = False
                for show_comm in self.show_completions:
                    if arg.startswith(show_comm):
                        valid = True
                        func_calls[action](arg, flags)
                if not valid:
                    print("Unknown command, try 'help show'")
        else:
            print("Unknown command, try 'help show'")
    else:
        self.help_show()
# Buggy code
def do_quit(self, arg):
    "Stop recording and exit:  QUIT"
    print("Thank you for using Poseidon")
    self.close()
    return True


# Traceback (FileNotFoundError)
poseidon$ record
Traceback (most recent call last):
File "/poseidon/poseidon/cli/cli.py", line 547, in <module>
PoseidonShell().cmdloop()
File "/usr/lib/python3.6/cmd.py", line 138, in cmdloop
stop = self.onecmd(line)
File "/usr/lib/python3.6/cmd.py", line 217, in onecmd
return func(arg)
File "/poseidon/poseidon/cli/cli.py", line 526, in do_record
self.file = open(arg, 'w')
FileNotFoundError: [Errno 2] No such file or directory: ''

# Fixed code
def do_quit(self, arg):
    "Stop the shell and exit:  QUIT"
    print("Thank you for using Poseidon")
    self.close()
    return True
# Buggy code
def iterbatches(self, batch_size=None, epoch=0, deterministic=False, pad_batches=False):
    """Get an object that iterates over minibatches from the dataset.

    Each minibatch is returned as a tuple of four numpy arrays: `(X,
    y, w, ids)`.

    Parameters
    ----------
    batch_size: int, optional
      Number of elements in each batch
    epoch: int, optional
      Number of epochs to walk over dataset
    deterministic: bool, optional
      If True, follow deterministic order.
    pad_batches: bool, optional
      If True, pad each batch to `batch_size`.

    Returns
    -------
    Generator which yields tuples of four numpy arrays `(X, y, w, ids)`
    """
    raise NotImplementedError()


# Traceback (AttributeError)
Traceback (most recent call last):
File "test_fit_on_batch.py", line 23, in <module>
model.fit_on_batch(X, y, w)
File "/Users/bharath/Code/deepchem/deepchem/models/keras_model.py", line 428, in fit_on_batch
if not self.built:
AttributeError: 'GraphConvModel' object has no attribute 'built'

# Fixed code
def iterbatches(
    self, batch_size=None, epochs=1, deterministic=False, pad_batches=False
):
    """Get an object that iterates over minibatches from the dataset.

    Each minibatch is returned as a tuple of four numpy arrays: `(X,
    y, w, ids)`.

    Parameters
    ----------
    batch_size: int, optional
      Number of elements in each batch
    epochs: int, optional
      Number of epochs to walk over dataset
    deterministic: bool, optional
      If True, follow deterministic order.
    pad_batches: bool, optional
      If True, pad each batch to `batch_size`.

    Returns
    -------
    Generator which yields tuples of four numpy arrays `(X, y, w, ids)`
    """
    raise NotImplementedError()
# Buggy code
def gen_data():
    for epoch in range(epochs):
        for X, y, w, ids in self.iterbatches(
            batch_size, epoch, deterministic, pad_batches
        ):
            yield (X, y, w)


# Traceback (AttributeError)
Traceback (most recent call last):
File "test_fit_on_batch.py", line 23, in <module>
model.fit_on_batch(X, y, w)
File "/Users/bharath/Code/deepchem/deepchem/models/keras_model.py", line 428, in fit_on_batch
if not self.built:
AttributeError: 'GraphConvModel' object has no attribute 'built'

# Fixed code
def gen_data():
    for X, y, w, ids in self.iterbatches(
        batch_size, epochs, deterministic, pad_batches
    ):
        yield (X, y, w)
# Buggy code
def iterbatches(self, batch_size=None, epoch=0, deterministic=False, pad_batches=False):
    """Get an object that iterates over minibatches from the dataset.

    It is guaranteed that the number of batches returned is
    `math.ceil(len(dataset)/batch_size)`. Each minibatch is returned as
    a tuple of four numpy arrays: `(X, y, w, ids)`.

    Parameters:
    -----------
    batch_size: int
      Number of elements in a batch. If None, then it yields batches
      with size equal to the size of each individual shard.
    epoch: int
      Not used
    deterministic: bool
      Whether or not we should should shuffle each shard before
      generating the batches.  Note that this is only local in the
      sense that it does not ever mix between different shards.
    pad_batches: bool
      Whether or not we should pad the last batch, globally, such that
      it has exactly batch_size elements.
    """
    shard_indices = list(range(self.get_number_shards()))
    return self._iterbatches_from_shards(
        shard_indices, batch_size, deterministic, pad_batches
    )


# Traceback (AttributeError)
Traceback (most recent call last):
File "test_fit_on_batch.py", line 23, in <module>
model.fit_on_batch(X, y, w)
File "/Users/bharath/Code/deepchem/deepchem/models/keras_model.py", line 428, in fit_on_batch
if not self.built:
AttributeError: 'GraphConvModel' object has no attribute 'built'

# Fixed code
def iterbatches(
    self, batch_size=None, epochs=1, deterministic=False, pad_batches=False
):
    """Get an object that iterates over minibatches from the dataset.

    It is guaranteed that the number of batches returned is
    `math.ceil(len(dataset)/batch_size)`. Each minibatch is returned as
    a tuple of four numpy arrays: `(X, y, w, ids)`.

    Parameters:
    -----------
    batch_size: int
      Number of elements in a batch. If None, then it yields batches
      with size equal to the size of each individual shard.
    epoch: int
      Number of epochs to walk over dataset
    deterministic: bool
      Whether or not we should should shuffle each shard before
      generating the batches.  Note that this is only local in the
      sense that it does not ever mix between different shards.
    pad_batches: bool
      Whether or not we should pad the last batch, globally, such that
      it has exactly batch_size elements.
    """
    shard_indices = list(range(self.get_number_shards()))
    return self._iterbatches_from_shards(
        shard_indices, batch_size, epochs, deterministic, pad_batches
    )
# Buggy code
def iterbatches(self, **kwargs):
    """Loop through all internal datasets in the same order.

    Parameters
    ----------
    batch_size: int
      Number of samples from each dataset to return
    epoch: int
      Number of times to loop through the datasets
    pad_batches: boolean
      Should all batches==batch_size

    Returns
    -------
    Generator which yields a dictionary {key: dataset.X[batch]}
    """
    key_order = [x for x in self.datasets.keys()]
    if "epochs" in kwargs:
        epochs = kwargs["epochs"]
        del kwargs["epochs"]
    else:
        epochs = 1
    kwargs["deterministic"] = True
    for epoch in range(epochs):
        iterators = [self.datasets[x].iterbatches(**kwargs) for x in key_order]
        for tup in zip(*iterators):
            m_d = {key_order[i]: tup[i][0] for i in range(len(key_order))}
            yield m_d


# Traceback (AttributeError)
Traceback (most recent call last):
File "test_fit_on_batch.py", line 23, in <module>
model.fit_on_batch(X, y, w)
File "/Users/bharath/Code/deepchem/deepchem/models/keras_model.py", line 428, in fit_on_batch
if not self.built:
AttributeError: 'GraphConvModel' object has no attribute 'built'

# Fixed code
def iterbatches(self, **kwargs):
    """Loop through all internal datasets in the same order.

    Parameters
    ----------
    batch_size: int
      Number of samples from each dataset to return
    epochs: int
      Number of times to loop through the datasets
    pad_batches: boolean
      Should all batches==batch_size

    Returns
    -------
    Generator which yields a dictionary {key: dataset.X[batch]}
    """
    key_order = [x for x in self.datasets.keys()]
    if "epochs" in kwargs:
        epochs = kwargs["epochs"]
        del kwargs["epochs"]
    else:
        epochs = 1
    kwargs["deterministic"] = True
    for epoch in range(epochs):
        iterators = [self.datasets[x].iterbatches(**kwargs) for x in key_order]
        for tup in zip(*iterators):
            m_d = {key_order[i]: tup[i][0] for i in range(len(key_order))}
            yield m_d
# Buggy code
def fit_on_batch(self, X, y, w, variables=None, loss=None, callbacks=[]):
    """Perform a single step of training.

    Parameters
    ----------
    X: ndarray
      the inputs for the batch
    y: ndarray
      the labels for the batch
    w: ndarray
      the weights for the batch
    variables: list of tf.Variable
      the variables to train.  If None (the default), all trainable variables in
      the model are used.
    loss: function
      a function of the form f(outputs, labels, weights) that computes the loss
      for each batch.  If None (the default), the model's standard loss function
      is used.
    callbacks: function or list of functions
      one or more functions of the form f(model, step) that will be invoked after
      every step.  This can be used to perform validation, logging, etc.
    """
    if not self.built:
        self.build()
    dataset = NumpyDataset(X, y, w)
    return self.fit(
        dataset, nb_epoch=1, variables=variables, loss=loss, callbacks=callbacks
    )


# Traceback (AttributeError)
Traceback (most recent call last):
File "test_fit_on_batch.py", line 23, in <module>
model.fit_on_batch(X, y, w)
File "/Users/bharath/Code/deepchem/deepchem/models/keras_model.py", line 428, in fit_on_batch
if not self.built:
AttributeError: 'GraphConvModel' object has no attribute 'built'

# Fixed code
def fit_on_batch(
    self,
    X,
    y,
    w,
    variables=None,
    loss=None,
    callbacks=[],
    checkpoint=True,
    max_checkpoints_to_keep=5,
):
    """Perform a single step of training.

    Parameters
    ----------
    X: ndarray
      the inputs for the batch
    y: ndarray
      the labels for the batch
    w: ndarray
      the weights for the batch
    variables: list of tf.Variable
      the variables to train.  If None (the default), all trainable variables in
      the model are used.
    loss: function
      a function of the form f(outputs, labels, weights) that computes the loss
      for each batch.  If None (the default), the model's standard loss function
      is used.
    callbacks: function or list of functions
      one or more functions of the form f(model, step) that will be invoked after
      every step.  This can be used to perform validation, logging, etc.
    checkpoint: bool
      if true, save a checkpoint after performing the training step
    max_checkpoints_to_keep: int
      the maximum number of checkpoints to keep.  Older checkpoints are discarded.
    """
    self._ensure_built()
    dataset = NumpyDataset(X, y, w)
    return self.fit(
        dataset,
        nb_epoch=1,
        max_checkpoints_to_keep=max_checkpoints_to_keep,
        checkpoint_interval=self._global_step.numpy() + 2 if checkpoint else 0,
        variables=variables,
        loss=loss,
        callbacks=callbacks,
    )
# Buggy code
def open(path, fs_options):
    source = vaex.file.open_for_arrow(
        path=path, mode="rb", fs_options=fs_options, mmap=True
    )
    try:
        # first we try if it opens as stream
        reader = pa.ipc.open_stream(source)
    except pa.lib.ArrowInvalid:
        # if not, we open as file
        reader = pa.ipc.open_file(source)
        # for some reason this reader is not iterable
        batches = [reader.get_batch(i) for i in range(reader.num_record_batches)]
    else:
        # if a stream, we're good
        batches = reader  # this reader is iterable
    table = pa.Table.from_batches(batches)
    return from_table(table)


# Traceback (OSError)
pyarrow.ipc.open_stream("feat.arrow")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/me/.local/lib/python3.8/site-packages/pyarrow/ipc.py", line 146, in open_stream
return RecordBatchStreamReader(source)
File "/home/me/.local/lib/python3.8/site-packages/pyarrow/ipc.py", line 62, in __init__
self._open(source)
File "pyarrow/ipc.pxi", line 360, in pyarrow.lib._RecordBatchStreamReader._open
File "pyarrow/error.pxi", line 123, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 100, in pyarrow.lib.check_status
OSError: Invalid flatbuffers message.

# Fixed code
def open(path, fs_options):
    source = vaex.file.open_for_arrow(
        path=path, mode="rb", fs_options=fs_options, mmap=True
    )
    file_signature = source.read(6)
    is_arrow_file = file_signature == b"ARROW1"
    source.seek(0)

    if is_arrow_file:
        reader = pa.ipc.open_file(source)
        # for some reason this reader is not iterable
        batches = [reader.get_batch(i) for i in range(reader.num_record_batches)]
    else:
        reader = pa.ipc.open_stream(source)
        batches = reader  # this reader is iterable
    table = pa.Table.from_batches(batches)
    return from_table(table)
# Buggy code
def destroy(self):
    for name in "jobItems", "jobFileIDs", "files", "statsFiles", "statsFileIDs":
        resource = getattr(self, name)
        if resource is not None:
            if isinstance(resource, AzureTable):
                resource.delete_table()
            elif isinstance(resource, AzureBlobContainer):
                resource.delete_container()
            else:
                assert False
            setattr(self, name, None)


# Traceback (toil.jobStores.abstractJobStore.JobStoreExistsException)
anovak@amn2master1:~/hgvm-graph-bakeoff-evaluations$ toil clean azure:hgvm:amntree
amn2master1 2016-08-29 20:12:58,971 MainThread INFO toil.lib.bioio: Logging set at level: INFO
amn2master1 2016-08-29 20:12:58,971 MainThread INFO toil.utils.toilClean: Attempting to delete the job store
amn2master1 2016-08-29 20:12:59,034 MainThread INFO toil.utils.toilClean: Successfully deleted the job store
anovak@amn2master1:~/hgvm-graph-bakeoff-evaluations$ scripts/parallelMappingEvaluation.py azure:hgvm:amntree graph_urls.tsv azure:hgvm:pilot-input/reads azure:hgvm:pilot-output/low-coverage/aug16/out1 --batchSystem=mesos --mesosMaster 10.0.0.5:5050 --kmer_size=16 --edge_max=3 --index_mode gcsa-mem --include_primary --sample_limit 10 --disableCaching --workDir /tmp 2>&amp;1 | tee log.txt
INFO:toil.lib.bioio:Logging set at level: INFO
INFO:toil.lib.bioio:Logging set at level: INFO
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): hgvm.table.core.windows.net
Traceback (most recent call last):
File "scripts/parallelMappingEvaluation.py", line 1170, in <module>
sys.exit(main(sys.argv))
File "scripts/parallelMappingEvaluation.py", line 1160, in main
failed_jobs = Job.Runner.startToil(root_job,  options)
File "/usr/local/lib/python2.7/dist-packages/toil/job.py", line 540, in startToil
with Toil(options) as toil:
File "/usr/local/lib/python2.7/dist-packages/toil/common.py", line 501, in __enter__
jobStore.initialize(config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 152, in initialize
raise JobStoreExistsException(self.locator)
toil.jobStores.abstractJobStore.JobStoreExistsException: The job store 'hgvm:amntree' already exists. Use --restart to resume the workflow, or remove the job store with 'toil clean' to start the workflow from scratch
anovak@amn2master1:~/hgvm-graph-bakeoff-evaluations$

# Fixed code
def destroy(self):
    self._bind()
    for name in "jobItems", "jobFileIDs", "files", "statsFiles", "statsFileIDs":
        resource = getattr(self, name)
        if resource is not None:
            if isinstance(resource, AzureTable):
                resource.delete_table()
            elif isinstance(resource, AzureBlobContainer):
                resource.delete_container()
            else:
                assert False
            setattr(self, name, None)
# Buggy code
def distVersion():
    """
    The distribution version identifying a published release on PyPI.
    """
    from pkg_resources import parse_version

    build_number = buildNumber()
    if build_number is not None and parse_version(baseVersion).is_prerelease:
        return baseVersion + ".dev" + build_number
    else:
        return baseVersion


# Traceback (AttributeError)
Traceback (most recent call last):
File "version_template.py", line 137, in <module>
_main()
File "version_template.py", line 133, in _main
sys.stdout.write(expand_(*sys.argv[1:]))
File "version_template.py", line 128, in expand_
return resolve(name)
File "version_template.py", line 122, in resolve
v = v()
File "version_template.py", line 61, in distVersion
if build_number is not None and parse_version(baseVersion).is_prerelease:
AttributeError: 'tuple' object has no attribute 'is_prerelease'

# Fixed code
def distVersion():
    """
    The distribution version identifying a published release on PyPI.
    """
    from pkg_resources import parse_version

    build_number = buildNumber()
    parsedBaseVersion = parse_version(baseVersion)
    if isinstance(parsedBaseVersion, tuple):
        raise RuntimeError(
            "Setuptools version 8.0 or newer required. Update by running "
            "'pip install setuptools --upgrade'"
        )

    if build_number is not None and parsedBaseVersion.is_prerelease:
        return baseVersion + ".dev" + build_number
    else:
        return baseVersion
# Buggy code
def _jobStoreExists(self):
    """
    Checks if job store exists by querying the existence of the statsFileIDs table. Note that
    this is the last component that is deleted in deleteJobStore.
    """
    for attempt in retry_azure():
        with attempt:
            try:
                table = self.tableService.query_tables(
                    table_name=self.qualify("statsFileIDs")
                )
                return table is not None
            except AzureMissingResourceHttpError as e:
                if e.status_code == 404:
                    return False
                else:
                    raise


# Traceback (toil.jobStores.abstractJobStore.NoSuchFileException)
cmarkello@c1master1:~$ toil clean azure:hgvm:hgvmevaljobstore
2016-05-13 23:08:36,438 INFO:toil.lib.bioio: Logging set at level: INFO
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Parsed arguments
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Checking if we have files for toil
2016-05-13 23:08:36,525 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.table.core.windows.net
2016-05-13 23:08:36,724 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.blob.core.windows.net
Traceback (most recent call last):
File "/usr/local/bin/toil", line 9, in <module>
load_entry_point('toil==3.2.0a2', 'console_scripts', 'toil')()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilMain.py", line 30, in main
module.main()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilClean.py", line 53, in main
jobStore = Toil.loadOrCreateJobStore(options.jobStore)
File "/usr/local/lib/python2.7/dist-packages/toil/common.py", line 589, in loadOrCreateJobStore
return AzureJobStore(account, namePrefix, config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 120, in __init__
super(AzureJobStore, self).__init__(config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/abstractJobStore.py", line 141, in __init__
with self.readSharedFileStream("config.pickle") as fileHandle:
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 318, in readSharedFileStream
raise NoSuchFileException(sharedFileID)
toil.jobStores.abstractJobStore.NoSuchFileException: File 'a77581f6_ad82_5142_acb7_5a6b01eab3fb' does not exist

# Fixed code
def _jobStoreExists(self):
    """
    Checks if job store exists by querying the existence of the statsFileIDs table. Note that
    this is the last component that is deleted in :meth:`.destroy`.
    """
    for attempt in retry_azure():
        with attempt:
            try:
                table = self.tableService.query_tables(
                    table_name=self._qualify("statsFileIDs")
                )
            except AzureMissingResourceHttpError as e:
                if e.status_code == 404:
                    return False
                else:
                    raise
            else:
                return table is not None
# Buggy code
def getEnv(self):
    return dict(AZURE_ACCOUNT_KEY=self.account_key)


# Traceback (toil.jobStores.abstractJobStore.NoSuchFileException)
cmarkello@c1master1:~$ toil clean azure:hgvm:hgvmevaljobstore
2016-05-13 23:08:36,438 INFO:toil.lib.bioio: Logging set at level: INFO
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Parsed arguments
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Checking if we have files for toil
2016-05-13 23:08:36,525 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.table.core.windows.net
2016-05-13 23:08:36,724 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.blob.core.windows.net
Traceback (most recent call last):
File "/usr/local/bin/toil", line 9, in <module>
load_entry_point('toil==3.2.0a2', 'console_scripts', 'toil')()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilMain.py", line 30, in main
module.main()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilClean.py", line 53, in main
jobStore = Toil.loadOrCreateJobStore(options.jobStore)
File "/usr/local/lib/python2.7/dist-packages/toil/common.py", line 589, in loadOrCreateJobStore
return AzureJobStore(account, namePrefix, config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 120, in __init__
super(AzureJobStore, self).__init__(config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/abstractJobStore.py", line 141, in __init__
with self.readSharedFileStream("config.pickle") as fileHandle:
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 318, in readSharedFileStream
raise NoSuchFileException(sharedFileID)
toil.jobStores.abstractJobStore.NoSuchFileException: File 'a77581f6_ad82_5142_acb7_5a6b01eab3fb' does not exist

# Fixed code
def getEnv(self):
    return dict(AZURE_ACCOUNT_KEY=self.accountKey)
# Buggy code
def _readFromUrl(cls, url, writable):
    blobService, containerName, blobName = cls._extractBlobInfoFromUrl(url)
    blobService.get_blob_to_file(containerName, blobName, writable)


# Traceback (toil.jobStores.abstractJobStore.NoSuchFileException)
cmarkello@c1master1:~$ toil clean azure:hgvm:hgvmevaljobstore
2016-05-13 23:08:36,438 INFO:toil.lib.bioio: Logging set at level: INFO
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Parsed arguments
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Checking if we have files for toil
2016-05-13 23:08:36,525 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.table.core.windows.net
2016-05-13 23:08:36,724 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.blob.core.windows.net
Traceback (most recent call last):
File "/usr/local/bin/toil", line 9, in <module>
load_entry_point('toil==3.2.0a2', 'console_scripts', 'toil')()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilMain.py", line 30, in main
module.main()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilClean.py", line 53, in main
jobStore = Toil.loadOrCreateJobStore(options.jobStore)
File "/usr/local/lib/python2.7/dist-packages/toil/common.py", line 589, in loadOrCreateJobStore
return AzureJobStore(account, namePrefix, config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 120, in __init__
super(AzureJobStore, self).__init__(config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/abstractJobStore.py", line 141, in __init__
with self.readSharedFileStream("config.pickle") as fileHandle:
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 318, in readSharedFileStream
raise NoSuchFileException(sharedFileID)
toil.jobStores.abstractJobStore.NoSuchFileException: File 'a77581f6_ad82_5142_acb7_5a6b01eab3fb' does not exist

# Fixed code
def _readFromUrl(cls, url, writable):
    blob = cls._parseWasbUrl(url)
    blob.service.get_blob_to_file(
        container_name=blob.container, blob_name=blob.name, stream=writable
    )
# Buggy code
def _writeToUrl(cls, readable, url):
    blobService, containerName, blobName = cls._extractBlobInfoFromUrl(url)
    blobService.put_block_blob_from_file(containerName, blobName, readable)
    blobService.get_blob(containerName, blobName)


# Traceback (toil.jobStores.abstractJobStore.NoSuchFileException)
cmarkello@c1master1:~$ toil clean azure:hgvm:hgvmevaljobstore
2016-05-13 23:08:36,438 INFO:toil.lib.bioio: Logging set at level: INFO
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Parsed arguments
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Checking if we have files for toil
2016-05-13 23:08:36,525 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.table.core.windows.net
2016-05-13 23:08:36,724 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.blob.core.windows.net
Traceback (most recent call last):
File "/usr/local/bin/toil", line 9, in <module>
load_entry_point('toil==3.2.0a2', 'console_scripts', 'toil')()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilMain.py", line 30, in main
module.main()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilClean.py", line 53, in main
jobStore = Toil.loadOrCreateJobStore(options.jobStore)
File "/usr/local/lib/python2.7/dist-packages/toil/common.py", line 589, in loadOrCreateJobStore
return AzureJobStore(account, namePrefix, config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 120, in __init__
super(AzureJobStore, self).__init__(config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/abstractJobStore.py", line 141, in __init__
with self.readSharedFileStream("config.pickle") as fileHandle:
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 318, in readSharedFileStream
raise NoSuchFileException(sharedFileID)
toil.jobStores.abstractJobStore.NoSuchFileException: File 'a77581f6_ad82_5142_acb7_5a6b01eab3fb' does not exist

# Fixed code
def _writeToUrl(cls, readable, url):
    blob = cls._parseWasbUrl(url)
    blob.service.put_block_blob_from_file(
        container_name=blob.container, blob_name=blob.name, stream=readable
    )
# Buggy code
def _supportsUrl(cls, url, export=False):
    return url.scheme.lower() == "wasb" or url.scheme.lower() == "wasbs"


# Traceback (toil.jobStores.abstractJobStore.NoSuchFileException)
cmarkello@c1master1:~$ toil clean azure:hgvm:hgvmevaljobstore
2016-05-13 23:08:36,438 INFO:toil.lib.bioio: Logging set at level: INFO
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Parsed arguments
2016-05-13 23:08:36,445 INFO:toil.utils.toilClean: Checking if we have files for toil
2016-05-13 23:08:36,525 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.table.core.windows.net
2016-05-13 23:08:36,724 INFO:requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): hgvm.blob.core.windows.net
Traceback (most recent call last):
File "/usr/local/bin/toil", line 9, in <module>
load_entry_point('toil==3.2.0a2', 'console_scripts', 'toil')()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilMain.py", line 30, in main
module.main()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilClean.py", line 53, in main
jobStore = Toil.loadOrCreateJobStore(options.jobStore)
File "/usr/local/lib/python2.7/dist-packages/toil/common.py", line 589, in loadOrCreateJobStore
return AzureJobStore(account, namePrefix, config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 120, in __init__
super(AzureJobStore, self).__init__(config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/abstractJobStore.py", line 141, in __init__
with self.readSharedFileStream("config.pickle") as fileHandle:
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/azureJobStore.py", line 318, in readSharedFileStream
raise NoSuchFileException(sharedFileID)
toil.jobStores.abstractJobStore.NoSuchFileException: File 'a77581f6_ad82_5142_acb7_5a6b01eab3fb' does not exist

# Fixed code
def _supportsUrl(cls, url, export=False):
    return url.scheme.lower() in ("wasb", "wasbs")
# Buggy code
def _downloadStream(self, key, encrypt=True):
    readable_fh, writable_fh = os.pipe()
    with os.fdopen(readable_fh, "r") as readable:
        with os.fdopen(writable_fh, "w") as writable:

            def writer():
                headers = self.encryptedHeaders if encrypt else self.headerValues
                try:
                    key.get_file(writable, headers=headers)
                finally:
                    writable.close()

            thread = ExceptionalThread(target=writer)
            thread.start()
            yield readable
            thread.join()


# Traceback (boto.exception.S3CreateError)
ubuntu@ip-172-31-24-34:~/common-workflow-language$ toil clean aws:us-west-2:peter-cwltoil-test
2016-04-13 15:36:32,632 INFO:toil.lib.bioio: Logging set at level: INFO
2016-04-13 15:36:32,632 INFO:toil.utils.toilClean: Parsed arguments
2016-04-13 15:36:32,633 INFO:toil.utils.toilClean: Checking if we have files for toil
Traceback (most recent call last):
File "/usr/local/bin/toil", line 9, in <module>
load_entry_point('toil==3.2.0a2.dev134', 'console_scripts', 'toil')()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilMain.py", line 30, in main
module.main()
File "/usr/local/lib/python2.7/dist-packages/toil/utils/toilClean.py", line 53, in main
jobStore = Toil.loadOrCreateJobStore(options.jobStore)
File "/usr/local/lib/python2.7/dist-packages/toil/common.py", line 501, in loadOrCreateJobStore
return AWSJobStore.loadOrCreateJobStore(jobStoreArgs, config=config)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/aws/jobStore.py", line 117, in loadOrCreateJobStore
return cls(region, namePrefix, config=config, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/aws/jobStore.py", line 174, in __init__
self.filesBucket = self._getOrCreateBucket(qualify('files'), versioning=True)
File "/usr/local/lib/python2.7/dist-packages/toil/jobStores/aws/jobStore.py", line 469, in _getOrCreateBucket
bucket = self.s3.create_bucket(bucket_name, location=self.region)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/connection.py", line 616, in create_bucket
response.status, response.reason, body)
boto.exception.S3CreateError: S3CreateError: 409 Conflict
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>BucketAlreadyExists</Code><Message>The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.</Message><BucketName>peter-cwltoil-test--files</BucketName><RequestId>DAF5D5E6B138F1AB</RequestId><HostId>t9Fz0/fKNcxA5q7gLBuk7FMu9AxCD4AdyXMIWhWOtJVyNS8ARDxnWDQOBZdeTmpkcVtXa9brMss=</HostId></Error>

# Fixed code
def _downloadStream(self, key, encrypt=True):
    store = self

    class DownloadPipe(ReadablePipe):
        def writeTo(self, writable):
            headers = store.encryptedHeaders if encrypt else store.headerValues
            try:
                key.get_file(writable, headers=headers)
            finally:
                writable.close()

    with DownloadPipe() as readable:
        yield readable