Skip to content

Commit

Permalink
test agent on dedicated server
Browse files Browse the repository at this point in the history
  • Loading branch information
noskill committed Nov 12, 2024
1 parent 25e04f2 commit 9377c8d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/vereya/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from tagilmo.utils.vereya_wrapper import MCConnector, RobustObserver
from base_test import BaseTest

def init_mission(mc, start_x, start_z, seed, forceReset="false", forceReuse="false", start_y=78, worldType = "default"):

def init_mission(mc, start_x, start_z, seed, forceReset="false",
forceReuse="false", start_y=78, worldType = "default", serverIp=None, serverPort=0):
want_depth = False
video_producer = mb.VideoProducer(width=320 * 4,
height=240 * 4, want_depth=want_depth)
Expand Down Expand Up @@ -59,7 +61,7 @@ def init_mission(mc, start_x, start_z, seed, forceReset="false", forceReuse="fal
os.mkdir('./observations')

if mc is None:
mc = MCConnector(miss)
mc = MCConnector(miss, serverIp=serverIp, serverPort=serverPort)
mc.mission_record.setDestination('./observations/')
mc.mission_record.is_recording_observations = True
obs = RobustObserver(mc)
Expand Down
13 changes: 13 additions & 0 deletions tests/vereya/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def run(self):
for act in acts:
self.rob.sendCommand(act)


class TestAgent(BaseTest):
mc = None

Expand Down Expand Up @@ -79,6 +80,18 @@ def test_agent(self):
inv = mc.getInventory()
self.assertEqual(count_items(inv, item_to_obtain), 1, msg=f"check if {item_to_obtain} was crafted")


class TestAgentServer(TestAgent):
@classmethod
def setUpClass(self, *args, **kwargs):
start = (4.0, 69.0, 68)
mc, obs = init_mission(None, start_x=start[0], start_y=start[1], start_z=start[2], forceReset='false', forceReuse=True, seed='2', serverIp='127.0.0.1', serverPort=25565)
self.mc = mc
self.rob = obs
assert mc.safeStart()
time.sleep(4)


def main():
VereyaPython.setupLogger()
unittest.main()
Expand Down

0 comments on commit 9377c8d

Please sign in to comment.