nip.parameters.version.register_conversion_function

nip.parameters.version.register_conversion_function#

nip.parameters.version.register_conversion_function(from_version: str | None, to_version: str) Callable[[Callable[[dict], dict]], Callable[[dict], dict]][source]#

Decorate a function to register it as a conversion function.

A conversion function is used to transform hyper-parameter dictionaries from one version of the package to another. The function should take a dictionary as input and return a dictionary as output.

Versions are represented as strings, e.g. “1.5.3”. It is possible to omit the last elements of the version, e.g. “1.5” for version 1.5.x or “1” for version 1.x.x. In this case, it applies to any version which matches the pattern.

The from_version parameter may be None. This deals with the case where the hyper-parameter dictionary does not have a _package_version field. This is the case for runs created prior to the introduction of this field.

Parameters:
  • from_version (str | None) – The version number from which the conversion function should be applied. See above for the format of the version number.

  • to_version (str) – The version number to which the conversion function should be applied. See above for the format of the version number.