Skip to main content

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

Metadata

Release files for hf-argparser 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hf-argparser 0.1.1
File Size Uploaded
hf_argparser-0.1.1.tar.gz 17.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hf-argparser 0.1.1
File Interpreter ABI Platform
hf_argparser-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.5 kB

Release files / hf_argparser-0.1.1.tar.gz

Download URL hf_argparser-0.1.1.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9290e503b85eadd7ee90cb2790eaeefc8e2d593bfd1bbff745af435f5dcc83bc
BLAKE2b-256 checksum
How to use checksums
5b318fc8e22c8b05dc68c97fd483017ecda08c48e478a77a94f492864afceadb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.9.3 CPython/3.9.6

Release files / hf_argparser-0.1.1-py3-none-any.whl

Download URL hf_argparser-0.1.1-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e8766e5509486b3a88fcb38cbc5a45fc907628762bd86faebb76ad9a0f6541e
BLAKE2b-256 checksum
How to use checksums
a08a55985913b461883f9fe6c9979bdfb1e6e3f9b43121ff3010b7511f28aa00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.9.3 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page