Argument Formatting

Argument Formatters

class slurmjobs.args.Argument[source]

The base-class for all argument formatters. If you want to provide a new argument formatter, just override this class and change either the:

  • format_arg method that is used to format positional and key-value pairs, or

  • format_value (which is called in format_arg) to format python values as a string. This is often some form of quoted repr or json formatting.

classmethod get(key='fire', *a, **kw)[source]

Return an instance of an argument formatter, based on its name.

format_arg(k, v=Ellipsis)[source]

Format a key-value pair for the command-line.

If it is a positional argument, the value will be in key and the value will be ....

Parameters
  • k – The key (or value, for positional arguments).

  • v – The value. If it’s a positional argument, it will be v=...

format_value(v)[source]

Format a value for the command-line.

class slurmjobs.args.FireArgument[source]

Argument formatting for Python Fire.

Example: python script.py a b --arg1 c --arg2 d

format_arg(k, v=Ellipsis)[source]

Format a key-value pair for the command-line.

If it is a positional argument, the value will be in key and the value will be ....

Parameters
  • k – The key (or value, for positional arguments).

  • v – The value. If it’s a positional argument, it will be v=...

class slurmjobs.args.ArgparseArgument[source]

Argument formatting for Python’s builtin argparse.

Example: python script.py a b --arg1 c --arg2 d

format_arg(k, v=Ellipsis)[source]

Format a key-value pair for the command-line.

If it is a positional argument, the value will be in key and the value will be ....

Parameters
  • k – The key (or value, for positional arguments).

  • v – The value. If it’s a positional argument, it will be v=...

class slurmjobs.args.SacredArgument[source]

Formatting for sacred.

Example: python script.py with arg1=a arg2=b

class slurmjobs.args.HydraArgument(default_prefix='+', **kw)[source]

Formatting for hydra.

Example: python script.py  db.user=root db.pass=1234

format_arg(k, v=Ellipsis)[source]

Format a key-value pair for the command-line.

If it is a positional argument, the value will be in key and the value will be ....

Parameters
  • k – The key (or value, for positional arguments).

  • v – The value. If it’s a positional argument, it will be v=...