wandb_utils.commands.common

Module Contents

wandb_utils.commands.common.F
class wandb_utils.commands.common.Metric(name: str, maximum: bool = True)

Bases: object

class wandb_utils.commands.common.MetricParamType

Bases: click.ParamType

Represents the type of a parameter. Validates and converts values from the command line or Python into the correct type.

To implement a custom type, subclass and implement at least the following:

  • The name class attribute must be set.

  • Calling an instance of the type with None must return None. This is already implemented by default.

  • convert() must convert string values to the correct type.

  • convert() must accept values that are already the correct type.

  • It must be able to convert a value if the ctx and param arguments are None. This can occur when converting prompt input.

name = metric
is_composite :ClassVar[bool] = False
arity :ClassVar[int] = 1
envvar_list_splitter :ClassVar[Optional[str]]
convert(self, value: str, param, ctx) Metric

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

to_info_dict(self) Dict[str, Any]

Gather information that could be useful for a tool generating user-facing documentation.

Use click.Context.to_info_dict() to traverse the entire CLI structure.

New in version 8.0.

get_metavar(self, param: click.core.Parameter) Optional[str]

Returns the metavar default for this param if it provides one.

get_missing_message(self, param: click.core.Parameter) Optional[str]

Optionally might return extra information about a missing parameter.

New in version 2.0.

split_envvar_value(self, rv: str) Sequence[str]

Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter.

If the splitter is set to None, which means that whitespace splits, then leading and trailing whitespace is ignored. Otherwise, leading and trailing splitters usually lead to empty items being included.

fail(self, message: str, param: Optional[click.core.Parameter] = None, ctx: Optional[click.core.Context] = None) NoReturn

Helper method to fail with an invalid value message.

shell_complete(self, ctx: click.core.Context, param: click.core.Parameter, incomplete: str) List[click.shell_completion.CompletionItem]

Return a list of CompletionItem objects for the incomplete value. Most types do not provide completions, but some do, and this allows custom types to provide custom completions as well.

Parameters
  • ctx – Invocation context for this command.

  • param – The parameter that is requesting completion.

  • incomplete – Value being completed. May be empty.

New in version 8.0.

class wandb_utils.commands.common.DictParamType

Bases: click.ParamType

Represents the type of a parameter. Validates and converts values from the command line or Python into the correct type.

To implement a custom type, subclass and implement at least the following:

  • The name class attribute must be set.

  • Calling an instance of the type with None must return None. This is already implemented by default.

  • convert() must convert string values to the correct type.

  • convert() must accept values that are already the correct type.

  • It must be able to convert a value if the ctx and param arguments are None. This can occur when converting prompt input.

name = dict
is_composite :ClassVar[bool] = False
arity :ClassVar[int] = 1
envvar_list_splitter :ClassVar[Optional[str]]
convert(self, value: str, param, ctx) Metric

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

to_info_dict(self) Dict[str, Any]

Gather information that could be useful for a tool generating user-facing documentation.

Use click.Context.to_info_dict() to traverse the entire CLI structure.

New in version 8.0.

get_metavar(self, param: click.core.Parameter) Optional[str]

Returns the metavar default for this param if it provides one.

get_missing_message(self, param: click.core.Parameter) Optional[str]

Optionally might return extra information about a missing parameter.

New in version 2.0.

split_envvar_value(self, rv: str) Sequence[str]

Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter.

If the splitter is set to None, which means that whitespace splits, then leading and trailing whitespace is ignored. Otherwise, leading and trailing splitters usually lead to empty items being included.

fail(self, message: str, param: Optional[click.core.Parameter] = None, ctx: Optional[click.core.Context] = None) NoReturn

Helper method to fail with an invalid value message.

shell_complete(self, ctx: click.core.Context, param: click.core.Parameter, incomplete: str) List[click.shell_completion.CompletionItem]

