votes up 6

Some specified arguments are not used by the HfArgumentParser: (remaining_args)

Package:
Exception Class:
ValueError

Raise code

        if len(namespace.__dict__) > 0:
            # additional namespace.
            outputs.append(namespace)
        if return_remaining_strings:
            return (*outputs, remaining_args)
        else:
            if remaining_args:
                raise ValueError(f"Some specified arguments are not used by the HfArgumentParser: {remaining_args}")

            return (*outputs,)

    def parse_json_file(self, json_file: str) -> Tuple[DataClass, ...]:
        """
        Alternative helper method that does not use `argparse` at all, instead loading a json file and populating the
        dataclass types. """
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

votes up 2 votes down

HfArgumentParser is subclass of argparse.ArgumentParser uses type hints on data classes to generate arguments.

The class is designed to play well with the native argparse. In particular, you can add more (non-data class backed) arguments to the parser after initialization and you'll get the output back after parsing as an additional namespace.

parse_args_into_dataclasses - Parse command-line args into instances of the specified data class types

Error code:

from transformers import HfArgumentParser,PyTorchBenchmarkArguments

parser = HfArgumentParser(PyTorchBenchmarkArguments)
benchmark_args = parser.parse_args_into_dataclasses()[0]
print(benchmark_args)

Explanation:

According to code

if return_remaining_strings:
    return (*outputs, remaining_args)
else:
    if remaining_args:
        raise ValueError(f"Some specified arguments are not used by the HfArgumentParser: {remaining_args}")

If arguments remain, it doesn't allow us to use them.

To avoid, return_remaining_strings can be used.

return_remaining_strings - allows to return a list of remaining argument strings

Fix code:

from transformers import HfArgumentParser,PyTorchBenchmarkArguments

parser = HfArgumentParser(PyTorchBenchmarkArguments)
benchmark_args = parser.parse_args_into_dataclasses(return_remaining_strings=True)[0]
print(benchmark_args)
Jul 14, 2021 anonim answer
anonim 13.0k

Add a possible fix

Please authorize to post fix