Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Config adapter for pytext XLM (#1172)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #1172

Config adapter for adding Union in XLMModel class from D18107524

The Encoder is a super type and will always have a class specified, adding this for the Tensorizer.

Reviewed By: rutyrinott

Differential Revision: D18717196

fbshipit-source-id: 50839d97220e77ed08a30345a4e6a293e0213a6c
  • Loading branch information
snisarg authored and facebook-github-bot committed Dec 17, 2019
1 parent 779ba2b commit 03a1082
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions pytext/config/config_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,22 @@ def rename_fl_task(json_config):
return json_config


@register_adapter(from_version=18)
def upgrade_if_xlm(json_config):
"""
Make `XLMModel` Union changes for encoder and tokens config.
Since they are now unions, insert the old class into the config if
no class name is mentioned.
"""
_, _, model = find_parameter(json_config, "task.model")
if model and "XLMModel" in model:
_, inputs, tokens = find_parameter(json_config, "task.model.inputs.tokens")
inputs["tokens"] = {}
inputs["tokens"]["XLMTensorizer"] = tokens

return json_config


def upgrade_one_version(json_config):
current_version = json_config.get("version", 0)
adapter = ADAPTERS.get(current_version)
Expand Down
2 changes: 1 addition & 1 deletion pytext/config/pytext_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ class LogitsConfig(TestConfig):
dump_raw_input: bool = False


LATEST_VERSION = 18
LATEST_VERSION = 19

0 comments on commit 03a1082

Please sign in to comment.