<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/saved_model/method_name_updater.py#L30-L143) |

Updates the method name(s) of the SavedModel stored in the given path.

    tf.compat.v1.saved_model.signature_def_utils.MethodNameUpdater(
        export_dir
    )

The `MethodNameUpdater` class provides the functionality to update the method
name field in the signature_defs of the given SavedModel. For example, it
can be used to replace the `predict` `method_name` to `regress`.

Typical usages of the `MethodNameUpdater`

    ...
    updater = tf.compat.v1.saved_model.signature_def_utils.MethodNameUpdater(
        export_dir)
    # Update all signature_defs with key "foo" in all meta graph defs.
    updater.replace_method_name(signature_key="foo", method_name="regress")
    # Update a single signature_def with key "bar" in the meta graph def with
    # tags ["serve"]
    updater.replace_method_name(signature_key="bar", method_name="classify",
                                tags="serve")
    updater.save(new_export_dir)

> [!NOTE]
> **Note:** This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.builder.MethodNameUpdater.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `export_dir` | Directory containing the SavedModel files. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `IOError` | If the saved model file does not exist, or cannot be successfully parsed. |

<br />

## Methods

### `replace_method_name`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/saved_model/method_name_updater.py#L69-L111)

    replace_method_name(
        signature_key, method_name, tags=None
    )

Replaces the method_name in the specified signature_def.

This will match and replace multiple sig defs iff tags is None (i.e when
multiple `MetaGraph`s have a signature_def with the same key).
If tags is not None, this will only replace a single signature_def in the
`MetaGraph` with matching tags.

<br />

<br />

<br />

| Args ||
|---|---|
| `signature_key` | Key of the signature_def to be updated. |
| `method_name` | new method_name to replace the existing one. |
| `tags` | A tag or sequence of tags identifying the `MetaGraph` to update. If None, all meta graphs will be updated. |

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | if signature_key or method_name are not defined or if no metagraphs were found with the associated tags or if no meta graph has a signature_def that matches signature_key. |

<br />

### `save`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/saved_model/method_name_updater.py#L113-L143)

    save(
        new_export_dir=None
    )

Saves the updated `SavedModel`.

<br />

<br />

<br />

| Args ||
|---|---|
| `new_export_dir` | Path where the updated `SavedModel` will be saved. If None, the input `SavedModel` will be overriden with the updates. |

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| [`errors.OpError`](https://www.tensorflow.org/api_docs/python/tf/errors/OpError) | If there are errors during the file save operation. |

<br />