Return a list of CompletionItem objects for the incomplete value. Most types do not provide completions, but some do, and this allows custom types to provide custom completions as well.

Parameters
  • ctx – Invocation context for this command.

  • param – The parameter that is requesting completion.

  • incomplete – Value being completed. May be empty.

New in version 8.0.

class wandb_utils.commands.common.ListParamType(sep: str = '|')

Bases: click.ParamType

Represents the type of a parameter. Validates and converts values from the command line or Python into the correct type.

To implement a custom type, subclass and implement at least the following:

  • The name class attribute must be set.

  • Calling an instance of the type with None must return None. This is already implemented by default.

  • convert() must convert string values to the correct type.

  • convert() must accept values that are already the correct type.

  • It must be able to convert a value if the ctx and param arguments are None. This can occur when converting prompt input.

name = list
is_composite :ClassVar[bool] = False
arity :ClassVar[int] = 1
envvar_list_splitter :ClassVar[Optional[str]]
convert(self, value: str, param, ctx) List[str]

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail() with a descriptive message.

Parameters
  • value – The value to convert.

  • param – The parameter that is using this type to convert its value. May be None.

  • ctx – The current context that arrived at this value. May be None.

to_info_dict(self) Dict[str, Any]

Gather information that could be useful for a tool generating user-facing documentation.

Use click.Context.to_info_dict() to traverse the entire CLI structure.

New in version 8.0.

get_metavar(self, param: click.core.Parameter) Optional[str]

Returns the metavar default for this param if it provides one.

get_missing_message(self, param: click.core.Parameter) Optional[str]

Optionally might return extra information about a missing parameter.

New in version 2.0.

split_envvar_value(self, rv: str) Sequence[str]

Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter.

If the splitter is set to None, which means that whitespace splits, then leading and trailing whitespace is ignored. Otherwise, leading and trailing splitters usually lead to empty items being included.

fail(self, message: str, param: Optional[click.core.Parameter] = None, ctx: Optional[click.core.Context] = None) NoReturn

Helper method to fail with an invalid value message.

shell_complete(self, ctx: click.core.Context, param: click.core.Parameter, incomplete: str) List[click.shell_completion.CompletionItem]

Return a list of CompletionItem objects for the incomplete value. Most types do not provide completions, but some do, and this allows custom types to provide custom completions as well.

Parameters
  • ctx – Invocation context for this command.

  • param – The parameter that is requesting completion.

  • incomplete – Value being completed. May be empty.

New in version 8.0.

wandb_utils.commands.common.METRIC
wandb_utils.commands.common.DICT
wandb_utils.commands.common.LIST
class wandb_utils.commands.common.WandbAPIWrapper(entity: str = None, project: str = None, sweep: str = None)

Bases: object

Contains an instance of wandb.Api or wandb.PublicApi and some other information.

wandb_utils.commands.common.pass_api_wrapper
wandb_utils.commands.common.pass_api_and_info(f: F) F

Code adopted from click.make_pass_decorator. Instead of passing an instance of WandbAPIWrapper, it passes the following args:

api: wandb.Api entity: Optional[str], project: Optional[str], sweep: Optional[str]

wandb_utils.commands.common.processor(f: Callable)

Helper decorator to rewrite a function so that it returns another function from it.

wandb_utils.commands.common.apply_decorators(decorators)
class wandb_utils.commands.common.FileFilter

Bases: object

class wandb_utils.commands.common.GlobBasedFileFilter(include_filter: Optional[List[str]] = None, exclude_filter: Optional[List[str]] = None)

Bases: FileFilter

match(self, path: Union[pathlib.Path, pathlib.PurePath], globs: List[str]) bool
class wandb_utils.commands.common.RunFilter

Bases: object

class wandb_utils.commands.common.NameBasedRunFilter(not_allowed_names: Optional[List[str]] = None, allowed_names: Optional[List[str]] = None)

Bases: RunFilter