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

Add cmdline args method to DialogPartnerWorld #3506

Merged
merged 1 commit into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions parlai/core/worlds.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,18 @@
import copy
import random

from typing import List, Dict, Union
from typing import Dict, List, Optional, Union

import parlai.utils.logging as logging
from parlai.core.agents import create_agents_from_shared
from parlai.core.loader import load_task_module, load_world_module
from parlai.core.metrics import aggregate_named_reports
from parlai.core.opt import Opt
from parlai.core.params import ParlaiParser
from parlai.core.teachers import Teacher, create_task_agent_from_taskname
from parlai.utils.data import DatatypeHelper
from parlai.utils.misc import Timer, display_messages
from parlai.tasks.tasks import ids_to_tasks
import parlai.utils.logging as logging


def validate(observation):
Expand Down Expand Up @@ -304,6 +305,17 @@ class DialogPartnerWorld(World):
chance to speak per turn and passing that back to the other one.
"""

@classmethod
def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Return the parser as-is.

Self-chat-specific world flags can be added here.
"""
return parser

def __init__(self, opt: Opt, agents=None, shared=None):
if not ((agents is not None) ^ (shared is not None)):
raise ValueError('You must supply either agents or shared, but not both.')
Expand Down
6 changes: 3 additions & 3 deletions parlai/tasks/md_gender/worlds.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
super().add_cmdline_args(parser, partial_opt)
parser = parser.add_argument_group('Gender Multiclass Interactive World')
parser.add_argument(
group = parser.add_argument_group('Gender Multiclass Interactive World')
group.add_argument(
'--self-threshold',
type=float,
default=0.52,
help='Threshold for choosing unknown for self',
)
parser.add_argument(
group.add_argument(
'--partner-threshold',
type=float,
default=0.52,
Expand Down
13 changes: 0 additions & 13 deletions parlai/tasks/self_chat/worlds.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

from parlai.agents.fixed_response.fixed_response import FixedResponseAgent
from parlai.core.agents import Agent
from parlai.core.opt import Opt
from parlai.core.params import ParlaiParser
from parlai.core.worlds import create_task, DialogPartnerWorld, validate
from parlai.core.message import Message

Expand Down Expand Up @@ -53,17 +51,6 @@ def load_openers(opt) -> Optional[List[str]]:


class SelfChatWorld(DialogPartnerWorld):
@classmethod
def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Return the parser as-is.

Self-chat-specific world flags can be added here.
"""
return parser

def __init__(self, opt, agents, shared=None):
super().__init__(opt, agents, shared)
self.init_contexts(shared=shared)
Expand Down