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

Commit

Permalink
Fixes to ParsedRemoteAgent (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexholdenmiller authored Jun 29, 2017
1 parent 855088f commit 6283bcb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion examples/memnn_luatorch_cpu/full_task_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ def main():
world_dict.parley()

# we need to save the dictionary to load it in memnn (sort it by freq)
dictionary.sort()
dictionary.save('/tmp/dict.txt', sort=True)

print('Dictionary ready, moving on to training.')

opt['datatype'] = 'train'
agent = ParsedRemoteAgent(opt, {'dictionary': dictionary})
agent = ParsedRemoteAgent(opt, {'dictionary_shared': dictionary.share()})
world_train = create_task(opt, agent)
opt['datatype'] = 'valid'
world_valid = create_task(opt, agent)
Expand Down
20 changes: 13 additions & 7 deletions parlai/agents/remote_agent/remote_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# of patent rights can be found in the PATENTS file in the same directory.
from parlai.core.agents import Agent, create_agent_from_shared
from parlai.core.dict import DictionaryAgent
import argparse
import copy
import numpy as np
import json
Expand All @@ -27,20 +28,21 @@ class RemoteAgentAgent(Agent):

@staticmethod
def add_cmdline_args(argparser):
argparser.add_argument(
remote = argparser.add_argument_group('Remote Agent Args')
remote.add_argument(
'--port', default=5555,
help='first port to connect to for remote agents')
argparser.add_argument(
remote.add_argument(
'--remote-address', default='localhost',
help='address to connect to, defaults to localhost for ' +
'connections, overriden with `*` if remote-host is set')
argparser.add_argument(
remote.add_argument(
'--remote-host', action='store_true',
help='whether or not this connection is the host or the client')
argparser.add_argument(
remote.add_argument(
'--remote-cmd',
help='command to launch paired agent, if applicable')
argparser.add_argument(
remote.add_argument(
'--remote-args',
help='optional arguments to pass to paired agent')

Expand Down Expand Up @@ -140,8 +142,12 @@ class ParsedRemoteAgent(RemoteAgentAgent):

@staticmethod
def add_cmdline_args(argparser):
super().add_cmdline_args(argparser)
ParsedRemoteAgent.dictionary_class().add_cmdline_args(argparser)
RemoteAgentAgent.add_cmdline_args(argparser)
try:
ParsedRemoteAgent.dictionary_class().add_cmdline_args(argparser)
except argparse.ArgumentError:
# don't freak out if the dictionary has already been added
pass

@staticmethod
def dictionary_class():
Expand Down
2 changes: 1 addition & 1 deletion parlai/core/worlds.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def parley(self):
for index, agent in enumerate(self.agents):
# The agent acts.
acts[index] = agent.act()
# We execute this action in the world.
# We execute this action in the world.
self.execute(agent, acts[index])
# All agents (might) observe the results.
for other_agent in self.agents:
Expand Down

0 comments on commit 6283bcb

Please sign in to comment.