Skip to main content

Standalone version of the HuggingFace ArgParser from the Transformers library

Project description

HF Argparser

Standalone Argument Parser from HuggingFace Transformers.

This is a standalone version of the argument parser used in the HuggingFace Transformers library. It is a simple wrapper around the argparse library that allows you to easily define your command-line arguments for your scripts using dataclasses.

Installation

pip install hf-argparser

Usage

from dataclasses import dataclass
from hf_argparser import HfArgumentParser, HFArg

@dataclass
class AddArgs():
    x: int
    y: int

@dataclass
class OutputArgs():
    output_file: str = field(
        default=None,
        metadata={'help': 'output filename'})

    parser = HfArgumentParser([AddArgs, OutputArgs])
    
    add_args, output_args, unknown_args = parser.parse_args_into_dataclasses(
            return_remaining_strings=True)
    return add_args, output_args, unknown_args

Above code is taken from this post by @kenilc.

See the Transformers documentation for more information on how to use the HfArgumentParser.

Todo

  • [] Automate pulling new changes to hf_argparser from transformers repo.
  • [] Automate creating new releases on PyPi.
  • [] Add tests.
  • [] Improve README.

Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hf_argparser-0.1.1.tar.gz (17.6 kB view hashes)

Uploaded Source

Built Distribution

hf_argparser-0.1.1-py3-none-any.whl (11.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page