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 predictmethod_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)
Args
export_dir
Directory containing the SavedModel files.
Raises
IOError
If the saved model file does not exist, or cannot be successfully
parsed.
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 MetaGraphs 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.
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.
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.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.saved_model.signature_def_utils.MethodNameUpdater\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/saved_model/method_name_updater.py#L30-L143) |\n\nUpdates the method name(s) of the SavedModel stored in the given path. \n\n tf.compat.v1.saved_model.signature_def_utils.MethodNameUpdater(\n export_dir\n )\n\nThe `MethodNameUpdater` class provides the functionality to update the method\nname field in the signature_defs of the given SavedModel. For example, it\ncan be used to replace the `predict` `method_name` to `regress`.\n\nTypical usages of the `MethodNameUpdater` \n\n ...\n updater = tf.compat.v1.saved_model.signature_def_utils.MethodNameUpdater(\n export_dir)\n # Update all signature_defs with key \"foo\" in all meta graph defs.\n updater.replace_method_name(signature_key=\"foo\", method_name=\"regress\")\n # Update a single signature_def with key \"bar\" in the meta graph def with\n # tags [\"serve\"]\n updater.replace_method_name(signature_key=\"bar\", method_name=\"classify\",\n tags=\"serve\")\n updater.save(new_export_dir)\n\n| **Note:** This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.builder.MethodNameUpdater.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------|--------------------------------------------|\n| `export_dir` | Directory containing the SavedModel files. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-----------|---------------------------------------------------------------------------|\n| `IOError` | If the saved model file does not exist, or cannot be successfully parsed. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `replace_method_name`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/saved_model/method_name_updater.py#L69-L111) \n\n replace_method_name(\n signature_key, method_name, tags=None\n )\n\nReplaces the method_name in the specified signature_def.\n\nThis will match and replace multiple sig defs iff tags is None (i.e when\nmultiple `MetaGraph`s have a signature_def with the same key).\nIf tags is not None, this will only replace a single signature_def in the\n`MetaGraph` with matching tags.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------------|------------------------------------------------------------------------------------------------------------|\n| `signature_key` | Key of the signature_def to be updated. |\n| `method_name` | new method_name to replace the existing one. |\n| `tags` | A tag or sequence of tags identifying the `MetaGraph` to update. If None, all meta graphs will be updated. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `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. |\n\n\u003cbr /\u003e\n\n### `save`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/saved_model/method_name_updater.py#L113-L143) \n\n save(\n new_export_dir=None\n )\n\nSaves the updated `SavedModel`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|------------------|------------------------------------------------------------------------------------------------------------------------|\n| `new_export_dir` | Path where the updated `SavedModel` will be saved. If None, the input `SavedModel` will be overriden with the updates. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|----------------------------------------------------------------------------------|-----------------------------------------------------|\n| [`errors.OpError`](https://www.tensorflow.org/api_docs/python/tf/errors/OpError) | If there are errors during the file save operation. |\n\n\u003cbr /\u003e"]]